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;
}
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;
}
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);
}
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());
}
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());
}
Aggregations