use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess in project cloudbreak by hortonworks.
the class RemoveHostsHandler method accept.
@Override
public void accept(Event<RemoveHostsRequest> removeHostsRequestEvent) {
RemoveHostsRequest request = removeHostsRequestEvent.getData();
Set<String> hostNames = request.getHostNames();
Selectable result;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
if (stack.getPrimaryGatewayInstance() != null && stack.getPrimaryGatewayInstance().isReachable()) {
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
PollingResult orchestratorRemovalPollingResult = removeHostsFromOrchestrator(stack, new ArrayList<>(hostNames), hostOrchestrator, allGatewayConfigs);
if (!orchestratorRemovalPollingResult.isSuccess()) {
LOGGER.warn("Can not remove hosts from orchestrator: {}", hostNames);
}
} else {
LOGGER.warn("Primary gateway is not reachable, can't remove hosts from orchestrator");
}
result = new RemoveHostsSuccess(request.getResourceId(), request.getHostGroupNames(), hostNames);
} catch (Exception e) {
result = new RemoveHostsFailed(removeHostsRequestEvent.getData().getResourceId(), e, request.getHostGroupNames(), hostNames);
}
eventBus.notify(result.selector(), new Event<>(removeHostsRequestEvent.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess in project cloudbreak by hortonworks.
the class ClusterDownscaleActions method decommissionAction.
@Bean(name = "DECOMMISSION_STATE")
public Action<?, ?> decommissionAction() {
return new AbstractClusterAction<>(CollectDownscaleCandidatesResult.class) {
@Override
protected void doExecute(ClusterViewContext context, CollectDownscaleCandidatesResult payload, Map<Object, Object> variables) {
variables.put(ContextKeys.PRIVATE_IDS, payload.getPrivateIds());
Selectable event;
if (isPayloadContainsAnyPrivateId(payload)) {
Boolean repair = (Boolean) variables.get(REPAIR);
Stack stack = stackService.getByIdWithListsInTransaction(context.getStackId());
DecommissionRequest decommissionRequest = new DecommissionRequest(context.getStackId(), payload.getHostGroupNames(), payload.getPrivateIds(), payload.getRequest().getDetails());
if (repair && stack.hasCustomHostname()) {
LOGGER.debug("Cluster decommission state identified that the current action is a repair, hence we're going that way from now.");
event = new DecommissionResult(decommissionRequest, getHostNamesForPrivateIds(payload.getPrivateIds(), stack));
} else {
event = decommissionRequest;
}
} else {
LOGGER.info("Handler wasn't able to collect any candidate [stackId:{}, host group name: {}] for downscaling, therefore we're handling " + "it as a success (since nothing to decommission)", context.getStackId(), payload.getHostGroupNames());
event = new RemoveHostsSuccess(context.getStackId(), payload.getHostGroupNames(), emptySet());
}
sendEvent(context, event.selector(), event);
}
};
}
Aggregations