Writing Java plugins for Flume in Clojure

I recently wrote a plugin in Clojure to add to the Cloudera Flume framework.  As it was my first time writing a full java class interface I had to learn about the proper use of both proxy and gen-class.  Given the poor error reporting at the java-clojure boundary, figuring out what you did wrong if you don’t get every detail exactly right (particularly when loading a class in the plugin’s final environment) can be difficult.

I’m sharing the basic plugin implementation here.  To understand everything you need to write a plugin, I suggest you first read a good introduction to gen_class to gain some insights that are missing from the clojure documentation.  For example, it may be clear to clojure experts, but wasn’t to me, that you can annotate metadata on any object by using the syntax #^{…}.  To define a static method the documentation says to annotate the method signature metadata.  As you can see in the full example, this means placing an annotation in front of the seq directly #^{:static true} [method [args] [super-args]].


To maintain state, you need to define a state accessor and an initialization function to return the clojure state.  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s