aljoscha commented on a change in pull request #13891: URL: https://github.com/apache/flink/pull/13891#discussion_r516061297
########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link org.apache.flink.api.common.RuntimeExecutionMode#BATCH} execution on + * the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to verify + * that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c1-d1", "ciao-a0-b0-c1-d1")); + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); Review comment: If I don't use a limit I have to use use the version that returns an `Iterator` and I manually have to deal with that. Though with `assertThat()` it should be pretty smooth. Let me try it. ########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link org.apache.flink.api.common.RuntimeExecutionMode#BATCH} execution on + * the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to verify + * that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c1-d1", "ciao-a0-b0-c1-d1")); + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" Review comment: The test verifies whether staged execution works, i.e. executing multiple operators that don't want to share a slot. The comment is copy-and-paste error 😅. As I mentioned in the PR description, this test hangs because we don't actually support this. ########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link org.apache.flink.api.common.RuntimeExecutionMode#BATCH} execution on + * the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to verify + * that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c1-d1", "ciao-a0-b0-c1-d1")); + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c0-d0", "ciao-a0-b0-c0-d0")); + } + + private StreamExecutionEnvironment getExecutionEnvironment() { + final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); + + Configuration config = new Configuration(); + config.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.BATCH); + env.configure(config, DataStreamBatchExecutionITCase.class.getClassLoader()); + + env.setParallelism(1); + env.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, Time.milliseconds(1))); + + // trick the collecting sink into working even in the face of failures 🙏 Review comment: yeah 😅 ########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link org.apache.flink.api.common.RuntimeExecutionMode#BATCH} execution on + * the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to verify + * that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c1-d1", "ciao-a0-b0-c1-d1")); + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); Review comment: I'm doing that now, thanks! ########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link org.apache.flink.api.common.RuntimeExecutionMode#BATCH} execution on + * the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to verify + * that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c1-d1", "ciao-a0-b0-c1-d1")); + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" Review comment: I'll remove those then. Otherwise ready to merge? ########## File path: flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java ########## @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.datastream; + +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.restartstrategy.RestartStrategies; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.operators.MapOperator; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExecutionOptions; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.test.util.MiniClusterWithClientResource; +import org.apache.flink.util.CloseableIterator; + +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +import static org.apache.flink.util.CollectionUtil.iteratorToList; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.Assert.assertThat; + +/** + * Integration test for {@link RuntimeExecutionMode#BATCH} execution on the DataStream API. + * + * <p>We use a {@link MiniClusterWithClientResource} with a single TaskManager with 1 slot to + * verify that programs in BATCH execution mode can be executed in stages. + */ +public class DataStreamBatchExecutionITCase { + private static final int DEFAULT_PARALLELISM = 1; + + @ClassRule + public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource( + new MiniClusterResourceConfiguration.Builder() + .setNumberTaskManagers(1) + .setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM) + .build()); + + /** + * We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline + * before the key-by should not be re-executed. Only the part after that will restart. We check + * that by suffixing the attempt number to records and asserting the correct number. + */ + @Test + public void batchFailoverWithKeyByBarrier() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("foo", "bar"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .keyBy(in -> in) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + try (CloseableIterator<String> result = mapped.executeAndCollect()) { + + // only the operators after the key-by "barrier" are restarted and will have the + // "attempt 1" suffix + assertThat( + iteratorToList(result), + containsInAnyOrder("foo-a0-b0-c1-d1", "bar-a0-b0-c1-d1")); + } + } + + @Ignore + @Test + public void stagedExecutionWithDifferentSlotGroups() throws Exception { + + final StreamExecutionEnvironment env = getExecutionEnvironment(); + + DataStreamSource<String> source = env.fromElements("ciao", "ciao"); + + SingleOutputStreamOperator<String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .map(new SuffixAttemptId("c")) + .slotSharingGroup("foo") + .map(new SuffixAttemptId("d")) + .slotSharingGroup("bar"); + + List<String> result = mapped.executeAndCollect(2); + + // only the operators after the key-by "barrier" are restarted and will have the "attempt 1" + // suffix + assertThat(result, contains("ciao-a0-b0-c0-d0", "ciao-a0-b0-c0-d0")); + } + + @Test + public void dataSetBatchFailoverWithKeyByBarrier() throws Exception { + + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + env.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, Time.milliseconds(1))); + + DataSet<String> source = env.fromElements("foo", "bar"); + + MapOperator<String, String> mapped = source + .map(new SuffixAttemptId("a")) + .map(new SuffixAttemptId("b")) + .groupBy(in -> in) + .first(1) + .map(new SuffixAttemptId("c")) + .map(new OnceFailingMapper("d")); + + List<String> result = mapped.collect(); + + // it seems the DataSet API restarts the whole graph here? + assertThat(result, containsInAnyOrder("foo-a1-b1-c1-d1", "bar-a1-b1-c1-d1")); + } Review comment: I just added this as an example to show how DataSet works and would not merge it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
