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);
}
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);
}
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());
}
Aggregations