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;
}
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;
}
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());
}
Aggregations