use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class DatalakeResizeRecoveryFlowEventChainTest method chainCreationTestAllEvents.
@Test
public void chainCreationTestAllEvents() {
SdxCluster oldCluster = new SdxCluster();
oldCluster.setId(OLD_CLUSTER_SDX_ID);
oldCluster.setDetached(true);
SdxCluster newCluster = new SdxCluster();
newCluster.setId(NEW_CLUSTER_SDX_ID);
DatalakeResizeRecoveryFlowChainStartEvent event = new DatalakeResizeRecoveryFlowChainStartEvent(oldCluster, newCluster, USER_CRN);
FlowTriggerEventQueue flowTriggerEventQueue = factory.createFlowTriggerEventQueue(event);
assertEquals(4, flowTriggerEventQueue.getQueue().size());
Queue<Selectable> flowQueue = flowTriggerEventQueue.getQueue();
checkEventIsDetach(flowQueue.remove());
checkEventIsDeletion(flowQueue.remove());
checkEventIsDetachRecovery(flowQueue.remove());
checkEventIsStart(flowQueue.remove());
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class DatalakeResizeFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DatalakeResizeFlowChainStartEvent event) {
Queue<Selectable> chain = new ConcurrentLinkedQueue<>();
if (event.shouldTakeBackup()) {
// Take a backup
chain.add(new DatalakeTriggerBackupEvent(DATALAKE_TRIGGER_BACKUP_EVENT.event(), event.getResourceId(), event.getUserId(), event.getBackupLocation(), "resize" + System.currentTimeMillis(), DatalakeBackupFailureReason.BACKUP_ON_RESIZE, event.accepted()));
// Stop datalake
chain.add(new SdxStartStopEvent(SDX_STOP_EVENT.event(), event.getResourceId(), event.getUserId(), STOP_DATAHUBS));
} else {
chain.add(new SdxStartStopEvent(SDX_STOP_EVENT.event(), event.getResourceId(), event.getUserId(), STOP_DATAHUBS, event.accepted()));
}
// Detach sdx from environment
chain.add(new SdxStartDetachEvent(SDX_DETACH_EVENT.event(), event.getResourceId(), event.getSdxCluster(), event.getUserId()));
// Create new
chain.add(new SdxEvent(SDX_VALIDATION_EVENT.event(), event.getResourceId(), event.getSdxCluster().getClusterName(), event.getUserId()));
if (event.shouldPerformRestore()) {
// restore the new cluster
chain.add(new DatalakeTriggerRestoreEvent(DATALAKE_TRIGGER_RESTORE_EVENT.event(), event.getResourceId(), event.getSdxCluster().getClusterName(), event.getUserId(), null, event.getBackupLocation(), null, DatalakeRestoreFailureReason.RESTORE_ON_RESIZE));
}
// Delete the detached Sdx
chain.add(new SdxDeleteStartEvent(SDX_DELETE_EVENT.event(), event.getResourceId(), event.getUserId(), true));
chain.add(new DatahubRefreshStartEvent(event.getResourceId(), event.getSdxCluster().getClusterName(), event.getUserId()));
return new FlowTriggerEventQueue(getName(), event, chain);
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class DatalakeUpgradeFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DatalakeUpgradeFlowChainStartEvent event) {
Queue<Selectable> chain = new ConcurrentLinkedQueue<>();
chain.add(new DatalakeTriggerBackupEvent(DATALAKE_TRIGGER_BACKUP_EVENT.event(), event.getResourceId(), event.getUserId(), event.getBackupLocation(), "", DatalakeBackupFailureReason.BACKUP_ON_UPGRADE, event.accepted()));
chain.add(new DatalakeUpgradeStartEvent(DATALAKE_UPGRADE_EVENT.event(), event.getResourceId(), event.getUserId(), event.getImageId(), event.getReplaceVms()));
return new FlowTriggerEventQueue(getName(), event, chain);
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class ClusterRepairFlowEventChainFactoryTest method testRepairMultipleGatewayWithNoAttached.
@Test
public void testRepairMultipleGatewayWithNoAttached() {
Stack stack = getStack(MULTIPLE_GATEWAY);
when(stackService.findClustersConnectedToDatalakeByDatalakeStackId(STACK_ID)).thenReturn(Set.of());
InstanceGroupView ig = mock(InstanceGroupView.class);
when(ig.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
when(ig.getNodeCount()).thenReturn(5);
when(instanceGroupService.findViewByStackId(STACK_ID)).thenReturn(Set.of(ig));
setupHostGroup(true);
setupStackView();
FlowTriggerEventQueue eventQueues = underTest.createFlowTriggerEventQueue(new TriggerEventBuilder(stack).withFailedPrimaryGateway().build());
List<String> triggeredOperations = eventQueues.getQueue().stream().map(Selectable::selector).collect(Collectors.toList());
assertEquals(List.of("FLOWCHAIN_INIT_TRIGGER_EVENT", "STACK_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "RESCHEDULE_STATUS_CHECK_TRIGGER_EVENT", "FLOWCHAIN_FINALIZE_TRIGGER_EVENT"), triggeredOperations);
}
use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.
the class ClusterRepairFlowEventChainFactoryTest method testRepairMultipleGatewayWithAttached.
@Test
public void testRepairMultipleGatewayWithAttached() {
Stack stack = getStack(MULTIPLE_GATEWAY);
when(stackService.findClustersConnectedToDatalakeByDatalakeStackId(STACK_ID)).thenReturn(Set.of(ATTACHED_WORKLOAD));
InstanceGroupView ig = mock(InstanceGroupView.class);
when(ig.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
when(ig.getNodeCount()).thenReturn(5);
when(instanceGroupService.findViewByStackId(STACK_ID)).thenReturn(Set.of(ig));
setupHostGroup(true);
setupStackView();
FlowTriggerEventQueue eventQueues = underTest.createFlowTriggerEventQueue(new TriggerEventBuilder(stack).withFailedPrimaryGateway().build());
List<String> triggeredOperations = eventQueues.getQueue().stream().map(Selectable::selector).collect(Collectors.toList());
assertEquals(List.of("FLOWCHAIN_INIT_TRIGGER_EVENT", "STACK_DOWNSCALE_TRIGGER_EVENT", "FULL_UPSCALE_TRIGGER_EVENT", "RESCHEDULE_STATUS_CHECK_TRIGGER_EVENT", "FLOWCHAIN_FINALIZE_TRIGGER_EVENT"), triggeredOperations);
}
Aggregations