From 61f1d9735bed20ad3b9b3b405671689c4c1d6a7f Mon Sep 17 00:00:00 2001 From: tedyu Date: Mon, 12 Nov 2018 17:02:45 -0800 Subject: [PATCH] HBASE-21466 WALProcedureStore uses wrong FileSystem if wal.dir is not under rootdir --- .../hbase/procedure2/store/wal/WALProcedureStore.java | 5 +++-- .../master/procedure/TestMasterProcedureEvents.java | 9 ++++++++- .../master/procedure/TestWALProcedureStoreOnHDFS.java | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java index 39ad939b2da..1b1018e82cf 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java @@ -248,8 +248,9 @@ public class WALProcedureStore extends ProcedureStoreBase { this.leaseRecovery = leaseRecovery; this.walDir = walDir; this.walArchiveDir = walArchiveDir; - this.fs = walDir.getFileSystem(conf); - this.enforceStreamCapability = conf.getBoolean(CommonFSUtils.UNSAFE_STREAM_CAPABILITY_ENFORCE, true); + this.fs = CommonFSUtils.getWALFileSystem(conf); + this.enforceStreamCapability = conf.getBoolean(CommonFSUtils.UNSAFE_STREAM_CAPABILITY_ENFORCE, + true); // Create the log directory for the procedure store if (!fs.exists(walDir)) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java index a56e842adb0..947beed8493 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java @@ -19,7 +19,10 @@ package org.apache.hadoop.hbase.master.procedure; import static org.junit.Assert.assertEquals; +import java.io.IOException; + import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.TableName; @@ -36,6 +39,7 @@ import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.CommonFSUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -61,14 +65,17 @@ public class TestMasterProcedureEvents { @Rule public TestName name = new TestName(); - private static void setupConf(Configuration conf) { + private static void setupConf(Configuration conf) throws IOException { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); conf.setBoolean(WALProcedureStore.USE_HSYNC_CONF_KEY, false); } @BeforeClass public static void setupCluster() throws Exception { + Configuration conf = UTIL.getConfiguration(); setupConf(UTIL.getConfiguration()); + UTIL.startMiniDFSCluster(3); + CommonFSUtils.setWALRootDir(conf, new Path(conf.get("fs.defaultFS"), "/tmp/wal")); UTIL.startMiniCluster(2); UTIL.waitUntilNoRegionsInTransition(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java index 6f619166ac5..c0ee24d2847 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java @@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.procedure2.store.ProcedureStore; import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.MasterTests; +import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.server.datanode.DataNode; @@ -82,10 +83,12 @@ public class TestWALProcedureStoreOnHDFS { // No @Before because some tests need to do additional config first private void setupDFS() throws Exception { + Configuration conf = UTIL.getConfiguration(); MiniDFSCluster dfs = UTIL.startMiniDFSCluster(3); + CommonFSUtils.setWALRootDir(conf, new Path(conf.get("fs.defaultFS"), "/tmp/wal")); Path logDir = new Path(new Path(dfs.getFileSystem().getUri()), "/test-logs"); - store = ProcedureTestingUtility.createWalStore(UTIL.getConfiguration(), logDir); + store = ProcedureTestingUtility.createWalStore(conf, logDir); store.registerListener(stopProcedureListener); store.start(8); store.recoverLease();