Search in sources :

Example 1 with HealthPolicyConfig

use of com.twitter.heron.healthmgr.HealthPolicyConfig in project incubator-heron by apache.

the class BackPressureDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_NOISE_FILTER, 20)).thenReturn(50);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 55);
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    BackPressureSensor sensor = mock(BackPressureSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    BackPressureDetector detector = new BackPressureDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    Assert.assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 45);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BackPressureSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new BackPressureDetector(sensor, config);
    symptoms = detector.detect();
    Assert.assertEquals(0, symptoms.size());
}
Also used : HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) BackPressureSensor(com.twitter.heron.healthmgr.sensors.BackPressureSensor) HashMap(java.util.HashMap) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 2 with HealthPolicyConfig

use of com.twitter.heron.healthmgr.HealthPolicyConfig in project incubator-heron by apache.

the class GrowingWaitQueueDetectorTest method testDetector.

@Test
public void testDetector() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_LIMIT, 10.0)).thenReturn(5.0);
    ComponentMetrics compMetrics;
    InstanceMetrics instanceMetrics;
    Map<Instant, Double> bufferSizes;
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    instanceMetrics = new InstanceMetrics("i1");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 300.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 700.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 1000.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 1300.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(instanceMetrics);
    topologyMetrics.put("bolt", compMetrics);
    BufferSizeSensor sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    GrowingWaitQueueDetector detector = new GrowingWaitQueueDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    instanceMetrics = new InstanceMetrics("i1");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 200.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 400.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 600.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 800.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(instanceMetrics);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new GrowingWaitQueueDetector(sensor, config);
    symptoms = detector.detect();
    assertEquals(0, symptoms.size());
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HashMap(java.util.HashMap) Instant(java.time.Instant) HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) BufferSizeSensor(com.twitter.heron.healthmgr.sensors.BufferSizeSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 3 with HealthPolicyConfig

use of com.twitter.heron.healthmgr.HealthPolicyConfig in project incubator-heron by apache.

the class ProcessingRateSkewDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    ExecuteCountSensor sensor = mock(ExecuteCountSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    when(sensor.getMetricName()).thenReturn(METRIC_EXE_COUNT.text());
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 500));
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(ExecuteCountSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new ProcessingRateSkewDetector(sensor, config);
    symptoms = detector.detect();
    assertEquals(0, symptoms.size());
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) HashMap(java.util.HashMap) ExecuteCountSensor(com.twitter.heron.healthmgr.sensors.ExecuteCountSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 4 with HealthPolicyConfig

use of com.twitter.heron.healthmgr.HealthPolicyConfig in project incubator-heron by apache.

the class ProcessingRateSkewDetectorTest method testReturnsMultipleComponents.

@Test
public void testReturnsMultipleComponents() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
    ComponentMetrics compMetrics1 = new ComponentMetrics("bolt-1");
    compMetrics1.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics1.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
    ComponentMetrics compMetrics2 = new ComponentMetrics("bolt-2");
    compMetrics2.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics2.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
    ComponentMetrics compMetrics3 = new ComponentMetrics("bolt-3");
    compMetrics3.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics3.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 500));
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt-1", compMetrics1);
    topologyMetrics.put("bolt-2", compMetrics2);
    topologyMetrics.put("bolt-3", compMetrics3);
    ExecuteCountSensor sensor = mock(ExecuteCountSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    when(sensor.getMetricName()).thenReturn(METRIC_EXE_COUNT.text());
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(2, symptoms.size());
    for (Symptom symptom : symptoms) {
        if (symptom.getComponent().getName().equals("bolt-1")) {
            compMetrics1 = null;
        } else if (symptom.getComponent().getName().equals("bolt-2")) {
            compMetrics2 = null;
        } else if (symptom.getComponent().getName().equals("bolt-3")) {
            compMetrics3 = null;
        }
    }
    assertNull(compMetrics1);
    assertNull(compMetrics2);
    assertNotNull(compMetrics3);
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) HashMap(java.util.HashMap) ExecuteCountSensor(com.twitter.heron.healthmgr.sensors.ExecuteCountSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 5 with HealthPolicyConfig

use of com.twitter.heron.healthmgr.HealthPolicyConfig in project incubator-heron by apache.

the class LargeWaitQueueDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SIZE_LIMIT, 1000)).thenReturn(20);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 21);
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    BufferSizeSensor sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    LargeWaitQueueDetector detector = new LargeWaitQueueDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 19);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new LargeWaitQueueDetector(sensor, config);
    symptoms = detector.detect();
    assertEquals(0, symptoms.size());
}
Also used : HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) HashMap(java.util.HashMap) BufferSizeSensor(com.twitter.heron.healthmgr.sensors.BufferSizeSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Aggregations

Symptom (com.microsoft.dhalion.detector.Symptom)6 ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)6 HealthPolicyConfig (com.twitter.heron.healthmgr.HealthPolicyConfig)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 InstanceMetrics (com.microsoft.dhalion.metrics.InstanceMetrics)4 BufferSizeSensor (com.twitter.heron.healthmgr.sensors.BufferSizeSensor)3 ExecuteCountSensor (com.twitter.heron.healthmgr.sensors.ExecuteCountSensor)2 BackPressureSensor (com.twitter.heron.healthmgr.sensors.BackPressureSensor)1 Instant (java.time.Instant)1