Search in sources :

Example 36 with Histogram

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;
        }
    });
}
Also used : Histogram(org.HdrHistogram.Histogram) ObjectPublisher(org.nustaq.fastcast.api.util.ObjectPublisher) ObjectSubscriber(org.nustaq.fastcast.api.util.ObjectSubscriber)

Aggregations

Histogram (org.HdrHistogram.Histogram)36 Utils.saveHistogram (io.grpc.benchmarks.Utils.saveHistogram)6 ByteBuffer (java.nio.ByteBuffer)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 InetSocketAddress (java.net.InetSocketAddress)4 DatagramChannel (java.nio.channels.DatagramChannel)4 ArrayList (java.util.ArrayList)4 ManagedChannel (io.grpc.ManagedChannel)3 SimpleRequest (io.grpc.benchmarks.proto.Messages.SimpleRequest)3 AtomicHistogram (org.HdrHistogram.AtomicHistogram)3 FCSubscriber (org.nustaq.fastcast.api.FCSubscriber)3 Bytez (org.nustaq.offheap.bytez.Bytez)3 ParameterException (com.beust.jcommander.ParameterException)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)2 IntHashSet (com.hazelcast.util.collection.IntHashSet)2 BenchmarkServiceStub (io.grpc.benchmarks.proto.BenchmarkServiceGrpc.BenchmarkServiceStub)2 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2