use of com.sequenceiq.cloudbreak.core.flow2.event.StopStartDownscaleTriggerEvent 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);
}
use of com.sequenceiq.cloudbreak.core.flow2.event.StopStartDownscaleTriggerEvent in project cloudbreak by hortonworks.
the class StopStartDownscaleActionsTest method testDecommissionViaCmAction.
@Test
void testDecommissionViaCmAction() throws Exception {
AbstractStopStartDownscaleActions<StopStartDownscaleTriggerEvent> action = (AbstractStopStartDownscaleActions<StopStartDownscaleTriggerEvent>) underTest.decommissionViaCmAction();
initActionPrivateFields(action);
List<InstanceMetaData> instancesActionableStarted = generateInstances(10, 100, InstanceStatus.SERVICES_HEALTHY, INSTANCE_GROUP_NAME_ACTIONABLE);
Set<Long> instanceIdsToRemove = instancesActionableStarted.stream().limit(5).map(InstanceMetaData::getId).collect(Collectors.toUnmodifiableSet());
StopStartDownscaleContext stopStartDownscaleContext = createContext(instanceIdsToRemove);
StopStartDownscaleTriggerEvent payload = new StopStartDownscaleTriggerEvent(SELECTOR, STACK_ID, INSTANCE_GROUP_NAME_ACTIONABLE, instanceIdsToRemove);
mockStackEtc();
when(reactorEventFactory.createEvent(anyMap(), isNotNull())).thenReturn(event);
new AbstractActionTestSupport<>(action).doExecute(stopStartDownscaleContext, payload, Collections.emptyMap());
verify(stopStartDownscaleFlowService).clusterDownscaleStarted(eq(STACK_ID), eq(INSTANCE_GROUP_NAME_ACTIONABLE), eq(instanceIdsToRemove));
verifyNoMoreInteractions(stopStartDownscaleFlowService);
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(reactorEventFactory).createEvent(anyMap(), argumentCaptor.capture());
verify(eventBus).notify("STOPSTARTDOWNSCALEDECOMMISSIONVIACMREQUEST", event);
assertThat(argumentCaptor.getValue()).isInstanceOf(StopStartDownscaleDecommissionViaCMRequest.class);
StopStartDownscaleDecommissionViaCMRequest req = (StopStartDownscaleDecommissionViaCMRequest) argumentCaptor.getValue();
Assert.assertEquals(instanceIdsToRemove, req.getInstanceIdsToDecommission());
Assert.assertEquals(INSTANCE_GROUP_NAME_ACTIONABLE, req.getHostGroupName());
}
Aggregations