You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by mbalassi <gi...@git.apache.org> on 2015/08/04 10:15:16 UTC

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

GitHub user mbalassi opened a pull request:

    https://github.com/apache/flink/pull/980

    [FLINK-2423] [streaming] ITCase for checkpoint notifications

    See javadoc and Jira.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mbalassi/flink FLINK-2423

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/980.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #980
    
----
commit 3637d0506aa7ebbf501b68805a83e2ea2919188a
Author: mbalassi <mb...@apache.org>
Date:   2015-08-04T08:11:10Z

    [FLINK-2423] [streaming] ITCase for checkpoint notifications

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by gyfora <gi...@git.apache.org>.
Github user gyfora commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-128001829
  
    In general I think it has a little more complexity than necessary coming from the actual application implemented here. I would get rid of the PrefixCounts and the specific operators for this counting application and would replace them with simple filters and maps. 
    
    I think that would serve the same purpose and would not hide the actual notification tests with a lot of unnecessary details


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-129851909
  
    Merging...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-129142526
  
    Indeed, the setup should ensure that we get notifications on both sides of the failure modulo failed checkpoints.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-127944519
  
    If no objections I will merge this in the evening.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by gyfora <gi...@git.apache.org>.
Github user gyfora commented on a diff in the pull request:

    https://github.com/apache/flink/pull/980#discussion_r36584713
  
    --- Diff: flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java ---
    @@ -0,0 +1,340 @@
    +/*
    + * 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.test.checkpointing;
    +
    +import org.apache.flink.api.common.functions.RichFilterFunction;
    +import org.apache.flink.api.common.functions.RichMapFunction;
    +import org.apache.flink.api.common.functions.RichReduceFunction;
    +import org.apache.flink.api.common.state.OperatorState;
    +import org.apache.flink.api.java.tuple.Tuple1;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.streaming.api.checkpoint.CheckpointNotifier;
    +import org.apache.flink.streaming.api.checkpoint.Checkpointed;
    +import org.apache.flink.streaming.api.datastream.DataStream;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.functions.co.RichCoFlatMapFunction;
    +import org.apache.flink.streaming.api.functions.sink.SinkFunction;
    +import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
    +import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
    +import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
    +import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
    +import org.apache.flink.util.Collector;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Random;
    +
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertTrue;
    +
    +/**
    + * Integration test for the {@link CheckpointNotifier} interface. The test ensures that
    + * {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for some completed
    + * checkpoints, that it is called at most once for any checkpoint id and that it is not
    + * called for a deliberately failed checkpoint.
    + *
    + * <p>
    + * The topology tested here includes a number of {@link OneInputStreamOperator}s and a
    + * {@link TwoInputStreamOperator}.
    + *
    + * <p>
    + * Note that as a result of doing the checks on the task level there is no way to verify
    + * that the {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for every
    + * successfully completed checkpoint.
    + */
    +@SuppressWarnings("serial")
    +public class StreamCheckpointNotifierITCase extends StreamFaultToleranceTestBase {
    +
    +	final long NUM_LONGS = 10_000_000L;
    +
    +	/**
    +	 * Runs the following program:
    +	 *
    +	 * <pre>
    +	 *     [ (source)->(filter) ] -> [ (co-map) ] -> [ (map) ] -> [ (groupBy/reduce)->(sink) ]
    +	 * </pre>
    +	 */
    +	@Override
    +	public void testProgram(StreamExecutionEnvironment env) {
    +
    +		DataStream<Long> stream = env.addSource(new GeneratingSourceFunction(NUM_LONGS));
    +
    +		stream
    +				// -------------- first vertex, chained to the src ----------------
    +				.filter(new LongRichFilterFunction())
    +
    +				// -------------- second vertex, applying the co-map ----------------
    +				.connect(stream).flatMap(new LeftIdentityCoRichFlatMapFunction())
    +
    +				// -------------- third vertex - the stateful one that also fails ----------------
    +				.map(new IdentityMapFunction())
    +				.startNewChain()
    +
    +				// -------------- fourth vertex - reducer and the sink ----------------
    +				.groupBy(0)
    +				.reduce(new OnceFailingReducer(NUM_LONGS))
    +				.addSink(new SinkFunction<Tuple1<Long>>() {
    +					@Override
    +					public void invoke(Tuple1<Long> value) {
    +						// do nothing
    +					}
    +				});
    +	}
    +
    +	@Override
    +	public void postSubmit() {
    +		List[][] checkList = new List[][]{	GeneratingSourceFunction.completedCheckpoints,
    +				IdentityMapFunction.completedCheckpoints,
    +				LongRichFilterFunction.completedCheckpoints,
    +				LeftIdentityCoRichFlatMapFunction.completedCheckpoints};
    +
    +		for(List[] parallelNotifications : checkList) {
    +			for (int i = 0; i < PARALLELISM; i++){
    +				List<Long> notifications = parallelNotifications[i];
    +				assertTrue("No checkpoint notification was received.",
    +						notifications.size() > 0);
    +				assertFalse("Failure checkpoint was marked as completed.",
    +						notifications.contains(OnceFailingReducer.failureCheckpointID));
    +				assertTrue("Checkpoint notification was received multiple times",
    +						notifications.size() == new HashSet<Long>(notifications).size());
    --- End diff --
    
    Maybe it would be also good to check whether we received anything after the failed checkpoint.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/980


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-128003870
  
    Thanks, fair enough. I'll give it another try soon.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by gyfora <gi...@git.apache.org>.
Github user gyfora commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-127951550
  
    Could you please wait until I get a chance to look at it? I will try to do so later today :) 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-129042045
  
    Simplified the testing topology and added a bit more comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on a diff in the pull request:

    https://github.com/apache/flink/pull/980#discussion_r36168137
  
    --- Diff: flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java ---
    @@ -0,0 +1,429 @@
    +/*
    + * 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.test.checkpointing;
    +
    +import org.apache.flink.api.common.functions.FilterFunction;
    +import org.apache.flink.api.common.functions.RichMapFunction;
    +import org.apache.flink.api.common.functions.RichReduceFunction;
    +import org.apache.flink.api.common.state.OperatorState;
    +import org.apache.flink.configuration.ConfigConstants;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.streaming.api.checkpoint.CheckpointNotifier;
    +import org.apache.flink.streaming.api.checkpoint.Checkpointed;
    +import org.apache.flink.streaming.api.datastream.DataStream;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.functions.co.RichCoFlatMapFunction;
    +import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
    +import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
    +import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
    +import org.apache.flink.test.util.ForkableFlinkMiniCluster;
    +import org.apache.flink.util.Collector;
    +import org.junit.AfterClass;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Random;
    +
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertTrue;
    +import static org.junit.Assert.fail;
    +
    +/**
    + * Integration test for the {@link CheckpointNotifier} interface. The test ensures that
    + * {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for some completed
    + * checkpoints, that it is called at most once for any checkpoint id and that it is not
    + * called for a deliberately failed checkpoint.
    + *
    + * <p>
    + * Note that as a result of doing the checks on the task level there is no way to verify
    + * that the {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for every
    + * successfully completed checkpoint.
    + */
    +@SuppressWarnings("serial")
    +public class StreamCheckpointNotifierITCase {
    +
    +	private static final int NUM_TASK_MANAGERS = 2;
    +	private static final int NUM_TASK_SLOTS = 3;
    +	private static final int PARALLELISM = NUM_TASK_MANAGERS * NUM_TASK_SLOTS;
    +
    +	private static ForkableFlinkMiniCluster cluster;
    +
    +	@BeforeClass
    +	public static void startCluster() {
    +		try {
    +			Configuration config = new Configuration();
    +			config.setInteger(ConfigConstants.LOCAL_INSTANCE_MANAGER_NUMBER_TASK_MANAGER, NUM_TASK_MANAGERS);
    +			config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, NUM_TASK_SLOTS);
    +			config.setString(ConfigConstants.DEFAULT_EXECUTION_RETRY_DELAY_KEY, "0 ms");
    +			config.setInteger(ConfigConstants.TASK_MANAGER_MEMORY_SIZE_KEY, 12);
    +
    +			cluster = new ForkableFlinkMiniCluster(config, false);
    +		}
    +		catch (Exception e) {
    +			e.printStackTrace();
    +			fail("Failed to start test cluster: " + e.getMessage());
    +		}
    +	}
    +
    +	@AfterClass
    +	public static void shutdownCluster() {
    +		try {
    +			cluster.shutdown();
    +			cluster = null;
    +		}
    +		catch (Exception e) {
    +			e.printStackTrace();
    +			fail("Failed to stop test cluster: " + e.getMessage());
    +		}
    +	}
    +
    +
    +
    +	/**
    +	 * Runs the following program:
    +	 *
    +	 * <pre>
    +	 *     [ (source)->(filter)->(map) ] -> [ (co-map) ] -> [ (map) ] -> [ (groupBy/reduce)->(sink) ]
    +	 * </pre>
    +	 */
    +	@Test
    +	public void runCheckpointedProgram() {
    +
    +		final long NUM_STRINGS = 10000000L;
    +		assertTrue("Broken test setup", NUM_STRINGS % 40 == 0);
    +
    +		try {
    +			StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment(
    +					"localhost", cluster.getJobManagerRPCPort());
    +			env.setParallelism(PARALLELISM);
    +			env.enableCheckpointing(500);
    +			env.getConfig().disableSysoutLogging();
    +
    +			DataStream<String> stream = env.addSource(new StringGeneratingSourceFunction(NUM_STRINGS));
    +
    +			stream
    +					// -------------- first vertex, chained to the src ----------------
    +					.filter(new StringRichFilterFunction())
    +
    +					// -------------- second vertex, applying the co-map ----------------
    +					.connect(stream).flatMap(new LeftIdentityCoRichFlatMapFunction())
    +
    +					// -------------- third vertex - the stateful one that also fails ----------------
    +					.map(new StringPrefixCountRichMapFunction())
    +					.startNewChain()
    +					.map(new IdentityMapFunction())
    +
    +							// -------------- fourth vertex - reducer and the sink ----------------
    +					.groupBy("prefix")
    +					.reduce(new OnceFailingReducer(NUM_STRINGS))
    +					.addSink(new RichSinkFunction<PrefixCount>() {
    +
    --- End diff --
    
    This sink is not needed any more.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint...

Posted by mbalassi <gi...@git.apache.org>.
Github user mbalassi commented on the pull request:

    https://github.com/apache/flink/pull/980#issuecomment-127952500
  
    Sure, thanks for checking it out. :+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---