use of com.twitter.heron.healthmgr.common.PackingPlanProvider 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());
}
use of com.twitter.heron.healthmgr.common.PackingPlanProvider in project incubator-heron by apache.
the class BufferSizeSensorTest method providesBufferSizeMetricForBolts.
@Test
public void providesBufferSizeMetricForBolts() {
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_BUFFER_SIZE + boltId + MetricName.METRIC_BUFFER_SIZE_SUFFIX;
registerStMgrInstanceMetricResponse(metricsProvider, metric, boltId.length());
}
BufferSizeSensor bufferSizeSensor = new BufferSizeSensor(null, packingPlanProvider, topologyProvider, metricsProvider);
Map<String, ComponentMetrics> componentMetrics = bufferSizeSensor.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_BUFFER_SIZE.text()).intValue());
assertEquals(2, componentMetrics.get("bolt-2").getMetrics().size());
assertEquals(boltIds[1].length(), componentMetrics.get("bolt-2").getMetrics(boltIds[1]).getMetricValueSum(MetricName.METRIC_BUFFER_SIZE.text()).intValue());
assertEquals(boltIds[2].length(), componentMetrics.get("bolt-2").getMetrics(boltIds[2]).getMetricValueSum(MetricName.METRIC_BUFFER_SIZE.text()).intValue());
}
use of com.twitter.heron.healthmgr.common.PackingPlanProvider 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());
}
Aggregations