Search in sources :

Example 1 with ClusterTerminationRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest in project cloudbreak by hortonworks.

the class ClusterTerminationActions method terminatingCluster.

@Bean(name = "CLUSTER_TERMINATING_STATE")
public Action<?, ?> terminatingCluster() {
    return new AbstractClusterAction<StackEvent>(StackEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, StackEvent payload, Map<Object, Object> variables) {
            clusterTerminationFlowService.terminateCluster(context);
            sendEvent(context);
        }

        @Override
        protected void initPayloadConverterMap(List<PayloadConverter<StackEvent>> payloadConverters) {
            payloadConverters.add(new DisableKerberosResultToStackEventConverter());
        }

        @Override
        protected Selectable createRequest(ClusterViewContext context) {
            return new ClusterTerminationRequest(context.getStackId(), context.getClusterView() != null ? context.getClusterView().getId() : null);
        }
    };
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) DisableKerberosResultToStackEventConverter(com.sequenceiq.cloudbreak.core.flow2.stack.provision.DisableKerberosResultToStackEventConverter) List(java.util.List) ClusterTerminationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest) PrepareClusterTerminationRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.PrepareClusterTerminationRequest) 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)

Example 2 with ClusterTerminationRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest in project cloudbreak by hortonworks.

the class ClusterTerminationHandler method accept.

@Override
public void accept(Event<ClusterTerminationRequest> event) {
    ClusterTerminationRequest request = event.getData();
    ClusterTerminationResult result;
    try {
        Boolean allowed = clusterTerminationService.deleteClusterComponents(request.getClusterId());
        result = new ClusterTerminationResult(request, allowed);
    } catch (RuntimeException e) {
        LOGGER.error("Failed to delete cluster containers", e);
        result = new ClusterTerminationResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterTerminationResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationResult) ClusterTerminationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest)

Aggregations

ClusterTerminationRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest)2 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)1 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)1 DisableKerberosResultToStackEventConverter (com.sequenceiq.cloudbreak.core.flow2.stack.provision.DisableKerberosResultToStackEventConverter)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 PrepareClusterTerminationRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.PrepareClusterTerminationRequest)1 ClusterTerminationResult (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationResult)1 List (java.util.List)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1