Search in sources :

Example 1 with UnhealthyInstancesDetectionResult

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));
}
Also used : UnhealthyInstancesDetectionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionResult) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) UnhealthyInstancesDetectionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionRequest) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 UnhealthyInstancesDetectionRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionRequest)1 UnhealthyInstancesDetectionResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionResult)1