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
This commit is contained in:
Eli Collins 2012-07-16 21:30:42 +00:00
parent 0d1867fa9d
commit 9404bc7cad
9 changed files with 26 additions and 11 deletions

View File

@ -84,10 +84,20 @@ public final class ExitUtil {
System.exit(status); 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. * Like {@link terminate(int, String)} without a message.
* @param status * @param status
* @throws ExitException * @throws ExitException if System.exit is disabled for test purposes
*/ */
public static void terminate(int status) throws ExitException { public static void terminate(int status) throws ExitException {
terminate(status, "ExitException"); terminate(status, "ExitException");

View File

@ -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-3665. Add a test for renaming across file systems via a symlink. (eli)
HDFS-3666. Plumb more exception messages to terminate. (eli)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-2982. Startup performance suffers when there are many edit log HDFS-2982. Startup performance suffers when there are many edit log

View File

@ -2996,7 +2996,7 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block
break; break;
} catch (Throwable t) { } catch (Throwable t) {
LOG.fatal("ReplicationMonitor thread received Runtime exception. ", t); LOG.fatal("ReplicationMonitor thread received Runtime exception. ", t);
terminate(1); terminate(1, t);
} }
} }
} }

View File

@ -1708,7 +1708,7 @@ public class DataNode extends Configured
datanode.join(); datanode.join();
} catch (Throwable e) { } catch (Throwable e) {
LOG.fatal("Exception in secureMain", e); LOG.fatal("Exception in secureMain", e);
terminate(1); terminate(1, e);
} finally { } finally {
// We need to terminate the process here because either shutdown was called // We need to terminate the process here because either shutdown was called
// or some disk related conditions like volumes tolerated or volumes required // or some disk related conditions like volumes tolerated or volumes required

View File

@ -524,8 +524,9 @@ public class FSEditLog {
editLogStream.setReadyToFlush(); editLogStream.setReadyToFlush();
} catch (IOException e) { } catch (IOException e) {
final String msg = final String msg =
"Could not sync enough journals to persistent storage. " "Could not sync enough journals to persistent storage " +
+ "Unsynced transactions: " + (txid - synctxid); "due to " + e.getMessage() + ". " +
"Unsynced transactions: " + (txid - synctxid);
LOG.fatal(msg, new Exception()); LOG.fatal(msg, new Exception());
terminate(1, msg); terminate(1, msg);
} }

View File

@ -1201,7 +1201,7 @@ public class NameNode {
namenode.join(); namenode.join();
} catch (Throwable e) { } catch (Throwable e) {
LOG.fatal("Exception in namenode join", e); LOG.fatal("Exception in namenode join", e);
terminate(1); terminate(1, e);
} }
} }
@ -1289,7 +1289,7 @@ public class NameNode {
} catch (Throwable ignored) { } catch (Throwable ignored) {
// This is unlikely to happen, but there's nothing we can do if it does. // This is unlikely to happen, but there's nothing we can do if it does.
} }
terminate(1, t.getMessage()); terminate(1, t);
} }
/** /**

View File

@ -330,7 +330,7 @@ public class SecondaryNameNode implements Runnable {
} catch (Throwable e) { } catch (Throwable e) {
LOG.fatal("Throwable Exception in doCheckpoint", e); LOG.fatal("Throwable Exception in doCheckpoint", e);
e.printStackTrace(); e.printStackTrace();
terminate(1); terminate(1, e);
} }
} }
} }

View File

@ -316,7 +316,7 @@ public class EditLogTailer {
} catch (Throwable t) { } catch (Throwable t) {
LOG.fatal("Unknown error encountered while tailing edits. " + LOG.fatal("Unknown error encountered while tailing edits. " +
"Shutting down standby NN.", t); "Shutting down standby NN.", t);
terminate(1, t.getMessage()); terminate(1, t);
} }
try { try {

View File

@ -125,7 +125,8 @@ public class TestEditLogJournalFailures {
} catch (RemoteException re) { } catch (RemoteException re) {
assertTrue(re.getClassName().contains("ExitException")); assertTrue(re.getClassName().contains("ExitException"));
GenericTestUtils.assertExceptionContains( 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); "Unsynced transactions: 1", re);
} }
} }
@ -227,7 +228,8 @@ public class TestEditLogJournalFailures {
} catch (RemoteException re) { } catch (RemoteException re) {
assertTrue(re.getClassName().contains("ExitException")); assertTrue(re.getClassName().contains("ExitException"));
GenericTestUtils.assertExceptionContains( 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); "Unsynced transactions: 1", re);
} }
} }