Search in sources :

Example 1 with ComponentMetrics

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

the class BackPressureDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_NOISE_FILTER, 20)).thenReturn(50);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 55);
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    BackPressureSensor sensor = mock(BackPressureSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    BackPressureDetector detector = new BackPressureDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    Assert.assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 45);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BackPressureSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new BackPressureDetector(sensor, config);
    symptoms = detector.detect();
    Assert.assertEquals(0, symptoms.size());
}
Also used : HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) BackPressureSensor(com.twitter.heron.healthmgr.sensors.BackPressureSensor) HashMap(java.util.HashMap) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 2 with ComponentMetrics

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

the class SlowInstanceDiagnoserTest method diagnosis1of3SlowInstances.

@Test
public void diagnosis1of3SlowInstances() {
    List<Symptom> symptoms = TestUtils.createBpSymptomList(123, 0, 0);
    symptoms.add(TestUtils.createWaitQueueDisparitySymptom(1000, 20, 20));
    Diagnosis result = new SlowInstanceDiagnoser().diagnose(symptoms);
    assertEquals(1, result.getSymptoms().size());
    ComponentMetrics data = result.getSymptoms().values().iterator().next().getComponent();
    assertEquals(123, data.getMetricValueSum("container_1_bolt_0", METRIC_BACK_PRESSURE.text()).intValue());
}
Also used : Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 3 with ComponentMetrics

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

the class ScaleUpResolverTest method testResolve.

@Test
public void testResolve() {
    TopologyAPI.Topology topology = createTestTopology();
    Config config = createConfig(topology);
    PackingPlan currentPlan = createPacking(topology, config);
    PackingPlanProvider packingPlanProvider = mock(PackingPlanProvider.class);
    when(packingPlanProvider.get()).thenReturn(currentPlan);
    ISchedulerClient scheduler = mock(ISchedulerClient.class);
    when(scheduler.updateTopology(any(UpdateTopologyRequest.class))).thenReturn(true);
    ComponentMetrics metrics = new ComponentMetrics("bolt", "i1", METRIC_BACK_PRESSURE.text(), 123);
    Symptom symptom = new Symptom(SYMPTOM_UNDER_PROVISIONING.text(), metrics);
    List<Diagnosis> diagnosis = new ArrayList<>();
    diagnosis.add(new Diagnosis("test", symptom));
    ScaleUpResolver resolver = new ScaleUpResolver(null, packingPlanProvider, scheduler, eventManager, null);
    ScaleUpResolver spyResolver = spy(resolver);
    doReturn(2).when(spyResolver).computeScaleUpFactor(metrics);
    doReturn(currentPlan).when(spyResolver).buildNewPackingPlan(any(HashMap.class), eq(currentPlan));
    List<Action> result = spyResolver.resolve(diagnosis);
    verify(scheduler, times(1)).updateTopology(any(UpdateTopologyRequest.class));
    assertEquals(1, result.size());
}
Also used : Action(com.microsoft.dhalion.resolver.Action) HashMap(java.util.HashMap) Config(com.twitter.heron.spi.common.Config) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) ArrayList(java.util.ArrayList) PackingPlanProvider(com.twitter.heron.healthmgr.common.PackingPlanProvider) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) UpdateTopologyRequest(com.twitter.heron.proto.scheduler.Scheduler.UpdateTopologyRequest) ISchedulerClient(com.twitter.heron.scheduler.client.ISchedulerClient) Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 4 with ComponentMetrics

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

the class GrowingWaitQueueDetectorTest method testDetector.

@Test
public void testDetector() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_LIMIT, 10.0)).thenReturn(5.0);
    ComponentMetrics compMetrics;
    InstanceMetrics instanceMetrics;
    Map<Instant, Double> bufferSizes;
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    instanceMetrics = new InstanceMetrics("i1");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 300.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 700.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 1000.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 1300.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(instanceMetrics);
    topologyMetrics.put("bolt", compMetrics);
    BufferSizeSensor sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    GrowingWaitQueueDetector detector = new GrowingWaitQueueDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    instanceMetrics = new InstanceMetrics("i1");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892222), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 200.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 400.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 600.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 800.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(instanceMetrics);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new GrowingWaitQueueDetector(sensor, config);
    symptoms = detector.detect();
    assertEquals(0, symptoms.size());
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HashMap(java.util.HashMap) Instant(java.time.Instant) HealthPolicyConfig(com.twitter.heron.healthmgr.HealthPolicyConfig) BufferSizeSensor(com.twitter.heron.healthmgr.sensors.BufferSizeSensor) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 5 with ComponentMetrics

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

the class ProcessingRateSkewDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    ExecuteCountSensor sensor = mock(ExecuteCountSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    when(sensor.getMetricName()).thenReturn(METRIC_EXE_COUNT.text());
    ProcessingRateSkewDetector detector = new ProcessingRateSkewDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt");
    compMetrics.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
    compMetrics.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 500));
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(ExecuteCountSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new ProcessingRateSkewDetector(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) ExecuteCountSensor(com.twitter.heron.healthmgr.sensors.ExecuteCountSensor) Symptom(com.microsoft.dhalion.detector.Symptom) 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