Search in sources :

Example 6 with ValuesAndExtrapolations

use of com.linkedin.cruisecontrol.monitor.sampling.aggregator.ValuesAndExtrapolations in project cruise-control by linkedin.

the class LoadMonitor method getMonitoredPartitionsPercentage.

private double getMonitoredPartitionsPercentage() {
    MetadataClient.ClusterAndGeneration clusterAndGeneration = _metadataClient.refreshMetadata();
    Cluster kafkaCluster = clusterAndGeneration.cluster();
    MetricSampleAggregationResult<String, PartitionEntity> metricSampleAggregationResult;
    try {
        metricSampleAggregationResult = _metricSampleAggregator.aggregate(clusterAndGeneration, System.currentTimeMillis(), new OperationProgress());
    } catch (NotEnoughValidWindowsException e) {
        return 0.0;
    }
    Map<PartitionEntity, ValuesAndExtrapolations> partitionLoads = metricSampleAggregationResult.valuesAndExtrapolations();
    AtomicInteger numPartitionsWithExtrapolations = new AtomicInteger(0);
    partitionLoads.values().forEach(valuesAndExtrapolations -> {
        if (!valuesAndExtrapolations.extrapolations().isEmpty()) {
            numPartitionsWithExtrapolations.incrementAndGet();
        }
    });
    _numPartitionsWithExtrapolations = numPartitionsWithExtrapolations.get();
    int totalNumPartitions = MonitorUtils.totalNumPartitions(kafkaCluster);
    return totalNumPartitions > 0 ? metricSampleAggregationResult.completeness().validEntityRatio() : 0.0;
}
Also used : MetadataClient(com.linkedin.kafka.cruisecontrol.common.MetadataClient) ValuesAndExtrapolations(com.linkedin.cruisecontrol.monitor.sampling.aggregator.ValuesAndExtrapolations) OperationProgress(com.linkedin.kafka.cruisecontrol.async.progress.OperationProgress) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PartitionEntity(com.linkedin.kafka.cruisecontrol.monitor.sampling.PartitionEntity) Cluster(org.apache.kafka.common.Cluster) NotEnoughValidWindowsException(com.linkedin.cruisecontrol.exception.NotEnoughValidWindowsException)

Aggregations

ValuesAndExtrapolations (com.linkedin.cruisecontrol.monitor.sampling.aggregator.ValuesAndExtrapolations)6 PartitionEntity (com.linkedin.kafka.cruisecontrol.monitor.sampling.PartitionEntity)6 OperationProgress (com.linkedin.kafka.cruisecontrol.async.progress.OperationProgress)4 MetadataClient (com.linkedin.kafka.cruisecontrol.common.MetadataClient)3 KafkaCruiseControlConfig (com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig)3 Metadata (org.apache.kafka.clients.Metadata)3 Cluster (org.apache.kafka.common.Cluster)3 TopicPartition (org.apache.kafka.common.TopicPartition)3 Test (org.junit.Test)3 NotEnoughValidWindowsException (com.linkedin.cruisecontrol.exception.NotEnoughValidWindowsException)2 Extrapolation (com.linkedin.cruisecontrol.monitor.sampling.aggregator.Extrapolation)2 Resource (com.linkedin.kafka.cruisecontrol.common.Resource)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 MetricDef (com.linkedin.cruisecontrol.metricdef.MetricDef)1 ModelCompletenessRequirements (com.linkedin.kafka.cruisecontrol.monitor.ModelCompletenessRequirements)1 KafkaCruiseControlMetricDef (com.linkedin.kafka.cruisecontrol.monitor.metricdefinition.KafkaCruiseControlMetricDef)1 PartitionMetricSample (com.linkedin.kafka.cruisecontrol.monitor.sampling.PartitionMetricSample)1 SampleExtrapolation (com.linkedin.kafka.cruisecontrol.monitor.sampling.aggregator.SampleExtrapolation)1