From bb11d47758a7e5845ceb196a936fbad1814faf07 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 28 Nov 2013 00:44:54 +0000 Subject: [PATCH] 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 --- .../main/java/org/apache/hadoop/io/nativeio/NativeIO.java | 8 ++++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 2 +- .../hadoop/hdfs/server/datanode/TestFsDatasetCache.java | 5 +++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java index c7eeb1c396..7ea7e59151 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java @@ -142,6 +142,10 @@ public void posixFadviseIfPossible(String identifier, NativeIO.POSIX.posixFadviseIfPossible(identifier, fd, offset, len, flags); } + + public boolean verifyCanMlock() { + return NativeIO.isAvailable(); + } } /** @@ -163,6 +167,10 @@ public long getMemlockLimit() { public long getOperatingSystemPageSize() { return 4096; } + + public boolean verifyCanMlock() { + return true; + } } static { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 527b659fe7..d44113b9f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index d146b51b83..a4834f2828 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -673,7 +673,7 @@ void startDataNode(Configuration conf, 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.", diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java index d439fab6aa..7c5ab7dbd5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java @@ -113,6 +113,9 @@ public void setUp() throws Exception { 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 void setUp() throws Exception { spyNN = DataNodeTestUtils.spyOnBposToNN(dn, nn); - prevCacheManipulator = NativeIO.POSIX.getCacheManipulator(); - NativeIO.POSIX.setCacheManipulator(new NoMlockCacheManipulator()); } @After