Search in sources :

Example 26 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics 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());
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) HashMap(java.util.HashMap) BufferSizeSensor(com.twitter.heron.healthmgr.sensors.BufferSizeSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 27 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics 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);
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 28 with ComponentMetrics

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

the class ExecuteCountSensorTest method providesBoltExecutionCountMetrics.

@Test
public void providesBoltExecutionCountMetrics() {
    TopologyProvider topologyProvider = mock(TopologyProvider.class);
    when(topologyProvider.getBoltNames()).thenReturn(new String[] { "bolt-1", "bolt-2" });
    MetricsProvider metricsProvider = mock(MetricsProvider.class);
    Map<String, ComponentMetrics> result = new HashMap<>();
    ComponentMetrics metrics = new ComponentMetrics("bolt-1");
    metrics.addInstanceMetric(createTestInstanceMetric("container_1_bolt-1_1", 123));
    metrics.addInstanceMetric(createTestInstanceMetric("container_1_bolt-1_2", 345));
    result.put("bolt-1", metrics);
    metrics = new ComponentMetrics("bolt-2");
    metrics.addInstanceMetric(createTestInstanceMetric("container_1_bolt-2_3", 321));
    metrics.addInstanceMetric(createTestInstanceMetric("container_1_bolt-2_4", 543));
    result.put("bolt-2", metrics);
    when(metricsProvider.getComponentMetrics(METRIC_EXE_COUNT.text(), DEFAULT_METRIC_DURATION, "bolt-1", "bolt-2")).thenReturn(result);
    ExecuteCountSensor executeCountSensor = new ExecuteCountSensor(topologyProvider, null, metricsProvider);
    Map<String, ComponentMetrics> componentMetrics = executeCountSensor.get();
    assertEquals(2, componentMetrics.size());
    assertEquals(123, componentMetrics.get("bolt-1").getMetrics("container_1_bolt-1_1").getMetricValueSum(METRIC_EXE_COUNT.text()).intValue());
    assertEquals(345, componentMetrics.get("bolt-1").getMetrics("container_1_bolt-1_2").getMetricValueSum(METRIC_EXE_COUNT.text()).intValue());
    assertEquals(321, componentMetrics.get("bolt-2").getMetrics("container_1_bolt-2_3").getMetricValueSum(METRIC_EXE_COUNT.text()).intValue());
    assertEquals(543, componentMetrics.get("bolt-2").getMetrics("container_1_bolt-2_4").getMetricValueSum(METRIC_EXE_COUNT.text()).intValue());
}
Also used : HashMap(java.util.HashMap) TopologyProvider(com.twitter.heron.healthmgr.common.TopologyProvider) MetricsProvider(com.microsoft.dhalion.api.MetricsProvider) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 29 with ComponentMetrics

use of com.microsoft.dhalion.metrics.ComponentMetrics 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());
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) Instant(java.time.Instant) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

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