org.apache.flink.streaming.api.functions.sink.DiscardingSink Java Examples
The following examples show how to use
org.apache.flink.streaming.api.functions.sink.DiscardingSink.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamingJobGraphGeneratorNodeHashTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that there are no collisions with two identical intermediate nodes connected to the * same predecessor. * * <pre> * /-> [ (map) ] -> [ (sink) ] * [ (src) ] -+ * \-> [ (map) ] -> [ (sink) ] * </pre> */ @Test public void testNodeHashIdenticalNodes() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(); env.setParallelism(4); env.disableOperatorChaining(); DataStream<String> src = env.addSource(new NoOpSourceFunction()); src.map(new NoOpMapFunction()).addSink(new DiscardingSink<>()); src.map(new NoOpMapFunction()).addSink(new DiscardingSink<>()); JobGraph jobGraph = env.getStreamGraph().getJobGraph(); Set<JobVertexID> vertexIds = new HashSet<>(); for (JobVertex vertex : jobGraph.getVertices()) { assertTrue(vertexIds.add(vertex.getID())); } }
Example #2
Source File: TimestampITCase.java From flink with Apache License 2.0 | 6 votes |
/** * These check whether timestamps are properly assigned at the sources and handled in * network transmission and between chained operators when timestamps are enabled. */ @Test public void testTimestampHandling() throws Exception { final int numElements = 10; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); DataStream<Integer> source1 = env.addSource(new MyTimestampSource(0L, numElements)); DataStream<Integer> source2 = env.addSource(new MyTimestampSource(0L, numElements)); source1 .map(new IdentityMap()) .connect(source2).map(new IdentityCoMap()) .transform("Custom Operator", BasicTypeInfo.INT_TYPE_INFO, new TimestampCheckingOperator()) .addSink(new DiscardingSink<Integer>()); env.execute(); }
Example #3
Source File: TimestampITCase.java From flink with Apache License 2.0 | 6 votes |
/** * These check whether timestamps are properly ignored when they are disabled. */ @Test public void testDisabledTimestamps() throws Exception { final int numElements = 10; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); DataStream<Integer> source1 = env.addSource(new MyNonWatermarkingSource(numElements)); DataStream<Integer> source2 = env.addSource(new MyNonWatermarkingSource(numElements)); source1 .map(new IdentityMap()) .connect(source2).map(new IdentityCoMap()) .transform("Custom Operator", BasicTypeInfo.INT_TYPE_INFO, new DisabledTimestampCheckingOperator()) .addSink(new DiscardingSink<Integer>()); env.execute(); }
Example #4
Source File: ContinuousFileReaderOperatorITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testEndInput() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); final File sourceFile = TEMPORARY_FOLDER.newFile(); final int elementCount = 10000; try (PrintWriter printWriter = new PrintWriter(sourceFile)) { for (int i = 0; i < elementCount; i++) { printWriter.println(i); } } DataStreamSource<String> source = env.readTextFile(sourceFile.getAbsolutePath()); // check the endInput is invoked at the right time TestBoundedOneInputStreamOperator checkingOperator = new TestBoundedOneInputStreamOperator(elementCount); DataStream<String> endInputChecking = source.transform("EndInputChecking", STRING_TYPE_INFO, checkingOperator); endInputChecking.addSink(new DiscardingSink<>()); env.execute("ContinuousFileReaderOperatorITCase.testEndInput"); }
Example #5
Source File: CheckpointExceptionHandlerConfigurationTest.java From flink with Apache License 2.0 | 6 votes |
public void doTestPropagationFromCheckpointConfig(boolean failTaskOnCheckpointErrors) { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); streamExecutionEnvironment.setParallelism(1); streamExecutionEnvironment.getCheckpointConfig().setCheckpointInterval(1000); streamExecutionEnvironment.getCheckpointConfig().setFailOnCheckpointingErrors(failTaskOnCheckpointErrors); streamExecutionEnvironment.addSource(new SourceFunction<Integer>() { @Override public void run(SourceContext<Integer> ctx) { } @Override public void cancel() { } }).addSink(new DiscardingSink<>()); }
Example #6
Source File: StreamGraphGeneratorTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Test whether an {@link OutputTypeConfigurable} implementation gets called with the correct * output type. In this test case the output type must be BasicTypeInfo.INT_TYPE_INFO. */ @Test public void testOutputTypeConfigurationWithOneInputTransformation() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> source = env.fromElements(1, 10); OutputTypeConfigurableOperationWithOneInput outputTypeConfigurableOperation = new OutputTypeConfigurableOperationWithOneInput(); DataStream<Integer> result = source.transform( "Single input and output type configurable operation", BasicTypeInfo.INT_TYPE_INFO, outputTypeConfigurableOperation); result.addSink(new DiscardingSink<>()); env.getStreamGraph(); assertEquals(BasicTypeInfo.INT_TYPE_INFO, outputTypeConfigurableOperation.getTypeInformation()); }
Example #7
Source File: SavepointITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Creates a streaming JobGraph from the StreamEnvironment. */ private JobGraph createJobGraph( int parallelism, int numberOfRetries, long restartDelay) { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(parallelism); env.disableOperatorChaining(); env.getConfig().setRestartStrategy(RestartStrategies.fixedDelayRestart(numberOfRetries, restartDelay)); env.getConfig().disableSysoutLogging(); DataStream<Integer> stream = env .addSource(new InfiniteTestSource()) .shuffle() .map(new StatefulCounter()); stream.addSink(new DiscardingSink<>()); return env.getStreamGraph().getJobGraph(); }
Example #8
Source File: StatefulStreamingJob.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ParameterTool pt = ParameterTool.fromArgs(args); final String checkpointDir = pt.getRequired("checkpoint.dir"); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStateBackend(new FsStateBackend(checkpointDir)); env.setRestartStrategy(RestartStrategies.noRestart()); env.enableCheckpointing(1000L); env.getConfig().disableGenericTypes(); env.addSource(new MySource()).uid("my-source") .keyBy(anInt -> 0) .map(new MyStatefulFunction()).uid("my-map") .addSink(new DiscardingSink<>()).uid("my-sink"); env.execute(); }
Example #9
Source File: OperatorIDGeneratorTest.java From flink with Apache License 2.0 | 6 votes |
private static OperatorID getOperatorID() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env .fromElements(1, 2, 3) .uid(UID).name(OPERATOR_NAME) .disableChaining() .addSink(new DiscardingSink<>()); JobGraph graph = env.getStreamGraph().getJobGraph(new JobID()); JobVertex vertex = StreamSupport.stream(graph.getVertices().spliterator(), false) .filter(node -> node.getName().contains(OPERATOR_NAME)) .findFirst() .orElseThrow(() -> new IllegalStateException("Unable to find vertex")); return vertex.getOperatorIDs().get(0); }
Example #10
Source File: TimestampITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * These check whether timestamps are properly ignored when they are disabled. */ @Test public void testDisabledTimestamps() throws Exception { final int numElements = 10; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); DataStream<Integer> source1 = env.addSource(new MyNonWatermarkingSource(numElements)); DataStream<Integer> source2 = env.addSource(new MyNonWatermarkingSource(numElements)); source1 .map(new IdentityMap()) .connect(source2).map(new IdentityCoMap()) .transform("Custom Operator", BasicTypeInfo.INT_TYPE_INFO, new DisabledTimestampCheckingOperator()) .addSink(new DiscardingSink<Integer>()); env.execute(); }
Example #11
Source File: TimestampITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * These check whether timestamps are properly assigned at the sources and handled in * network transmission and between chained operators when timestamps are enabled. */ @Test public void testTimestampHandling() throws Exception { final int numElements = 10; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); DataStream<Integer> source1 = env.addSource(new MyTimestampSource(0L, numElements)); DataStream<Integer> source2 = env.addSource(new MyTimestampSource(0L, numElements)); source1 .map(new IdentityMap()) .connect(source2).map(new IdentityCoMap()) .transform("Custom Operator", BasicTypeInfo.INT_TYPE_INFO, new TimestampCheckingOperator()) .addSink(new DiscardingSink<Integer>()); env.execute(); }
Example #12
Source File: StatefulStreamingJob.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ParameterTool pt = ParameterTool.fromArgs(args); final String checkpointDir = pt.getRequired("checkpoint.dir"); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStateBackend(new FsStateBackend(checkpointDir)); env.setRestartStrategy(RestartStrategies.noRestart()); env.enableCheckpointing(1000L); env.getConfig().disableGenericTypes(); env.addSource(new MySource()).uid("my-source") .keyBy(anInt -> 0) .map(new MyStatefulFunction()).uid("my-map") .addSink(new DiscardingSink<>()).uid("my-sink"); env.execute(); }
Example #13
Source File: AsyncWaitOperatorTest.java From flink with Apache License 2.0 | 6 votes |
/** * Test for the temporary fix to FLINK-13063. */ @Test public void testAsyncOperatorIsNeverChained() { StreamExecutionEnvironment chainEnv = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> input = chainEnv.fromElements(1); input = AsyncDataStream.orderedWait( input, new LazyAsyncFunction(), TIMEOUT, TimeUnit.MILLISECONDS, 6).map((x) -> x); AsyncDataStream.unorderedWait( input, new MyAsyncFunction(), TIMEOUT, TimeUnit.MILLISECONDS, 3).map((x) -> x).addSink(new DiscardingSink<>()); final JobGraph jobGraph = chainEnv.getStreamGraph().getJobGraph(); Assert.assertEquals(3, jobGraph.getVerticesSortedTopologicallyFromSources().size()); }
Example #14
Source File: StreamGraphGeneratorTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the max parallelism is properly set for connected * streams. */ @Test public void testMaxParallelismWithConnectedKeyedStream() { int maxParallelism = 42; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> input1 = env.fromElements(1, 2, 3, 4).setMaxParallelism(128); DataStream<Integer> input2 = env.fromElements(1, 2, 3, 4).setMaxParallelism(129); env.getConfig().setMaxParallelism(maxParallelism); DataStream<Integer> keyedResult = input1 .connect(input2) .keyBy(value -> value, value -> value) .map(new NoOpIntCoMap()); keyedResult.addSink(new DiscardingSink<>()); StreamGraph graph = env.getStreamGraph(); StreamNode keyedResultNode = graph.getStreamNode(keyedResult.getId()); StreamPartitioner<?> streamPartitioner1 = keyedResultNode.getInEdges().get(0).getPartitioner(); StreamPartitioner<?> streamPartitioner2 = keyedResultNode.getInEdges().get(1).getPartitioner(); }
Example #15
Source File: StreamGraphGeneratorTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the max parallelism is properly set for connected * streams. */ @Test public void testMaxParallelismWithConnectedKeyedStream() { int maxParallelism = 42; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> input1 = env.fromElements(1, 2, 3, 4).setMaxParallelism(128); DataStream<Integer> input2 = env.fromElements(1, 2, 3, 4).setMaxParallelism(129); env.getConfig().setMaxParallelism(maxParallelism); DataStream<Integer> keyedResult = input1 .connect(input2) .keyBy(value -> value, value -> value) .map(new NoOpIntCoMap()); keyedResult.addSink(new DiscardingSink<>()); StreamGraph graph = env.getStreamGraph(); StreamNode keyedResultNode = graph.getStreamNode(keyedResult.getId()); StreamPartitioner<?> streamPartitioner1 = keyedResultNode.getInEdges().get(0).getPartitioner(); StreamPartitioner<?> streamPartitioner2 = keyedResultNode.getInEdges().get(1).getPartitioner(); }
Example #16
Source File: StreamingJobGraphGeneratorNodeHashTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that there are no collisions with two identical sources. * * <pre> * [ (src0) ] --\ * +--> [ (sink) ] * [ (src1) ] --/ * </pre> */ @Test public void testNodeHashIdenticalSources() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(); env.setParallelism(4); env.disableOperatorChaining(); DataStream<String> src0 = env.addSource(new NoOpSourceFunction()); DataStream<String> src1 = env.addSource(new NoOpSourceFunction()); src0.union(src1).addSink(new DiscardingSink<>()); JobGraph jobGraph = env.getStreamGraph().getJobGraph(); List<JobVertex> vertices = jobGraph.getVerticesSortedTopologicallyFromSources(); assertTrue(vertices.get(0).isInputVertex()); assertTrue(vertices.get(1).isInputVertex()); assertNotNull(vertices.get(0).getID()); assertNotNull(vertices.get(1).getID()); assertNotEquals(vertices.get(0).getID(), vertices.get(1).getID()); }
Example #17
Source File: StreamGraphGeneratorTest.java From flink with Apache License 2.0 | 6 votes |
/** * Test whether an {@link OutputTypeConfigurable} implementation gets called with the correct * output type. In this test case the output type must be BasicTypeInfo.INT_TYPE_INFO. */ @Test public void testOutputTypeConfigurationWithOneInputTransformation() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Integer> source = env.fromElements(1, 10); OutputTypeConfigurableOperationWithOneInput outputTypeConfigurableOperation = new OutputTypeConfigurableOperationWithOneInput(); DataStream<Integer> result = source.transform( "Single input and output type configurable operation", BasicTypeInfo.INT_TYPE_INFO, outputTypeConfigurableOperation); result.addSink(new DiscardingSink<>()); env.getStreamGraph(); assertEquals(BasicTypeInfo.INT_TYPE_INFO, outputTypeConfigurableOperation.getTypeInformation()); }
Example #18
Source File: CheckpointExceptionHandlerConfigurationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public void doTestPropagationFromCheckpointConfig(boolean failTaskOnCheckpointErrors) throws Exception { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); streamExecutionEnvironment.setParallelism(1); streamExecutionEnvironment.getCheckpointConfig().setCheckpointInterval(1000); streamExecutionEnvironment.getCheckpointConfig().setFailOnCheckpointingErrors(failTaskOnCheckpointErrors); streamExecutionEnvironment.addSource(new SourceFunction<Integer>() { @Override public void run(SourceContext<Integer> ctx) throws Exception { } @Override public void cancel() { } }).addSink(new DiscardingSink<>()); StreamGraph streamGraph = streamExecutionEnvironment.getStreamGraph(); JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(streamGraph); SerializedValue<ExecutionConfig> serializedExecutionConfig = jobGraph.getSerializedExecutionConfig(); ExecutionConfig executionConfig = serializedExecutionConfig.deserializeValue(Thread.currentThread().getContextClassLoader()); Assert.assertEquals(failTaskOnCheckpointErrors, executionConfig.isFailTaskOnCheckpointError()); }
Example #19
Source File: KafkaShortRetentionTestBase.java From flink with Apache License 2.0 | 5 votes |
/** * Ensure that the consumer is properly failing if "auto.offset.reset" is set to "none". */ public void runFailOnAutoOffsetResetNone() throws Exception { final String topic = "auto-offset-reset-none-test"; final int parallelism = 1; kafkaServer.createTestTopic(topic, parallelism, 1); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(parallelism); env.setRestartStrategy(RestartStrategies.noRestart()); // fail immediately env.getConfig().disableSysoutLogging(); // ----------- add consumer ---------- Properties customProps = new Properties(); customProps.putAll(standardProps); customProps.putAll(secureProps); customProps.setProperty("auto.offset.reset", "none"); // test that "none" leads to an exception FlinkKafkaConsumerBase<String> source = kafkaServer.getConsumer(topic, new SimpleStringSchema(), customProps); DataStreamSource<String> consuming = env.addSource(source); consuming.addSink(new DiscardingSink<String>()); try { env.execute("Test auto offset reset none"); } catch (Throwable e) { // check if correct exception has been thrown if (!e.getCause().getCause().getMessage().contains("Unable to find previous offset") // kafka 0.8 && !e.getCause().getCause().getMessage().contains("Undefined offset with no reset policy for partition") // kafka 0.9 ) { throw e; } } kafkaServer.deleteTestTopic(topic); }
Example #20
Source File: TestJob.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); final DataStreamSource<Integer> source = env.fromElements(1, 2, 3, 4); final SingleOutputStreamOperator<Integer> mapper = source.map(element -> 2 * element); mapper.addSink(new DiscardingSink<>()); ParameterTool parameterTool = ParameterTool.fromArgs(args); env.execute(TestJob.class.getCanonicalName() + "-" + parameterTool.getRequired("arg")); }
Example #21
Source File: DistributedCacheDfsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDistributeFileViaDFS() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(testFile.toString(), "test_data", false); env.registerCachedFile(testDir.toString(), "test_dir", false); env.fromElements(1) .map(new TestMapFunction()) .addSink(new DiscardingSink<>()); env.execute("Distributed Cache Via Blob Test Program"); }
Example #22
Source File: StreamExecutionEnvironmentTest.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static <T> SourceFunction<T> getFunctionFromDataSource(DataStreamSource<T> dataStreamSource) { dataStreamSource.addSink(new DiscardingSink<T>()); AbstractUdfStreamOperator<?, ?> operator = (AbstractUdfStreamOperator<?, ?>) getOperatorFromDataStream(dataStreamSource); return (SourceFunction<T>) operator.getUserFunction(); }
Example #23
Source File: StreamingJobGraphGeneratorNodeHashTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDisablingAutoUidsAcceptsManuallySetId() { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(); env.getConfig().disableAutoGeneratedUIDs(); env .addSource(new NoOpSourceFunction()).uid("uid1") .addSink(new DiscardingSink<>()).uid("uid2"); env.getStreamGraph(); }
Example #24
Source File: StreamGraphGeneratorTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the global and operator-wide max parallelism setting is respected. */ @Test public void testMaxParallelismForwarding() { int globalMaxParallelism = 42; int keyedResult2MaxParallelism = 17; StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setMaxParallelism(globalMaxParallelism); DataStream<Integer> source = env.fromElements(1, 2, 3); DataStream<Integer> keyedResult1 = source.keyBy(value -> value).map(new NoOpIntMap()); DataStream<Integer> keyedResult2 = keyedResult1 .keyBy(value -> value) .map(new NoOpIntMap()) .setMaxParallelism(keyedResult2MaxParallelism); keyedResult2.addSink(new DiscardingSink<>()); StreamGraph graph = env.getStreamGraph(); StreamNode keyedResult1Node = graph.getStreamNode(keyedResult1.getId()); StreamNode keyedResult2Node = graph.getStreamNode(keyedResult2.getId()); assertEquals(globalMaxParallelism, keyedResult1Node.getMaxParallelism()); assertEquals(keyedResult2MaxParallelism, keyedResult2Node.getMaxParallelism()); }
Example #25
Source File: SavepointWriterITCase.java From flink with Apache License 2.0 | 5 votes |
private void validateModification(String savepointPath) throws ProgramInvocationException { StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment(); sEnv.setStateBackend(backend); CollectSink.accountList.clear(); DataStream<Account> stream = sEnv.fromCollection(accounts) .keyBy(acc -> acc.id) .flatMap(new UpdateAndGetAccount()) .uid(ACCOUNT_UID); stream.addSink(new CollectSink()); stream .map(acc -> acc.id) .map(new StatefulOperator()) .uid(MODIFY_UID) .addSink(new DiscardingSink<>()); JobGraph jobGraph = sEnv.getStreamGraph().getJobGraph(); jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPath, false)); ClusterClient<?> client = miniClusterResource.getClusterClient(); client.submitJob(jobGraph, SavepointWriterITCase.class.getClassLoader()); Assert.assertEquals("Unexpected output", 3, CollectSink.accountList.size()); }
Example #26
Source File: SavepointReaderITTestBase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOperatorStateInputFormat() throws Exception { StreamExecutionEnvironment streamEnv = StreamExecutionEnvironment.getExecutionEnvironment(); streamEnv.setParallelism(4); DataStream<Integer> data = streamEnv .addSource(new SavepointSource()) .rebalance(); data .connect(data.broadcast(broadcast)) .process(new StatefulOperator(list, union, broadcast)) .uid(UID) .addSink(new DiscardingSink<>()); JobGraph jobGraph = streamEnv.getStreamGraph().getJobGraph(); String savepoint = takeSavepoint(jobGraph); ExecutionEnvironment batchEnv = ExecutionEnvironment.getExecutionEnvironment(); verifyListState(savepoint, batchEnv); verifyUnionState(savepoint, batchEnv); verifyBroadcastState(savepoint, batchEnv); }
Example #27
Source File: StreamingJobGraphGeneratorNodeHashTest.java From flink with Apache License 2.0 | 5 votes |
@Test(expected = IllegalStateException.class) public void testDisablingAutoUidsFailsStreamGraphCreation() { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(); env.getConfig().disableAutoGeneratedUIDs(); env.addSource(new NoOpSourceFunction()).addSink(new DiscardingSink<>()); env.getStreamGraph(); }
Example #28
Source File: RescalingITCase.java From flink with Apache License 2.0 | 5 votes |
private static JobGraph createJobGraphWithOperatorState( int parallelism, int maxParallelism, OperatorCheckpointMethod checkpointMethod) { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(parallelism); env.getConfig().setMaxParallelism(maxParallelism); env.enableCheckpointing(Long.MAX_VALUE); env.setRestartStrategy(RestartStrategies.noRestart()); StateSourceBase.workStartedLatch = new CountDownLatch(parallelism); SourceFunction<Integer> src; switch (checkpointMethod) { case CHECKPOINTED_FUNCTION: src = new PartitionedStateSource(false); break; case CHECKPOINTED_FUNCTION_BROADCAST: src = new PartitionedStateSource(true); break; case LIST_CHECKPOINTED: src = new PartitionedStateSourceListCheckpointed(); break; case NON_PARTITIONED: src = new NonPartitionedStateSource(); break; default: throw new IllegalArgumentException(); } DataStream<Integer> input = env.addSource(src); input.addSink(new DiscardingSink<Integer>()); return env.getStreamGraph().getJobGraph(); }
Example #29
Source File: StreamingJobGraphGeneratorNodeHashTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that a manual hash at the beginning of a chain is accepted. */ @Test public void testManualHashAssignmentForStartNodeInInChain() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(); env.setParallelism(4); env.addSource(new NoOpSourceFunction()).uid("source") .map(new NoOpMapFunction()) .addSink(new DiscardingSink<>()); env.getStreamGraph().getJobGraph(); }
Example #30
Source File: CheckpointedStreamingProgram.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().disableSysoutLogging(); env.enableCheckpointing(CHECKPOINT_INTERVALL); env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 100L)); env.disableOperatorChaining(); DataStream<String> text = env.addSource(new SimpleStringGenerator()); text.map(new StatefulMapper()).addSink(new DiscardingSink<>()); env.setParallelism(1); env.execute("Checkpointed Streaming Program"); }