use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class GrowingWaitQueueDetector method computeWaitQueueSizeTrend.
private double computeWaitQueueSizeTrend(MeasurementsTable metrics) {
double maxSlope = 0;
for (String instance : metrics.uniqueInstances()) {
if (metrics.instance(instance) == null || metrics.instance(instance).size() < 3) {
// missing of insufficient data for creating a trend line
continue;
}
Collection<Measurement> measurements = metrics.instance(instance).sort(false, MeasurementsTable.SortKey.TIME_STAMP).get();
SimpleRegression simpleRegression = new SimpleRegression(true);
for (Measurement m : measurements) {
simpleRegression.addData(m.instant().getEpochSecond(), m.value());
}
double slope = simpleRegression.getSlope();
if (maxSlope < slope) {
maxSlope = slope;
}
}
return maxSlope;
}
use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class BufferSizeSensor method fetch.
/**
* The buffer size as provided by tracker
*
* @return buffer size measurements
*/
@Override
public Collection<Measurement> fetch() {
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 + MetricName.METRIC_WAIT_Q_SIZE_SUFFIX;
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 totalSize = table.type(metric).sum();
Measurement measurement = new Measurement(component, instance, getMetricName(), now, totalSize);
result.add(measurement);
}
}
return result;
}
use of com.microsoft.dhalion.core.Measurement 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());
}
use of com.microsoft.dhalion.core.Measurement 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());
}
use of com.microsoft.dhalion.core.Measurement 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());
}
Aggregations