ソースを参照

HDFS-1692. In secure mode, Datanode process doesn't exit when disks fail. Contributed by Bharath Mundlapudi.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1136741 13f79535-47bb-0310-9956-ffa450edef68

Suresh Srinivas 14 年 前
コミット
58dc1381e0

+ 3 - 0
hdfs/CHANGES.txt

@@ -751,6 +751,9 @@ Trunk (unreleased changes)
     HDFS-1656. Fixes an issue to do with fetching of delegation tokens in
     HftpFileSystem. Contributed by Kan Zhang.
 
+    HDFS-1692. In secure mode, Datanode process doesn't exit when disks 
+    fail. (Bharath Mundlapudi via suresh)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 7 - 0
hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -2280,6 +2280,13 @@ public class DataNode extends Configured
     } catch (Throwable e) {
       LOG.error(StringUtils.stringifyException(e));
       System.exit(-1);
+    } finally {
+      // We need to add System.exit here because either shutdown was called or
+      // some disk related conditions like volumes tolerated or volumes required
+      // condition was not met. Also, In secure mode, control will go to Jsvc
+      // and Datanode process hangs without System.exit.
+      LOG.warn("Exiting Datanode");
+      System.exit(0);
     }
   }
   

+ 6 - 7
hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java

@@ -47,7 +47,7 @@ class DataXceiverServer implements Runnable, FSConstants {
   
   ServerSocket ss;
   DataNode datanode;
-  // Record all sockets opend for data transfer
+  // Record all sockets opened for data transfer
   Map<Socket, Socket> childSockets = Collections.synchronizedMap(
                                        new HashMap<Socket, Socket>());
   
@@ -140,19 +140,18 @@ class DataXceiverServer implements Runnable, FSConstants {
       } catch (SocketTimeoutException ignored) {
         // wake up to see if should continue to run
       } catch (IOException ie) {
-        LOG.warn(datanode.getMachineName() + ":DataXceiveServer: " 
-                                + StringUtils.stringifyException(ie));
+        LOG.warn(datanode.getMachineName() + ":DataXceiveServer: ", ie);
       } catch (Throwable te) {
-        LOG.error(datanode.getMachineName() + ":DataXceiveServer: Exiting due to:" 
-                                 + StringUtils.stringifyException(te));
+        LOG.error(datanode.getMachineName()
+            + ":DataXceiveServer: Exiting due to: ", te);
         datanode.shouldRun = false;
       }
     }
     try {
       ss.close();
     } catch (IOException ie) {
-      LOG.warn(datanode.getMachineName() + ":DataXceiveServer: " 
-                              + StringUtils.stringifyException(ie));
+      LOG.warn(datanode.getMachineName()
+          + ":DataXceiveServer: Close exception due to: ", ie);
     }
   }
   

+ 2 - 1
hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java

@@ -879,7 +879,8 @@ public class FSDataset implements FSConstants, FSDatasetInterface {
           if (removedVols == null) {
             removedVols = new ArrayList<FSVolume>(1);
           }
-          removedVols.add(volumeList.get(idx));
+          removedVols.add(fsv);
+          fsv.shutdown(); 
           volumeList.set(idx, null); // Remove the volume
           numFailedVolumes++;
         }