public interface MetricSampler extends CruiseControlConfigurable, AutoCloseable
Kafka Cruise Control periodically collects the metrics of all the partitions in the cluster, including the leader and follower
replicas. The getSamples(Cluster, Set, long, long, SamplingMode, MetricDef, long)
will be called for all the replicas of partitions in the cluster in one sampling period.
The MetricSampler may be used by multiple threads at the same time, so the implementation need to be thread safe.
Modifier and Type | Interface and Description |
---|---|
static class |
MetricSampler.Samples
A container class that wraps both the partition metric samples and broker metric samples.
|
static class |
MetricSampler.SamplingMode
The sampling mode to indicate which type of samples is interested.
|
Modifier and Type | Field and Description |
---|---|
static MetricSampler.Samples |
EMPTY_SAMPLES |
Modifier and Type | Method and Description |
---|---|
MetricSampler.Samples |
getSamples(org.apache.kafka.common.Cluster cluster,
Set<org.apache.kafka.common.TopicPartition> assignedPartitions,
long startTimeMs,
long endTimeMs,
MetricSampler.SamplingMode mode,
MetricDef metricDef,
long timeout)
Get the metric sample of the given topic partition and replica from the Kafka cluster.
|
configure
close
static final MetricSampler.Samples EMPTY_SAMPLES
MetricSampler.Samples getSamples(org.apache.kafka.common.Cluster cluster, Set<org.apache.kafka.common.TopicPartition> assignedPartitions, long startTimeMs, long endTimeMs, MetricSampler.SamplingMode mode, MetricDef metricDef, long timeout) throws MetricSamplingException
cluster
- the metadata of the cluster.assignedPartitions
- the topic partitionstartTimeMs
- the start time of the sampling period.endTimeMs
- the end time of the sampling period.mode
- The sampling mode.metricDef
- the metric definitions.timeout
- The sampling timeout to stop sampling even if there is more data to get.MetricSamplingException