@Beta public class PerHostPercentileTracker extends Object implements LatencyTracker
LatencyTrackerthat records latencies for each host over a sliding time interval, and exposes an API to retrieve the latency at a given percentile.
PerHostPercentileTracker tracker = PerHostPercentileTracker .builderWithHighestTrackableLatencyMillis(15000) .build(); cluster.register(tracker); ... tracker.getLatencyAtPercentile(host1, 99.0);
This class uses HdrHistogram to record latencies:
for each host, there is a "live" histogram where current latencies are recorded, and a "cached", read-only histogram
that is used when clients call
getLatencyAtPercentile(Host, double). Each time the cached histogram becomes
older than the interval, the two histograms are switched. Note that statistics will not be available during the first
interval at cluster startup, since we don't have a cached histogram yet.
Note that this class is currently marked "beta": it hasn't been extensively tested yet, and the API is still subject to change.
|Modifier and Type||Class and Description|
Helper class to builder
|Modifier and Type||Method and Description|
Returns a builder to create a new instance.
Returns the request latency for a host at a given percentile.
Gets invoked when the tracker is registered with a cluster, or at cluster startup if the tracker was registered at initialization with
Gets invoked when the tracker is unregistered from a cluster, or at cluster shutdown if the tracker was not unregistered.
A method that is called after each request to a Cassandra node with the duration of that operation.
public static PerHostPercentileTracker.Builder builderWithHighestTrackableLatencyMillis(long highestTrackableLatencyMillis)
highestTrackableLatencyMillis- the highest expected latency. If a higher value is reported, it will be ignored and a warning will be logged. A good rule of thumb is to set it slightly higher than
Note that there is no guarantee that this method won't be called concurrently by multiple threads, so implementations should synchronize internally if need be.
host- The Cassandra host on which a request has been performed. This parameter is never
Statementthat has been executed. This parameter is never
Exceptionthrown when receiving the response, or
nullif the response was successful.
newLatencyNanos- the latency in nanoseconds of the operation. This latency corresponds to the time elapsed between when the query was sent to
hostand when the response was received by the driver (or the operation timed out, in which
newLatencyNanoswill approximately be the timeout value).
public long getLatencyAtPercentile(Host host, double percentile)
host- the host.
percentile- the percentile (for example,
99.0for the 99th percentile).
public void onRegister(Cluster cluster)
public void onUnregister(Cluster cluster)
Copyright © 2012–2015. All rights reserved.