Search in sources :

Example 1 with HealthPolicyConfig

use of org.apache.heron.healthmgr.HealthPolicyConfig in project heron by twitter.

the class GrowingWaitQueueDetectorTest method testDetector.

@Test
public void testDetector() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_LIMIT, 10.0)).thenReturn(5.0);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892222), 0.0);
    Measurement measurement2 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892270), 300.0);
    Measurement measurement3 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892330), 700.0);
    Measurement measurement4 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892390), 1000.0);
    Measurement measurement5 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892450), 1300.0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    metrics.add(measurement3);
    metrics.add(measurement4);
    metrics.add(measurement5);
    GrowingWaitQueueDetector detector = new GrowingWaitQueueDetector(config);
    PoliciesExecutor.ExecutionContext context = mock(PoliciesExecutor.ExecutionContext.class);
    when(context.checkpoint()).thenReturn(Instant.now());
    detector.initialize(context);
    Collection<Symptom> symptoms = detector.detect(metrics);
    assertEquals(1, symptoms.size());
    assertEquals(1, symptoms.iterator().next().assignments().size());
    measurement1 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892222), 0.0);
    measurement2 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892270), 200.0);
    measurement3 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892330), 400.0);
    measurement4 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892390), 600.0);
    measurement5 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892450), 800.0);
    metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    metrics.add(measurement3);
    metrics.add(measurement4);
    metrics.add(measurement5);
    detector = new GrowingWaitQueueDetector(config);
    symptoms = detector.detect(metrics);
    assertEquals(0, symptoms.size());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) ArrayList(java.util.ArrayList) PoliciesExecutor(com.microsoft.dhalion.policy.PoliciesExecutor) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Example 2 with HealthPolicyConfig

use of org.apache.heron.healthmgr.HealthPolicyConfig in project heron by twitter.

the class BackPressureDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() throws IOException {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_NOISE_FILTER, 20)).thenReturn(50);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_BACK_PRESSURE.text(), now, 55);
    Measurement measurement2 = new Measurement("bolt", "i2", METRIC_BACK_PRESSURE.text(), now, 3);
    Measurement measurement3 = new Measurement("bolt", "i3", METRIC_BACK_PRESSURE.text(), now, 0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    metrics.add(measurement3);
    HealthManagerMetrics publishingMetrics = mock(HealthManagerMetrics.class);
    BackPressureDetector detector = new BackPressureDetector(config, publishingMetrics);
    PoliciesExecutor.ExecutionContext context = mock(PoliciesExecutor.ExecutionContext.class);
    when(context.checkpoint()).thenReturn(now);
    detector.initialize(context);
    Collection<Symptom> symptoms = detector.detect(metrics);
    Assert.assertEquals(2, symptoms.size());
    SymptomsTable compSymptom = SymptomsTable.of(symptoms).type(SYMPTOM_COMP_BACK_PRESSURE.text());
    Assert.assertEquals(1, compSymptom.size());
    Assert.assertEquals(1, compSymptom.get().iterator().next().assignments().size());
    SymptomsTable instanceSymptom = SymptomsTable.of(symptoms).type(SYMPTOM_INSTANCE_BACK_PRESSURE.text());
    Assert.assertEquals(1, instanceSymptom.size());
    Assert.assertEquals(1, instanceSymptom.get().iterator().next().assignments().size());
    Symptom symptom = symptoms.iterator().next();
    measurement1 = new Measurement("bolt", "i1", METRIC_BACK_PRESSURE.text(), now, 45);
    measurement2 = new Measurement("bolt", "i2", METRIC_BACK_PRESSURE.text(), now, 3);
    metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    detector = new BackPressureDetector(config, publishingMetrics);
    detector.initialize(context);
    symptoms = detector.detect(metrics);
    Assert.assertEquals(0, symptoms.size());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) HealthManagerMetrics(org.apache.heron.healthmgr.HealthManagerMetrics) ArrayList(java.util.ArrayList) PoliciesExecutor(com.microsoft.dhalion.policy.PoliciesExecutor) Symptom(com.microsoft.dhalion.core.Symptom) SymptomsTable(com.microsoft.dhalion.core.SymptomsTable) Test(org.junit.Test)

