From 9404bc7cad3b3882568d4922e399d9245fad2825 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Mon, 16 Jul 2012 21:30:42 +0000 Subject: [PATCH] HDFS-3666. Plumb more exception messages to terminate. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1362274 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/hadoop/util/ExitUtil.java | 12 +++++++++++- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hdfs/server/blockmanagement/BlockManager.java | 2 +- .../apache/hadoop/hdfs/server/datanode/DataNode.java | 2 +- .../hadoop/hdfs/server/namenode/FSEditLog.java | 5 +++-- .../apache/hadoop/hdfs/server/namenode/NameNode.java | 4 ++-- .../hdfs/server/namenode/SecondaryNameNode.java | 2 +- .../hdfs/server/namenode/ha/EditLogTailer.java | 2 +- .../server/namenode/TestEditLogJournalFailures.java | 6 ++++-- 9 files changed, 26 insertions(+), 11 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java index 837e4f3c9de..8adcb13ac43 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java @@ -84,10 +84,20 @@ public final class ExitUtil { System.exit(status); } + /** + * Like {@link terminate(int, String)} but takes an exception to + * @param status + * @param t Exception + * @throws ExitException if System.exit is disabled for test purposes + */ + public static void terminate(int status, Throwable t) throws ExitException { + terminate(status, t.getMessage()); + } + /** * Like {@link terminate(int, String)} without a message. * @param status - * @throws ExitException + * @throws ExitException if System.exit is disabled for test purposes */ public static void terminate(int status) throws ExitException { terminate(status, "ExitException"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 021126adde2..55ac84765f1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -159,6 +159,8 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3665. Add a test for renaming across file systems via a symlink. (eli) + HDFS-3666. Plumb more exception messages to terminate. (eli) + OPTIMIZATIONS HDFS-2982. Startup performance suffers when there are many edit log diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index e9e9443aac6..226635dec41 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -2996,7 +2996,7 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block break; } catch (Throwable t) { LOG.fatal("ReplicationMonitor thread received Runtime exception. ", t); - terminate(1); + terminate(1, t); } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 4d6f948dae8..25298fd5faa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -1708,7 +1708,7 @@ public class DataNode extends Configured datanode.join(); } catch (Throwable e) { LOG.fatal("Exception in secureMain", e); - terminate(1); + terminate(1, e); } finally { // We need to terminate the process here because either shutdown was called // or some disk related conditions like volumes tolerated or volumes required diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java index e3417d1ede3..ac7f63b6889 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java @@ -524,8 +524,9 @@ public class FSEditLog { editLogStream.setReadyToFlush(); } catch (IOException e) { final String msg = - "Could not sync enough journals to persistent storage. " - + "Unsynced transactions: " + (txid - synctxid); + "Could not sync enough journals to persistent storage " + + "due to " + e.getMessage() + ". " + + "Unsynced transactions: " + (txid - synctxid); LOG.fatal(msg, new Exception()); terminate(1, msg); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index dccfa04a89d..899f0cbc753 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -1201,7 +1201,7 @@ public class NameNode { namenode.join(); } catch (Throwable e) { LOG.fatal("Exception in namenode join", e); - terminate(1); + terminate(1, e); } } @@ -1289,7 +1289,7 @@ public class NameNode { } catch (Throwable ignored) { // This is unlikely to happen, but there's nothing we can do if it does. } - terminate(1, t.getMessage()); + terminate(1, t); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java index 044f9254ebe..c32bd3383b7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java @@ -330,7 +330,7 @@ public class SecondaryNameNode implements Runnable { } catch (Throwable e) { LOG.fatal("Throwable Exception in doCheckpoint", e); e.printStackTrace(); - terminate(1); + terminate(1, e); } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java index 3e811dfba85..e2e65d41444 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java @@ -316,7 +316,7 @@ public class EditLogTailer { } catch (Throwable t) { LOG.fatal("Unknown error encountered while tailing edits. " + "Shutting down standby NN.", t); - terminate(1, t.getMessage()); + terminate(1, t); } try { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java index bc5cc7e4594..879d2922c8e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java @@ -125,7 +125,8 @@ public class TestEditLogJournalFailures { } catch (RemoteException re) { assertTrue(re.getClassName().contains("ExitException")); GenericTestUtils.assertExceptionContains( - "Could not sync enough journals to persistent storage. " + + "Could not sync enough journals to persistent storage due to " + + "No journals available to flush. " + "Unsynced transactions: 1", re); } } @@ -227,7 +228,8 @@ public class TestEditLogJournalFailures { } catch (RemoteException re) { assertTrue(re.getClassName().contains("ExitException")); GenericTestUtils.assertExceptionContains( - "Could not sync enough journals to persistent storage. " + + "Could not sync enough journals to persistent storage due to " + + "setReadyToFlush failed for too many journals. " + "Unsynced transactions: 1", re); } }