use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class WaitQueueDisparityDetectorTest method testConfigAndFilter.
@Test
public void testConfigAndFilter() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_DISPARITY_RATIO, 20.0)).thenReturn(15.0);
ComponentMetrics compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BUFFER_SIZE.text(), 1501));
compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BUFFER_SIZE.text(), 100));
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
topologyMetrics.put("bolt", compMetrics);
BufferSizeSensor sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
when(sensor.getMetricName()).thenReturn(METRIC_BUFFER_SIZE.text());
WaitQueueDisparityDetector detector = new WaitQueueDisparityDetector(sensor, config);
List<Symptom> symptoms = detector.detect();
assertEquals(1, symptoms.size());
compMetrics = new ComponentMetrics("bolt");
compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BUFFER_SIZE.text(), 1500));
compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BUFFER_SIZE.text(), 110));
topologyMetrics.put("bolt", compMetrics);
sensor = mock(BufferSizeSensor.class);
when(sensor.get()).thenReturn(topologyMetrics);
detector = new WaitQueueDisparityDetector(sensor, config);
symptoms = detector.detect();
assertEquals(0, symptoms.size());
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class ScaleUpResolverTest method testScaleUpFactorComputation.
@Test
public void testScaleUpFactorComputation() {
ScaleUpResolver resolver = new ScaleUpResolver(null, null, null, eventManager, null);
ComponentMetrics metrics = new ComponentMetrics("bolt");
metrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BACK_PRESSURE.text(), 500));
metrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BACK_PRESSURE.text(), 0));
int result = resolver.computeScaleUpFactor(metrics);
assertEquals(4, result);
metrics = new ComponentMetrics("bolt");
metrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BACK_PRESSURE.text(), 750));
metrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BACK_PRESSURE.text(), 0));
result = resolver.computeScaleUpFactor(metrics);
assertEquals(8, result);
metrics = new ComponentMetrics("bolt");
metrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_BACK_PRESSURE.text(), 400));
metrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_BACK_PRESSURE.text(), 100));
metrics.addInstanceMetric(new InstanceMetrics("i3", METRIC_BACK_PRESSURE.text(), 0));
result = resolver.computeScaleUpFactor(metrics);
assertEquals(6, result);
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class ExecuteCountSensorTest method createTestInstanceMetric.
private InstanceMetrics createTestInstanceMetric(String name, int value) {
InstanceMetrics instanceMetrics = new InstanceMetrics(name);
instanceMetrics.addMetric(METRIC_EXE_COUNT.text(), value);
return instanceMetrics;
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class TrackerMetricsProviderTest method testGetTimeLineMetrics.
@Test
public void testGetTimeLineMetrics() {
TrackerMetricsProvider spyMetricsProvider = createMetricsProviderSpy();
String metric = "count";
String comp = "bolt";
String response = "{\"status\": \"success\", \"executiontime\": 0.002241849899291992, " + "\"message\": \"\", \"version\": \"ver\", \"result\": " + "{\"timeline\": {\"count\": " + "{\"container_1_bolt_1\": {\"1497481288\": \"104\"}, " + "\"container_1_bolt_2\": {\"1497481228\": \"12\", \"1497481348\": \"2\", " + "\"1497481168\": \"3\"}}}, " + "\"endtime\": 1497481388, \"component\": \"bolt\", \"starttime\": 1497481208}}";
doReturn(response).when(spyMetricsProvider).getMetricsFromTracker(metric, comp, Instant.ofEpochSecond(10), Duration.ofSeconds(60));
Map<String, ComponentMetrics> metrics = spyMetricsProvider.getComponentMetrics(metric, Instant.ofEpochSecond(10), Duration.ofSeconds(60), comp);
assertEquals(1, metrics.size());
ComponentMetrics componentMetrics = metrics.get(comp);
assertNotNull(componentMetrics);
assertEquals(2, componentMetrics.getMetrics().size());
InstanceMetrics instanceMetrics = componentMetrics.getMetrics("container_1_bolt_1");
assertNotNull(instanceMetrics);
assertEquals(1, instanceMetrics.getMetrics().size());
Map<Instant, Double> metricValues = instanceMetrics.getMetrics().get(metric);
assertEquals(1, metricValues.size());
assertEquals(104, metricValues.get(Instant.ofEpochSecond(1497481288)).intValue());
instanceMetrics = componentMetrics.getMetrics("container_1_bolt_2");
assertNotNull(instanceMetrics);
assertEquals(1, instanceMetrics.getMetrics().size());
metricValues = instanceMetrics.getMetrics().get(metric);
assertEquals(3, metricValues.size());
assertEquals(12, metricValues.get(Instant.ofEpochSecond(1497481228L)).intValue());
assertEquals(2, metricValues.get(Instant.ofEpochSecond(1497481348L)).intValue());
assertEquals(3, metricValues.get(Instant.ofEpochSecond(1497481168L)).intValue());
}
Aggregations