diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java index 07bcb0ee49b..0118eab8e27 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java @@ -82,7 +82,6 @@ public class WALFactory { static final String DEFAULT_WAL_PROVIDER = Providers.defaultProvider.name(); public static final String META_WAL_PROVIDER = "hbase.wal.meta_provider"; - static final String DEFAULT_META_WAL_PROVIDER = Providers.defaultProvider.name(); final String factoryId; private final WALProvider provider; @@ -237,14 +236,15 @@ public class WALFactory { return provider.getWALs(); } - private WALProvider getMetaProvider() throws IOException { + @VisibleForTesting + WALProvider getMetaProvider() throws IOException { for (;;) { WALProvider provider = this.metaProvider.get(); if (provider != null) { return provider; } - provider = getProvider(META_WAL_PROVIDER, DEFAULT_META_WAL_PROVIDER, - AbstractFSWALProvider.META_WAL_PROVIDER_ID); + provider = getProvider(META_WAL_PROVIDER, conf.get(WAL_PROVIDER, DEFAULT_WAL_PROVIDER), + AbstractFSWALProvider.META_WAL_PROVIDER_ID); if (metaProvider.compareAndSet(null, provider)) { return provider; } else { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestShutdownWhileWALBroken.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestShutdownWhileWALBroken.java index 6c9b5e358c8..f1b090d4a6c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestShutdownWhileWALBroken.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestShutdownWhileWALBroken.java @@ -116,7 +116,6 @@ public class TestShutdownWhileWALBroken { UTIL.getConfiguration().setClass(HConstants.REGION_SERVER_IMPL, MyRegionServer.class, HRegionServer.class); UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, walType); - UTIL.getConfiguration().set(WALFactory.META_WAL_PROVIDER, walType); UTIL.startMiniCluster(2); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java index 992e6a52410..8afae061be4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java @@ -48,7 +48,6 @@ public class TestAsyncLogRolling extends AbstractTestLogRolling { Configuration conf = TestAsyncLogRolling.TEST_UTIL.getConfiguration(); conf.setInt(FanOutOneBlockAsyncDFSOutputHelper.ASYNC_DFS_OUTPUT_CREATE_MAX_RETRIES, 100); conf.set(WALFactory.WAL_PROVIDER, "asyncfs"); - conf.set(WALFactory.META_WAL_PROVIDER, "asyncfs"); AbstractTestLogRolling.setUpBeforeClass(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java index f3cf2bfe643..e19361e2003 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java @@ -90,7 +90,6 @@ public class TestLogRolling extends AbstractTestLogRolling { conf.setInt("hbase.regionserver.hlog.tolerable.lowreplication", 2); conf.setInt("hbase.regionserver.hlog.lowreplication.rolllimit", 3); conf.set(WALFactory.WAL_PROVIDER, "filesystem"); - conf.set(WALFactory.META_WAL_PROVIDER, "filesystem"); AbstractTestLogRolling.setUpBeforeClass(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java index fd2b3c49856..ac1bfc99d4a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase.wal; +import static org.apache.hadoop.hbase.wal.WALFactory.META_WAL_PROVIDER; +import static org.apache.hadoop.hbase.wal.WALFactory.WAL_PROVIDER; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -673,4 +675,33 @@ public class TestWALFactory { increments++; } } + + @Test + public void testWALProviders() throws IOException { + Configuration conf = new Configuration(); + WALFactory walFactory = new WALFactory(conf, this.currentServername.toString()); + assertEquals(walFactory.getWALProvider().getClass(), walFactory.getMetaProvider().getClass()); + } + + @Test + public void testOnlySetWALProvider() throws IOException { + Configuration conf = new Configuration(); + conf.set(WAL_PROVIDER, WALFactory.Providers.multiwal.name()); + WALFactory walFactory = new WALFactory(conf, this.currentServername.toString()); + + assertEquals(WALFactory.Providers.multiwal.clazz, walFactory.getWALProvider().getClass()); + assertEquals(WALFactory.Providers.multiwal.clazz, walFactory.getMetaProvider().getClass()); + } + + @Test + public void testOnlySetMetaWALProvider() throws IOException { + Configuration conf = new Configuration(); + conf.set(META_WAL_PROVIDER, WALFactory.Providers.asyncfs.name()); + WALFactory walFactory = new WALFactory(conf, this.currentServername.toString()); + + assertEquals(WALFactory.Providers.defaultProvider.clazz, + walFactory.getWALProvider().getClass()); + assertEquals(WALFactory.Providers.asyncfs.clazz, walFactory.getMetaProvider().getClass()); + } + } diff --git a/src/main/asciidoc/_chapters/architecture.adoc b/src/main/asciidoc/_chapters/architecture.adoc index 19a700a1207..5f215e54455 100644 --- a/src/main/asciidoc/_chapters/architecture.adoc +++ b/src/main/asciidoc/_chapters/architecture.adoc @@ -1043,7 +1043,8 @@ In HBase, there are a number of WAL imlementations (or 'Providers'). Each is kno by a short name label (that unfortunately is not always descriptive). You set the provider in _hbase-site.xml_ passing the WAL provder short-name as the value on the _hbase.wal.provider_ property (Set the provider for _hbase:meta_ using the -_hbase.wal.meta_provider_ property). +_hbase.wal.meta_provider_ property, otherwise it uses the same provider configured +by _hbase.wal.provider_). * _asyncfs_: The *default*. New since hbase-2.0.0 (HBASE-15536, HBASE-14790). This _AsyncFSWAL_ provider, as it identifies itself in RegionServer logs, is built on a new non-blocking dfsclient implementation. It is currently resident in the hbase codebase but intent is to move it back up into HDFS itself. WALs edits are written concurrently ("fan-out") style to each of the WAL-block replicas on each DataNode rather than in a chained pipeline as the default client does. Latencies should be better. See link:https://www.slideshare.net/HBaseCon/apache-hbase-improvements-and-practices-at-xiaomi[Apache HBase Improements and Practices at Xiaomi] at slide 14 onward for more detail on implementation. * _filesystem_: This was the default in hbase-1.x releases. It is built on the blocking _DFSClient_ and writes to replicas in classic _DFSCLient_ pipeline mode. In logs it identifies as _FSHLog_ or _FSHLogProvider_.