com.datastax.driver.core.ClusterWidePercentileTracker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dse-java-driver-core Show documentation
Show all versions of dse-java-driver-core Show documentation
A driver for DataStax Enterprise (DSE)
and Apache Cassandra 1.2+ clusters that works exclusively with the
Cassandra Query Language version 3 (CQL3) and Cassandra's binary protocol,
supporting DSE-specific features such as geospatial types, DSE Graph and DSE authentication.
/*
* Copyright DataStax, Inc.
*
* This software can be used solely with DataStax Enterprise. Please consult the license at
* http://www.datastax.com/terms/datastax-dse-driver-license-terms
*/
package com.datastax.driver.core;
/**
* A {@code PercentileTracker} that aggregates all measurements into a single histogram.
*
* This gives you global latency percentiles for the whole cluster, meaning that latencies of slower hosts will tend to
* appear in higher percentiles.
*/
public class ClusterWidePercentileTracker extends PercentileTracker {
private volatile Cluster cluster;
private ClusterWidePercentileTracker(long highestTrackableLatencyMillis,
int numberOfSignificantValueDigits,
int minRecordedValues,
long intervalMs) {
super(highestTrackableLatencyMillis, numberOfSignificantValueDigits, minRecordedValues, intervalMs);
}
@Override
public void onRegister(Cluster cluster) {
this.cluster = cluster;
}
@Override
protected Cluster computeKey(Host host, Statement statement, Exception exception) {
return cluster;
}
/**
* Returns a builder to create a new instance.
*
* @param 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 {@link SocketOptions#getReadTimeoutMillis()}.
* @return the builder.
*/
public static Builder builder(long highestTrackableLatencyMillis) {
return new Builder(highestTrackableLatencyMillis);
}
/**
* Helper class to build {@code PerHostPercentileTracker} instances with a fluent interface.
*/
public static class Builder extends PercentileTracker.Builder {
Builder(long highestTrackableLatencyMillis) {
super(highestTrackableLatencyMillis);
}
@Override
protected Builder self() {
return this;
}
@Override
public ClusterWidePercentileTracker build() {
return new ClusterWidePercentileTracker(highestTrackableLatencyMillis, numberOfSignificantValueDigits,
minRecordedValues, intervalMs);
}
}
}