hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [24/40] hadoop git commit: HDFS-10601. Improve log message to include hostname when the NameNode is in safemode. Contributed by Kuhu Shukla.
Date Mon, 20 Mar 2017 23:18:35 GMT
HDFS-10601. Improve log message to include hostname when the NameNode is in safemode. Contributed
by Kuhu Shukla.


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

Branch: refs/heads/HADOOP-13345
Commit: ba62b50ebacd33b55eafc9db55a2fe5b4c80207a
Parents: 7114bad
Author: Kihwal Lee <kihwal@apache.org>
Authored: Thu Mar 16 10:53:38 2017 -0500
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Thu Mar 16 10:54:59 2017 -0500

----------------------------------------------------------------------
 .../hdfs/server/namenode/FSNamesystem.java      |  7 +++++-
 .../org/apache/hadoop/hdfs/TestSafeMode.java    | 24 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba62b50e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
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 062896c..8f09740 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
@@ -106,6 +106,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -547,6 +548,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
    */
   private boolean manualSafeMode = false;
   private boolean resourceLowSafeMode = false;
+  private String nameNodeHostName = null;
 
   /**
    * Notify that loading of this FSDirectory is complete, and
@@ -1116,6 +1118,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
       dir.setINodeAttributeProvider(inodeAttributeProvider);
     }
     snapshotManager.registerMXBean();
+    InetSocketAddress serviceAddress = NameNode.getServiceAddress(conf, true);
+    this.nameNodeHostName = (serviceAddress != null) ?
+        serviceAddress.getHostName() : "";
   }
   
   /** 
@@ -1383,7 +1388,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
 
   private SafeModeException newSafemodeException(String errorMsg) {
     return new SafeModeException(errorMsg + ". Name node is in safe " +
-        "mode.\n" + getSafeModeTip());
+        "mode.\n" + getSafeModeTip() + " NamenodeHostName:" + nameNodeHostName);
   }
 
   boolean isPermissionEnabled() {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba62b50e/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java
----------------------------------------------------------------------
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 ada61b9..62dac74 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
@@ -304,6 +304,30 @@ public class TestSafeMode {
     }
   }
 
+  @Test
+  public void testSafeModeExceptionText() throws Exception {
+    final Path file1 = new Path("/file1");
+    DFSTestUtil.createFile(fs, file1, 1024, (short)1, 0);
+    assertTrue("Could not enter SM",
+        dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER));
+    try {
+      FSRun fsRun = new FSRun() {
+        @Override
+        public void run(FileSystem fileSystem) throws IOException {
+          ((DistributedFileSystem)fileSystem).setQuota(file1, 1, 1);
+        }
+      };
+      fsRun.run(fs);
+      fail("Should not succeed with no exceptions!");
+    } catch (RemoteException re) {
+      assertEquals(SafeModeException.class.getName(), re.getClassName());
+      GenericTestUtils.assertExceptionContains(
+          NameNode.getServiceAddress(conf, true).getHostName(), re);
+    } catch (IOException ioe) {
+      fail("Encountered exception" + " " + StringUtils.stringifyException(ioe));
+    }
+  }
+
   /**
    * Run various fs operations while the NN is in safe mode,
    * assert that they are either allowed or fail as expected.


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message