Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
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;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import com.datastax.driver.core.exceptions.BootstrappingException;
import com.datastax.driver.core.exceptions.DriverInternalError;
import com.datastax.driver.core.exceptions.OverloadedException;
import com.datastax.driver.core.exceptions.QueryValidationException;
import com.datastax.driver.core.exceptions.UnavailableException;
import com.datastax.driver.core.exceptions.UnpreparedException;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.Recorder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A {@link LatencyTracker} that records query latencies over a sliding time interval, and exposes
* an API to retrieve the latency at a given percentile.
*
*
Percentiles may be computed separately for different categories of requests; this is
* implementation-dependent and determined by {@link #computeKey(Host, Statement, Exception)}.
*
*
This class is used by percentile-aware components such as {@link
* QueryLogger.Builder#withDynamicThreshold(PercentileTracker, double)} QueryLogger} and {@link
* com.datastax.driver.core.policies.PercentileSpeculativeExecutionPolicy}.
*
*
It uses HdrHistogram to record
* latencies: for each category, there is a "live" histogram where current latencies are recorded,
* and a "cached", read-only histogram that is used when clients call {@link
* #getLatencyAtPercentile(Host, Statement, Exception, double)}. Each time the cached histogram
* becomes older than the interval, the two histograms are switched. Statistics will not be
* available during the first interval at cluster startup, since we don't have a cached histogram
* yet.
*/
public abstract class PercentileTracker implements LatencyTracker {
private static final Logger logger = LoggerFactory.getLogger(PercentileTracker.class);
private final long highestTrackableLatencyMillis;
private final int numberOfSignificantValueDigits;
private final int minRecordedValues;
private final long intervalMs;
// The "live" recorders: this is where we store the latencies received from the cluster
private final ConcurrentMap