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