Search in sources :

Example 1 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable 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 Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable 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 Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class FlowChains method triggerNextFlow.

public void triggerNextFlow(String flowChainId) {
    Queue<Selectable> queue = flowChainMap.get(flowChainId);
    if (queue != null) {
        Selectable selectable = queue.poll();
        if (selectable != null) {
            sendEvent(flowChainId, selectable);
        } else {
            removeFlowChain(flowChainId);
            triggerParentFlowChain(flowChainId);
        }
        flowLogService.saveChain(flowChainId, flowChainParentMap.get(flowChainId), queue);
    }
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable)

Example 4 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class ProperTerminationFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(TerminationEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackEvent(ClusterTerminationEvent.PROPER_TERMINATION_EVENT.event(), event.getStackId(), null));
    flowEventChain.add(new TerminationEvent(StackTerminationEvent.TERMINATION_EVENT.event(), event.getStackId(), event.getForced(), event.getDeleteDependencies()));
    return flowEventChain;
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ClusterTerminationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent) StackTerminationEvent(com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationEvent) TerminationEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationEvent)

Example 5 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class ProvisionFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackEvent(START_CREATION_EVENT.event(), event.getStackId(), event.accepted()));
    flowEventChain.add(new StackEvent(CLUSTER_CREATION_EVENT.event(), event.getStackId()));
    return flowEventChain;
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Aggregations

Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)35 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)10 Map (java.util.Map)10 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)10 Bean (org.springframework.context.annotation.Bean)9 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)4 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)3 StackScalingFlowContext (com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)3 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)2 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)2 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)2 StackAndClusterUpscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent)2