public WorkflowStatus checkStatus()

in flux/src/main/java/software/amazon/aws/clients/swf/flux/WorkflowStatusCheckerImpl.java [52:90]


    public WorkflowStatus checkStatus() {
        WorkflowExecution execution = WorkflowExecution.builder().workflowId(workflowId).runId(runId).build();

        DescribeWorkflowExecutionRequest request
                = DescribeWorkflowExecutionRequest.builder()
                                                    .domain(workflowDomain)
                                                    .execution(execution)
                                                    .build();

        try {
            DescribeWorkflowExecutionResponse detail = swf.describeWorkflowExecution(request);
            // first check if it's still running
            if (ExecutionStatus.OPEN == detail.executionInfo().executionStatus()) {
                return WorkflowStatus.IN_PROGRESS;
            }

            switch (detail.executionInfo().closeStatus()) {
                case FAILED:
                    return WorkflowStatus.FAILED;
                case CANCELED:
                    return WorkflowStatus.CANCELED;
                case TERMINATED:
                    return WorkflowStatus.TERMINATED;
                case TIMED_OUT:
                    return WorkflowStatus.TIMED_OUT;
                case COMPLETED:
                case CONTINUED_AS_NEW:
                case UNKNOWN_TO_SDK_VERSION: // we'll treat this as completed since we don't know what else to do.
                default:
                    return WorkflowStatus.COMPLETED;
            }
        } catch (Exception e) {
            log.info("Error retrieving workflow status", e);
        }

        log.info("Unable to determine workflow status for remote workflow (id: {}, run id: {})", workflowId, runId);

        return WorkflowStatus.UNKNOWN;
    }