Search in sources :

Example 1 with ClusterProxyRegistrationRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationRequest 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 ClusterProxyRegistrationRequest

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

the class ClusterProxyRegistrationHandler method accept.

@Override
public void accept(Event<ClusterProxyRegistrationRequest> event) {
    ClusterProxyRegistrationRequest request = event.getData();
    Selectable response = registerCluster(request);
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : ClusterProxyRegistrationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable)

Aggregations

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