Skip to content

Instantly share code, notes, and snippets.

@kawasima
Created December 27, 2013 10:32
Show Gist options
  • Save kawasima/8145171 to your computer and use it in GitHub Desktop.
Save kawasima/8145171 to your computer and use it in GitHub Desktop.
Flume custome sink written by Clojure.
(ns example.print-sink
(:import [org.apache.flume Sink Sink$Status]
[org.apache.flume.event EventHelper])
(:gen-class :name example.PrintSink
:extends org.apache.flume.sink.AbstractSink
:exposes-methods {getChannel parentGetChannel}))
(defn -configure [this context])
(defn -process [this]
(let [ch (. this parentGetChannel)
tx (. ch getTransaction)
status (atom Sink$Status/BACKOFF)]
(. tx begin)
(try
(when-let [event (. ch take)]
(println (EventHelper/dumpEvent event))
(reset! status Sink$Status/READY))
(. tx commit)
(catch Throwable t
(. tx tollback))
(finally
(. tx close)))
(println @status)
@status))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment