use of com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult 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);
}
};
}
use of com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult in project cloudbreak by hortonworks.
the class CollectDownscaleCandidatesHandler method accept.
@Override
public void accept(Event<CollectDownscaleCandidatesRequest> event) {
CollectDownscaleCandidatesRequest request = event.getData();
CollectDownscaleCandidatesResult result;
try {
Stack stack = stackService.getByIdWithLists(request.getStackId());
Set<String> hostNames;
if (request.getHostNames() == null || request.getHostNames().isEmpty()) {
hostNames = ambariDecommissioner.collectDownscaleCandidates(stack, request.getHostGroupName(), request.getScalingAdjustment());
} else {
hostNames = request.getHostNames();
String hostName = hostNames.stream().findFirst().orElseThrow(() -> new BadRequestException("Unable to find host name"));
ambariDecommissioner.verifyNodeCount(stack, stack.getCluster(), hostName);
}
result = new CollectDownscaleCandidatesResult(request, hostNames);
} catch (Exception e) {
result = new CollectDownscaleCandidatesResult(e.getMessage(), e, request);
}
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Aggregations