From b76b36ebbc2fb2137d0b8e30cac212808fd5ca9f Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Mon, 12 Oct 2020 14:22:44 -0700 Subject: [PATCH] HDFS-15625: Namenode trashEmptier should not init ViewFs on startup (#2378). Contributed by Uma Maheswara Rao G. --- .../org/apache/hadoop/hdfs/server/namenode/NameNode.java | 5 ++++- .../viewfs/TestNNStartupWhenViewFSOverloadSchemeEnabled.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index e58072a7a7..461f676ba6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -41,6 +41,7 @@ import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtilClient; +import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.HAUtil; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; @@ -927,7 +928,9 @@ private void startTrashEmptier(final Configuration conf) throws IOException { new PrivilegedExceptionAction() { @Override public FileSystem run() throws IOException { - return FileSystem.get(conf); + FileSystem dfs = new DistributedFileSystem(); + dfs.initialize(FileSystem.getDefaultUri(conf), conf); + return dfs; } }); this.emptier = new Thread(new Trash(fs, conf).getEmptier(), "Trash Emptier"); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestNNStartupWhenViewFSOverloadSchemeEnabled.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestNNStartupWhenViewFSOverloadSchemeEnabled.java index 9d394c0049..bbdbd5a0b0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestNNStartupWhenViewFSOverloadSchemeEnabled.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestNNStartupWhenViewFSOverloadSchemeEnabled.java @@ -60,7 +60,7 @@ public static void setUp() { @Test(timeout = 30000) public void testHANameNodeAndDataNodeStartup() throws Exception { cluster = new MiniDFSCluster.Builder(CONF) - .nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(1) + .nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(0) .waitSafeMode(false).build(); cluster.waitActive(); cluster.transitionToActive(0); @@ -73,7 +73,7 @@ public void testHANameNodeAndDataNodeStartup() throws Exception { @Test(timeout = 30000) public void testNameNodeAndDataNodeStartup() throws Exception { cluster = - new MiniDFSCluster.Builder(CONF).numDataNodes(1).waitSafeMode(false) + new MiniDFSCluster.Builder(CONF).numDataNodes(0).waitSafeMode(false) .build(); cluster.waitActive(); }