Search in sources :

Example 1 with ExecutionCondition

use of com.flink.platform.common.enums.ExecutionCondition in project flink-platform-backend by itinycheng.

the class JobFlowDagHelper method isPreconditionSatisfied.

public static boolean isPreconditionSatisfied(JobVertex toVertex, DAG<Long, JobVertex, JobEdge> dag) {
    Collection<JobVertex> preVertices = dag.getPreVertices(toVertex);
    if (CollectionUtils.isEmpty(preVertices)) {
        return true;
    }
    ExecutionCondition precondition = toVertex.getPrecondition();
    if (precondition == AND) {
        return preVertices.stream().allMatch(fromVertex -> fromVertex.getJobRunStatus() == dag.getEdge(fromVertex, toVertex).getExpectStatus());
    } else if (precondition == OR) {
        return preVertices.stream().anyMatch(fromVertex -> fromVertex.getJobRunStatus() == dag.getEdge(fromVertex, toVertex).getExpectStatus());
    } else {
        throw new IllegalStateException("Can't handle precondition status: " + precondition);
    }
}
Also used : DAG(com.flink.platform.common.graph.DAG) ABNORMAL(com.flink.platform.common.enums.ExecutionStatus.ABNORMAL) Collection(java.util.Collection) Set(java.util.Set) JobVertex(com.flink.platform.common.model.JobVertex) ExecutionCondition(com.flink.platform.common.enums.ExecutionCondition) CollectionUtils(org.apache.commons.collections4.CollectionUtils) RUNNING(com.flink.platform.common.enums.ExecutionStatus.RUNNING) HashSet(java.util.HashSet) Objects(java.util.Objects) ERROR(com.flink.platform.common.enums.ExecutionStatus.ERROR) AND(com.flink.platform.common.enums.ExecutionCondition.AND) ExecutionStatus(com.flink.platform.common.enums.ExecutionStatus) OR(com.flink.platform.common.enums.ExecutionCondition.OR) KILLED(com.flink.platform.common.enums.ExecutionStatus.KILLED) FAILURE(com.flink.platform.common.enums.ExecutionStatus.FAILURE) SUCCESS(com.flink.platform.common.enums.ExecutionStatus.SUCCESS) JobFlowDag(com.flink.platform.dao.entity.JobFlowDag) SUBMITTED(com.flink.platform.common.enums.ExecutionStatus.SUBMITTED) Nonnull(javax.annotation.Nonnull) NOT_EXIST(com.flink.platform.common.enums.ExecutionStatus.NOT_EXIST) JobEdge(com.flink.platform.common.model.JobEdge) Collectors.toSet(java.util.stream.Collectors.toSet) JobVertex(com.flink.platform.common.model.JobVertex) ExecutionCondition(com.flink.platform.common.enums.ExecutionCondition)

Aggregations

ExecutionCondition (com.flink.platform.common.enums.ExecutionCondition)1 AND (com.flink.platform.common.enums.ExecutionCondition.AND)1 OR (com.flink.platform.common.enums.ExecutionCondition.OR)1 ExecutionStatus (com.flink.platform.common.enums.ExecutionStatus)1 ABNORMAL (com.flink.platform.common.enums.ExecutionStatus.ABNORMAL)1 ERROR (com.flink.platform.common.enums.ExecutionStatus.ERROR)1 FAILURE (com.flink.platform.common.enums.ExecutionStatus.FAILURE)1 KILLED (com.flink.platform.common.enums.ExecutionStatus.KILLED)1 NOT_EXIST (com.flink.platform.common.enums.ExecutionStatus.NOT_EXIST)1 RUNNING (com.flink.platform.common.enums.ExecutionStatus.RUNNING)1 SUBMITTED (com.flink.platform.common.enums.ExecutionStatus.SUBMITTED)1 SUCCESS (com.flink.platform.common.enums.ExecutionStatus.SUCCESS)1 DAG (com.flink.platform.common.graph.DAG)1 JobEdge (com.flink.platform.common.model.JobEdge)1 JobVertex (com.flink.platform.common.model.JobVertex)1 JobFlowDag (com.flink.platform.dao.entity.JobFlowDag)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 Set (java.util.Set)1