use of com.sequenceiq.flow.domain.RetryableStateResponse 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