EventSink rpcSink = fact.createSink(ctx, "rpcSink", "0.0.0.0", 31337);
EventSink counter = fact.createSink(ctx, "counter", (Object) "count");
EventSource txtsrc = srcfact.createSource(ctx, "asciisynth", 25, 100);
DirectDriver svrconn = new DirectDriver(rpcSrc, counter);
svrconn.start();
assertTrue("rpc server took too long to start",
svrconn.waitForAtLeastState(DriverState.ACTIVE, 1000));
// start and send the data
DirectDriver cliconn = new DirectDriver(txtsrc, rpcSink);
cliconn.start();
// the avro version sometimes takes a while to start jetty
assertTrue("rpc client took too long to connect",
cliconn.waitForAtLeastState(DriverState.ACTIVE, 10000));
assertTrue("rpc client took too long to close cleanly",
cliconn.waitForAtLeastState(DriverState.IDLE, 2500));
Clock.sleep(2000); // data could be stuck in tcp buffer
svrconn.stop();
rpcSrc.close(); // force rpc close to make sure next test does not port
// conflict.
assertTrue("rpc server took too long to close cleanly",
svrconn.waitForAtLeastState(DriverState.IDLE, 2000));
LOG.info("read " + ((CounterSink) counter).getCount() + " lines");
assertEquals(LINES, ((CounterSink) counter).getCount());
assertNull(cliconn.getException());
assertNull(svrconn.getException());
}