Browse Source

client protoype with kestrel-client

master
Brett Langdon 14 years ago
parent
commit
d28a2e4de7
2 changed files with 20 additions and 2 deletions
  1. +1
    -0
      build.xml
  2. +19
    -2
      src/com/blangdon/flume/kestrel/KestrelSink.java

+ 1
- 0
build.xml View File

@ -16,6 +16,7 @@
<!-- in case we are running in release env --> <!-- in case we are running in release env -->
<fileset dir="${flume.base}/lib"> <fileset dir="${flume.base}/lib">
<include name="flume-*.jar" /> <include name="flume-*.jar" />
<include name="kestrel-client*.jar" />
</fileset> </fileset>
<pathelement location="${flume.base}/lib/"/> <pathelement location="${flume.base}/lib/"/>
</path> </path>


+ 19
- 2
src/com/blangdon/flume/kestrel/KestrelSink.java View File

@ -1,6 +1,8 @@
package com.blangdon.flume.Kestrel; package com.blangdon.flume.Kestrel;
import iinteractive.kestrel.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,24 +21,39 @@ import com.google.common.base.Preconditions;
public class KestrelSink extends EventSink.Base { public class KestrelSink extends EventSink.Base {
public KestrelSink(){
private String queue = null;
private String server = null;
private Client client = null;
public KestrelSink(String queue, String server){
//constructor //constructor
this.queue = queue;
this.server = server;
this.client = new Client(this.server);
} }
@Override @Override
public void open() throws IOException { public void open() throws IOException {
// Initialized the sink // Initialized the sink
this.client.connect();
} }
@Override @Override
public void append(Event e) throws IOException { public void append(Event e) throws IOException {
//send to Kestrel //send to Kestrel
String message = new String(e.getBody());
try{
this.client.put(this.queue, message);
}catch( KestrelException ke ){
throw new IOException(ke.getMessage());
}
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
// Cleanup // Cleanup
this.client.disconnect();
} }
public static SinkBuilder builder() { public static SinkBuilder builder() {
@ -47,7 +64,7 @@ public class KestrelSink extends EventSink.Base {
Preconditions.checkArgument(argv.length > 1, Preconditions.checkArgument(argv.length > 1,
"usage: kestrelSink(queueName, server:port, [server2:port, server3:port,...])"); "usage: kestrelSink(queueName, server:port, [server2:port, server3:port,...])");
return new KestrelSink();
return new KestrelSink(argv[0], argv[1]);
} }
}; };
} }


Loading…
Cancel
Save