Example 3 with HealthPolicyConfig

use of org.apache.heron.healthmgr.HealthPolicyConfig in project heron by twitter.

the class LargeWaitQueueDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SIZE_LIMIT, 1000)).thenReturn(20);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892222), 21);
    Measurement measurement2 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892322), 21);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    LargeWaitQueueDetector detector = new LargeWaitQueueDetector(config);
    PoliciesExecutor.ExecutionContext context = mock(PoliciesExecutor.ExecutionContext.class);
    when(context.checkpoint()).thenReturn(Instant.now());
    detector.initialize(context);
    Collection<Symptom> symptoms = detector.detect(metrics);
    assertEquals(1, symptoms.size());
    assertEquals(1, symptoms.iterator().next().assignments().size());
    measurement1 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892222), 11);
    measurement2 = new Measurement("bolt", "i1", METRIC_WAIT_Q_SIZE.text(), Instant.ofEpochSecond(1497892322), 10);
    metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    detector = new LargeWaitQueueDetector(config);
    symptoms = detector.detect(metrics);
    assertEquals(0, symptoms.size());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) ArrayList(java.util.ArrayList) PoliciesExecutor(com.microsoft.dhalion.policy.PoliciesExecutor) Symptom(com.microsoft.dhalion.core.Symptom) Test(org.junit.Test)

Example 4 with HealthPolicyConfig

use of org.apache.heron.healthmgr.HealthPolicyConfig in project heron by twitter.

the class ProcessingRateSkewDetectorTest method testGetMaxMin.

@Test
public void testGetMaxMin() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    Measurement measurement2 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892122), 3000);
    Measurement measurement3 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 200.0);
    Measurement measurement4 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 400.0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    metrics.add(measurement3);
    metrics.add(measurement4);
    MeasurementsTable metricsTable = MeasurementsTable.of(metrics);
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(config);
    assertEquals(2000, (int) detector.getMaxOfAverage(metricsTable));
    assertEquals(300, (int) detector.getMinOfAverage(metricsTable));
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) MeasurementsTable(com.microsoft.dhalion.core.MeasurementsTable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with HealthPolicyConfig

use of org.apache.heron.healthmgr.HealthPolicyConfig in project heron by twitter.

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);
    Measurement measurement1 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    Measurement measurement2 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 200.0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(config);
    PoliciesExecutor.ExecutionContext context = mock(PoliciesExecutor.ExecutionContext.class);
    when(context.checkpoint()).thenReturn(Instant.now());
    detector.initialize(context);
    Collection<Symptom> symptoms = detector.detect(metrics);
    assertEquals(3, symptoms.size());
    SymptomsTable symptomsTable = SymptomsTable.of(symptoms);
    assertEquals(1, symptomsTable.type("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).size());
    assertEquals(1, symptomsTable.type("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i1").size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i2").size());
    measurement1 = new Measurement("bolt", "i1", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    measurement2 = new Measurement("bolt", "i2", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 500.0);
    metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    detector = new ProcessingRateSkewDetector(config);
    detector.initialize(context);
    symptoms = detector.detect(metrics);
    assertEquals(0, symptoms.size());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) HealthPolicyConfig(org.apache.heron.healthmgr.HealthPolicyConfig) ArrayList(java.util.ArrayList) PoliciesExecutor(com.microsoft.dhalion.policy.PoliciesExecutor) Symptom(com.microsoft.dhalion.core.Symptom) SymptomsTable(com.microsoft.dhalion.core.SymptomsTable) Test(org.junit.Test)

Aggregations

Measurement (com.microsoft.dhalion.core.Measurement)7 ArrayList (java.util.ArrayList)7 HealthPolicyConfig (org.apache.heron.healthmgr.HealthPolicyConfig)7 Test (org.junit.Test)7 Symptom (com.microsoft.dhalion.core.Symptom)6 PoliciesExecutor (com.microsoft.dhalion.policy.PoliciesExecutor)6 SymptomsTable (com.microsoft.dhalion.core.SymptomsTable)4 MeasurementsTable (com.microsoft.dhalion.core.MeasurementsTable)1 HealthManagerMetrics (org.apache.heron.healthmgr.HealthManagerMetrics)1