@Test public void testMeetCompletenessRequirements() { TestContext context = prepareContext(); LoadMonitor loadMonitor = context.loadmonitor(); KafkaPartitionMetricSampleAggregator aggregator = context.aggregator(); ModelCompletenessRequirements requirements1 = new ModelCompletenessRequirements(1, 1.0, false); ModelCompletenessRequirements requirements2 = new ModelCompletenessRequirements(1, 0.5, false); ModelCompletenessRequirements requirements3 = new ModelCompletenessRequirements(2, 1.0, false); ModelCompletenessRequirements requirements4 = new ModelCompletenessRequirements(2, 0.5, false); CruiseControlUnitTestUtils.populateSampleAggregator(2, 4, aggregator, PE_T0P0, 0, WINDOW_MS, METRIC_DEF); CruiseControlUnitTestUtils.populateSampleAggregator(2, 4, aggregator, PE_T0P1, 0, WINDOW_MS, METRIC_DEF); CruiseControlUnitTestUtils.populateSampleAggregator(2, 4, aggregator, PE_T1P0, 0, WINDOW_MS, METRIC_DEF); MetadataClient.ClusterAndGeneration clusterAndGeneration = loadMonitor.refreshClusterAndGeneration(); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements1)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements2)); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements3)); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements4)); CruiseControlUnitTestUtils.populateSampleAggregator(1, 4, aggregator, PE_T0P0, 2, WINDOW_MS, METRIC_DEF); CruiseControlUnitTestUtils.populateSampleAggregator(1, 4, aggregator, PE_T0P1, 2, WINDOW_MS, METRIC_DEF); CruiseControlUnitTestUtils.populateSampleAggregator(1, 4, aggregator, PE_T1P0, 2, WINDOW_MS, METRIC_DEF); CruiseControlUnitTestUtils.populateSampleAggregator(1, 1, aggregator, PE_T1P1, 2, WINDOW_MS, METRIC_DEF); clusterAndGeneration = loadMonitor.refreshClusterAndGeneration(); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements1)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements2)); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements3)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements4)); CruiseControlUnitTestUtils.populateSampleAggregator(1, 1, aggregator, PE_T1P1, 0, WINDOW_MS, METRIC_DEF); clusterAndGeneration = loadMonitor.refreshClusterAndGeneration(); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements1)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements2)); assertFalse(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements3)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements4)); CruiseControlUnitTestUtils.populateSampleAggregator(1, 3, aggregator, PE_T1P1, 1, WINDOW_MS, METRIC_DEF); clusterAndGeneration = loadMonitor.refreshClusterAndGeneration(); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements1)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements2)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements3)); assertTrue(loadMonitor.meetCompletenessRequirements(clusterAndGeneration.cluster(), requirements4)); }
public boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements) { int numValidWindows = _partitionMetricSampleAggregator.validWindows(cluster, requirements.minMonitoredPartitionsPercentage()).size(); int requiredNumValidWindows = requirements.minRequiredNumWindows(); return numValidWindows >= requiredNumValidWindows; }
LoadMonitor { public boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements) { int numValidWindows = _partitionMetricSampleAggregator.validWindows(cluster, requirements.minMonitoredPartitionsPercentage()).size(); int requiredNumValidWindows = requirements.minRequiredNumWindows(); return numValidWindows >= requiredNumValidWindows; } }
LoadMonitor { public boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements) { int numValidWindows = _partitionMetricSampleAggregator.validWindows(cluster, requirements.minMonitoredPartitionsPercentage()).size(); int requiredNumValidWindows = requirements.minRequiredNumWindows(); return numValidWindows >= requiredNumValidWindows; } LoadMonitor(KafkaCruiseControlConfig config, Time time, MetricRegistry dropwizardMetricRegistry, MetricDef metricDef);   LoadMonitor(KafkaCruiseControlConfig config,
              MetadataClient metadataClient,
              AdminClient adminClient,
              Time time,
              MetricRegistry dropwizardMetricRegistry,
              MetricDef metricDef); }
