Search in sources :

Example 1 with MultiHostgroupClusterAndStackDownscaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent 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 2 with MultiHostgroupClusterAndStackDownscaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent in project cloudbreak by hortonworks.

the class ReactorFlowManager method triggerStackRemoveInstances.

public FlowIdentifier triggerStackRemoveInstances(Long stackId, Map<String, Set<Long>> instanceIdsByHostgroupMap, boolean forced) {
    String selector = FlowChainTriggers.FULL_DOWNSCALE_MULTIHOSTGROUP_TRIGGER_EVENT;
    ClusterDownscaleDetails details = new ClusterDownscaleDetails(forced, false);
    MultiHostgroupClusterAndStackDownscaleTriggerEvent event = new MultiHostgroupClusterAndStackDownscaleTriggerEvent(selector, stackId, instanceIdsByHostgroupMap, details, ScalingType.DOWNSCALE_TOGETHER, new Promise<>());
    return reactorNotifier.notify(stackId, selector, event);
}
Also used : MultiHostgroupClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent) ClusterDownscaleDetails(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleDetails)

Example 3 with MultiHostgroupClusterAndStackDownscaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent in project cloudbreak by hortonworks.

the class MultiHostgroupDownscaleFlowEventChainFactoryTest method testCreateFlowWithTwoHostgroup.

@Test
public void testCreateFlowWithTwoHostgroup() {
    Map<String, Set<Long>> instanceIdsByHostgroupMap = new HashMap<>();
    instanceIdsByHostgroupMap.put("firstGroup", Sets.newHashSet(1L, 2L));
    instanceIdsByHostgroupMap.put("secondGroup", Sets.newHashSet(3L, 4L));
    ClusterDownscaleDetails details = new ClusterDownscaleDetails();
    MultiHostgroupClusterAndStackDownscaleTriggerEvent event = new MultiHostgroupClusterAndStackDownscaleTriggerEvent("selector", STACK_ID, instanceIdsByHostgroupMap, details, ScalingType.DOWNSCALE_TOGETHER, new Promise<>());
    when(stackService.getPlatformVariantByStackId(STACK_ID)).thenReturn(cloudPlatformVariant);
    when(cloudPlatformVariant.getVariant()).thenReturn(Variant.variant("AWS"));
    Queue<Selectable> queue = underTest.createFlowTriggerEventQueue(event).getQueue();
    assertEquals(4L, queue.size());
    assertEquals(FLOWCHAIN_INIT_TRIGGER_EVENT.event(), queue.poll().selector());
    assertEquals(DECOMMISSION_EVENT.event(), queue.poll().selector());
    assertEquals(STACK_DOWNSCALE_EVENT.event(), queue.poll().selector());
    assertEquals(FLOWCHAIN_FINALIZE_TRIGGER_EVENT.event(), queue.poll().selector());
}
Also used : Set(java.util.Set) MultiHostgroupClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent) HashMap(java.util.HashMap) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterDownscaleDetails(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleDetails) Test(org.junit.jupiter.api.Test)

Aggregations

MultiHostgroupClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.MultiHostgroupClusterAndStackDownscaleTriggerEvent)3 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 ClusterDownscaleDetails (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleDetails)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)1 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)1 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)1 StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)1 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)1 FlowChainFinalizePayload (com.sequenceiq.flow.core.chain.finalize.flowevents.FlowChainFinalizePayload)1 FlowChainInitPayload (com.sequenceiq.flow.core.chain.init.flowevents.FlowChainInitPayload)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 Test (org.junit.jupiter.api.Test)1