Created
December 27, 2013 10:32
-
-
Save kawasima/8145171 to your computer and use it in GitHub Desktop.
Flume custome sink written by Clojure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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