public class LoadMonitor
extends java.lang.Object
PartitionMetricSample
. It is also responsible for aggregate the metrics samples into
AggregatedMetricValues
for the analyzer to generate the balancing proposals.Modifier and Type | Class and Description |
---|---|
class |
LoadMonitor.AutoCloseableSemaphore |
Constructor and Description |
---|
LoadMonitor(KafkaCruiseControlConfig config,
org.apache.kafka.common.utils.Time time,
DataBalancerMetricsRegistry metricRegistry,
MetricDef metricDef)
Construct a load monitor.
|
Modifier and Type | Method and Description |
---|---|
LoadMonitor.AutoCloseableSemaphore |
acquireForModelGeneration(OperationProgress operationProgress)
Acquire the semaphore for the cluster model generation.
|
MetricSampleAggregationResult<java.lang.String,BrokerEntity> |
brokerMetrics() |
java.util.Set<java.lang.Integer> |
brokersWithOfflineReplicas(int timeout)
Get all the brokers having offline replca in the cluster based on the partition assignment.
|
java.util.Set<java.lang.Integer> |
brokersWithReplicas(int timeout)
Get all the active brokers in the cluster based on the replica assignment.
|
BrokerStats |
cachedBrokerLoadStats(boolean allowCapacityEstimation)
Get the cached load.
|
ClusterModel |
clusterModel(long from,
long to,
ModelCompletenessRequirements requirements,
boolean populateReplicaPlacementInfo,
OperationProgress operationProgress)
Get the cluster load model for a time range.
|
ClusterModel |
clusterModel(long from,
long to,
ModelCompletenessRequirements requirements,
OperationProgress operationProgress)
Get the cluster load model for a time range.
|
ClusterModel |
clusterModel(long now,
ModelCompletenessRequirements requirements,
OperationProgress operationProgress)
Get the most recent cluster load model before the given timestamp.
|
ModelGeneration |
clusterModelGeneration()
Get the current cluster model generation.
|
long |
computeThrottle()
Computes a replication throttle based on the network capacity and the current network usage
|
java.util.Map<BrokerEntity,ValuesAndExtrapolations> |
currentBrokerMetricValues()
Get the latest metric values of the brokers.
|
java.util.Map<PartitionEntity,ValuesAndExtrapolations> |
currentPartitionMetricValues()
Get the latest metric values of the partitions.
|
java.util.Set<java.lang.Integer> |
deadBrokersWithReplicas(int timeout)
Get all the dead brokers in the cluster based on the replica assignment.
|
MetadataClient.ClusterAndGeneration |
forceRefreshClusterAndGeneration() |
org.apache.kafka.common.Cluster |
kafkaCluster()
Get the cluster information from Kafka metadata.
|
boolean |
meetCompletenessRequirements(MetadataClient.ClusterAndGeneration clusterAndGeneration,
ModelCompletenessRequirements requirements)
Check whether the monitored load meets the load requirements.
|
boolean |
meetCompletenessRequirements(ModelCompletenessRequirements requirements)
Check whether the monitored load meets the load requirements.
|
void |
pauseMetricSampling(java.lang.String reason)
Pause all the activities of the load monitor.
|
MetadataClient.ClusterAndGeneration |
refreshClusterAndGeneration() |
void |
resumeMetricSampling(java.lang.String reason)
Resume the activities of the load monitor.
|
void |
shutdown()
Shutdown the load monitor.
|
void |
startUp()
Start the load monitor.
|
LoadMonitorState |
state(OperationProgress operationProgress,
MetadataClient.ClusterAndGeneration clusterAndGeneration)
Get the state of the load monitor.
|
LoadMonitorTaskRunner.LoadMonitorTaskRunnerState |
taskRunnerState()
Return the load monitor task runner state.
|
public LoadMonitor(KafkaCruiseControlConfig config, org.apache.kafka.common.utils.Time time, DataBalancerMetricsRegistry metricRegistry, MetricDef metricDef)
config
- The load monitor configuration.time
- The time object.metricRegistry
- The sensor registry for cruise controlmetricDef
- The metric definitions.public void startUp()
public void shutdown()
public LoadMonitorState state(OperationProgress operationProgress, MetadataClient.ClusterAndGeneration clusterAndGeneration)
public LoadMonitorTaskRunner.LoadMonitorTaskRunnerState taskRunnerState()
public org.apache.kafka.common.Cluster kafkaCluster()
public void pauseMetricSampling(java.lang.String reason)
reason
- The reason for pausing metric sampling.public void resumeMetricSampling(java.lang.String reason)
reason
- The reason for resuming metric sampling.public LoadMonitor.AutoCloseableSemaphore acquireForModelGeneration(OperationProgress operationProgress) throws java.lang.InterruptedException
operationProgress
- the progress for the job.java.lang.InterruptedException
public java.util.Map<BrokerEntity,ValuesAndExtrapolations> currentBrokerMetricValues()
public java.util.Map<PartitionEntity,ValuesAndExtrapolations> currentPartitionMetricValues()
public ClusterModel clusterModel(long now, ModelCompletenessRequirements requirements, OperationProgress operationProgress) throws NotEnoughValidWindowsException
now
- The current time in millisecond.requirements
- the load requirements for getting the cluster model.operationProgress
- the progress to report.NotEnoughValidWindowsException
- If there is not enough sample to generate cluster model.public ClusterModel clusterModel(long from, long to, ModelCompletenessRequirements requirements, OperationProgress operationProgress) throws NotEnoughValidWindowsException
from
- start of the time windowto
- end of the time windowrequirements
- the load completeness requirements.operationProgress
- the progress of the job to report.NotEnoughValidWindowsException
- If there is not enough sample to generate cluster model.public ClusterModel clusterModel(long from, long to, ModelCompletenessRequirements requirements, boolean populateReplicaPlacementInfo, OperationProgress operationProgress) throws NotEnoughValidWindowsException
from
- start of the time windowto
- end of the time windowrequirements
- the load completeness requirements.populateReplicaPlacementInfo
- whether populate replica placement information.operationProgress
- the progress of the job to report.NotEnoughValidWindowsException
- If there is not enough sample to generate cluster model.public ModelGeneration clusterModelGeneration()
public BrokerStats cachedBrokerLoadStats(boolean allowCapacityEstimation)
public java.util.Set<java.lang.Integer> brokersWithReplicas(int timeout)
timeout
- the timeout in milliseconds.public MetadataClient.ClusterAndGeneration refreshClusterAndGeneration()
public MetadataClient.ClusterAndGeneration forceRefreshClusterAndGeneration()
public boolean meetCompletenessRequirements(MetadataClient.ClusterAndGeneration clusterAndGeneration, ModelCompletenessRequirements requirements)
public boolean meetCompletenessRequirements(ModelCompletenessRequirements requirements)
public MetricSampleAggregationResult<java.lang.String,BrokerEntity> brokerMetrics()
public long computeThrottle()
public java.util.Set<java.lang.Integer> deadBrokersWithReplicas(int timeout)
timeout
- the timeout in milliseconds.public java.util.Set<java.lang.Integer> brokersWithOfflineReplicas(int timeout)
timeout
- the timeout in milliseconds.