use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class FreeIpaScalingService method triggerUpscale.
private UpscaleResponse triggerUpscale(UpscaleRequest request, Stack stack, AvailabilityType originalAvailabilityType) {
Operation operation = startScalingOperation(stack.getAccountId(), request.getEnvironmentCrn(), OperationType.UPSCALE);
UpscaleEvent upscaleEvent = new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), stack.getId(), request.getTargetAvailabilityType().getInstanceCount(), false, false, false, operation.getOperationId());
try {
LOGGER.info("Trigger upscale flow with event: {}", upscaleEvent);
FlowIdentifier flowIdentifier = flowManager.notify(UpscaleFlowEvent.UPSCALE_EVENT.event(), upscaleEvent);
UpscaleResponse response = new UpscaleResponse();
response.setOperationId(operation.getOperationId());
response.setOriginalAvailabilityType(originalAvailabilityType);
response.setTargetAvailabilityType(request.getTargetAvailabilityType());
response.setFlowIdentifier(flowIdentifier);
return response;
} catch (Exception e) {
String exception = handleFlowException(operation, e, stack);
throw new BadRequestException(exception);
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class DistroXV1Controller method launchSyncComponentVersionsFromCm.
private DistroXSyncCmV1Response launchSyncComponentVersionsFromCm(NameOrCrn nameOrCrn) {
Long workspaceId = getWorkspaceIdForCurrentUser();
FlowIdentifier flowIdentifier = stackOperations.syncComponentVersionsFromCm(nameOrCrn, workspaceId, Set.of());
return new DistroXSyncCmV1Response(flowIdentifier);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeWhenRegisterClusterProxyFail.
@Test
public void testCcmUpgradeWhenRegisterClusterProxyFail() throws CloudbreakOrchestratorException {
doThrow(new BadRequestException()).when(upgradeCcmService).registerClusterProxy(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(FlowLog::getFinalized), "flow has not finalized");
InOrder inOrder = Mockito.inOrder(upgradeCcmService);
inOrder.verify(upgradeCcmService, times(1)).updateTunnel(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).pushSaltState(STACK_ID, CLUSTER_ID);
inOrder.verify(upgradeCcmService, times(1)).reconfigureNginx(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).registerClusterProxy(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).ccmUpgradeFailed(STACK_ID, CLUSTER_ID, Tunnel.CCM);
verify(upgradeCcmService, never()).healthCheckState(STACK_ID);
verify(upgradeCcmService, never()).deregisterAgent(STACK_ID, Tunnel.CCM);
verify(upgradeCcmService, never()).removeAgent(STACK_ID, Tunnel.CCM);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeWhenSuccessful.
@Test
public void testCcmUpgradeWhenSuccessful() throws CloudbreakOrchestratorException {
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(FlowLog::getFinalized), "flow has not finalized");
InOrder inOrder = Mockito.inOrder(upgradeCcmService);
inOrder.verify(upgradeCcmService, times(1)).updateTunnel(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).pushSaltState(STACK_ID, CLUSTER_ID);
inOrder.verify(upgradeCcmService, times(1)).reconfigureNginx(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).registerClusterProxy(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).healthCheck(STACK_ID);
inOrder.verify(upgradeCcmService, times(1)).removeAgent(STACK_ID, Tunnel.CCM);
inOrder.verify(upgradeCcmService, times(1)).deregisterAgent(STACK_ID, Tunnel.CCM);
verify(upgradeCcmService, never()).ccmUpgradeFailed(STACK_ID, CLUSTER_ID, Tunnel.CCM);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class FreeIpaFlowManager method checkFlowOperationForResource.
private FlowIdentifier checkFlowOperationForResource(Event<? extends Acceptable> event) {
try {
Promise<AcceptResult> acceptPromise = event.getData().accepted();
FlowAcceptResult accepted = (FlowAcceptResult) Benchmark.checkedMeasure(() -> acceptPromise.await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS), LOGGER, "Accepting flow event took {}ms");
if (accepted == null) {
reactorReporter.logErrorReport();
throw new RuntimeException("FlowAcceptResult was null. Maybe flow is under operation, request not allowed.");
}
switch(accepted.getResultType()) {
case RUNNING_IN_FLOW:
return new FlowIdentifier(FlowType.FLOW, accepted.getAsFlowId());
case RUNNING_IN_FLOW_CHAIN:
return new FlowIdentifier(FlowType.FLOW_CHAIN, accepted.getAsFlowChainId());
case ALREADY_EXISTING_FLOW:
throw new FlowsAlreadyRunningException(String.format("Request not allowed, freeipa cluster already has a running operation. " + "Running operation(s): [%s]", flowNameFormatService.formatFlows(accepted.getAlreadyRunningFlows())));
default:
throw new IllegalStateException("Illegal resultType: " + accepted.getResultType());
}
} catch (InterruptedException e) {
reactorReporter.logErrorReport();
throw new RuntimeException(e.getMessage());
}
}
Aggregations