Prechádzať zdrojové kódy

HDFS-5562. TestCacheDirectives and TestFsDatasetCache should stub out native mlock. Contributed by Colin Patrick McCabe and Akira Ajisaka.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1546246 13f79535-47bb-0310-9956-ffa450edef68
Andrew Wang 11 rokov pred
rodič
commit
bb11d47758

+ 8 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java

@@ -142,6 +142,10 @@ public class NativeIO {
         NativeIO.POSIX.posixFadviseIfPossible(identifier, fd, offset,
             len, flags);
       }
+
+      public boolean verifyCanMlock() {
+        return NativeIO.isAvailable();
+      }
     }
 
     /**
@@ -163,6 +167,10 @@ public class NativeIO {
       public long getOperatingSystemPageSize() {
         return 4096;
       }
+
+      public boolean verifyCanMlock() {
+        return true;
+      }
     }
 
     static {

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

@@ -416,6 +416,9 @@ Trunk (Unreleased)
     HDFS-5565. CacheAdmin help should match against non-dashed commands
     (wang via cmccabe)
 
+    HDFS-5562. TestCacheDirectives and TestFsDatasetCache should stub out
+    native mlock. (Colin McCabe and Akira Ajisaka via wang)
+
 Release 2.3.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -673,7 +673,7 @@ public class DataNode extends Configured
     this.dnConf = new DNConf(conf);
 
     if (dnConf.maxLockedMemory > 0) {
-      if (!NativeIO.isAvailable()) {
+      if (!NativeIO.POSIX.getCacheManipulator().verifyCanMlock()) {
         throw new RuntimeException(String.format(
             "Cannot start datanode because the configured max locked memory" +
             " size (%s) is greater than zero and native code is not available.",

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java

@@ -113,6 +113,9 @@ public class TestFsDatasetCache {
     conf.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);
     conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_CACHING_ENABLED_KEY, true);
 
+    prevCacheManipulator = NativeIO.POSIX.getCacheManipulator();
+    NativeIO.POSIX.setCacheManipulator(new NoMlockCacheManipulator());
+
     cluster = new MiniDFSCluster.Builder(conf)
         .numDataNodes(1).build();
     cluster.waitActive();
@@ -125,8 +128,6 @@ public class TestFsDatasetCache {
 
     spyNN = DataNodeTestUtils.spyOnBposToNN(dn, nn);
 
-    prevCacheManipulator = NativeIO.POSIX.getCacheManipulator();
-    NativeIO.POSIX.setCacheManipulator(new NoMlockCacheManipulator());
   }
 
   @After