Search in sources :

Example 21 with ComponentMetrics

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

the class ScaleUpResolver method resolve.

@Override
public List<Action> resolve(List<Diagnosis> diagnosis) {
    for (Diagnosis diagnoses : diagnosis) {
        Symptom bpSymptom = diagnoses.getSymptoms().get(SYMPTOM_UNDER_PROVISIONING.text());
        if (bpSymptom == null || bpSymptom.getComponents().isEmpty()) {
            // nothing to fix as there is no back pressure
            continue;
        }
        if (bpSymptom.getComponents().size() > 1) {
            throw new UnsupportedOperationException("Multiple components with back pressure symptom");
        }
        ComponentMetrics bpComponent = bpSymptom.getComponent();
        int newParallelism = computeScaleUpFactor(bpComponent);
        Map<String, Integer> changeRequest = new HashMap<>();
        changeRequest.put(bpComponent.getName(), newParallelism);
        PackingPlan currentPackingPlan = packingPlanProvider.get();
        PackingPlan newPlan = buildNewPackingPlan(changeRequest, currentPackingPlan);
        if (newPlan == null) {
            return null;
        }
        Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder().setCurrentPackingPlan(getSerializedPlan(currentPackingPlan)).setProposedPackingPlan(getSerializedPlan(newPlan)).build();
        LOG.info("Sending Updating topology request: " + updateTopologyRequest);
        if (!schedulerClient.updateTopology(updateTopologyRequest)) {
            throw new RuntimeException(String.format("Failed to update topology with Scheduler, " + "updateTopologyRequest=%s", updateTopologyRequest));
        }
        TopologyUpdate action = new TopologyUpdate();
        LOG.info("Broadcasting topology update event");
        eventManager.onEvent(action);
        LOG.info("Scheduler updated topology successfully.");
        List<Action> actions = new ArrayList<>();
        actions.add(action);
        return actions;
    }
    return null;
}
Also used : Action(com.microsoft.dhalion.resolver.Action) HashMap(java.util.HashMap) Scheduler(com.twitter.heron.proto.scheduler.Scheduler) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) ArrayList(java.util.ArrayList) TopologyUpdate(com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate) Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics)

Example 22 with ComponentMetrics

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

the class TrackerMetricsProvider method getComponentMetrics.

@Override
public Map<String, ComponentMetrics> getComponentMetrics(String metric, Instant startTime, Duration duration, String... components) {
    Map<String, ComponentMetrics> result = new HashMap<>();
    for (String component : components) {
        String response = getMetricsFromTracker(metric, component, startTime, duration);
        Map<String, InstanceMetrics> metrics = parse(response, component, metric);
        ComponentMetrics componentMetric = new ComponentMetrics(component, metrics);
        result.put(component, componentMetric);
    }
    return result;
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HashMap(java.util.HashMap) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics)

Example 23 with ComponentMetrics

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

the class ComponentMetricsHelperTest method detectsMultipleCompIncreasingBuffer.

@Test
public void detectsMultipleCompIncreasingBuffer() {
    ComponentMetrics compMetrics;
    InstanceMetrics instanceMetrics;
    Map<Instant, Double> bufferSizes;
    compMetrics = new ComponentMetrics("bolt");
    instanceMetrics = new InstanceMetrics("i1");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892210), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 300.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 600.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 900.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 1200.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics.addInstanceMetric(instanceMetrics);
    instanceMetrics = new InstanceMetrics("i2");
    bufferSizes = new HashMap<>();
    bufferSizes.put(Instant.ofEpochSecond(1497892270), 0.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892330), 180.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892390), 360.0);
    bufferSizes.put(Instant.ofEpochSecond(1497892450), 540.0);
    instanceMetrics.addMetric(METRIC_BUFFER_SIZE.text(), bufferSizes);
    compMetrics.addInstanceMetric(instanceMetrics);
    ComponentMetricsHelper helper = new ComponentMetricsHelper(compMetrics);
    helper.computeBufferSizeTrend();
    assertEquals(5, helper.getMaxBufferChangeRate(), 0.1);
    HashMap<String, InstanceMetrics> metrics = compMetrics.getMetrics();
    assertEquals(1, metrics.get("i1").getMetrics().get(METRIC_WAIT_Q_GROWTH_RATE.text()).size());
    assertEquals(5, metrics.get("i1").getMetricValueSum(METRIC_WAIT_Q_GROWTH_RATE.text()), 0.1);
    assertEquals(3, metrics.get("i2").getMetricValueSum(METRIC_WAIT_Q_GROWTH_RATE.text()), 0.1);
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) Instant(java.time.Instant) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 24 with ComponentMetrics

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

