Package org.apache.cassandra.metrics
Class Sampler<T>
java.lang.Object
org.apache.cassandra.metrics.Sampler<T>
- Direct Known Subclasses:
FrequencySampler,MaxSampler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the ranked items collected during a sample periodstatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabstract voidbeginSampling(int capacity, long durationMillis) Begin sampling with the configured capacity and durationvoiddisable()abstract List<Sampler.Sample<T>>finishSampling(int count) Stop sampling and return the resultsprotected abstract voidbooleanisActive()booleanA sampler is enabled between {@link this#beginSampling} and {@link this#finishSampling}static voidshutdownNowAndWait(long time, TimeUnit units) abstract StringvoidupdateEndTime(long endTimeMillis) Update the end time for the sampler.
-
Field Details
-
samplerExecutor
-
-
Constructor Details
-
Sampler
public Sampler()
-
-
Method Details
-
addSample
-
insert
-
isEnabled
public boolean isEnabled()A sampler is enabled between {@link this#beginSampling} and {@link this#finishSampling}- Returns:
- true if the sampler is enabled.
-
disable
public void disable() -
isActive
public boolean isActive()- Returns:
- true if the sampler is active. A sampler is active only if it is enabled and the current time is within the `durationMillis` when beginning sampling.
-
updateEndTime
public void updateEndTime(long endTimeMillis) Update the end time for the sampler. Implicitly, calling this method enables the sampler. -
beginSampling
public abstract void beginSampling(int capacity, long durationMillis) Begin sampling with the configured capacity and duration- Parameters:
capacity- Number of sample items to keep in memory, the lower this is the less accurate results are. For best results use value close to cardinality, but understand the memory trade offs.durationMillis- Upperbound duration in milliseconds for sampling. The sampler stops accepting new samples after exceeding the duration even iffinishSampling(int)} is not called.
-
finishSampling
Stop sampling and return the results- Parameters:
count- The number of the samples requested to retrieve from the sampler- Returns:
- a list of samples, the size is the minimum of the total samples and .
-
toString
-
shutdownNowAndWait
public static void shutdownNowAndWait(long time, TimeUnit units) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-