Search in sources :

Example 1 with ChangePrimaryGatewayRequest

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

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

the class ChangePrimaryGatewayHandler method accept.

@Override
public void accept(Event<ChangePrimaryGatewayRequest> event) {
    ChangePrimaryGatewayRequest request = event.getData();
    Selectable response;
    try {
        response = new ChangePrimaryGatewaySuccess(request.getStackId(), clusterServiceRunner.changePrimaryGateway(request.getStackId()));
    } catch (Exception e) {
        response = new ChangePrimaryGatewayFailed(request.getStackId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : ChangePrimaryGatewayRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest) ChangePrimaryGatewaySuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewaySuccess) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ChangePrimaryGatewayFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayFailed)

Aggregations

Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)2 ChangePrimaryGatewayRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest)2 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)1 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)1 ChangePrimaryGatewayFailed (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayFailed)1 ChangePrimaryGatewaySuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewaySuccess)1 ChangePrimaryGatewayTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1