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;
}
Aggregations