use of com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionResult in project cloudbreak by hortonworks.
the class UnhealthyInstancesDetectionHandler method accept.
@Override
public void accept(Event<UnhealthyInstancesDetectionRequest> event) {
UnhealthyInstancesDetectionRequest request = event.getData();
UnhealthyInstancesDetectionResult result;
Long stackId = request.getStackId();
Stack stack = stackService.getById(stackId);
try {
Set<InstanceMetaData> candidateUnhealthyInstances = unhealthyInstanceSelector.selectCandidateUnhealthyInstances(stack.getId());
if (candidateUnhealthyInstances.isEmpty()) {
result = new UnhealthyInstancesDetectionResult(request, Collections.emptySet());
} else {
Set<String> unhealthyInstances = unhealthyInstancesFinalizer.finalizeUnhealthyInstances(stack, candidateUnhealthyInstances);
result = new UnhealthyInstancesDetectionResult(request, unhealthyInstances);
}
} catch (RuntimeException e) {
String msg = String.format("Could not get statuses for unhealty instances: %s", e.getMessage());
LOG.error(msg, e);
result = new UnhealthyInstancesDetectionResult(msg, e, request);
}
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Aggregations