瀏覽代碼

HDFS-1745. Federation: Fix fault injection test failures. Contributed by Suresh Srinvias.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/branches/HDFS-1052@1080331 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 14 年之前
父節點
當前提交
a06950120d
共有 2 個文件被更改,包括 14 次插入4 次删除
  1. 1 0
      CHANGES.txt
  2. 13 4
      src/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

+ 1 - 0
CHANGES.txt

@@ -231,6 +231,7 @@ Trunk (unreleased changes)
     HDFS-1744. Federation: Add new layout version to offline image viewer
     and edits viewer. (suresh)
 
+    HDFS-1745. Federation: Fix fault injection test failures. (suresh)
 
   IMPROVEMENTS
 

+ 13 - 4
src/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -342,7 +342,7 @@ public class DataNode extends Configured
   private InetSocketAddress selfAddr;
   
   private static volatile DataNode datanodeObject = null;
-  private final String hostName; // Host name of this datanode
+  private volatile String hostName; // Host name of this datanode
   
   private static String dnThreadName;
   int socketTimeout;
@@ -1089,13 +1089,14 @@ public class DataNode extends Configured
                 
       while(shouldRun && shouldServiceRun) {
         try {
-          // reset name to machineName. Mainly for web interface. Same for all DB
-          bpRegistration.name = hostName + ":" + bpRegistration.getPort();
+          // Use returned registration from namenode with updated machine name.
           bpRegistration = bpNamenode.registerDatanode(bpRegistration);
 
           LOG.info("bpReg after =" + bpRegistration.storageInfo + 
               ";sid=" + bpRegistration.storageID + ";name="+bpRegistration.getName());
 
+          NetUtils.getHostname();
+          hostName = bpRegistration.getHost();
           break;
         } catch(SocketTimeoutException e) {  // namenode is busy
           LOG.info("Problem connecting to server: " + nnAddr);
@@ -1722,8 +1723,9 @@ public class DataNode extends Configured
   static UpgradeManagerDatanode getUpgradeManagerDatanode(String bpid) {
     DataNode dn = getDataNode();
     BPOfferService bpos = dn.blockPoolManager.get(bpid);
-    if(bpos==null)
+    if(bpos==null) {
       return null;
+    }
     return bpos.getUpgradeManager();
   }
 
@@ -2621,4 +2623,11 @@ public class DataNode extends Configured
     }
     return true;
   }
+  
+  /** Methods used by fault injection tests */
+  public DatanodeID getDatanodeId() {
+    LOG.info("SURESH machienname " + getMachineName());
+    return new DatanodeID(getMachineName(), getStorageId(),
+        infoServer.getPort(), getIpcPort());
+  }
 }