use of org.HdrHistogram.Histogram in project fast-cast by RuedigerMoeller.
the class AsyncLatPublisher method initFastCast.
public void initFastCast() throws Exception {
fastCast = FastCast.getFastCast();
fastCast.setNodeId("PUB");
fastCast.loadConfig(CFG_FILE_PATH);
pub = new ObjectPublisher(fastCast.onTransport("default").publish("stream"), AsyncLatMessage.class);
fastCast.onTransport("back").subscribe("back", new ObjectSubscriber(false, AsyncLatMessage.class) {
@Override
protected void objectReceived(String s, long l, Object o) {
if ("END".equals(o)) {
final Histogram oldHi = hi;
hi = new Histogram(TimeUnit.SECONDS.toNanos(2), 3);
// no lambdas to stay 1.7 compatible
// move printing out of the receiving thread
dumper.execute(new Runnable() {
@Override
public void run() {
oldHi.outputPercentileDistribution(System.out, 1000.0);
}
});
// hi.reset();
return;
}
final long value = System.nanoTime() - ((AsyncLatMessage) o).getSendTimeStampNanos();
if (value < 1_000_000_000)
hi.recordValue(value);
}
@Override
public boolean dropped() {
System.exit(-2);
return false;
}
});
}
Aggregations