This is an automated email from the ASF dual-hosted git repository. ndimiduk pushed a commit to branch HBASE-18095/client-locate-meta-no-zookeeper in repository https://gitbox.apache.org/repos/asf/hbase.git
commit e2a9f11f601f2f8c47d513cccc9102d13aaafba9 Author: Bharath Vissapragada <bhara...@apache.org> AuthorDate: Fri Jan 3 14:27:01 2020 -0800 HBASE-23604: Clarify AsyncRegistry usage in the code. (#957) * HBASE-23604: Cleanup AsyncRegistry interface - Cleans up the method names to make more sense and adds a little more javadocs for context. In future patches we can revisit the name of the actual class to make it more self explanatory. - Does AsyncRegistry -> ConnectionRegistry rename. "async" ness of the registry is kind of implicit based on the interface contents and need not be reflected in the name. Signed-off-by: Nick Dimiduk <ndimi...@apache.org> Signed-off-by: stack <st...@apache.org> Signed-off-by: Viraj Jasani <vjas...@apache.org> --- .../hadoop/hbase/client/AsyncConnectionImpl.java | 11 ++++++----- .../hbase/client/AsyncMetaRegionLocator.java | 6 +++--- .../hbase/client/AsyncTableRegionLocatorImpl.java | 2 +- .../hadoop/hbase/client/ConnectionFactory.java | 2 +- ...{AsyncRegistry.java => ConnectionRegistry.java} | 13 +++++++------ ...Factory.java => ConnectionRegistryFactory.java} | 22 ++++++++++++---------- .../hadoop/hbase/client/RawAsyncHBaseAdmin.java | 17 +++++++++-------- ...syncRegistry.java => ZKConnectionRegistry.java} | 18 +++++++++--------- ...istry.java => DoNothingConnectionRegistry.java} | 8 ++++---- .../hbase/client/TestAsyncAdminRpcPriority.java | 2 +- .../client/TestAsyncMetaRegionLocatorFailFast.java | 10 +++++----- .../hbase/client/TestAsyncTableRpcPriority.java | 2 +- ...ryLeak.java => TestConnectionRegistryLeak.java} | 14 +++++++------- .../hbase/client/AsyncClusterConnectionImpl.java | 4 ++-- .../hbase/client/ClusterConnectionFactory.java | 2 +- .../example/TestZooKeeperTableArchiveClient.java | 18 +++++++++++------- .../hbase/client/AbstractTestRegionLocator.java | 3 ++- ...cRegistry.java => DummyConnectionRegistry.java} | 11 ++++++----- .../hbase/client/RegionReplicaTestHelper.java | 6 +++--- .../client/TestAsyncAdminWithRegionReplicas.java | 3 ++- .../hbase/client/TestAsyncMetaRegionLocator.java | 4 ++-- .../client/TestAsyncNonMetaRegionLocator.java | 3 ++- ...stAsyncNonMetaRegionLocatorConcurrenyLimit.java | 3 ++- .../hbase/client/TestAsyncRegionLocator.java | 3 ++- .../TestAsyncSingleRequestRpcRetryingCaller.java | 3 ++- .../client/TestAsyncTableUseMetaReplicas.java | 2 +- .../hbase/client/TestMetaRegionLocationCache.java | 4 ++-- ...Registry.java => TestZKConnectionRegistry.java} | 20 ++++++++++---------- .../regionserver/TestWALEntrySinkFilter.java | 19 ++++++++----------- 29 files changed, 124 insertions(+), 111 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java index 78fad9e..9d90249 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java @@ -85,7 +85,7 @@ class AsyncConnectionImpl implements AsyncConnection { private final User user; - final AsyncRegistry registry; + final ConnectionRegistry registry; private final int rpcTimeout; @@ -122,7 +122,7 @@ class AsyncConnectionImpl implements AsyncConnection { private volatile ConnectionOverAsyncConnection conn; - public AsyncConnectionImpl(Configuration conf, AsyncRegistry registry, String clusterId, + public AsyncConnectionImpl(Configuration conf, ConnectionRegistry registry, String clusterId, SocketAddress localAddress, User user) { this.conf = conf; this.user = user; @@ -136,7 +136,8 @@ class AsyncConnectionImpl implements AsyncConnection { } else { this.metrics = Optional.empty(); } - this.rpcClient = RpcClientFactory.createClient(conf, clusterId, localAddress, metrics.orElse(null)); + this.rpcClient = RpcClientFactory.createClient( + conf, clusterId, localAddress, metrics.orElse(null)); this.rpcControllerFactory = RpcControllerFactory.instantiate(conf); this.hostnameCanChange = conf.getBoolean(RESOLVE_HOSTNAME_ON_FAIL_KEY, true); this.rpcTimeout = @@ -257,7 +258,7 @@ class AsyncConnectionImpl implements AsyncConnection { CompletableFuture<MasterService.Interface> getMasterStub() { return ConnectionUtils.getOrFetch(masterStub, masterStubMakeFuture, false, () -> { CompletableFuture<MasterService.Interface> future = new CompletableFuture<>(); - addListener(registry.getMasterAddress(), (addr, error) -> { + addListener(registry.getActiveMaster(), (addr, error) -> { if (error != null) { future.completeExceptionally(error); } else if (addr == null) { @@ -368,7 +369,7 @@ class AsyncConnectionImpl implements AsyncConnection { @Override public CompletableFuture<Hbck> getHbck() { CompletableFuture<Hbck> future = new CompletableFuture<>(); - addListener(registry.getMasterAddress(), (sn, error) -> { + addListener(registry.getActiveMaster(), (sn, error) -> { if (error != null) { future.completeExceptionally(error); } else { diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java index e920636..3571f960 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncMetaRegionLocator.java @@ -38,14 +38,14 @@ import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesti @InterfaceAudience.Private class AsyncMetaRegionLocator { - private final AsyncRegistry registry; + private final ConnectionRegistry registry; private final AtomicReference<RegionLocations> metaRegionLocations = new AtomicReference<>(); private final AtomicReference<CompletableFuture<RegionLocations>> metaRelocateFuture = new AtomicReference<>(); - AsyncMetaRegionLocator(AsyncRegistry registry) { + AsyncMetaRegionLocator(ConnectionRegistry registry) { this.registry = registry; } @@ -60,7 +60,7 @@ class AsyncMetaRegionLocator { */ CompletableFuture<RegionLocations> getRegionLocations(int replicaId, boolean reload) { return ConnectionUtils.getOrFetch(metaRegionLocations, metaRelocateFuture, reload, - registry::getMetaRegionLocation, locs -> isGood(locs, replicaId), "meta region location"); + registry::getMetaRegionLocations, locs -> isGood(locs, replicaId), "meta region location"); } private HRegionLocation getCacheLocation(HRegionLocation loc) { diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java index 0e116ab..fa3ea1c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java @@ -55,7 +55,7 @@ class AsyncTableRegionLocatorImpl implements AsyncTableRegionLocator { @Override public CompletableFuture<List<HRegionLocation>> getAllRegionLocations() { if (TableName.isMetaTableName(tableName)) { - return conn.registry.getMetaRegionLocation() + return conn.registry.getMetaRegionLocations() .thenApply(locs -> Arrays.asList(locs.getRegionLocations())); } return AsyncMetaTableAccessor.getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME), diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java index 2b432e4..027b898 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java @@ -279,7 +279,7 @@ public class ConnectionFactory { public static CompletableFuture<AsyncConnection> createAsyncConnection(Configuration conf, final User user) { CompletableFuture<AsyncConnection> future = new CompletableFuture<>(); - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(conf); + ConnectionRegistry registry = ConnectionRegistryFactory.getRegistry(conf); addListener(registry.getClusterId(), (clusterId, error) -> { if (error != null) { registry.close(); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistry.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistry.java similarity index 77% rename from hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistry.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistry.java index 9537777..cd22d78 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistry.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistry.java @@ -24,16 +24,17 @@ import org.apache.hadoop.hbase.ServerName; import org.apache.yetus.audience.InterfaceAudience; /** - * Implementations hold cluster information such as this cluster's id, location of hbase:meta, etc.. + * Registry for meta information needed for connection setup to a HBase cluster. Implementations + * hold cluster information such as this cluster's id, location of hbase:meta, etc.. * Internal use only. */ @InterfaceAudience.Private -interface AsyncRegistry extends Closeable { +interface ConnectionRegistry extends Closeable { /** - * Get the location of meta region. + * Get the location of meta region(s). */ - CompletableFuture<RegionLocations> getMetaRegionLocation(); + CompletableFuture<RegionLocations> getMetaRegionLocations(); /** * Should only be called once. @@ -43,9 +44,9 @@ interface AsyncRegistry extends Closeable { CompletableFuture<String> getClusterId(); /** - * Get the address of HMaster. + * Get the address of active HMaster. */ - CompletableFuture<ServerName> getMasterAddress(); + CompletableFuture<ServerName> getActiveMaster(); /** * Closes this instance and releases any system resources associated with it diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistryFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistryFactory.java similarity index 66% rename from hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistryFactory.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistryFactory.java index 28726ae..80d358b 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegistryFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistryFactory.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,26 +18,28 @@ package org.apache.hadoop.hbase.client; import org.apache.hadoop.conf.Configuration; -import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.util.ReflectionUtils; +import org.apache.yetus.audience.InterfaceAudience; /** - * Get instance of configured Registry. + * Factory class to get the instance of configured connection registry. */ @InterfaceAudience.Private -final class AsyncRegistryFactory { +final class ConnectionRegistryFactory { - static final String REGISTRY_IMPL_CONF_KEY = "hbase.client.registry.impl"; + static final String CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY = + "hbase.client.connection.registry.impl"; - private AsyncRegistryFactory() { + private ConnectionRegistryFactory() { } /** - * @return The cluster registry implementation to use. + * @return The connection registry implementation to use. */ - static AsyncRegistry getRegistry(Configuration conf) { - Class<? extends AsyncRegistry> clazz = - conf.getClass(REGISTRY_IMPL_CONF_KEY, ZKAsyncRegistry.class, AsyncRegistry.class); + static ConnectionRegistry getRegistry(Configuration conf) { + Class<? extends ConnectionRegistry> clazz = conf.getClass( + CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionRegistry.class, + ConnectionRegistry.class); return ReflectionUtils.newInstance(clazz, conf); } } diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java index 4a349d5..75324c9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java @@ -709,7 +709,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { @Override public CompletableFuture<Boolean> isTableAvailable(TableName tableName) { if (TableName.isMetaTableName(tableName)) { - return connection.registry.getMetaRegionLocation().thenApply(locs -> Stream + return connection.registry.getMetaRegionLocations().thenApply(locs -> Stream .of(locs.getRegionLocations()).allMatch(loc -> loc != null && loc.getServerName() != null)); } CompletableFuture<Boolean> future = new CompletableFuture<>(); @@ -847,7 +847,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { @Override public CompletableFuture<List<RegionInfo>> getRegions(TableName tableName) { if (tableName.equals(META_TABLE_NAME)) { - return connection.registry.getMetaRegionLocation() + return connection.registry.getMetaRegionLocations() .thenApply(locs -> Stream.of(locs.getRegionLocations()).map(HRegionLocation::getRegion) .collect(Collectors.toList())); } else { @@ -1075,8 +1075,9 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { if (TableName.META_TABLE_NAME.equals(tableName)) { CompletableFuture<List<HRegionLocation>> future = new CompletableFuture<>(); // For meta table, we use zk to fetch all locations. - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(connection.getConfiguration()); - addListener(registry.getMetaRegionLocation(), (metaRegions, err) -> { + ConnectionRegistry registry = ConnectionRegistryFactory.getRegistry( + connection.getConfiguration()); + addListener(registry.getMetaRegionLocations(), (metaRegions, err) -> { if (err != null) { future.completeExceptionally(err); } else if (metaRegions == null || metaRegions.isEmpty() || @@ -1104,7 +1105,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { switch (compactType) { case MOB: - addListener(connection.registry.getMasterAddress(), (serverName, err) -> { + addListener(connection.registry.getActiveMaster(), (serverName, err) -> { if (err != null) { future.completeExceptionally(err); return; @@ -2343,7 +2344,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { String encodedName = Bytes.toString(regionNameOrEncodedRegionName); if (encodedName.length() < RegionInfo.MD5_HEX_LENGTH) { // old format encodedName, should be meta region - future = connection.registry.getMetaRegionLocation() + future = connection.registry.getMetaRegionLocations() .thenApply(locs -> Stream.of(locs.getRegionLocations()) .filter(loc -> loc.getRegion().getEncodedName().equals(encodedName)).findFirst()); } else { @@ -2354,7 +2355,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { RegionInfo regionInfo = MetaTableAccessor.parseRegionInfoFromRegionName(regionNameOrEncodedRegionName); if (regionInfo.isMetaRegion()) { - future = connection.registry.getMetaRegionLocation() + future = connection.registry.getMetaRegionLocations() .thenApply(locs -> Stream.of(locs.getRegionLocations()) .filter(loc -> loc.getRegion().getReplicaId() == regionInfo.getReplicaId()) .findFirst()); @@ -2927,7 +2928,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin { switch (compactType) { case MOB: - addListener(connection.registry.getMasterAddress(), (serverName, err) -> { + addListener(connection.registry.getActiveMaster(), (serverName, err) -> { if (err != null) { future.completeExceptionally(err); return; diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKConnectionRegistry.java similarity index 92% rename from hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java rename to hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKConnectionRegistry.java index 08e3846..3abfc9f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKAsyncRegistry.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZKConnectionRegistry.java @@ -50,15 +50,15 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos; * Zookeeper based registry implementation. */ @InterfaceAudience.Private -class ZKAsyncRegistry implements AsyncRegistry { +class ZKConnectionRegistry implements ConnectionRegistry { - private static final Logger LOG = LoggerFactory.getLogger(ZKAsyncRegistry.class); + private static final Logger LOG = LoggerFactory.getLogger(ZKConnectionRegistry.class); private final ReadOnlyZKClient zk; private final ZNodePaths znodePaths; - ZKAsyncRegistry(Configuration conf) { + ZKConnectionRegistry(Configuration conf) { this.znodePaths = new ZNodePaths(conf); this.zk = new ReadOnlyZKClient(conf); } @@ -93,7 +93,7 @@ class ZKAsyncRegistry implements AsyncRegistry { @Override public CompletableFuture<String> getClusterId() { - return getAndConvert(znodePaths.clusterIdZNode, ZKAsyncRegistry::getClusterId); + return getAndConvert(znodePaths.clusterIdZNode, ZKConnectionRegistry::getClusterId); } @VisibleForTesting @@ -144,7 +144,7 @@ class ZKAsyncRegistry implements AsyncRegistry { int replicaId = znodePaths.getMetaReplicaIdFromZnode(metaReplicaZNode); String path = ZNodePaths.joinZNode(znodePaths.baseZNode, metaReplicaZNode); if (replicaId == DEFAULT_REPLICA_ID) { - addListener(getAndConvert(path, ZKAsyncRegistry::getMetaProto), (proto, error) -> { + addListener(getAndConvert(path, ZKConnectionRegistry::getMetaProto), (proto, error) -> { if (error != null) { future.completeExceptionally(error); return; @@ -162,7 +162,7 @@ class ZKAsyncRegistry implements AsyncRegistry { tryComplete(remaining, locs, future); }); } else { - addListener(getAndConvert(path, ZKAsyncRegistry::getMetaProto), (proto, error) -> { + addListener(getAndConvert(path, ZKConnectionRegistry::getMetaProto), (proto, error) -> { if (future.isDone()) { return; } @@ -191,7 +191,7 @@ class ZKAsyncRegistry implements AsyncRegistry { } @Override - public CompletableFuture<RegionLocations> getMetaRegionLocation() { + public CompletableFuture<RegionLocations> getMetaRegionLocations() { CompletableFuture<RegionLocations> future = new CompletableFuture<>(); addListener( zk.list(znodePaths.baseZNode) @@ -217,8 +217,8 @@ class ZKAsyncRegistry implements AsyncRegistry { } @Override - public CompletableFuture<ServerName> getMasterAddress() { - return getAndConvert(znodePaths.masterAddressZNode, ZKAsyncRegistry::getMasterProto) + public CompletableFuture<ServerName> getActiveMaster() { + return getAndConvert(znodePaths.masterAddressZNode, ZKConnectionRegistry::getMasterProto) .thenApply(proto -> { if (proto == null) { return null; diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingAsyncRegistry.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingConnectionRegistry.java similarity index 89% rename from hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingAsyncRegistry.java rename to hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingConnectionRegistry.java index 8c7b073..4bd6687 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingAsyncRegistry.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/DoNothingConnectionRegistry.java @@ -27,13 +27,13 @@ import org.apache.yetus.audience.InterfaceAudience; * Registry that does nothing. Otherwise, default Registry wants zookeeper up and running. */ @InterfaceAudience.Private -class DoNothingAsyncRegistry implements AsyncRegistry { +class DoNothingConnectionRegistry implements ConnectionRegistry { - public DoNothingAsyncRegistry(Configuration conf) { + public DoNothingConnectionRegistry(Configuration conf) { } @Override - public CompletableFuture<RegionLocations> getMetaRegionLocation() { + public CompletableFuture<RegionLocations> getMetaRegionLocations() { return CompletableFuture.completedFuture(null); } @@ -43,7 +43,7 @@ class DoNothingAsyncRegistry implements AsyncRegistry { } @Override - public CompletableFuture<ServerName> getMasterAddress() { + public CompletableFuture<ServerName> getActiveMaster() { return CompletableFuture.completedFuture(null); } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminRpcPriority.java index d4db7a4..75a9433 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminRpcPriority.java @@ -142,7 +142,7 @@ public class TestAsyncAdminRpcPriority { }).when(adminStub).stopServer(any(HBaseRpcController.class), any(StopServerRequest.class), any()); - conn = new AsyncConnectionImpl(CONF, new DoNothingAsyncRegistry(CONF), "test", null, + conn = new AsyncConnectionImpl(CONF, new DoNothingConnectionRegistry(CONF), "test", null, UserProvider.instantiate(CONF).getCurrent()) { @Override diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocatorFailFast.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocatorFailFast.java index f29c3bf..b306500 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocatorFailFast.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocatorFailFast.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -43,21 +43,21 @@ public class TestAsyncMetaRegionLocatorFailFast { private static AsyncMetaRegionLocator LOCATOR; - private static final class FaultyAsyncRegistry extends DoNothingAsyncRegistry { + private static final class FaultyConnectionRegistry extends DoNothingConnectionRegistry { - public FaultyAsyncRegistry(Configuration conf) { + public FaultyConnectionRegistry(Configuration conf) { super(conf); } @Override - public CompletableFuture<RegionLocations> getMetaRegionLocation() { + public CompletableFuture<RegionLocations> getMetaRegionLocations() { return FutureUtils.failedFuture(new DoNotRetryRegionException("inject error")); } } @BeforeClass public static void setUp() { - LOCATOR = new AsyncMetaRegionLocator(new FaultyAsyncRegistry(CONF)); + LOCATOR = new AsyncMetaRegionLocator(new FaultyConnectionRegistry(CONF)); } @Test(expected = DoNotRetryIOException.class) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index 15429cb..b104798 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -175,7 +175,7 @@ public class TestAsyncTableRpcPriority { return null; } }).when(stub).get(any(HBaseRpcController.class), any(GetRequest.class), any()); - conn = new AsyncConnectionImpl(CONF, new DoNothingAsyncRegistry(CONF), "test", null, + conn = new AsyncConnectionImpl(CONF, new DoNothingConnectionRegistry(CONF), "test", null, UserProvider.instantiate(CONF).getCurrent()) { @Override diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegistryLeak.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionRegistryLeak.java similarity index 83% rename from hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegistryLeak.java rename to hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionRegistryLeak.java index 7c21075..f02ec42 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegistryLeak.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionRegistryLeak.java @@ -38,17 +38,17 @@ import org.junit.Test; import org.junit.experimental.categories.Category; @Category({ ClientTests.class, SmallTests.class }) -public class TestAsyncRegistryLeak { +public class TestConnectionRegistryLeak { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncRegistryLeak.class); + HBaseClassTestRule.forClass(TestConnectionRegistryLeak.class); - public static final class AsyncRegistryForTest extends DoNothingAsyncRegistry { + public static final class ConnectionRegistryForTest extends DoNothingConnectionRegistry { private boolean closed = false; - public AsyncRegistryForTest(Configuration conf) { + public ConnectionRegistryForTest(Configuration conf) { super(conf); CREATED.add(this); } @@ -64,14 +64,14 @@ public class TestAsyncRegistryLeak { } } - private static final List<AsyncRegistryForTest> CREATED = new ArrayList<>(); + private static final List<ConnectionRegistryForTest> CREATED = new ArrayList<>(); private static Configuration CONF = HBaseConfiguration.create(); @BeforeClass public static void setUp() { - CONF.setClass(AsyncRegistryFactory.REGISTRY_IMPL_CONF_KEY, AsyncRegistryForTest.class, - AsyncRegistry.class); + CONF.setClass(ConnectionRegistryFactory.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, + ConnectionRegistryForTest.class, ConnectionRegistry.class); } @Test diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncClusterConnectionImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncClusterConnectionImpl.java index 046ef41..f40f3ac 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncClusterConnectionImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncClusterConnectionImpl.java @@ -50,8 +50,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpeci @InterfaceAudience.Private class AsyncClusterConnectionImpl extends AsyncConnectionImpl implements AsyncClusterConnection { - public AsyncClusterConnectionImpl(Configuration conf, AsyncRegistry registry, String clusterId, - SocketAddress localAddress, User user) { + public AsyncClusterConnectionImpl(Configuration conf, ConnectionRegistry registry, + String clusterId, SocketAddress localAddress, User user) { super(conf, registry, clusterId, localAddress, user); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClusterConnectionFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClusterConnectionFactory.java index 46c0f5a..0094ffa 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClusterConnectionFactory.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClusterConnectionFactory.java @@ -49,7 +49,7 @@ public final class ClusterConnectionFactory { */ public static AsyncClusterConnection createAsyncClusterConnection(Configuration conf, SocketAddress localAddress, User user) throws IOException { - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(conf); + ConnectionRegistry registry = ConnectionRegistryFactory.getRegistry(conf); String clusterId = FutureUtils.get(registry.getClusterId()); Class<? extends AsyncClusterConnection> clazz = conf.getClass(HBASE_SERVER_CLUSTER_CONNECTION_IMPL, AsyncClusterConnectionImpl.class, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java index 0945bc9..e8aa822 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; - import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -40,7 +39,7 @@ import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; -import org.apache.hadoop.hbase.client.DummyAsyncRegistry; +import org.apache.hadoop.hbase.client.DummyConnectionRegistry; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.master.cleaner.BaseHFileCleanerDelegate; import org.apache.hadoop.hbase.master.cleaner.DirScanPool; @@ -92,7 +91,7 @@ public class TestZooKeeperTableArchiveClient { private static RegionServerServices rss; private static DirScanPool POOL; - public static final class MockRegistry extends DummyAsyncRegistry { + public static final class MockRegistry extends DummyConnectionRegistry { public MockRegistry(Configuration conf) { } @@ -110,8 +109,8 @@ public class TestZooKeeperTableArchiveClient { public static void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); UTIL.startMiniZKCluster(); - UTIL.getConfiguration().setClass("hbase.client.registry.impl", MockRegistry.class, - DummyAsyncRegistry.class); + UTIL.getConfiguration().setClass(MockRegistry.REGISTRY_IMPL_CONF_KEY, MockRegistry.class, + DummyConnectionRegistry.class); CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration()); archivingClient = new ZKTableArchiveClient(UTIL.getConfiguration(), CONNECTION); // make hfile archiving node so we can archive files @@ -147,9 +146,13 @@ public class TestZooKeeperTableArchiveClient { @AfterClass public static void cleanupTest() throws Exception { - CONNECTION.close(); + if (CONNECTION != null) { + CONNECTION.close(); + } UTIL.shutdownMiniZKCluster(); - POOL.shutdownNow(); + if (POOL != null) { + POOL.shutdownNow(); + } } /** @@ -353,6 +356,7 @@ public class TestZooKeeperTableArchiveClient { * @throws IOException on failure * @throws KeeperException on failure */ + @SuppressWarnings("checkstyle:EmptyBlock") private List<BaseHFileCleanerDelegate> turnOnArchiving(String tableName, HFileCleaner cleaner) throws IOException, KeeperException { // turn on hfile retention diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestRegionLocator.java index 4668d15..f96daf6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestRegionLocator.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestRegionLocator.java @@ -58,7 +58,8 @@ public abstract class AbstractTestRegionLocator { } UTIL.getAdmin().createTable(td, SPLIT_KEYS); UTIL.waitTableAvailable(TABLE_NAME); - try (AsyncRegistry registry = AsyncRegistryFactory.getRegistry(UTIL.getConfiguration())) { + try (ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(UTIL.getConfiguration())) { RegionReplicaTestHelper.waitUntilAllMetaReplicasHavingRegionLocation(UTIL.getConfiguration(), registry, REGION_REPLICATION); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyAsyncRegistry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyConnectionRegistry.java similarity index 81% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyAsyncRegistry.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyConnectionRegistry.java index 245876e..a669362 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyAsyncRegistry.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/DummyConnectionRegistry.java @@ -23,14 +23,15 @@ import org.apache.hadoop.hbase.ServerName; /** * Can be overridden in UT if you only want to implement part of the methods in - * {@link AsyncRegistry}. + * {@link ConnectionRegistry}. */ -public class DummyAsyncRegistry implements AsyncRegistry { +public class DummyConnectionRegistry implements ConnectionRegistry { - public static final String REGISTRY_IMPL_CONF_KEY = AsyncRegistryFactory.REGISTRY_IMPL_CONF_KEY; + public static final String REGISTRY_IMPL_CONF_KEY = + ConnectionRegistryFactory.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY; @Override - public CompletableFuture<RegionLocations> getMetaRegionLocation() { + public CompletableFuture<RegionLocations> getMetaRegionLocations() { return null; } @@ -40,7 +41,7 @@ public class DummyAsyncRegistry implements AsyncRegistry { } @Override - public CompletableFuture<ServerName> getMasterAddress() { + public CompletableFuture<ServerName> getActiveMaster() { return null; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/RegionReplicaTestHelper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/RegionReplicaTestHelper.java index ba3e74c..73924a3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/RegionReplicaTestHelper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/RegionReplicaTestHelper.java @@ -44,7 +44,7 @@ public final class RegionReplicaTestHelper { // waits for all replicas to have region location static void waitUntilAllMetaReplicasHavingRegionLocation(Configuration conf, - AsyncRegistry registry, int regionReplication) throws IOException { + ConnectionRegistry registry, int regionReplication) throws IOException { Waiter.waitFor(conf, conf.getLong("hbase.client.sync.wait.timeout.msec", 60000), 200, true, new ExplainingPredicate<IOException>() { @Override @@ -55,7 +55,7 @@ public final class RegionReplicaTestHelper { @Override public boolean evaluate() throws IOException { try { - RegionLocations locs = registry.getMetaRegionLocation().get(); + RegionLocations locs = registry.getMetaRegionLocations().get(); if (locs.size() < regionReplication) { return false; } @@ -66,7 +66,7 @@ public final class RegionReplicaTestHelper { } return true; } catch (Exception e) { - TestZKAsyncRegistry.LOG.warn("Failed to get meta region locations", e); + TestZKConnectionRegistry.LOG.warn("Failed to get meta region locations", e); return false; } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminWithRegionReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminWithRegionReplicas.java index 1401afe..6d7d368 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminWithRegionReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncAdminWithRegionReplicas.java @@ -53,7 +53,8 @@ public class TestAsyncAdminWithRegionReplicas extends TestAsyncAdminBase { public static void setUpBeforeClass() throws Exception { TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3); TestAsyncAdminBase.setUpBeforeClass(); - try (AsyncRegistry registry = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration())) { + try (ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration())) { RegionReplicaTestHelper .waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), registry, 3); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java index 1f0d40b..609a129 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java @@ -45,7 +45,7 @@ public class TestAsyncMetaRegionLocator { private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private static AsyncRegistry REGISTRY; + private static ConnectionRegistry REGISTRY; private static AsyncMetaRegionLocator LOCATOR; @@ -54,7 +54,7 @@ public class TestAsyncMetaRegionLocator { TEST_UTIL.getConfiguration().set(BaseLoadBalancer.TABLES_ON_MASTER, "none"); TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3); TEST_UTIL.startMiniCluster(3); - REGISTRY = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + REGISTRY = ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); RegionReplicaTestHelper .waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), REGISTRY, 3); TEST_UTIL.getAdmin().balancerSwitch(false, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java index d1ed5b7..d8388de 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java @@ -79,7 +79,8 @@ public class TestAsyncNonMetaRegionLocator { public static void setUp() throws Exception { TEST_UTIL.startMiniCluster(3); TEST_UTIL.getAdmin().balancerSwitch(false, true); - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); CONN = new AsyncConnectionImpl(TEST_UTIL.getConfiguration(), registry, registry.getClusterId().get(), null, User.getCurrent()); LOCATOR = new AsyncNonMetaRegionLocator(CONN); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocatorConcurrenyLimit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocatorConcurrenyLimit.java index 7e06218..88ab3ad 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocatorConcurrenyLimit.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocatorConcurrenyLimit.java @@ -123,7 +123,8 @@ public class TestAsyncNonMetaRegionLocatorConcurrenyLimit { conf.setInt(MAX_CONCURRENT_LOCATE_REQUEST_PER_TABLE, MAX_ALLOWED); TEST_UTIL.startMiniCluster(3); TEST_UTIL.getAdmin().balancerSwitch(false, true); - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); CONN = new AsyncConnectionImpl(TEST_UTIL.getConfiguration(), registry, registry.getClusterId().get(), null, User.getCurrent()); LOCATOR = new AsyncNonMetaRegionLocator(CONN); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java index a7cf322..753e4f3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java @@ -98,7 +98,8 @@ public class TestAsyncRegionLocator { TEST_UTIL.startMiniCluster(1); TEST_UTIL.createTable(TABLE_NAME, FAMILY); TEST_UTIL.waitTableAvailable(TABLE_NAME); - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); CONN = new AsyncConnectionImpl(TEST_UTIL.getConfiguration(), registry, registry.getClusterId().get(), null, User.getCurrent()); LOCATOR = CONN.getLocator(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSingleRequestRpcRetryingCaller.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSingleRequestRpcRetryingCaller.java index b6e5362..4205012 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSingleRequestRpcRetryingCaller.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSingleRequestRpcRetryingCaller.java @@ -71,7 +71,8 @@ public class TestAsyncSingleRequestRpcRetryingCaller { TEST_UTIL.getAdmin().balancerSwitch(false, true); TEST_UTIL.createTable(TABLE_NAME, FAMILY); TEST_UTIL.waitTableAvailable(TABLE_NAME); - AsyncRegistry registry = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + ConnectionRegistry registry = + ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); CONN = new AsyncConnectionImpl(TEST_UTIL.getConfiguration(), registry, registry.getClusterId().get(), null, User.getCurrent()); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableUseMetaReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableUseMetaReplicas.java index e74d3fa..ed6c66f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableUseMetaReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableUseMetaReplicas.java @@ -92,7 +92,7 @@ public class TestAsyncTableUseMetaReplicas { conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, FailPrimaryMetaScanCp.class.getName()); UTIL.startMiniCluster(3); - try (AsyncRegistry registry = AsyncRegistryFactory.getRegistry(conf)) { + try (ConnectionRegistry registry = ConnectionRegistryFactory.getRegistry(conf)) { RegionReplicaTestHelper.waitUntilAllMetaReplicasHavingRegionLocation(conf, registry, 3); } try (Table table = UTIL.createTable(TABLE_NAME, FAMILY)) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaRegionLocationCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaRegionLocationCache.java index 02236a6..1205b05 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaRegionLocationCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaRegionLocationCache.java @@ -53,13 +53,13 @@ public class TestMetaRegionLocationCache { HBaseClassTestRule.forClass(TestMetaRegionLocationCache.class); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private static AsyncRegistry REGISTRY; + private static ConnectionRegistry REGISTRY; @BeforeClass public static void setUp() throws Exception { TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3); TEST_UTIL.startMiniCluster(3); - REGISTRY = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); + REGISTRY = ConnectionRegistryFactory.getRegistry(TEST_UTIL.getConfiguration()); RegionReplicaTestHelper.waitUntilAllMetaReplicasHavingRegionLocation( TEST_UTIL.getConfiguration(), REGISTRY, 3); TEST_UTIL.getAdmin().balancerSwitch(false, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKConnectionRegistry.java similarity index 89% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKConnectionRegistry.java index 3e4ca94..cb45ee5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKAsyncRegistry.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestZKConnectionRegistry.java @@ -48,16 +48,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Category({ MediumTests.class, ClientTests.class }) -public class TestZKAsyncRegistry { +public class TestZKConnectionRegistry { @ClassRule public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestZKAsyncRegistry.class); + HBaseClassTestRule.forClass(TestZKConnectionRegistry.class); - static final Logger LOG = LoggerFactory.getLogger(TestZKAsyncRegistry.class); + static final Logger LOG = LoggerFactory.getLogger(TestZKConnectionRegistry.class); static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private static ZKAsyncRegistry REGISTRY; + private static ZKConnectionRegistry REGISTRY; @BeforeClass public static void setUp() throws Exception { @@ -67,7 +67,7 @@ public class TestZKAsyncRegistry { // make sure that we do not depend on this config when getting locations for meta replicas, see // HBASE-21658. conf.setInt(META_REPLICAS_NUM, 1); - REGISTRY = new ZKAsyncRegistry(conf); + REGISTRY = new ZKConnectionRegistry(conf); } @AfterClass @@ -84,10 +84,10 @@ public class TestZKAsyncRegistry { assertEquals("Expected " + expectedClusterId + ", found=" + clusterId, expectedClusterId, clusterId); assertEquals(TEST_UTIL.getHBaseCluster().getMaster().getServerName(), - REGISTRY.getMasterAddress().get()); + REGISTRY.getActiveMaster().get()); RegionReplicaTestHelper .waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), REGISTRY, 3); - RegionLocations locs = REGISTRY.getMetaRegionLocation().get(); + RegionLocations locs = REGISTRY.getMetaRegionLocations().get(); assertEquals(3, locs.getRegionLocations().length); IntStream.range(0, 3).forEach(i -> { HRegionLocation loc = locs.getRegionLocation(i); @@ -102,7 +102,7 @@ public class TestZKAsyncRegistry { try (ReadOnlyZKClient zk1 = REGISTRY.getZKClient()) { Configuration otherConf = new Configuration(TEST_UTIL.getConfiguration()); otherConf.set(HConstants.ZOOKEEPER_QUORUM, "127.0.0.1"); - try (ZKAsyncRegistry otherRegistry = new ZKAsyncRegistry(otherConf)) { + try (ZKConnectionRegistry otherRegistry = new ZKConnectionRegistry(otherConf)) { ReadOnlyZKClient zk2 = otherRegistry.getZKClient(); assertNotSame("Using a different configuration / quorum should result in different " + "backing zk connection.", zk1, zk2); @@ -119,9 +119,9 @@ public class TestZKAsyncRegistry { public void testNoMetaAvailable() throws InterruptedException { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); conf.set("zookeeper.znode.metaserver", "whatever"); - try (ZKAsyncRegistry registry = new ZKAsyncRegistry(conf)) { + try (ZKConnectionRegistry registry = new ZKConnectionRegistry(conf)) { try { - registry.getMetaRegionLocation().get(); + registry.getMetaRegionLocations().get(); fail("Should have failed since we set an incorrect meta znode prefix"); } catch (ExecutionException e) { assertThat(e.getCause(), instanceOf(IOException.class)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java index 41d4f46..5e16723 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntrySinkFilter.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.replication.regionserver; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.net.SocketAddress; import java.util.ArrayList; @@ -43,8 +42,8 @@ import org.apache.hadoop.hbase.client.AsyncConnection; import org.apache.hadoop.hbase.client.AsyncTable; import org.apache.hadoop.hbase.client.ClusterConnectionFactory; import org.apache.hadoop.hbase.client.DummyAsyncClusterConnection; -import org.apache.hadoop.hbase.client.DummyAsyncRegistry; import org.apache.hadoop.hbase.client.DummyAsyncTable; +import org.apache.hadoop.hbase.client.DummyConnectionRegistry; import org.apache.hadoop.hbase.client.Row; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.testclassification.ReplicationTests; @@ -57,9 +56,7 @@ import org.junit.experimental.categories.Category; import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.apache.hbase.thirdparty.com.google.protobuf.ByteString; - import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; /** @@ -108,12 +105,12 @@ public class TestWALEntrySinkFilter { public void testWALEntryFilter() throws IOException { Configuration conf = HBaseConfiguration.create(); // Make it so our filter is instantiated on construction of ReplicationSink. - conf.setClass(DummyAsyncRegistry.REGISTRY_IMPL_CONF_KEY, DevNullAsyncRegistry.class, - DummyAsyncRegistry.class); + conf.setClass(DummyConnectionRegistry.REGISTRY_IMPL_CONF_KEY, DevNullConnectionRegistry.class, + DummyConnectionRegistry.class); conf.setClass(WALEntrySinkFilter.WAL_ENTRY_FILTER_KEY, - IfTimeIsGreaterThanBOUNDARYWALEntrySinkFilterImpl.class, WALEntrySinkFilter.class); + IfTimeIsGreaterThanBOUNDARYWALEntrySinkFilterImpl.class, WALEntrySinkFilter.class); conf.setClass(ClusterConnectionFactory.HBASE_SERVER_CLUSTER_CONNECTION_IMPL, - DevNullAsyncClusterConnection.class, AsyncClusterConnection.class); + DevNullAsyncClusterConnection.class, AsyncClusterConnection.class); ReplicationSink sink = new ReplicationSink(conf, STOPPABLE); // Create some dumb walentries. List<AdminProtos.WALEntry> entries = new ArrayList<>(); @@ -190,9 +187,9 @@ public class TestWALEntrySinkFilter { } } - public static class DevNullAsyncRegistry extends DummyAsyncRegistry { + public static class DevNullConnectionRegistry extends DummyConnectionRegistry { - public DevNullAsyncRegistry(Configuration conf) { + public DevNullConnectionRegistry(Configuration conf) { } @Override