use of com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate in project incubator-heron by apache.
the class PackingPlanProviderTest method refreshesPackingPlanOnUpdate.
@Test
public void refreshesPackingPlanOnUpdate() {
PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
PackingPlanProvider provider = new PackingPlanProvider(adaptor, eventManager, topologyName);
PackingPlan packing = provider.get();
Assert.assertEquals(1, packing.getContainers().size());
provider.onEvent(new TopologyUpdate());
provider.get();
verify(adaptor, times(2)).getPackingPlan(topologyName);
}
use of com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate in project incubator-heron by apache.
the class TopologyProviderTest method refreshesPackingPlanOnUpdate.
@Test
public void refreshesPackingPlanOnUpdate() {
SchedulerStateManagerAdaptor adaptor = getMockSchedulerStateManagerAdaptor();
TopologyProvider provider = new TopologyProvider(adaptor, eventManager, topology);
Assert.assertEquals(2, provider.get().getBoltsCount());
// once fetched it is cached
provider.onEvent(new TopologyUpdate());
provider.get();
verify(adaptor, times(2)).getPhysicalPlan(topology);
}
use of com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate 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;
}
Aggregations