Search in sources :

Example 1 with DecommissionResult

use of com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult in project cloudbreak by hortonworks.

the class DecommissionHandler method accept.

@Override
public void accept(Event<DecommissionRequest> event) {
    DecommissionRequest request = event.getData();
    DecommissionResult result;
    try {
        Stack stack = stackService.getByIdWithLists(request.getStackId());
        Map<String, HostMetadata> hostsToRemove = ambariDecommissioner.collectHostsToRemove(stack, request.getHostGroupName(), request.getHostNames());
        Set<String> hostNames;
        if (!hostsToRemove.isEmpty()) {
            executePreTerminationRecipes(stack, request.getHostGroupName(), hostsToRemove.keySet());
            hostNames = ambariDecommissioner.decommissionAmbariNodes(stack, hostsToRemove);
        } else {
            hostNames = request.getHostNames();
        }
        result = new DecommissionResult(request, hostNames);
    } catch (Exception e) {
        result = new DecommissionResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : DecommissionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest) DecommissionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Aggregations

HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 DecommissionRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest)1 DecommissionResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult)1