Search in sources :

Example 1 with MetricAnomalyFinder

use of com.linkedin.cruisecontrol.detector.metricanomaly.MetricAnomalyFinder in project cruise-control by linkedin.

the class AnomalyDetectorTestUtils method createMetricAnomalyFinder.

/**
 * Create metric anomaly finder based on config.
 * @param props Cruise Control config.
 * @return The created anomaly finder.
 */
@SuppressWarnings("unchecked")
public static MetricAnomalyFinder<BrokerEntity> createMetricAnomalyFinder(Properties props) {
    KafkaCruiseControlConfig config = new KafkaCruiseControlConfig(props);
    KafkaCruiseControl mockKafkaCruiseControl = EasyMock.mock(KafkaCruiseControl.class);
    EasyMock.expect(mockKafkaCruiseControl.config()).andReturn(config).anyTimes();
    EasyMock.expect(mockKafkaCruiseControl.timeMs()).andReturn(ANOMALY_DETECTION_TIME_MS).anyTimes();
    EasyMock.replay(mockKafkaCruiseControl);
    Map<String, Object> originalConfigs = new HashMap<>(config.originals());
    originalConfigs.put(KAFKA_CRUISE_CONTROL_OBJECT_CONFIG, mockKafkaCruiseControl);
    List<MetricAnomalyFinder> kafkaMetricAnomalyFinders = config.getConfiguredInstances(AnomalyDetectorConfig.METRIC_ANOMALY_FINDER_CLASSES_CONFIG, MetricAnomalyFinder.class, originalConfigs);
    return kafkaMetricAnomalyFinders.get(0);
}
Also used : KafkaCruiseControl(com.linkedin.kafka.cruisecontrol.KafkaCruiseControl) HashMap(java.util.HashMap) KafkaCruiseControlConfig(com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig) MetricAnomalyFinder(com.linkedin.cruisecontrol.detector.metricanomaly.MetricAnomalyFinder)

Aggregations

MetricAnomalyFinder (com.linkedin.cruisecontrol.detector.metricanomaly.MetricAnomalyFinder)1 KafkaCruiseControl (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)1 KafkaCruiseControlConfig (com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig)1 HashMap (java.util.HashMap)1