You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/09/27 12:39:31 UTC

[flink] 04/06: [FLINK-12433][runtime] Add NoOpFailoverStrategy

This is an automated email from the ASF dual-hosted git repository.

gary pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 064209650fc695f3d3e4a26a6bbd9785167eb840
Author: Gary Yao <ga...@apache.org>
AuthorDate: Mon Sep 9 10:44:56 2019 +0200

    [FLINK-12433][runtime] Add NoOpFailoverStrategy
    
    Introduce a NoOpFailoverStrategy that is exclusively configured if the new
    generation scheduler is used. This is because the new scheduler does not depend
    on the legacy FailoverStrategy interface.
---
 .../failover/FailoverStrategyLoader.java           | 12 ++++-
 .../failover/NoOpFailoverStrategy.java             | 53 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/FailoverStrategyLoader.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/FailoverStrategyLoader.java
index e80c6ed..632f3af 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/FailoverStrategyLoader.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/FailoverStrategyLoader.java
@@ -44,13 +44,20 @@ public class FailoverStrategyLoader {
 	/** Config name for the {@link RestartPipelinedRegionStrategy}. */
 	public static final String LEGACY_PIPELINED_REGION_RESTART_STRATEGY_NAME = "region-legacy";
 
+	/** Config name for the {@link NoOpFailoverStrategy}. */
+	public static final String NO_OP_FAILOVER_STRATEGY = "noop";
+
 	// ------------------------------------------------------------------------
 
 	/**
 	 * Loads a FailoverStrategy Factory from the given configuration.
 	 */
 	public static FailoverStrategy.Factory loadFailoverStrategy(Configuration config, @Nullable Logger logger) {
-		final String strategyParam = config.getString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY);
+		// The new generation scheduler does not depend on the FailoverStrategy loaded here.
+		// Therefore, we load a noop failover strategy if the new generation scheduler is configured.
+		final String strategyParam = config.getString(JobManagerOptions.SCHEDULER).equals("ng") ?
+			NO_OP_FAILOVER_STRATEGY :
+			config.getString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY);
 
 		if (StringUtils.isNullOrWhitespaceOnly(strategyParam)) {
 			if (logger != null) {
@@ -74,6 +81,9 @@ public class FailoverStrategyLoader {
 				case INDIVIDUAL_RESTART_STRATEGY_NAME:
 					return new RestartIndividualStrategy.Factory();
 
+				case NO_OP_FAILOVER_STRATEGY:
+					return new NoOpFailoverStrategy.Factory();
+
 				default:
 					// we could interpret the parameter as a factory class name and instantiate that
 					// for now we simply do not support this
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/NoOpFailoverStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/NoOpFailoverStrategy.java
new file mode 100644
index 0000000..0cc3780
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/NoOpFailoverStrategy.java
@@ -0,0 +1,53 @@
+/*
+ * 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.runtime.executiongraph.failover;
+
+import org.apache.flink.runtime.executiongraph.Execution;
+import org.apache.flink.runtime.executiongraph.ExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ExecutionJobVertex;
+
+import java.util.List;
+
+/**
+ * FailoverStrategy that does not do anything.
+ */
+public class NoOpFailoverStrategy extends FailoverStrategy {
+
+	@Override
+	public void onTaskFailure(final Execution taskExecution, final Throwable cause) {
+	}
+
+	@Override
+	public void notifyNewVertices(final List<ExecutionJobVertex> newJobVerticesTopological) {
+	}
+
+	@Override
+	public String getStrategyName() {
+		return "NoOp failover strategy";
+	}
+
+	public static class Factory implements FailoverStrategy.Factory {
+
+		@Override
+		public FailoverStrategy create(final ExecutionGraph executionGraph) {
+			return new NoOpFailoverStrategy();
+		}
+	}
+}