Search in sources :

Example 1 with ClusterProxyEnablementService

use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService in project cloudbreak by hortonworks.

the class ClusterCreationActions method clusterProxyRegistrationAction.

@Bean(name = "CLUSTER_PROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
    return new AbstractStackCreationAction<>(ProvisionEvent.class) {

        @Inject
        private ClusterProxyEnablementService clusterProxyEnablementService;

        @Override
        protected void prepareExecution(ProvisionEvent payload, Map<Object, Object> variables) {
            super.prepareExecution(payload, variables);
            variables.put(PROVISION_TYPE, payload.getProvisionType());
        }

        @Override
        protected void doExecute(StackCreationContext context, ProvisionEvent payload, Map<Object, Object> variables) {
            if (clusterProxyEnablementService.isClusterProxyApplicable(context.getStack().cloudPlatform())) {
                clusterCreationService.registeringToClusterProxy(context.getStack());
                sendEvent(context);
            } else {
                ClusterProxyRegistrationSuccess clusterProxyRegistrationSuccess = new ClusterProxyRegistrationSuccess(payload.getResourceId());
                sendEvent(context, clusterProxyRegistrationSuccess);
            }
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            return new ClusterProxyRegistrationRequest(context.getStack().getId(), context.getStack().cloudPlatform());
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) ClusterProxyEnablementService(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService) ClusterProxyRegistrationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationRequest) ProvisionEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionEvent) ClusterProxyRegistrationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClusterProxyEnablementService

use of com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService in project cloudbreak by hortonworks.

the class StackUpscaleActions method reRegisterWithClusterProxy.

@Bean(name = "RE_REGISTER_WITH_CLUSTER_PROXY_STATE")
public Action<?, ?> reRegisterWithClusterProxy() {
    return new AbstractStackUpscaleAction<>(StackEvent.class) {

        @Inject
        private ClusterProxyEnablementService clusterProxyEnablementService;

        @Override
        protected void doExecute(StackScalingFlowContext context, StackEvent payload, Map<Object, Object> variables) {
            if (clusterProxyEnablementService.isClusterProxyApplicable(context.getStack().cloudPlatform())) {
                stackUpscaleService.reRegisterWithClusterProxy(context.getStack().getId());
                sendEvent(context);
            } else {
                LOGGER.info("Cluster Proxy integration is DISABLED, skipping re-registering with Cluster Proxy service");
                StackEvent bootstrapNewNodesEvent = new StackEvent(StackUpscaleEvent.CLUSTER_PROXY_RE_REGISTRATION_FINISHED_EVENT.event(), payload.getResourceId());
                sendEvent(context, bootstrapNewNodesEvent);
            }
        }

        @Override
        protected Selectable createRequest(StackScalingFlowContext context) {
            return new ClusterProxyReRegistrationRequest(context.getStack().getId(), context.getStack().getCloudPlatform(), StackUpscaleEvent.CLUSTER_PROXY_RE_REGISTRATION_FINISHED_EVENT.event());
        }
    };
}
Also used : ClusterProxyReRegistrationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyReRegistrationRequest) ClusterProxyEnablementService(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Map(java.util.Map) HashMap(java.util.HashMap) StackScalingFlowContext(com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

ClusterProxyEnablementService (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService)2 Map (java.util.Map)2 Bean (org.springframework.context.annotation.Bean)2 StackScalingFlowContext (com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext)1 AbstractStackCreationAction (com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction)1 StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 ClusterProxyReRegistrationRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyReRegistrationRequest)1 ClusterProxyRegistrationRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationRequest)1 ClusterProxyRegistrationSuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess)1 ProvisionEvent (com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionEvent)1 HashMap (java.util.HashMap)1