use of com.sequenceiq.flow.api.model.operation.OperationProgressStatus in project cloudbreak by hortonworks.
the class OperationDetailsPopulator method calculateProgress.
private OperationProgressStatus calculateProgress(List<FlowProgressResponse> provisionFlows) {
FlowProgressResponse lastFlowProgress = provisionFlows.get(provisionFlows.size() - 1);
if (lastFlowProgress.getTransitions() == null) {
return OperationProgressStatus.UNKNOWN;
}
OperationProgressStatus progressStatus = OperationProgressStatus.FINISHED;
boolean hasCancelState = false;
boolean hasFailedStatus = false;
boolean hasPendingStatus = false;
for (FlowStateTransitionResponse fsTransitionResp : lastFlowProgress.getTransitions()) {
if (OperationProgressStatus.CANCELLED.name().equals(fsTransitionResp.getStatus())) {
hasCancelState = true;
} else if (StateStatus.FAILED.name().equals(fsTransitionResp.getStatus())) {
hasFailedStatus = true;
} else if (StateStatus.PENDING.name().equals(fsTransitionResp.getStatus())) {
hasPendingStatus = true;
}
}
if (hasFailedStatus) {
progressStatus = OperationProgressStatus.FAILED;
} else if (hasCancelState) {
progressStatus = OperationProgressStatus.CANCELLED;
} else if (hasPendingStatus) {
progressStatus = OperationProgressStatus.RUNNING;
}
return progressStatus;
}
use of com.sequenceiq.flow.api.model.operation.OperationProgressStatus in project cloudbreak by hortonworks.
the class SdxPollerProvider method upgradeCcmPoller.
public AttemptResult<Void> upgradeCcmPoller(Long envId, String datalakeCrn) {
if (PollGroup.CANCELLED.equals(EnvironmentInMemoryStateStore.get(envId))) {
String message = "SDX polling cancelled in inmemory store, environment id: " + envId;
LOGGER.info(message);
throw new PollerStoppedException(message);
}
OperationView operation = sdxService.getOperation(datalakeCrn, false);
OperationProgressStatus progressStatus = operation.getProgressStatus();
switch(progressStatus) {
case CANCELLED:
return AttemptResults.breakFor("SDX Upgrade CCM cancelled for datalake CRN " + datalakeCrn);
case FAILED:
return AttemptResults.breakFor("SDX Upgrade CCM failed for environment CRN " + datalakeCrn);
case FINISHED:
return AttemptResults.justFinish();
case RUNNING:
return AttemptResults.justContinue();
default:
return AttemptResults.breakFor("SDX Upgrade CCM is in ambiguous state " + progressStatus + " for environment CRN " + datalakeCrn);
}
}
Aggregations