You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by rm...@apache.org on 2015/04/14 10:45:34 UTC

flink git commit: [runtime] Avoid IllegalStateException when TaskManager is killed during startup

Repository: flink
Updated Branches:
  refs/heads/master 322782c84 -> c910300e2


[runtime] Avoid IllegalStateException when TaskManager is killed during startup

This closes #587


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/c910300e
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/c910300e
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/c910300e

Branch: refs/heads/master
Commit: c910300e2feecc9b0c129eca39ededa62be427e9
Parents: 322782c
Author: Robert Metzger <rm...@apache.org>
Authored: Fri Apr 10 17:49:20 2015 +0200
Committer: Robert Metzger <rm...@apache.org>
Committed: Tue Apr 14 09:38:19 2015 +0200

----------------------------------------------------------------------
 .../apache/flink/runtime/io/disk/iomanager/IOManager.java | 10 +++++++++-
 .../java/org/apache/flink/yarn/YARNSessionFIFOITCase.java |  8 +++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/c910300e/flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java
index c1a4b84..c0bd360 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java
@@ -103,7 +103,14 @@ public abstract class IOManager {
 				shutdown();
 			}
 		};
-		Runtime.getRuntime().addShutdownHook(this.shutdownHook);
+		try {
+			Runtime.getRuntime().addShutdownHook(this.shutdownHook);
+		} catch (IllegalStateException e) {
+			// race, JVM is in shutdown already, we can safely ignore this
+			LOG.debug("Unable to add shutdown hook, shutdown already in progress", e);
+		} catch (Throwable t) {
+			LOG.warn("Error while adding shutdown hook for IOManager", t);
+		}
 	}
 
 	/**
@@ -132,6 +139,7 @@ public abstract class IOManager {
 			}
 			catch (IllegalStateException e) {
 				// race, JVM is in shutdown already, we can safely ignore this
+				LOG.debug("Unable to remove shutdown hook, shutdown already in progress", e);
 			}
 			catch (Throwable t) {
 				LOG.warn("Exception while unregistering IOManager's shutdown hook.", t);

http://git-wip-us.apache.org/repos/asf/flink/blob/c910300e/flink-yarn-tests/src/main/java/org/apache/flink/yarn/YARNSessionFIFOITCase.java
----------------------------------------------------------------------
diff --git a/flink-yarn-tests/src/main/java/org/apache/flink/yarn/YARNSessionFIFOITCase.java b/flink-yarn-tests/src/main/java/org/apache/flink/yarn/YARNSessionFIFOITCase.java
index 74f658c..bb18e87 100644
--- a/flink-yarn-tests/src/main/java/org/apache/flink/yarn/YARNSessionFIFOITCase.java
+++ b/flink-yarn-tests/src/main/java/org/apache/flink/yarn/YARNSessionFIFOITCase.java
@@ -123,7 +123,13 @@ public class YARNSessionFIFOITCase extends YarnTestBase {
 		checkForLogString("The Flink YARN client has been started in detached mode");
 
 		Assert.assertFalse("The runner should detach.", runner.isAlive());
-		sleep(5000); // wait for 5 seconds to make sure the the app has been started completely before we kill it
+
+		LOG.info("Waiting until two containers are running");
+		// wait until two containers are running
+		while(getRunningContainers() < 2) {
+			sleep(500);
+		}
+		LOG.info("Two containers are running. Killing the application");
 
 		// kill application "externally".
 		try {