Browse Source

HDFS-6051. HDFS cannot run on Windows since short-circuit memory segment changes (cmccabe)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.4@1574260 13f79535-47bb-0310-9956-ffa450edef68
Colin McCabe 11 years ago
parent
commit
85704729b9

+ 11 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/SharedFileDescriptorFactory.java

@@ -48,6 +48,16 @@ public class SharedFileDescriptorFactory {
   private final String prefix;
   private final String path;
 
+  public static String getLoadingFailureReason() {
+    if (!NativeIO.isAvailable()) {
+      return "NativeIO is not available.";
+    }
+    if (!SystemUtils.IS_OS_UNIX) {
+      return "The OS is not UNIX.";
+    }
+    return null;
+  }
+
   /**
    * Create a SharedFileDescriptorFactory.
    *
@@ -56,8 +66,7 @@ public class SharedFileDescriptorFactory {
    */
   public SharedFileDescriptorFactory(String prefix, String path)
       throws IOException {
-    Preconditions.checkArgument(NativeIO.isAvailable());
-    Preconditions.checkArgument(SystemUtils.IS_OS_UNIX);
+    Preconditions.checkState(getLoadingFailureReason() == null);
     this.prefix = prefix;
     this.path = path;
     deleteStaleTemporaryFiles0(prefix, path);

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -272,6 +272,9 @@ Release 2.4.0 - UNRELEASED
     HDFS-6047 TestPread NPE inside in DFSInputStream hedgedFetchBlockByteRange
     (stack)
 
+    HDFS-6051. HDFS cannot run on Windows since short-circuit shared memory
+    segment changes. (cmccabe)
+
   BREAKDOWN OF HDFS-5698 SUBTASKS AND RELATED JIRAS
 
     HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9)

+ 13 - 7
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java

@@ -149,23 +149,29 @@ public class ShortCircuitRegistry {
     SharedFileDescriptorFactory shmFactory = null;
     DomainSocketWatcher watcher = null;
     try {
-      if (!NativeIO.isAvailable()) {
-        LOG.debug("Disabling ShortCircuitRegistry because NativeIO is " +
-            "not available.");
+      String loadingFailureReason =
+          SharedFileDescriptorFactory.getLoadingFailureReason();
+      if (loadingFailureReason != null) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Disabling ShortCircuitRegistry because " +
+                    loadingFailureReason);
+        }
         return;
       }
       String shmPath = conf.get(DFS_DATANODE_SHARED_FILE_DESCRIPTOR_PATH,
           DFS_DATANODE_SHARED_FILE_DESCRIPTOR_PATH_DEFAULT);
       if (shmPath.isEmpty()) {
-        LOG.info("Disabling ShortCircuitRegistry because shmPath was not set.");
+        LOG.debug("Disabling ShortCircuitRegistry because shmPath was not set.");
         return;
       }
       int interruptCheck = conf.getInt(
           DFS_SHORT_CIRCUIT_SHARED_MEMORY_WATCHER_INTERRUPT_CHECK_MS,
           DFS_SHORT_CIRCUIT_SHARED_MEMORY_WATCHER_INTERRUPT_CHECK_MS_DEFAULT);
       if (interruptCheck <= 0) {
-        LOG.info("Disabling ShortCircuitRegistry because interruptCheckMs " +
-            "was set to " + interruptCheck);
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Disabling ShortCircuitRegistry because " +
+                    "interruptCheckMs was set to " + interruptCheck);
+        }
         return;
       }
       shmFactory = 
@@ -174,7 +180,7 @@ public class ShortCircuitRegistry {
       enabled = true;
       if (LOG.isDebugEnabled()) {
         LOG.debug("created new ShortCircuitRegistry with interruptCheck=" +
-          interruptCheck + ", shmPath=" + shmPath);
+                  interruptCheck + ", shmPath=" + shmPath);
       }
     } finally {
       this.enabled = enabled;