use of com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest 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));
}
use of com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest in project cloudbreak by hortonworks.
the class ClusterDownscaleActions method decommissionAction.
@Bean(name = "DECOMMISSION_STATE")
public Action<?, ?> decommissionAction() {
return new AbstractClusterAction<CollectDownscaleCandidatesResult>(CollectDownscaleCandidatesResult.class) {
@Override
protected void doExecute(ClusterViewContext context, CollectDownscaleCandidatesResult payload, Map<Object, Object> variables) {
Selectable request = new DecommissionRequest(context.getStackId(), payload.getHostGroupName(), payload.getHostNames());
sendEvent(context.getFlowId(), request.selector(), request);
}
};
}
Aggregations