Search in sources :

Example 1 with DecommissionRequest

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));
}
Also used : DecommissionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest) DecommissionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 2 with DecommissionRequest

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

Aggregations

DecommissionRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest)2 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)1 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)1 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)1 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 CollectDownscaleCandidatesResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult)1 DecommissionResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1