diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 9c68cde9de1..db8a0318451 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -558,6 +558,8 @@ Release 2.8.0 - UNRELEASED HDFS-8607. TestFileCorruption doesn't work as expected. (Walter Su via Arpit Agarwal) + HDFS-8592. SafeModeException never get unwrapped. (wheat9) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 8109c80e139..397b729d194 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -1314,7 +1314,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, void checkNameNodeSafeMode(String errorMsg) throws RetriableException, SafeModeException { if (isInSafeMode()) { - SafeModeException se = new SafeModeException(errorMsg, safeMode); + SafeModeException se = newSafemodeException(errorMsg); if (haEnabled && haContext != null && haContext.getState().getServiceState() == HAServiceState.ACTIVE && shouldRetrySafeMode(this.safeMode)) { @@ -1325,6 +1325,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, } } + private SafeModeException newSafemodeException(String errorMsg) { + return new SafeModeException(errorMsg + ". Name node is in safe " + + "mode.\n" + safeMode.getTurnOffTip()); + } + boolean isPermissionEnabled() { return isPermissionEnabled; } @@ -1793,8 +1798,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, for (LocatedBlock b : ret.blocks.getLocatedBlocks()) { // if safemode & no block locations yet then throw safemodeException if ((b.getLocations() == null) || (b.getLocations().length == 0)) { - SafeModeException se = new SafeModeException( - "Zero blocklocations for " + src, safeMode); + SafeModeException se = newSafemodeException( + "Zero blocklocations for " + src); if (haEnabled && haContext != null && haContext.getState().getServiceState() == HAServiceState.ACTIVE) { throw new RetriableException(se); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SafeModeException.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SafeModeException.java index 458f0527175..8080bcf7c6f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SafeModeException.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SafeModeException.java @@ -32,8 +32,7 @@ import org.apache.hadoop.classification.InterfaceStability; @InterfaceStability.Evolving public class SafeModeException extends IOException { private static final long serialVersionUID = 1L; - - public SafeModeException(String text, FSNamesystem.SafeModeInfo mode ) { - super(text + ". Name node is in safe mode.\n" + mode.getTurnOffTip()); + public SafeModeException(String msg) { + super(msg); } } \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java index 80fe9eead54..6cea7e89517 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java @@ -295,8 +295,8 @@ public class TestSafeMode { fail(msg); } catch (RemoteException re) { assertEquals(SafeModeException.class.getName(), re.getClassName()); - GenericTestUtils.assertExceptionContains( - "Name node is in safe mode", re); + GenericTestUtils.assertExceptionContains("Name node is in safe mode", re); + } catch (SafeModeException ignored) { } catch (IOException ioe) { fail(msg + " " + StringUtils.stringifyException(ioe)); }