Search in sources :

Example 26 with Measurement

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

the class BackPressureSensor method fetch.

/**
 * Computes the average (millis/sec) back-pressure caused by instances in the configured window
 *
 * @return the average value measurements
 */
@Override
public Collection<Measurement> fetch() {
    publishingMetrics.executeSensorIncr(BACKPRESSURE_SENSOR);
    Collection<Measurement> result = new ArrayList<>();
    Instant now = context.checkpoint();
    List<String> boltComponents = physicalPlanProvider.getBoltNames();
    Duration duration = getDuration();
    for (String component : boltComponents) {
        String[] boltInstanceNames = packingPlanProvider.getBoltInstanceNames(component);
        for (String instance : boltInstanceNames) {
            String metric = getMetricName() + instance;
            Collection<Measurement> stmgrResult = metricsProvider.getMeasurements(now, duration, metric, COMPONENT_STMGR);
            if (stmgrResult.isEmpty()) {
                continue;
            }
            MeasurementsTable table = MeasurementsTable.of(stmgrResult).component(COMPONENT_STMGR);
            if (table.size() == 0) {
                continue;
            }
            double averageBp = table.type(metric).sum() / duration.getSeconds();
            // The maximum value of averageBp should be 1000, i.e. 1000 millis of BP per second. Due to
            // a bug in Heron (Issue: 1753), this value could be higher in some cases. The following
            // check partially corrects the reported BP value
            averageBp = averageBp > 1000 ? 1000 : averageBp;
            Measurement measurement = new Measurement(component, instance, getMetricName(), now, averageBp);
            result.add(measurement);
        }
    }
    return result;
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) MeasurementsTable(com.microsoft.dhalion.core.MeasurementsTable) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Duration(java.time.Duration)

Example 27 with Measurement

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

the class MetricsCacheMetricsProvider method parse.

@VisibleForTesting
@SuppressWarnings("unchecked")
Collection<Measurement> parse(TopologyManager.MetricResponse response, String component, String metric, Instant startTime) {
    Collection<Measurement> metricsData = new ArrayList();
    if (response == null || !response.getStatus().getStatus().equals(StatusCode.OK)) {
        LOG.info(String.format("Query failure from MetricsCache for %s:%s ", component, metric));
        return metricsData;
    }
    if (response.getMetricCount() == 0) {
        LOG.info(String.format("Did not get any metrics from MetricsCache for %s:%s ", component, metric));
        return metricsData;
    }
    // convert heron.protobuf.taskMetrics to dhalion.InstanceMetrics
    for (TaskMetric tm : response.getMetricList()) {
        String instanceId = tm.getInstanceId();
        for (IndividualMetric im : tm.getMetricList()) {
            String metricName = im.getName();
            // case 1
            for (IntervalValue iv : im.getIntervalValuesList()) {
                MetricInterval mi = iv.getInterval();
                String value = iv.getValue();
                Measurement measurement = new Measurement(component, instanceId, metricName, Instant.ofEpochSecond(mi.getStart()), Double.parseDouble(value));
                metricsData.add(measurement);
            }
            // case 2
            if (im.hasValue()) {
                Measurement measurement = new Measurement(component, instanceId, metricName, startTime, Double.parseDouble(im.getValue()));
                metricsData.add(measurement);
            }
        }
    }
    return metricsData;
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) TaskMetric(org.apache.heron.proto.tmanager.TopologyManager.MetricResponse.TaskMetric) ArrayList(java.util.ArrayList) MetricInterval(org.apache.heron.proto.tmanager.TopologyManager.MetricInterval) IndividualMetric(org.apache.heron.proto.tmanager.TopologyManager.MetricResponse.IndividualMetric) IntervalValue(org.apache.heron.proto.tmanager.TopologyManager.MetricResponse.IndividualMetric.IntervalValue) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 28 with Measurement

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

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);
    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);
    Measurement measurement3 = new Measurement("bolt2", "i3", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    Measurement measurement4 = new Measurement("bolt2", "i4", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 200.0);
    Measurement measurement5 = new Measurement("bolt3", "i5", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 1000);
    Measurement measurement6 = new Measurement("bolt3", "i6", METRIC_EXE_COUNT.text(), Instant.ofEpochSecond(1497892222), 500.0);
    Collection<Measurement> metrics = new ArrayList<>();
    metrics.add(measurement1);
    metrics.add(measurement2);
    metrics.add(measurement3);
    metrics.add(measurement4);
    metrics.add(measurement5);
    metrics.add(measurement6);
    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(6, symptoms.size());
    SymptomsTable symptomsTable = SymptomsTable.of(symptoms);
    assertEquals(2, symptomsTable.type("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).size());
    assertEquals(2, 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("POSITIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i3").size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i2").size());
    assertEquals(1, symptomsTable.type("NEGATIVE " + BaseDetector.SymptomType.SYMPTOM_PROCESSING_RATE_SKEW).assignment("i4").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)28 Test (org.junit.Test)20 MeasurementsTable (com.microsoft.dhalion.core.MeasurementsTable)14 ArrayList (java.util.ArrayList)13 PoliciesExecutor (com.microsoft.dhalion.policy.PoliciesExecutor)8 HealthPolicyConfig (org.apache.heron.healthmgr.HealthPolicyConfig)7 Symptom (com.microsoft.dhalion.core.Symptom)6 Instant (java.time.Instant)6 SymptomsTable (com.microsoft.dhalion.core.SymptomsTable)4 TopologyManager (org.apache.heron.proto.tmanager.TopologyManager)4 MetricsProvider (com.microsoft.dhalion.api.MetricsProvider)3 ExecutionContext (com.microsoft.dhalion.policy.PoliciesExecutor.ExecutionContext)3 PackingPlanProvider (org.apache.heron.healthmgr.common.PackingPlanProvider)3 PhysicalPlanProvider (org.apache.heron.healthmgr.common.PhysicalPlanProvider)3 Duration (java.time.Duration)2 HealthManagerMetrics (org.apache.heron.healthmgr.HealthManagerMetrics)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DocumentContext (com.jayway.jsonpath.DocumentContext)1 Action (com.microsoft.dhalion.core.Action)1 Diagnosis (com.microsoft.dhalion.core.Diagnosis)1