use of org.apache.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate in project heron by twitter.
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(null, null));
provider.get();
verify(adaptor, times(2)).getPackingPlan(topologyName);
}
use of org.apache.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate in project heron by twitter.
the class ScaleUpResolver method resolve.
@Override
public Collection<Action> resolve(Collection<Diagnosis> diagnosis) {
List<Action> actions = new ArrayList<>();
DiagnosisTable table = DiagnosisTable.of(diagnosis);
table = table.type(DIAGNOSIS_UNDER_PROVISIONING.text());
if (table.size() == 0) {
LOG.fine("No under-previsioning diagnosis present, ending as there's nothing to fix");
return actions;
}
// Scale the first assigned component
Diagnosis diagnoses = table.first();
// verify diagnoses instance is valid
if (diagnoses.assignments().isEmpty()) {
LOG.warning(String.format("Diagnosis %s is missing assignments", diagnoses.id()));
return actions;
}
String component = diagnoses.assignments().iterator().next();
int newParallelism = computeScaleUpFactor(component);
Map<String, Integer> changeRequest = new HashMap<>();
changeRequest.put(component, 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));
}
LOG.info("Scheduler updated topology successfully.");
LOG.info("Broadcasting topology update event");
TopologyUpdate action = new TopologyUpdate(context.checkpoint(), Collections.singletonList(component));
eventManager.onEvent(action);
actions.add(action);
return actions;
}
Aggregations