Search in sources :

Example 1 with OperationProgressStatus

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;
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) OperationProgressStatus(com.sequenceiq.flow.api.model.operation.OperationProgressStatus) FlowStateTransitionResponse(com.sequenceiq.flow.api.model.FlowStateTransitionResponse)

Example 2 with OperationProgressStatus

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);
    }
}
Also used : OperationProgressStatus(com.sequenceiq.flow.api.model.operation.OperationProgressStatus) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

OperationProgressStatus (com.sequenceiq.flow.api.model.operation.OperationProgressStatus)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 FlowProgressResponse (com.sequenceiq.flow.api.model.FlowProgressResponse)1 FlowStateTransitionResponse (com.sequenceiq.flow.api.model.FlowStateTransitionResponse)1 OperationView (com.sequenceiq.flow.api.model.operation.OperationView)1