Search in sources :

Example 1 with TopologyUpdate

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);
}
Also used : PackingPlans(com.twitter.heron.proto.system.PackingPlans) RoundRobinPacking(com.twitter.heron.packing.roundrobin.RoundRobinPacking) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyUpdate(com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 2 with TopologyUpdate

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);
}
Also used : TopologyUpdate(com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 3 with TopologyUpdate

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;
}
Also used : Action(com.microsoft.dhalion.resolver.Action) HashMap(java.util.HashMap) Scheduler(com.twitter.heron.proto.scheduler.Scheduler) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) ArrayList(java.util.ArrayList) TopologyUpdate(com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate) Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ComponentMetrics(com.microsoft.dhalion.metrics.ComponentMetrics)

Aggregations

TopologyUpdate (com.twitter.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate)3 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)2 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)2 Test (org.junit.Test)2 Symptom (com.microsoft.dhalion.detector.Symptom)1 Diagnosis (com.microsoft.dhalion.diagnoser.Diagnosis)1 ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)1 Action (com.microsoft.dhalion.resolver.Action)1 RoundRobinPacking (com.twitter.heron.packing.roundrobin.RoundRobinPacking)1 Scheduler (com.twitter.heron.proto.scheduler.Scheduler)1 PackingPlans (com.twitter.heron.proto.system.PackingPlans)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1