hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r910760 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java
Date Tue, 16 Feb 2010 23:14:50 GMT
Author: tomwhite
Date: Tue Feb 16 23:14:49 2010
New Revision: 910760

URL: http://svn.apache.org/viewvc?rev=910760&view=rev
Log:
HDFS-894. DatanodeID.ipcPort is not updated when existing node re-registers. Contributed by
Todd Lipcon.

Added:
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java
Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=910760&r1=910759&r2=910760&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Tue Feb 16 23:14:49 2010
@@ -134,6 +134,9 @@
     HDFS-938. Replace calls to UGI.getUserName() with UGI.getShortUserName()
     (jghoman)
 
+    HDFS-894. DatanodeID.ipcPort is not updated when existing node re-registers.
+    (Todd Lipcon via tomwhite)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java?rev=910760&r1=910759&r2=910760&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/protocol/DatanodeID.java Tue Feb 16
23:14:49 2010
@@ -153,6 +153,7 @@
   public void updateRegInfo(DatanodeID nodeReg) {
     name = nodeReg.getName();
     infoPort = nodeReg.getInfoPort();
+    ipcPort = nodeReg.getIpcPort();
     // update any more fields added in future.
   }
     

Added: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java?rev=910760&view=auto
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java (added)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDatanodeRegistration.java Tue
Feb 16 23:14:49 2010
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs;
+
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdfs.protocol.FSConstants.DatanodeReportType;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.DFSClient;
+import org.apache.hadoop.fs.Path;
+import junit.framework.TestCase;
+
+/**
+ * This class tests that a file need not be closed before its
+ * data can be read by another client.
+ */
+public class TestDatanodeRegistration extends TestCase {
+
+  /**
+   * Regression test for HDFS-894 ensures that, when datanodes
+   * are restarted, the new IPC port is registered with the
+   * namenode.
+   */
+  public void testChangeIpcPort() throws Exception {
+    HdfsConfiguration conf = new HdfsConfiguration();
+    MiniDFSCluster cluster = null;
+    FileSystem fs = null;
+    try {
+      cluster = new MiniDFSCluster(conf, 1, true, null);
+      fs = cluster.getFileSystem();
+
+      InetSocketAddress addr = new InetSocketAddress(
+        "localhost",
+        cluster.getNameNodePort());
+      DFSClient client = new DFSClient(addr, conf);
+
+      // Restart datanodes
+      cluster.restartDataNodes();
+
+      // Wait until we get a heartbeat from the new datanode
+      DatanodeInfo[] report = client.datanodeReport(DatanodeReportType.ALL);
+      long firstUpdateAfterRestart = report[0].getLastUpdate();
+
+      boolean gotHeartbeat = false;
+      for (int i = 0; i < 10 && !gotHeartbeat; i++) {
+        try {
+          Thread.sleep(i*1000);
+        } catch (InterruptedException ie) {}
+
+        report = client.datanodeReport(DatanodeReportType.ALL);
+        gotHeartbeat = (report[0].getLastUpdate() > firstUpdateAfterRestart);
+      }
+      if (!gotHeartbeat) {
+        fail("Never got a heartbeat from restarted datanode.");
+      }
+
+      int realIpcPort = cluster.getDataNodes().get(0)
+        .dnRegistration.getIpcPort();
+      // Now make sure the reported IPC port is the correct one.
+      assertEquals(realIpcPort, report[0].getIpcPort());
+    } finally {
+      if (cluster != null) {
+        cluster.shutdown();
+      }
+    }
+  }
+}



Mime
View raw message