use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.
the class ProcessingRateSkewDetectorTest method testReturnsMultipleComponents.
@Test
public void testReturnsMultipleComponents() {
HealthPolicyConfig config = mock(HealthPolicyConfig.class);
when(config.getConfig(CONF_SKEW_RATIO, 1.5)).thenReturn(2.5);
ComponentMetrics compMetrics1 = new ComponentMetrics("bolt-1");
compMetrics1.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
compMetrics1.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
ComponentMetrics compMetrics2 = new ComponentMetrics("bolt-2");
compMetrics2.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
compMetrics2.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 200));
ComponentMetrics compMetrics3 = new ComponentMetrics("bolt-3");
compMetrics3.addInstanceMetric(new InstanceMetrics("i1", METRIC_EXE_COUNT.text(), 1000));
compMetrics3.addInstanceMetric(new InstanceMetrics("i2", METRIC_EXE_COUNT.text(), 500));
Map<String, ComponentMetrics> topologyMetrics = new HashMap<>();
topologyMetrics.put("bolt-1", compMetrics1);
topologyMetrics.put("bolt-2", compMetrics2);
topologyMetrics.put("bolt-3", compMetrics3);
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(2, symptoms.size());
for (Symptom symptom : symptoms) {
if (symptom.getComponent().getName().equals("bolt-1")) {
compMetrics1 = null;
} else if (symptom.getComponent().getName().equals("bolt-2")) {
compMetrics2 = null;
} else if (symptom.getComponent().getName().equals("bolt-3")) {
compMetrics3 = null;
}
}
assertNull(compMetrics1);
assertNull(compMetrics2);
assertNotNull(compMetrics3);
}
use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.
the class UnderProvisioningDiagnoserTest method validateDiagnosis.
private void validateDiagnosis(Diagnosis result) {
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());
}
use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.
the class GrowingWaitQueueDetector method detect.
/**
* Detects all components unable to keep up with input load, hence having a growing pending buffer
* or wait queue
*
* @return A collection of all components executing slower than input rate.
*/
@Override
public List<Symptom> detect() {
ArrayList<Symptom> result = new ArrayList<>();
Map<String, ComponentMetrics> bufferSizes = pendingBufferSensor.get();
for (ComponentMetrics compMetrics : bufferSizes.values()) {
ComponentMetricsHelper compStats = new ComponentMetricsHelper(compMetrics);
compStats.computeBufferSizeTrend();
if (compStats.getMaxBufferChangeRate() > rateLimit) {
LOG.info(String.format("Detected growing wait queues for %s, max rate %f", compMetrics.getName(), compStats.getMaxBufferChangeRate()));
result.add(new Symptom(SYMPTOM_GROWING_WAIT_Q.text(), compMetrics));
}
}
return result;
}
use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.
the class SlowInstanceDiagnoser method diagnose.
@Override
public Diagnosis diagnose(List<Symptom> symptoms) {
List<Symptom> bpSymptoms = getBackPressureSymptoms(symptoms);
Map<String, ComponentMetrics> processingRateSkewComponents = getProcessingRateSkewComponents(symptoms);
Map<String, ComponentMetrics> waitQDisparityComponents = getWaitQDisparityComponents(symptoms);
if (bpSymptoms.isEmpty() || waitQDisparityComponents.isEmpty() || !processingRateSkewComponents.isEmpty()) {
// execution count, no action is needed
return null;
} else if (bpSymptoms.size() > 1) {
// TODO handle cases where multiple detectors create back pressure symptom
throw new IllegalStateException("Multiple back-pressure symptoms case");
}
ComponentMetrics bpMetrics = bpSymptoms.iterator().next().getComponent();
// verify wait Q disparity and back pressure for the same component exists
ComponentMetrics pendingBufferMetrics = waitQDisparityComponents.get(bpMetrics.getName());
if (pendingBufferMetrics == null) {
// no wait Q disparity for the component with back pressure. There is no slow instance
return null;
}
ComponentMetrics mergedData = ComponentMetrics.merge(bpMetrics, pendingBufferMetrics);
ComponentMetricsHelper compStats = new ComponentMetricsHelper(mergedData);
compStats.computeBpStats();
MetricsStats bufferStats = compStats.computeMinMaxStats(METRIC_BUFFER_SIZE);
Symptom resultSymptom = null;
for (InstanceMetrics boltMetrics : compStats.getBoltsWithBackpressure()) {
double bufferSize = boltMetrics.getMetricValueSum(METRIC_BUFFER_SIZE.text());
double bpValue = boltMetrics.getMetricValueSum(METRIC_BACK_PRESSURE.text());
if (bufferStats.getMetricMax() < bufferSize * 2) {
LOG.info(String.format("SLOW: %s back-pressure(%s) and high buffer size: %s " + "and similar processing rates", boltMetrics.getName(), bpValue, bufferSize));
resultSymptom = new Symptom(SYMPTOM_SLOW_INSTANCE.text(), mergedData);
}
}
return resultSymptom != null ? new Diagnosis(DIAGNOSIS_SLOW_INSTANCE.text(), resultSymptom) : null;
}
use of com.microsoft.dhalion.metrics.ComponentMetrics in project incubator-heron by apache.
the class BufferSizeSensor method get.
/**
* The buffer size as provided by tracker
*
* @return buffer size
*/
public Map<String, ComponentMetrics> get(String... desiredBoltNames) {
Map<String, ComponentMetrics> result = new HashMap<>();
Set<String> boltNameFilter = new HashSet<>();
if (desiredBoltNames.length > 0) {
boltNameFilter.addAll(Arrays.asList(desiredBoltNames));
}
String[] boltComponents = topologyProvider.getBoltNames();
for (String boltComponent : boltComponents) {
if (!boltNameFilter.isEmpty() && !boltNameFilter.contains(boltComponent)) {
continue;
}
String[] boltInstanceNames = packingPlanProvider.getBoltInstanceNames(boltComponent);
Map<String, InstanceMetrics> instanceMetrics = new HashMap<>();
for (String boltInstanceName : boltInstanceNames) {
String metric = getMetricName() + boltInstanceName + MetricName.METRIC_BUFFER_SIZE_SUFFIX;
Map<String, ComponentMetrics> stmgrResult = metricsProvider.getComponentMetrics(metric, getDuration(), COMPONENT_STMGR);
if (stmgrResult.get(COMPONENT_STMGR) == null) {
continue;
}
HashMap<String, InstanceMetrics> streamManagerResult = stmgrResult.get(COMPONENT_STMGR).getMetrics();
if (streamManagerResult.isEmpty()) {
continue;
}
// since a bolt instance belongs to one stream manager, expect just one metrics
// manager instance in the result
Double stmgrInstanceResult = 0.0;
for (Iterator<InstanceMetrics> it = streamManagerResult.values().iterator(); it.hasNext(); ) {
InstanceMetrics iMetrics = it.next();
Double val = iMetrics.getMetricValueSum(metric);
if (val == null) {
continue;
} else {
stmgrInstanceResult += val;
}
}
InstanceMetrics boltInstanceMetric = new InstanceMetrics(boltInstanceName, getMetricName(), stmgrInstanceResult);
instanceMetrics.put(boltInstanceName, boltInstanceMetric);
}
ComponentMetrics componentMetrics = new ComponentMetrics(boltComponent, instanceMetrics);
result.put(boltComponent, componentMetrics);
}
return result;
}
Aggregations