Search in sources :

Example 1 with ContainerRestart

use of com.twitter.heron.healthmgr.common.HealthManagerEvents.ContainerRestart in project incubator-heron by apache.

the class RestartContainerResolver method resolve.

@Override
public List<Action> resolve(List<Diagnosis> diagnosis) {
    List<Action> actions = new ArrayList<>();
    for (Diagnosis diagnoses : diagnosis) {
        Symptom bpSymptom = diagnoses.getSymptoms().get(SYMPTOM_SLOW_INSTANCE.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");
        }
        // want to know which stmgr has backpressure
        String stmgrId = null;
        for (InstanceMetrics im : bpSymptom.getComponent().getMetrics().values()) {
            if (im.hasMetricAboveLimit(METRIC_BACK_PRESSURE.text(), noiseFilterMillis)) {
                String instanceId = im.getName();
                int fromIndex = instanceId.indexOf('_') + 1;
                int toIndex = instanceId.indexOf('_', fromIndex);
                stmgrId = instanceId.substring(fromIndex, toIndex);
                break;
            }
        }
        LOG.info("Restarting container: " + stmgrId);
        boolean b = schedulerClient.restartTopology(RestartTopologyRequest.newBuilder().setContainerIndex(Integer.valueOf(stmgrId)).setTopologyName(topologyName).build());
        LOG.info("Restarted container result: " + b);
        ContainerRestart action = new ContainerRestart();
        LOG.info("Broadcasting container restart event");
        eventManager.onEvent(action);
        actions.add(action);
        return actions;
    }
    return actions;
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) Action(com.microsoft.dhalion.resolver.Action) ArrayList(java.util.ArrayList) Diagnosis(com.microsoft.dhalion.diagnoser.Diagnosis) Symptom(com.microsoft.dhalion.detector.Symptom) ContainerRestart(com.twitter.heron.healthmgr.common.HealthManagerEvents.ContainerRestart)

Aggregations

Symptom (com.microsoft.dhalion.detector.Symptom)1 Diagnosis (com.microsoft.dhalion.diagnoser.Diagnosis)1 InstanceMetrics (com.microsoft.dhalion.metrics.InstanceMetrics)1 Action (com.microsoft.dhalion.resolver.Action)1 ContainerRestart (com.twitter.heron.healthmgr.common.HealthManagerEvents.ContainerRestart)1 ArrayList (java.util.ArrayList)1