use of com.sequenceiq.flow.domain.RetryResponse in project cloudbreak by hortonworks.
the class StackCommonService method retryInWorkspace.
public FlowIdentifier retryInWorkspace(NameOrCrn nameOrCrn, Long workspaceId) {
Long stackId = stackService.getIdByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
RetryResponse retry = flowRetryService.retry(stackId);
eventService.fireCloudbreakEvent(stackId, Status.UPDATE_IN_PROGRESS.name(), STACK_RETRY_FLOW_START, List.of(retry.getName()));
return retry.getFlowIdentifier();
}
use of com.sequenceiq.flow.domain.RetryResponse in project cloudbreak by hortonworks.
the class FreeIpaRetryServiceTest method testRetry.
@Test
public void testRetry() {
Stack stack = new Stack();
stack.setId(6L);
when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, "afda");
when(flowRetryService.retry(stack.getId())).thenReturn(new RetryResponse("asdf", flowIdentifier));
FlowIdentifier result = underTest.retry(ENV_CRN, ACCOUNT_ID);
assertEquals(flowIdentifier, result);
}
use of com.sequenceiq.flow.domain.RetryResponse in project cloudbreak by hortonworks.
the class FreeIpaRetryService method retry.
public FlowIdentifier retry(String environmentCrn, String accountId) {
Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
MDCBuilder.buildMdcContext(stack);
RetryResponse retry = flowRetryService.retry(stack.getId());
return retry.getFlowIdentifier();
}
use of com.sequenceiq.flow.domain.RetryResponse in project cloudbreak by hortonworks.
the class FlowRetryService method retry.
public RetryResponse retry(Long stackId) {
RetryableStateResponse retryableStateResponse = getRetryableStateResponse(stackId);
switch(retryableStateResponse.getState()) {
case FLOW_PENDING:
String flowPendingMessage = "Retry cannot be performed, because there is already an active flow.";
LOGGER.info(flowPendingMessage + " stackId: {}", stackId);
throw new BadRequestException(flowPendingMessage);
case LAST_NOT_FAILED_OR_NOT_RETRYABLE:
String notFailedOrNotRetryableMessage = "Retry cannot be performed. The last flow did not fail or not retryable." + retryableStateResponse.getLastKnownStateMessage();
LOGGER.info(notFailedOrNotRetryableMessage + " stackId: {}", stackId);
throw new BadRequestException(notFailedOrNotRetryableMessage);
case NO_SUCCESSFUL_STATE:
String noSuccessfulStateMessage = "Cannot restart previous flow because there is no successful state in the flow.";
LOGGER.info(noSuccessfulStateMessage + " stackId: {}", stackId);
throw new BadRequestException(noSuccessfulStateMessage);
case RETRYABLE:
FlowLog lastSuccessfulStateFlowLog = retryableStateResponse.getLastSuccessfulStateFlowLog();
flow2Handler.restartFlow(lastSuccessfulStateFlowLog);
if (lastSuccessfulStateFlowLog.getFlowChainId() != null) {
return new RetryResponse(retryableStateResponse.getName(), new FlowIdentifier(FlowType.FLOW_CHAIN, lastSuccessfulStateFlowLog.getFlowChainId()));
} else {
return new RetryResponse(retryableStateResponse.getName(), new FlowIdentifier(FlowType.FLOW, lastSuccessfulStateFlowLog.getFlowId()));
}
default:
throw new NotImplementedException("Retry state handling is not implemented: " + retryableStateResponse.getState());
}
}
Aggregations