use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class StackOperationService method start.
@VisibleForTesting
FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster) {
FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered();
environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable());
dataLakeStatusCheckerService.validateRunningState(stack);
if (stack.isAvailable()) {
eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED);
} else if (stack.isReadyForStart() || stack.isStartFailed()) {
Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED);
flowIdentifier = flowManager.triggerStackStart(stack.getId());
if (updateCluster && cluster != null) {
clusterOperationService.updateStatus(startStack, StatusRequest.STARTED);
}
} else {
throw NotAllowedStatusUpdate.stack(stack).to(DetailedStackStatus.START_REQUESTED).badRequest();
}
return flowIdentifier;
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class CcmUpgradeFlowIntegrationTest method testCcmUpgradeWhenReRegisterFail.
@Test
public void testCcmUpgradeWhenReRegisterFail() {
doThrow(new BadRequestException()).when(ccmUpgradeService).reregister(STACK_ID);
FlowIdentifier flowIdentifier = triggerFlow();
letItFlow(flowIdentifier);
ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
verify(flowLogRepository, times(2)).save(flowLog.capture());
Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(f -> f.getFinalized()), "flow has not finalized");
verify(ccmUpgradeService, times(1)).prepare(STACK_ID);
verify(ccmUpgradeService, times(1)).ccmUpgradeFailed(STACK_ID);
verify(ccmUpgradeService, times(1)).reregister(STACK_ID);
verify(ccmUpgradeService, never()).ccmUpgradePreparationFailed(STACK_ID);
verify(ccmUpgradeService, never()).unregister(STACK_ID);
verify(ccmUpgradeService, never()).removeAutoSsh(STACK_ID);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class CcmUpgradeFlowIntegrationTest method testCcmUpgradeWhenPrepFail.
@Test
public void testCcmUpgradeWhenPrepFail() {
doThrow(new BadRequestException()).when(ccmUpgradeService).prepare(STACK_ID);
FlowIdentifier flowIdentifier = triggerFlow();
letItFlow(flowIdentifier);
ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
verify(flowLogRepository, times(2)).save(flowLog.capture());
Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(f -> f.getFinalized()), "flow has not finalized");
verify(ccmUpgradeService, times(1)).prepare(STACK_ID);
verify(ccmUpgradeService, times(1)).ccmUpgradePreparationFailed(STACK_ID);
verify(ccmUpgradeService, never()).ccmUpgradeFailed(STACK_ID);
verify(ccmUpgradeService, never()).reregister(STACK_ID);
verify(ccmUpgradeService, never()).unregister(STACK_ID);
verify(ccmUpgradeService, never()).removeAutoSsh(STACK_ID);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class ClusterOperationService method stop.
private FlowIdentifier stop(Stack stack, Cluster cluster) {
StopRestrictionReason reason = stackStopRestrictionService.isInfrastructureStoppable(stack);
FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered();
if (stack.isStopped()) {
eventService.fireCloudbreakEvent(stack.getId(), stack.getStatus().name(), CLUSTER_STOP_IGNORED);
} else if (reason != StopRestrictionReason.NONE) {
throw new BadRequestException(String.format("Cannot stop a cluster '%s'. Reason: %s", cluster.getId(), reason.getReason()));
} else if (!stack.isReadyForStop() && !stack.isStopFailed()) {
throw NotAllowedStatusUpdate.cluster(stack).to(STOPPED).expectedIn(AVAILABLE).badRequest();
} else {
clusterService.updateClusterStatusByStackId(stack.getId(), DetailedStackStatus.STOP_REQUESTED);
flowIdentifier = flowManager.triggerClusterStop(stack.getId());
}
return flowIdentifier;
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeBackupFlow.
private SdxBackupResponse triggerDatalakeBackupFlow(Long clusterId, String backupLocation, String backupName) {
String selector = DATALAKE_TRIGGER_BACKUP_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeTriggerBackupEvent startEvent = new DatalakeTriggerBackupEvent(selector, clusterId, userId, backupLocation, backupName, DatalakeBackupFailureReason.USER_TRIGGERED);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeBackupFlow(startEvent);
return new SdxBackupResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
Aggregations