Search in sources :

Example 11 with IntermediateDataSet

use of org.apache.flink.runtime.jobgraph.IntermediateDataSet in project flink by apache.

the class TestJobDataFlowValidator method checkDataFlow.

public static void checkDataFlow(TestJobWithDescription testJob, boolean withDrain) {
    Map<String, Map<Integer, OperatorFinishedEvent>> finishEvents = new HashMap<>();
    for (TestEvent ev : testJob.eventQueue.getAll()) {
        if (ev instanceof OperatorFinishedEvent) {
            finishEvents.computeIfAbsent(ev.operatorId, ign -> new HashMap<>()).put(ev.subtaskIndex, ((OperatorFinishedEvent) ev));
        }
    }
    for (JobVertex upstream : testJob.jobGraph.getVertices()) {
        for (IntermediateDataSet produced : upstream.getProducedDataSets()) {
            JobEdge edge = produced.getConsumer();
            Optional<String> upstreamIDOptional = getTrackedOperatorID(upstream, true, testJob);
            Optional<String> downstreamIDOptional = getTrackedOperatorID(edge.getTarget(), false, testJob);
            if (upstreamIDOptional.isPresent() && downstreamIDOptional.isPresent()) {
                final String upstreamID = upstreamIDOptional.get();
                final String downstreamID = downstreamIDOptional.get();
                if (testJob.sources.contains(upstreamID)) {
                    // TODO: if we add tests for FLIP-27 sources we might need to adjust
                    // this condition
                    LOG.debug("Legacy sources do not have the finish() method and thus do not" + " emit FinishEvent");
                } else {
                    checkDataFlow(upstreamID, downstreamID, edge, finishEvents, withDrain);
                }
            } else {
                LOG.debug("Ignoring edge (untracked operator): {}", edge);
            }
        }
    }
}
Also used : Logger(org.slf4j.Logger) JobEdge(org.apache.flink.runtime.jobgraph.JobEdge) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ListIterator(java.util.ListIterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) TestJobWithDescription(org.apache.flink.runtime.operators.lifecycle.TestJobWithDescription) LoggerFactory(org.slf4j.LoggerFactory) Assert.assertTrue(org.junit.Assert.assertTrue) HashMap(java.util.HashMap) OperatorIDPair(org.apache.flink.runtime.OperatorIDPair) String.format(java.lang.String.format) TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) IntermediateDataSet(org.apache.flink.runtime.jobgraph.IntermediateDataSet) Assert.assertNull(org.junit.Assert.assertNull) OperatorFinishedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorFinishedEvent) Map(java.util.Map) Optional(java.util.Optional) OperatorFinishedEvent(org.apache.flink.runtime.operators.lifecycle.event.OperatorFinishedEvent) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) IntermediateDataSet(org.apache.flink.runtime.jobgraph.IntermediateDataSet) HashMap(java.util.HashMap) TestEvent(org.apache.flink.runtime.operators.lifecycle.event.TestEvent) JobEdge(org.apache.flink.runtime.jobgraph.JobEdge) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IntermediateDataSet (org.apache.flink.runtime.jobgraph.IntermediateDataSet)11 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)6 ArrayList (java.util.ArrayList)5 JobException (org.apache.flink.runtime.JobException)4 Test (org.junit.Test)4 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)3 JobID (org.apache.flink.api.common.JobID)3 Configuration (org.apache.flink.configuration.Configuration)3 NoRestartStrategy (org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy)3 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)3 JobEdge (org.apache.flink.runtime.jobgraph.JobEdge)3 Scheduler (org.apache.flink.runtime.jobmanager.scheduler.Scheduler)3 HashMap (java.util.HashMap)2 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)2 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1