Package org.apache.hadoop.hbase.client
Class AbstractRpcBasedConnectionRegistry
java.lang.Object
org.apache.hadoop.hbase.client.AbstractRpcBasedConnectionRegistry
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ConnectionRegistry
- Direct Known Subclasses:
MasterRegistry
,RpcConnectionRegistry
@Private
abstract class AbstractRpcBasedConnectionRegistry
extends Object
implements ConnectionRegistry
Base class for rpc based connection registry implementation.
The implementation needs a bootstrap node list in configuration, and then it will use the methods
in
RegistryProtos.ClientMetaService
to refresh the connection registry end points.
It also supports hedged reads, the default fan out value is 2.
For the actual configuration names, see javadoc of sub classes.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
For describing the actual asynchronous rpc call. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default value for the fan out of hedged requests.private final int
private final RegistryEndpointsRefresher
private final RpcControllerFactory
private final ConnectionRegistryRpcStubHolder
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate IOException
badResponse
(String debug) protected final <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message>
CompletableFuture<T>call
(AbstractRpcBasedConnectionRegistry.Callable<T> callable, Predicate<T> isValidResp, String debug) private <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message>
CompletableFuture<T>call
(org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService.Interface stub, AbstractRpcBasedConnectionRegistry.Callable<T> callable) void
close()
Closes this instance and releases any system resources associated with itprotected abstract CompletableFuture<Set<ServerName>>
Get the address of active HMaster.protected abstract Set<ServerName>
getBootstrapNodes
(org.apache.hadoop.conf.Configuration conf) Should only be called once.Get the location of meta region(s).(package private) Set<ServerName>
private <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message>
voidgroupCall
(CompletableFuture<T> future, Set<ServerName> servers, List<org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService.Interface> stubs, int startIndexInclusive, AbstractRpcBasedConnectionRegistry.Callable<T> callable, Predicate<T> isValidResp, String debug, ConcurrentLinkedQueue<Throwable> errors) send requests concurrently to hedgedReadsFanout end points.private void
private static RegionLocations
transformMetaRegionLocations
(org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.GetMetaRegionLocationsResponse resp) Simple helper to transform the result of getMetaRegionLocations() rpc.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.client.ConnectionRegistry
getConnectionString
-
Field Details
-
HEDGED_REQS_FANOUT_DEFAULT
Default value for the fan out of hedged requests.- See Also:
-
hedgedReadFanOut
-
rpcStubHolder
-
rpcControllerFactory
-
registryEndpointRefresher
-
-
Constructor Details
-
AbstractRpcBasedConnectionRegistry
protected AbstractRpcBasedConnectionRegistry(org.apache.hadoop.conf.Configuration conf, User user, String hedgedReqsFanoutConfigName, String initialRefreshDelaySecsConfigName, String refreshIntervalSecsConfigName, String minRefreshIntervalSecsConfigName) throws IOException - Throws:
IOException
-
-
Method Details
-
getBootstrapNodes
protected abstract Set<ServerName> getBootstrapNodes(org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
fetchEndpoints
-
refreshStubs
- Throws:
IOException
-
call
private <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message> CompletableFuture<T> call(org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService.Interface stub, AbstractRpcBasedConnectionRegistry.Callable<T> callable) -
badResponse
-
groupCall
private <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message> void groupCall(CompletableFuture<T> future, Set<ServerName> servers, List<org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService.Interface> stubs, int startIndexInclusive, AbstractRpcBasedConnectionRegistry.Callable<T> callable, Predicate<T> isValidResp, String debug, ConcurrentLinkedQueue<Throwable> errors) send requests concurrently to hedgedReadsFanout end points. If any of the request is succeeded, we will complete the future and quit. If all the requests in one round are failed, we will start another round to send requests concurrently tohedgedReadsFanout end points. If all end points have been tried and all of them are failed, we will fail the future. -
call
protected final <T extends org.apache.hbase.thirdparty.com.google.protobuf.Message> CompletableFuture<T> call(AbstractRpcBasedConnectionRegistry.Callable<T> callable, Predicate<T> isValidResp, String debug) -
getParsedServers
- Throws:
IOException
-
transformMetaRegionLocations
private static RegionLocations transformMetaRegionLocations(org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.GetMetaRegionLocationsResponse resp) Simple helper to transform the result of getMetaRegionLocations() rpc. -
getMetaRegionLocations
Description copied from interface:ConnectionRegistry
Get the location of meta region(s).- Specified by:
getMetaRegionLocations
in interfaceConnectionRegistry
-
getClusterId
Description copied from interface:ConnectionRegistry
Should only be called once.The upper layer should store this value somewhere as it will not be change any more.
- Specified by:
getClusterId
in interfaceConnectionRegistry
-
getActiveMaster
Description copied from interface:ConnectionRegistry
Get the address of active HMaster.- Specified by:
getActiveMaster
in interfaceConnectionRegistry
-
close
Description copied from interface:ConnectionRegistry
Closes this instance and releases any system resources associated with it- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceConnectionRegistry
-