Search in sources :

Example 1 with RemoveHostsRequest

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);
        }
    };
}
Also used : RemoveHostsRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest) AbstractClusterAction(com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction) DecommissionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult) Map(java.util.Map) ClusterViewContext(com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext) Bean(org.springframework.context.annotation.Bean)

Example 2 with RemoveHostsRequest

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));
}
Also used : RemoveHostsSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess) RemoveHostsFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) RemoveHostsRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollingResult(com.sequenceiq.cloudbreak.polling.PollingResult) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

RemoveHostsRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)1 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 PollingResult (com.sequenceiq.cloudbreak.polling.PollingResult)1 RemoveHostsFailed (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed)1 RemoveHostsSuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess)1 DecommissionResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult)1 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1