use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterUpgradeDiskSpaceValidationHandlerTest method testHandlerShouldReturnFinishEventWhenImageServiceThrowsAnException.
@Test
public void testHandlerShouldReturnFinishEventWhenImageServiceThrowsAnException() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
when(imageService.getCurrentImage(STACK_ID)).thenThrow(new CloudbreakImageNotFoundException("Image not found"));
Selectable nextFlowStepSelector = underTest.doAccept(createEvent());
assertEquals(FINISH_CLUSTER_UPGRADE_DISK_SPACE_VALIDATION_EVENT.name(), nextFlowStepSelector.selector());
verify(imageService).getCurrentImage(STACK_ID);
verifyNoInteractions(stackService);
verifyNoInteractions(diskSpaceValidationService);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable 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.common.event.Selectable 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);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable 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);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable 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);
}
Aggregations