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;
}
Aggregations