Search in sources :

Example 1 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class GrowingWaitQueueDetector method detect.

/**
 * Detects all components unable to keep up with input load, hence having a growing pending buffer
 * or wait queue
 *
 * @return A collection of symptoms each one corresponding to a components executing slower
 * than input rate.
 */
@Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
    Collection<Symptom> result = new ArrayList<>();
    MeasurementsTable waitQueueMetrics = MeasurementsTable.of(measurements).type(METRIC_WAIT_Q_SIZE.text());
    for (String component : waitQueueMetrics.uniqueComponents()) {
        double maxSlope = computeWaitQueueSizeTrend(waitQueueMetrics.component(component));
        if (maxSlope > rateLimit) {
            LOG.info(String.format("Detected growing wait queues for %s, max rate %f", component, maxSlope));
            Collection<String> addresses = Collections.singletonList(component);
            result.add(new Symptom(SYMPTOM_GROWING_WAIT_Q.text(), context.checkpoint(), addresses));
        }
    }
    return result;
}
Also used : MeasurementsTable(com.microsoft.dhalion.core.MeasurementsTable) ArrayList(java.util.ArrayList) Symptom(com.microsoft.dhalion.core.Symptom)

Example 2 with Symptom

use of com.microsoft.dhalion.core.Symptom in project heron by twitter.

the class LargeWaitQueueDetector method detect.

/**
 * Detects all components having a large pending buffer or wait queue
 *
 * @return A collection of symptoms each one corresponding to components with
 * large wait queues.
 */
@Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
    Collection<Symptom> result = new ArrayList<>();
    MeasurementsTable waitQueueMetrics = MeasurementsTable.of(measurements).type(METRIC_WAIT_Q_SIZE.text());
    for (String component : waitQueueMetrics.uniqueComponents()) {
        Set<String> addresses = new HashSet<>();
        MeasurementsTable instanceMetrics = waitQueueMetrics.component(component);
        for (String instance : instanceMetrics.uniqueInstances()) {
            double avgWaitQSize = instanceMetrics.instance(instance).mean();
            if (avgWaitQSize > sizeLimit) {
                LOG.info(String.format("Detected large wait queues for instance" + "%s, smallest queue is + %f", instance, avgWaitQSize));
                addresses.add(instance);
            }
        }
        if (addresses.size() > 0) {
            result.add(new Symptom(SYMPTOM_LARGE_WAIT_Q.text(), context.checkpoint(), addresses));
        }
    }
    return result;
}
Also used : MeasurementsTable(com.microsoft.dhalion.core.MeasurementsTable) ArrayList(java.util.ArrayList) Symptom(com.microsoft.dhalion.core.Symptom) HashSet(java.util.HashSet)

Example 3 with Symptom

use of com.microsoft.dhalion.core.Symptom 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 4 with Symptom

use of com.microsoft.dhalion.core.Symptom 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 5 with Symptom

use of com.microsoft.dhalion.core.Symptom 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)

Aggregations

Symptom (com.microsoft.dhalion.core.Symptom)20 Test (org.junit.Test)16 Diagnosis (com.microsoft.dhalion.core.Diagnosis)10 ArrayList (java.util.ArrayList)10 Measurement (com.microsoft.dhalion.core.Measurement)6 PoliciesExecutor (com.microsoft.dhalion.policy.PoliciesExecutor)6 HealthPolicyConfig (org.apache.heron.healthmgr.HealthPolicyConfig)6 MeasurementsTable (com.microsoft.dhalion.core.MeasurementsTable)4 SymptomsTable (com.microsoft.dhalion.core.SymptomsTable)4 Instant (java.time.Instant)2 HashSet (java.util.HashSet)2 HealthManagerMetrics (org.apache.heron.healthmgr.HealthManagerMetrics)1