diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java index e0b5b85a90..c0ad4eceb1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java @@ -34,8 +34,8 @@ import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver; import org.apache.hadoop.hdfs.server.federation.resolver.MembershipNamenodeResolver; import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver; -import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileImpl; import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreSerializerPBImpl; +import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreZooKeeperImpl; import org.apache.hadoop.http.HttpConfig; /** @@ -1275,7 +1275,7 @@ public class DFSConfigKeys extends CommonConfigurationKeys { public static final String FEDERATION_STORE_DRIVER_CLASS = FEDERATION_STORE_PREFIX + "driver.class"; public static final Class - FEDERATION_STORE_DRIVER_CLASS_DEFAULT = StateStoreFileImpl.class; + FEDERATION_STORE_DRIVER_CLASS_DEFAULT = StateStoreZooKeeperImpl.class; public static final String FEDERATION_STORE_CONNECTION_TEST_MS = FEDERATION_STORE_PREFIX + "connection.test"; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml index 59df122ffb..f6d232eb01 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml @@ -5085,9 +5085,15 @@ dfs.federation.router.store.driver.class - org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileImpl + org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreZooKeeperImpl - Class to implement the State Store. By default it uses the local disk. + Class to implement the State Store. There are three implementation classes currently + being supported: + org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileImpl, + org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileSystemImpl and + org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreZooKeeperImpl. + These implementation classes use the local file, filesystem and ZooKeeper as a backend respectively. + By default it uses the ZooKeeper as the default State Store. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSRouterFederation.md b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSRouterFederation.md index 564975586a..ebe94a05db 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSRouterFederation.md +++ b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSRouterFederation.md @@ -325,7 +325,7 @@ The connection to the State Store and the internal caching at the Router. |:---- |:---- |:---- | | dfs.federation.router.store.enable | `true` | If `true`, the Router connects to the State Store. | | dfs.federation.router.store.serializer | `StateStoreSerializerPBImpl` | Class to serialize State Store records. | -| dfs.federation.router.store.driver.class | `StateStoreZKImpl` | Class to implement the State Store. | +| dfs.federation.router.store.driver.class | `StateStoreZooKeeperImpl` | Class to implement the State Store. | | dfs.federation.router.store.connection.test | 60000 | How often to check for the connection to the State Store in milliseconds. | | dfs.federation.router.cache.ttl | 60000 | How often to refresh the State Store caches in milliseconds. | | dfs.federation.router.store.membership.expiration | 300000 | Expiration time in milliseconds for a membership record. | diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/RouterConfigBuilder.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/RouterConfigBuilder.java index 3659bf9950..b332f1f4a5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/RouterConfigBuilder.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/RouterConfigBuilder.java @@ -19,6 +19,8 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.DFSConfigKeys; +import org.apache.hadoop.hdfs.server.federation.store.FederationStateStoreTestUtils; +import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver; /** * Constructs a router configuration with individual features enabled/disabled. @@ -119,6 +121,10 @@ public RouterConfigBuilder heartbeat() { } public RouterConfigBuilder stateStore() { + // reset the State Store driver implementation class for testing + conf.setClass(DFSConfigKeys.FEDERATION_STORE_DRIVER_CLASS, + FederationStateStoreTestUtils.getTestDriverClass(), + StateStoreDriver.class); return this.stateStore(true); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/store/FederationStateStoreTestUtils.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/store/FederationStateStoreTestUtils.java index dbb8f3f239..def3935799 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/store/FederationStateStoreTestUtils.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/store/FederationStateStoreTestUtils.java @@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.server.federation.resolver.FederationNamenodeServiceState; import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver; import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileBaseImpl; +import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreFileImpl; import org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord; import org.apache.hadoop.hdfs.server.federation.store.records.MembershipState; import org.apache.hadoop.hdfs.server.federation.store.records.MembershipStats; @@ -50,17 +51,21 @@ */ public final class FederationStateStoreTestUtils { + /** The State Store Driver implementation class for testing .*/ + private static final Class + FEDERATION_STORE_DRIVER_CLASS_FOR_TEST = StateStoreFileImpl.class; + private FederationStateStoreTestUtils() { // Utility Class } /** - * Get the default State Store driver implementation. + * Get the State Store driver implementation for testing. * - * @return Class of the default State Store driver implementation. + * @return Class of the State Store driver implementation. */ - public static Class getDefaultDriver() { - return DFSConfigKeys.FEDERATION_STORE_DRIVER_CLASS_DEFAULT; + public static Class getTestDriverClass() { + return FEDERATION_STORE_DRIVER_CLASS_FOR_TEST; } /** @@ -69,7 +74,7 @@ public static Class getDefaultDriver() { * @return State Store configuration. */ public static Configuration getStateStoreConfiguration() { - Class clazz = getDefaultDriver(); + Class clazz = getTestDriverClass(); return getStateStoreConfiguration(clazz); } @@ -146,7 +151,7 @@ public static void waitStateStore(StateStoreService stateStore, * @throws IOException */ public static void deleteStateStore() throws IOException { - Class driverClass = getDefaultDriver(); + Class driverClass = getTestDriverClass(); deleteStateStore(driverClass); }