the class BackPressureSensorTest method providesBackPressureMetricForBolts.

@Test
public void providesBackPressureMetricForBolts() {
    TopologyProvider topologyProvider = mock(TopologyProvider.class);
    when(topologyProvider.getBoltNames()).thenReturn(new String[] { "bolt-1", "bolt-2" });
    String[] boltIds = new String[] { "container_1_bolt-1_1", "container_2_bolt-2_22", "container_1_bolt-2_333" };
    PackingPlanProvider packingPlanProvider = mock(PackingPlanProvider.class);
    when(packingPlanProvider.getBoltInstanceNames("bolt-1")).thenReturn(new String[] { boltIds[0] });
    when(packingPlanProvider.getBoltInstanceNames("bolt-2")).thenReturn(new String[] { boltIds[1], boltIds[2] });
    MetricsProvider metricsProvider = mock(MetricsProvider.class);
    for (String boltId : boltIds) {
        String metric = MetricName.METRIC_BACK_PRESSURE + boltId;
        // the back pressure sensor will return average bp per second, so multiply by duration
        BufferSizeSensorTest.registerStMgrInstanceMetricResponse(metricsProvider, metric, boltId.length() * DEFAULT_METRIC_DURATION.getSeconds());
    }
    BackPressureSensor backPressureSensor = new BackPressureSensor(packingPlanProvider, topologyProvider, null, metricsProvider);
    Map<String, ComponentMetrics> componentMetrics = backPressureSensor.get();
    assertEquals(2, componentMetrics.size());
    assertEquals(1, componentMetrics.get("bolt-1").getMetrics().size());
    assertEquals(boltIds[0].length(), componentMetrics.get("bolt-1").getMetrics(boltIds[0]).getMetricValueSum(MetricName.METRIC_BACK_PRESSURE.text()).intValue());
    assertEquals(2, componentMetrics.get("bolt-2").getMetrics().size());
    assertEquals(boltIds[1].length(), componentMetrics.get("bolt-2").getMetrics(boltIds[1]).getMetricValueSum(MetricName.METRIC_BACK_PRESSURE.text()).intValue());
    assertEquals(boltIds[2].length(), componentMetrics.get("bolt-2").getMetrics(boltIds[2]).getMetricValueSum(MetricName.METRIC_BACK_PRESSURE.text()).intValue());
}
Also used : TopologyProvider(com.twitter.heron.healthmgr.common.TopologyProvider) PackingPlanProvider(com.twitter.heron.healthmgr.common.PackingPlanProvider) MetricsProvider(com.microsoft.dhalion.api.MetricsProvider) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics) Test(org.junit.Test)

Example 25 with ComponentMetrics

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

the class LargeWaitQueueDetectorTest method testConfigAndFilter.

@Test
public void testConfigAndFilter() {
    HealthPolicyConfig config = mock(HealthPolicyConfig.class);
    when(config.getConfig(CONF_SIZE_LIMIT, 1000)).thenReturn(20);
    ComponentMetrics compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 21);
    Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
    topologyMetrics.put("bolt", compMetrics);
    BufferSizeSensor sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    LargeWaitQueueDetector detector = new LargeWaitQueueDetector(sensor, config);
    List<Symptom> symptoms = detector.detect();
    assertEquals(1, symptoms.size());
    compMetrics = new ComponentMetrics("bolt", "i1", METRIC_BUFFER_SIZE.text(), 19);
    topologyMetrics.put("bolt", compMetrics);
    sensor = mock(BufferSizeSensor.class);
    when(sensor.get()).thenReturn(topologyMetrics);
    detector = new LargeWaitQueueDetector(sensor, config);
    symptoms = detector.detect();
    assertEquals(0, symptoms.size());
}
Also used : 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)

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