getSamples
public MetricSampler.Samples getSamples(org.apache.kafka.common.Cluster cluster,
java.util.Set<org.apache.kafka.common.TopicPartition> assignedPartitions,
long startTimeMs,
long endTimeMs,
MetricSampler.SamplingMode mode,
MetricDef metricDef,
long timeout)
throws MetricSamplingException
Get the metric sample of the given topic partition and replica from the Kafka cluster.
The samples include PartitionMetricSamples and BrokerMetricSamples.
Due to the lack of direct metrics at partition level, Kafka Cruise Control needs to estimate the CPU
utilization for each partition by using the following formula:
BROKER_CPU_UTIL = a * ALL_TOPIC_BYTES_IN_RATE + b * ALL_TOPIC_BYTES_OUT_RATE + c * ALL_FOLLOWER_BYTES_IN_RATE
LEADER_PARTITION_CPU_UTIL = a * LEADER_PARTITION_BYTES_IN + b * LEADER_PARTITION_BYTES_OUT
FOLLOWER_PARTITION_CPU_UTIL = c * LEADER_PARTITION_BYTES_IN
Kafka Cruise Control needs to know the parameters of a, b and c for cost evaluation of leader and
partition movement.
- Specified by:
getSamples
in interface MetricSampler
- Parameters:
cluster
- the metadata of the cluster.
assignedPartitions
- the topic partition
startTimeMs
- 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.
- Returns:
- the PartitionMetricSample of the topic partition and replica id
- Throws:
MetricSamplingException