Search in sources :

Example 1 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class StopStartDownscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(ClusterAndStackDownscaleTriggerEvent event) {
    StackView stackView = stackService.getViewByIdWithoutAuth(event.getResourceId());
    Map<String, Set<Long>> hostGroupsWithPrivateIds = event.getHostGroupsWithPrivateIds();
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    // TODO CB-14929: Is a stack sync really required here. What does it do ? (As of now it also serves to accept the event)
    addStackSyncTriggerEvent(event, flowEventChain);
    if (hostGroupsWithPrivateIds.keySet().size() > 1) {
        throw new BadRequestException("Start stop downscale flow was intended to handle only 1 hostgroup.");
    }
    for (Map.Entry<String, Set<Long>> hostGroupWithPrivateIds : hostGroupsWithPrivateIds.entrySet()) {
        StopStartDownscaleTriggerEvent te = new StopStartDownscaleTriggerEvent(StopStartDownscaleEvent.STOPSTART_DOWNSCALE_TRIGGER_EVENT.event(), stackView.getId(), hostGroupWithPrivateIds.getKey(), hostGroupWithPrivateIds.getValue());
        flowEventChain.add(te);
    }
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : Set(java.util.Set) StopStartDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StopStartDownscaleTriggerEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Map(java.util.Map)

Example 2 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class SyncFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackSyncTriggerEvent(STACK_SYNC_EVENT.event(), event.getResourceId(), true, event.accepted()));
    flowEventChain.add(new StackEvent(CLUSTER_SYNC_EVENT.event(), event.getResourceId()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackSyncTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 3 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class UpscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackAndClusterUpscaleTriggerEvent event) {
    StackView stackView = stackService.getViewByIdWithoutAuth(event.getResourceId());
    ClusterView clusterView = stackView.getClusterView();
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    addStackSyncTriggerEvent(event, flowEventChain);
    addStackScaleTriggerEvent(event, flowEventChain);
    addClusterScaleTriggerEventIfNeeded(event, stackView, clusterView, flowEventChain);
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 4 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class MultiHostgroupDownscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(MultiHostgroupClusterAndStackDownscaleTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new FlowChainInitPayload(getName(), event.getResourceId(), event.accepted()));
    ClusterScaleTriggerEvent cste = new ClusterDownscaleTriggerEvent(DECOMMISSION_EVENT.event(), event.getResourceId(), Collections.emptyMap(), event.getPrivateIdsByHostgroupMap(), Collections.emptyMap(), event.accepted(), event.getDetails());
    flowEventChain.add(cste);
    if (event.getScalingType() == ScalingType.DOWNSCALE_TOGETHER) {
        CloudPlatformVariant cloudPlatformVariant = stackService.getPlatformVariantByStackId(event.getResourceId());
        StackScaleTriggerEvent sste = new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getResourceId(), Collections.emptyMap(), event.getPrivateIdsByHostgroupMap(), Collections.emptyMap(), cloudPlatformVariant.getVariant().value());
        flowEventChain.add(sste);
    }
    flowEventChain.add(new FlowChainFinalizePayload(getName(), event.getResourceId(), event.accepted()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : FlowChainInitPayload(com.sequenceiq.flow.core.chain.init.flowevents.FlowChainInitPayload) ClusterDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent) StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) FlowChainFinalizePayload(com.sequenceiq.flow.core.chain.finalize.flowevents.FlowChainFinalizePayload) ClusterScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent) MultiHostgroupClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent) StackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 5 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class ProperTerminationFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(TerminationEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new TerminationEvent(ClusterTerminationEvent.PROPER_TERMINATION_EVENT.event(), event.getResourceId(), event.getTerminationType()));
    flowEventChain.add(new TerminationEvent(START_EXTERNAL_DATABASE_TERMINATION_EVENT.event(), event.getResourceId(), event.getTerminationType()));
    flowEventChain.add(new TerminationEvent(StackTerminationEvent.TERMINATION_EVENT.event(), event.getResourceId(), event.getTerminationType(), event.accepted()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.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)

Aggregations

FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)52 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)35 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)26 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)15 Test (org.junit.Test)10 Test (org.junit.jupiter.api.Test)9 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)5 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)4 TerminationEvent (com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationEvent)4 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)3 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)3 StackSyncTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent)3 StackTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationEvent)3 DatalakeResizeRecoveryFlowChainStartEvent (com.sequenceiq.datalake.flow.detach.event.DatalakeResizeRecoveryFlowChainStartEvent)3 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 Payload (com.sequenceiq.cloudbreak.common.event.Payload)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)2