Search in sources :

Example 1 with JobType

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

the class BlockingShuffleITCase method createJobGraph.

private JobGraph createJobGraph(int numRecordsToSend, boolean deletePartitionFile) {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
    env.setBufferTimeout(-1);
    env.setParallelism(numTaskManagers * numSlotsPerTaskManager);
    DataStream<String> source = env.addSource(new StringSource(numRecordsToSend));
    source.rebalance().map((MapFunction<String, String>) value -> value).broadcast().addSink(new VerifySink(deletePartitionFile));
    StreamGraph streamGraph = env.getStreamGraph();
    streamGraph.setGlobalStreamExchangeMode(GlobalStreamExchangeMode.ALL_EDGES_BLOCKING);
    // a scheduler supporting batch jobs is required for this job graph, because it contains
    // blocking data exchanges.
    // The scheduler is selected based on the JobType.
    streamGraph.setJobType(JobType.BATCH);
    return StreamingJobGraphGenerator.createJobGraph(streamGraph);
}
Also used : Files(java.nio.file.Files) Configuration(org.apache.flink.configuration.Configuration) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) Test(org.junit.Test) IOException(java.io.IOException) StreamingJobGraphGenerator(org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator) RestartStrategies(org.apache.flink.api.common.restartstrategy.RestartStrategies) JobType(org.apache.flink.runtime.jobgraph.JobType) File(java.io.File) MapFunction(org.apache.flink.api.common.functions.MapFunction) RichSinkFunction(org.apache.flink.streaming.api.functions.sink.RichSinkFunction) DataStream(org.apache.flink.streaming.api.datastream.DataStream) NettyShuffleEnvironmentOptions(org.apache.flink.configuration.NettyShuffleEnvironmentOptions) CoreOptions(org.apache.flink.configuration.CoreOptions) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) ParallelSourceFunction(org.apache.flink.streaming.api.functions.source.ParallelSourceFunction) GlobalStreamExchangeMode(org.apache.flink.streaming.api.graph.GlobalStreamExchangeMode) ClassRule(org.junit.ClassRule) TemporaryFolder(org.junit.rules.TemporaryFolder) Assert.assertEquals(org.junit.Assert.assertEquals) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 MapFunction (org.apache.flink.api.common.functions.MapFunction)1 RestartStrategies (org.apache.flink.api.common.restartstrategy.RestartStrategies)1 Configuration (org.apache.flink.configuration.Configuration)1 CoreOptions (org.apache.flink.configuration.CoreOptions)1 NettyShuffleEnvironmentOptions (org.apache.flink.configuration.NettyShuffleEnvironmentOptions)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 JobType (org.apache.flink.runtime.jobgraph.JobType)1 DataStream (org.apache.flink.streaming.api.datastream.DataStream)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 RichSinkFunction (org.apache.flink.streaming.api.functions.sink.RichSinkFunction)1 ParallelSourceFunction (org.apache.flink.streaming.api.functions.source.ParallelSourceFunction)1 GlobalStreamExchangeMode (org.apache.flink.streaming.api.graph.GlobalStreamExchangeMode)1 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)1 StreamingJobGraphGenerator (org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 ClassRule (org.junit.ClassRule)1 Test (org.junit.Test)1