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);
}
}
Aggregations