LoadMonitor { public boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements) { int numValidWindows = _partitionMetricSampleAggregator.validWindows(cluster, requirements.minMonitoredPartitionsPercentage()).size(); int requiredNumValidWindows = requirements.minRequiredNumWindows(); return numValidWindows >= requiredNumValidWindows; } LoadMonitor(KafkaCruiseControlConfig config, Time time, MetricRegistry dropwizardMetricRegistry, MetricDef metricDef);   LoadMonitor(KafkaCruiseControlConfig config,
              MetadataClient metadataClient,
              AdminClient adminClient,
              Time time,
              MetricRegistry dropwizardMetricRegistry,
              MetricDef metricDef); void startUp(); void shutdown(); LoadMonitorState state(Cluster kafkaCluster); TopicConfigProvider topicConfigProvider(); LoadMonitorTaskRunner.LoadMonitorTaskRunnerState taskRunnerState(); void bootstrap(long startMs, long endMs, boolean clearMetrics); void bootstrap(long startMs, boolean clearMetrics); void bootstrap(boolean clearMetrics); void train(long startMs, long endMs); Cluster kafkaCluster(); void pauseMetricSampling(String reason, boolean forcePauseSampling); void resumeMetricSampling(String reason); MetricSampler.SamplingMode samplingMode(); void setSamplingMode(MetricSampler.SamplingMode samplingMode); AutoCloseableSemaphore acquireForModelGeneration(OperationProgress operationProgress); Map<BrokerEntity, ValuesAndExtrapolations> currentBrokerMetricValues(); Map<PartitionEntity, ValuesAndExtrapolations> currentPartitionMetricValues(); ClusterModel clusterModel(long now,
                                   ModelCompletenessRequirements requirements,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ClusterModel clusterModel(long from,
                                   long to,
                                   ModelCompletenessRequirements requirements,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ClusterModel clusterCapacity(); ClusterModel clusterModel(long from,
                                   long to,
                                   ModelCompletenessRequirements requirements,
                                   boolean populateReplicaPlacementInfo,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ModelGeneration clusterModelGeneration(); synchronized BrokerStats cachedBrokerLoadStats(boolean allowCapacityEstimation); Set<Integer> brokersWithReplicas(long timeout); MetadataClient.ClusterAndGeneration refreshClusterAndGeneration(); boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements); boolean meetCompletenessRequirements(ModelCompletenessRequirements requirements); MetricSampleAggregationResult<String, BrokerEntity> brokerMetrics(); Set<Integer> deadBrokersWithReplicas(long timeout); Set<Integer> brokersWithOfflineReplicas(long timeout); long lastUpdateMs(); }
LoadMonitor { public boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements) { int numValidWindows = _partitionMetricSampleAggregator.validWindows(cluster, requirements.minMonitoredPartitionsPercentage()).size(); int requiredNumValidWindows = requirements.minRequiredNumWindows(); return numValidWindows >= requiredNumValidWindows; } LoadMonitor(KafkaCruiseControlConfig config, Time time, MetricRegistry dropwizardMetricRegistry, MetricDef metricDef);   LoadMonitor(KafkaCruiseControlConfig config,
              MetadataClient metadataClient,
              AdminClient adminClient,
              Time time,
              MetricRegistry dropwizardMetricRegistry,
              MetricDef metricDef); void startUp(); void shutdown(); LoadMonitorState state(Cluster kafkaCluster); TopicConfigProvider topicConfigProvider(); LoadMonitorTaskRunner.LoadMonitorTaskRunnerState taskRunnerState(); void bootstrap(long startMs, long endMs, boolean clearMetrics); void bootstrap(long startMs, boolean clearMetrics); void bootstrap(boolean clearMetrics); void train(long startMs, long endMs); Cluster kafkaCluster(); void pauseMetricSampling(String reason, boolean forcePauseSampling); void resumeMetricSampling(String reason); MetricSampler.SamplingMode samplingMode(); void setSamplingMode(MetricSampler.SamplingMode samplingMode); AutoCloseableSemaphore acquireForModelGeneration(OperationProgress operationProgress); Map<BrokerEntity, ValuesAndExtrapolations> currentBrokerMetricValues(); Map<PartitionEntity, ValuesAndExtrapolations> currentPartitionMetricValues(); ClusterModel clusterModel(long now,
                                   ModelCompletenessRequirements requirements,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ClusterModel clusterModel(long from,
                                   long to,
                                   ModelCompletenessRequirements requirements,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ClusterModel clusterCapacity(); ClusterModel clusterModel(long from,
                                   long to,
                                   ModelCompletenessRequirements requirements,
                                   boolean populateReplicaPlacementInfo,
                                   boolean allowCapacityEstimation,
                                   OperationProgress operationProgress); ModelGeneration clusterModelGeneration(); synchronized BrokerStats cachedBrokerLoadStats(boolean allowCapacityEstimation); Set<Integer> brokersWithReplicas(long timeout); MetadataClient.ClusterAndGeneration refreshClusterAndGeneration(); boolean meetCompletenessRequirements(Cluster cluster, ModelCompletenessRequirements requirements); boolean meetCompletenessRequirements(ModelCompletenessRequirements requirements); MetricSampleAggregationResult<String, BrokerEntity> brokerMetrics(); Set<Integer> deadBrokersWithReplicas(long timeout); Set<Integer> brokersWithOfflineReplicas(long timeout); long lastUpdateMs();  }