Search in sources :

Example 1 with AbstractClusterAction

use of com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayActions method repairGatewayAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_STATE")
public Action<?, ?> repairGatewayAction() {
    return new AbstractClusterAction<ChangePrimaryGatewayTriggerEvent>(ChangePrimaryGatewayTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, ChangePrimaryGatewayTriggerEvent payload, Map<Object, Object> variables) {
            changePrimaryGatewayService.changePrimaryGatewayStarted(context.getStackId());
            Selectable request = new ChangePrimaryGatewayRequest(context.getStackId());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : ChangePrimaryGatewayTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent) ChangePrimaryGatewayRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) 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 AbstractClusterAction

use of com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction in project cloudbreak by hortonworks.

the class ClusterDownscaleActions method collectCandidatesAction.

@Bean(name = "COLLECT_CANDIDATES_STATE")
public Action<?, ?> collectCandidatesAction() {
    return new AbstractClusterAction<ClusterDownscaleTriggerEvent>(ClusterDownscaleTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, ClusterDownscaleTriggerEvent payload, Map<Object, Object> variables) {
            clusterDownscaleService.clusterDownscaleStarted(context.getStackId(), payload.getHostGroupName(), payload.getAdjustment(), payload.getHostNames());
            Selectable request = new CollectDownscaleCandidatesRequest(context.getStackId(), payload.getHostGroupName(), payload.getAdjustment(), payload.getHostNames());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : ClusterDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) CollectDownscaleCandidatesRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesRequest) 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 3 with AbstractClusterAction

use of com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction in project cloudbreak by hortonworks.

the class ClusterCredentialChangeActions method changingClusterCredential.

@Bean(name = "CLUSTER_CREDENTIALCHANGE_STATE")
public Action<?, ?> changingClusterCredential() {
    return new AbstractClusterAction<ClusterCredentialChangeTriggerEvent>(ClusterCredentialChangeTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext ctx, ClusterCredentialChangeTriggerEvent payload, Map<Object, Object> variables) {
            clusterCredentialChangeService.credentialChange(ctx.getStackId());
            ClusterCredentialChangeRequest request;
            switch(payload.getType()) {
                case REPLACE:
                    request = ClusterCredentialChangeRequest.replaceUserRequest(ctx.getStackId(), payload.getUser(), payload.getPassword());
                    break;
                case UPDATE:
                    request = ClusterCredentialChangeRequest.changePasswordRequest(ctx.getStackId(), payload.getPassword());
                    break;
                default:
                    throw new UnsupportedOperationException("Ambari credential update request not supported: " + payload.getType());
            }
            sendEvent(ctx.getFlowId(), request);
        }
    };
}
Also used : ClusterCredentialChangeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterCredentialChangeTriggerEvent) ClusterCredentialChangeRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeRequest) 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 4 with AbstractClusterAction

use of com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction 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 5 with AbstractClusterAction

use of com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction in project cloudbreak by hortonworks.

the class EphemeralClusterActions method updateNameserverAction.

@Bean(name = "EPHEMERAL_CLUSTER_UPDATE_STATE")
public Action<?, ?> updateNameserverAction() {
    return new AbstractClusterAction<EphemeralClusterUpdateTriggerEvent>(EphemeralClusterUpdateTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, EphemeralClusterUpdateTriggerEvent payload, Map<Object, Object> variables) {
            ephemeralClusterService.updateClusterStarted(context.getStackId());
            Selectable request = new EphemeralClusterUpdateRequest(context.getStackId());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : EphemeralClusterUpdateRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateRequest) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) EphemeralClusterUpdateTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateTriggerEvent) 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

AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)6 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)6 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)4 ClusterCredentialChangeTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterCredentialChangeTriggerEvent)1 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)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 ChangePrimaryGatewayRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest)1 ChangePrimaryGatewayTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent)1 ClusterTerminationRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterTerminationRequest)1 EphemeralClusterUpdateRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateRequest)1 EphemeralClusterUpdateTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateTriggerEvent)1 ClusterCredentialChangeRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeRequest)1 CollectDownscaleCandidatesRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesRequest)1 CollectDownscaleCandidatesResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult)1 DecommissionRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest)1 List (java.util.List)1