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