Search in sources :

Example 1 with Recorder

use of org.HdrHistogram.Recorder in project hazelcast-simulator by hazelcast.

the class TestContainer_TimeStep_AsyncSupportTest method getProbeTotalCount.

private static long getProbeTotalCount(String probeName, TestContainer container) {
    Map<String, Probe> probeMap = container.getProbeMap();
    HdrProbe probe = (HdrProbe) probeMap.get(probeName);
    Recorder recorder = probe.getRecorder();
    return recorder.getIntervalHistogram().getTotalCount();
}
Also used : HdrProbe(com.hazelcast.simulator.probes.impl.HdrProbe) Recorder(org.HdrHistogram.Recorder) Probe(com.hazelcast.simulator.probes.Probe) HdrProbe(com.hazelcast.simulator.probes.impl.HdrProbe)

Example 2 with Recorder

use of org.HdrHistogram.Recorder in project java-driver by datastax.

the class PercentileTracker method getLastIntervalHistogram.

/**
 * @return null if no histogram is available yet (no entries recorded, or not for long enough)
 */
private Histogram getLastIntervalHistogram(Host host, Statement statement, Exception exception) {
    Object key = computeKey(host, statement, exception);
    if (key == null)
        return null;
    try {
        while (true) {
            CachedHistogram entry = cachedHistograms.get(key);
            if (entry == null)
                return null;
            long age = System.currentTimeMillis() - entry.timestamp;
            if (age < intervalMs) {
                // current histogram is recent enough
                return entry.histogram.get();
            } else {
                // need to refresh
                Recorder recorder = recorders.get(key);
                // intervalMs should be much larger than the time it takes to replace a histogram, so this future should never block
                Histogram staleHistogram = entry.histogram.get(0, MILLISECONDS);
                SettableFuture<Histogram> future = SettableFuture.create();
                CachedHistogram newEntry = new CachedHistogram(future);
                if (cachedHistograms.replace(key, entry, newEntry)) {
                    // Only get the new histogram if we successfully replaced the cache entry.
                    // This ensures that only one thread will do it.
                    Histogram newHistogram = recorder.getIntervalHistogram(staleHistogram);
                    future.set(newHistogram);
                    return newHistogram;
                }
            // If we couldn't replace the entry it means we raced, so loop to try again
            }
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return null;
    } catch (ExecutionException e) {
        throw new DriverInternalError("Unexpected error", e.getCause());
    } catch (TimeoutException e) {
        throw new DriverInternalError("Unexpected timeout while getting histogram", e);
    }
}
Also used : Histogram(org.HdrHistogram.Histogram) Recorder(org.HdrHistogram.Recorder)

Example 3 with Recorder

use of org.HdrHistogram.Recorder in project HdrHistogram by HdrHistogram.

the class HdrHistogramRecordingBench method setup.

@Setup
public void setup() throws NoSuchMethodException {
    histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
    synchronizedHistogram = new SynchronizedHistogram(highestTrackableValue, numberOfSignificantValueDigits);
    atomicHistogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);
    concurrentHistogram = new ConcurrentHistogram(highestTrackableValue, numberOfSignificantValueDigits);
    recorder = new Recorder(highestTrackableValue, numberOfSignificantValueDigits);
    singleWriterRecorder = new SingleWriterRecorder(highestTrackableValue, numberOfSignificantValueDigits);
    doubleHistogram = new DoubleHistogram(highestTrackableValue, numberOfSignificantValueDigits);
    doubleRecorder = new DoubleRecorder(highestTrackableValue, numberOfSignificantValueDigits);
    singleWriterDoubleRecorder = new SingleWriterDoubleRecorder(highestTrackableValue, numberOfSignificantValueDigits);
}
Also used : AbstractHistogram(org.HdrHistogram.AbstractHistogram) HdrHistogram(org.HdrHistogram) Recorder(org.HdrHistogram.Recorder) Setup(org.openjdk.jmh.annotations.Setup)

Example 4 with Recorder

use of org.HdrHistogram.Recorder in project java-driver by datastax.

the class PercentileTracker method getRecorder.

private Recorder getRecorder(Host host, Statement statement, Exception exception) {
    Object key = computeKey(host, statement, exception);
    if (key == null)
        return null;
    Recorder recorder = recorders.get(key);
    if (recorder == null) {
        recorder = new Recorder(highestTrackableLatencyMillis, numberOfSignificantValueDigits);
        Recorder old = recorders.putIfAbsent(key, recorder);
        if (old != null) {
            // We got beaten at creating the recorder, use the actual instance and discard ours
            recorder = old;
        } else {
            // Also set an empty cache entry to remember the time we started recording:
            cachedHistograms.putIfAbsent(key, CachedHistogram.empty());
        }
    }
    return recorder;
}
Also used : Recorder(org.HdrHistogram.Recorder)

Aggregations

Recorder (org.HdrHistogram.Recorder)4 Probe (com.hazelcast.simulator.probes.Probe)1 HdrProbe (com.hazelcast.simulator.probes.impl.HdrProbe)1 HdrHistogram (org.HdrHistogram)1 AbstractHistogram (org.HdrHistogram.AbstractHistogram)1 Histogram (org.HdrHistogram.Histogram)1 Setup (org.openjdk.jmh.annotations.Setup)1