Search in sources :

Example 6 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics 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 7 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.

the class UnderProvisioningDiagnoserTest method validateDiagnosis.

private void validateDiagnosis(Diagnosis result) {
    assertEquals(1, result.getSymptoms().size());
    ComponentMetrics data = result.getSymptoms().values().iterator().next().getComponent();
    assertEquals(123, data.getMetricValueSum("container_1_bolt_0", METRIC_BACK_PRESSURE.text()).intValue());
}
Also used : ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics)

Example 8 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.

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 all components executing slower than input rate.
 */
@Override
public List<Symptom> detect() {
    ArrayList<Symptom> result = new ArrayList<>();
    Map<String, ComponentMetrics> bufferSizes = pendingBufferSensor.get();
    for (ComponentMetrics compMetrics : bufferSizes.values()) {
        ComponentMetricsHelper compStats = new ComponentMetricsHelper(compMetrics);
        compStats.computeBufferSizeTrend();
        if (compStats.getMaxBufferChangeRate() > rateLimit) {
            LOG.info(String.format("Detected growing wait queues for %s, max rate %f", compMetrics.getName(), compStats.getMaxBufferChangeRate()));
            result.add(new Symptom(SYMPTOM_GROWING_WAIT_Q.text(), compMetrics));
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ComponentMetricsHelper(com.twitter.heron.healthmgr.common.ComponentMetricsHelper) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics)

Example 9 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.

the class SlowInstanceDiagnoser method diagnose.

@Override
public Diagnosis diagnose(List<Symptom> symptoms) {
    List<Symptom> bpSymptoms = getBackPressureSymptoms(symptoms);
    Map<String, ComponentMetrics> processingRateSkewComponents = getProcessingRateSkewComponents(symptoms);
    Map<String, ComponentMetrics> waitQDisparityComponents = getWaitQDisparityComponents(symptoms);
    if (bpSymptoms.isEmpty() || waitQDisparityComponents.isEmpty() || !processingRateSkewComponents.isEmpty()) {
        // execution count, no action is needed
        return null;
    } else if (bpSymptoms.size() > 1) {
        // TODO handle cases where multiple detectors create back pressure symptom
        throw new IllegalStateException("Multiple back-pressure symptoms case");
    }
    ComponentMetrics bpMetrics = bpSymptoms.iterator().next().getComponent();
    // verify wait Q disparity and back pressure for the same component exists
    ComponentMetrics pendingBufferMetrics = waitQDisparityComponents.get(bpMetrics.getName());
    if (pendingBufferMetrics == null) {
        // no wait Q disparity for the component with back pressure. There is no slow instance
        return null;
    }
    ComponentMetrics mergedData = ComponentMetrics.merge(bpMetrics, pendingBufferMetrics);
    ComponentMetricsHelper compStats = new ComponentMetricsHelper(mergedData);
    compStats.computeBpStats();
    MetricsStats bufferStats = compStats.computeMinMaxStats(METRIC_BUFFER_SIZE);
    Symptom resultSymptom = null;
    for (InstanceMetrics boltMetrics : compStats.getBoltsWithBackpressure()) {
        double bufferSize = boltMetrics.getMetricValueSum(METRIC_BUFFER_SIZE.text());
        double bpValue = boltMetrics.getMetricValueSum(METRIC_BACK_PRESSURE.text());
        if (bufferStats.getMetricMax() < bufferSize * 2) {
            LOG.info(String.format("SLOW: %s back-pressure(%s) and high buffer size: %s " + "and similar processing rates", boltMetrics.getName(), bpValue, bufferSize));
            resultSymptom = new Symptom(SYMPTOM_SLOW_INSTANCE.text(), mergedData);
        }
    }
    return resultSymptom != null ? new Diagnosis(DIAGNOSIS_SLOW_INSTANCE.text(), resultSymptom) : null;
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) ComponentMetricsHelper(com.twitter.heron.healthmgr.common.ComponentMetricsHelper) Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) MetricsStats(com.twitter.heron.healthmgr.common.MetricsStats)

Example 10 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.

the class BufferSizeSensor method get.

/**
 * The buffer size as provided by tracker
 *
 * @return buffer size
 */
public Map<String, ComponentMetrics> get(String... desiredBoltNames) {
    Map<String, ComponentMetrics> result = new HashMap<>();
    Set<String> boltNameFilter = new HashSet<>();
    if (desiredBoltNames.length > 0) {
        boltNameFilter.addAll(Arrays.asList(desiredBoltNames));
    }
    String[] boltComponents = topologyProvider.getBoltNames();
    for (String boltComponent : boltComponents) {
        if (!boltNameFilter.isEmpty() && !boltNameFilter.contains(boltComponent)) {
            continue;
        }
        String[] boltInstanceNames = packingPlanProvider.getBoltInstanceNames(boltComponent);
        Map<String, InstanceMetrics> instanceMetrics = new HashMap<>();
        for (String boltInstanceName : boltInstanceNames) {
            String metric = getMetricName() + boltInstanceName + MetricName.METRIC_BUFFER_SIZE_SUFFIX;
            Map<String, ComponentMetrics> stmgrResult = metricsProvider.getComponentMetrics(metric, getDuration(), COMPONENT_STMGR);
            if (stmgrResult.get(COMPONENT_STMGR) == null) {
                continue;
            }
            HashMap<String, InstanceMetrics> streamManagerResult = stmgrResult.get(COMPONENT_STMGR).getMetrics();
            if (streamManagerResult.isEmpty()) {
                continue;
            }
            // since a bolt instance belongs to one stream manager, expect just one metrics
            // manager instance in the result
            Double stmgrInstanceResult = 0.0;
            for (Iterator<InstanceMetrics> it = streamManagerResult.values().iterator(); it.hasNext(); ) {
                InstanceMetrics iMetrics = it.next();
                Double val = iMetrics.getMetricValueSum(metric);
                if (val == null) {
                    continue;
                } else {
                    stmgrInstanceResult += val;
                }
            }
            InstanceMetrics boltInstanceMetric = new InstanceMetrics(boltInstanceName, getMetricName(), stmgrInstanceResult);
            instanceMetrics.put(boltInstanceName, boltInstanceMetric);
        }
        ComponentMetrics componentMetrics = new ComponentMetrics(boltComponent, instanceMetrics);
        result.put(boltComponent, componentMetrics);
    }
    return result;
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HashMap(java.util.HashMap) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) HashSet(java.util.HashSet)

Aggregations

ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)29 Symptom (com.microsoft.dhalion.detector.Symptom)16 InstanceMetrics (com.microsoft.dhalion.metrics.InstanceMetrics)15 Test (org.junit.Test)15 HashMap (java.util.HashMap)14 ComponentMetricsHelper (com.twitter.heron.healthmgr.common.ComponentMetricsHelper)7 Diagnosis (com.microsoft.dhalion.diagnoser.Diagnosis)6 HealthPolicyConfig (com.twitter.heron.healthmgr.HealthPolicyConfig)6 ArrayList (java.util.ArrayList)6 MetricsStats (com.twitter.heron.healthmgr.common.MetricsStats)4 Instant (java.time.Instant)4 MetricsProvider (com.microsoft.dhalion.api.MetricsProvider)3 PackingPlanProvider (com.twitter.heron.healthmgr.common.PackingPlanProvider)3 TopologyProvider (com.twitter.heron.healthmgr.common.TopologyProvider)3 BufferSizeSensor (com.twitter.heron.healthmgr.sensors.BufferSizeSensor)3 Action (com.microsoft.dhalion.resolver.Action)2 ExecuteCountSensor (com.twitter.heron.healthmgr.sensors.ExecuteCountSensor)2 TopologyMaster (com.twitter.heron.proto.tmaster.TopologyMaster)2 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)2 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)1