Hi Gary,

2014-09-15 1:48 GMT+02:00 terreyshih <[email protected]>:

>
> I have written a customized sink which calls some POJO API and does some
> processing.  The problem is I would like to debug the whole process via
> Eclipse.
>
> How can I start an agent which uses this customized sink in Eclipse so I
> can trace/debut it ?
>
> I can probably do remote debugging but I was wondering if anyone has done
> it in Eclipse.
>
>
I usually set up some tests and then debug them in my IDE. You can see some
sink tests at the flume-ng-sinks package:


https://github.com/apache/flume/blob/trunk/flume-ng-sinks/flume-ng-elasticsearch-sink/src/test/java/org/apache/flume/sink/elasticsearch/TestElasticSearchSink.java
https://github.com/apache/flume/blob/trunk/flume-ng-sinks/flume-irc-sink/src/test/java/org/apache/flume/sink/irc/TestIRCSink.java

These tests use a channel and a sink and feed test events directly to the
channel. The general idea is:

// Set up context
Context context = new Context();
context.put("foo", "bar");

// Instantiate sink and configure it
Sink sink = new MySink();
Configurables.configure(sink, context);

// Instantiate memoryChannel and configure it
Channel memoryChannel = new MemoryChannel();
Configurables.configure(memoryChannel, context);
sink.setChannel(memoryChannel);

sink.start();

// Start a transaction and put some events
Transaction txn = memoryChannel.getTransaction();
txn.begin();
Event event = // ... generate your test event ...
memoryChannel.put(event);
txn.commit();
txn.close();

// Process events with sink
Sink.Status status = sink.process();
// ... check status, sink effects, etc ...

You can add a source to the mix if that's really needed or even set up a
full agent.

Best,
-- 

Santiago M. Mola



Avenida de Europa, 26. Ática 5. 3ª Planta
28224 Pozuelo de Alarcón, Madrid
Tel: 91 352 59 42 // @stratiobd

Reply via email to