Package org.apache.hadoop.hbase.client
Class ConnectionUtils
java.lang.Object
org.apache.hadoop.hbase.client.ConnectionUtils
Utility used by client connections.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static interface
(package private) static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Key for configuration in Configuration whose value is the class we implement making a new Connection instance.private static final org.slf4j.Logger
(package private) static final byte[]
private static final String
(package private) static final NonceGenerator
Dummy nonce generator for disabled nonces.static final long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) static long
(package private) static int
calcPriority
(int priority, TableName tableName) Select the priority for the rpc call.(package private) static <REQ,
PREQ, PRESP, RESP>
CompletableFuture<RESP>call
(HBaseRpcController controller, HRegionLocation loc, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.Interface stub, REQ req, ConnectionUtils.Converter<PREQ, byte[], REQ> reqConvert, ConnectionUtils.RpcCall<PRESP, PREQ> rpcCall, ConnectionUtils.Converter<RESP, HBaseRpcController, PRESP> respConverter) (package private) static void
checkHasFamilies
(Mutation mutation) private static <T> void
connect
(CompletableFuture<T> srcFuture, CompletableFuture<T> dstFuture, Optional<MetricsConnection> metrics) Connect the two futures, if the src future is done, then mark the dst future as done.(package private) static byte[]
createCloseRowBefore
(byte[] row) Create a row before the specified row and very close to the specified row.(package private) static byte[]
createClosestRowAfter
(byte[] row) Create the closest row after the specified rowstatic ScanResultCache
createScanResultCache
(Scan scan) (package private) static Result
filterCells
(Result result, ExtendedCell keepCellsAfter) (package private) static RegionLocateType
getLocateType
(Scan scan) private static String
(package private) static <T> CompletableFuture<T>
getOrFetch
(AtomicReference<T> cacheRef, AtomicReference<CompletableFuture<T>> futureRef, boolean reload, Supplier<CompletableFuture<T>> fetch, Predicate<T> validator, String type) static long
getPauseTime
(long pause, int tries) Calculate pause time.(package private) static int
getPriority
(TableName tableName) (package private) static String
getStubKey
(String serviceName, ServerName serverName) Get a unique key for the rpc stub to the given server.(package private) static void
incRegionCountMetrics
(ScanMetrics scanMetrics) (package private) static void
incRPCCallsMetrics
(ScanMetrics scanMetrics, boolean isRegionServerRemote) (package private) static void
incRPCRetriesMetrics
(ScanMetrics scanMetrics, boolean isRegionServerRemote) (package private) static boolean
isEmptyStartRow
(byte[] row) (package private) static boolean
isEmptyStopRow
(byte[] row) (package private) static boolean
static boolean
(package private) static boolean
noMoreResultsForReverseScan
(Scan scan, RegionInfo info) (package private) static boolean
noMoreResultsForScan
(Scan scan, RegionInfo info) (package private) static void
resetController
(HBaseRpcController controller, long timeoutNs, int priority, TableName tableName) (package private) static int
retries2Attempts
(int retries) Return retires + 1.private static <T> void
sendRequestsToSecondaryReplicas
(Function<Integer, CompletableFuture<T>> requestReplica, RegionLocations locs, CompletableFuture<T> future, Optional<MetricsConnection> metrics) (package private) static void
setCoprocessorError
(org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, Throwable error) static void
setServerSideHConnectionRetriesConfig
(org.apache.hadoop.conf.Configuration c, String sn, org.slf4j.Logger log) Changes the configuration to set the number of retries needed when using Connection internally, e.g.(package private) static void
shutdownPool
(ExecutorService pool) (package private) static <T> CompletableFuture<T>
timelineConsistentRead
(AsyncRegionLocator locator, TableName tableName, Query query, byte[] row, RegionLocateType locateType, Function<Integer, CompletableFuture<T>> requestReplica, long rpcTimeoutNs, long primaryCallTimeoutNs, org.apache.hbase.thirdparty.io.netty.util.Timer retryTimer, Optional<MetricsConnection> metrics) toCheckExistenceOnly
(List<Get> gets) (package private) static Get
toCheckExistenceOnly
(Get get) (package private) static Throwable
(package private) static void
updateResultsMetrics
(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote) (package private) static void
updateServerSideMetrics
(ScanMetrics scanMetrics, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse response) Use the scan metrics returned by the server to add to the identically named counters in the client side metrics.(package private) static void
updateStats
(Optional<ServerStatisticTracker> optStats, Optional<MetricsConnection> optMetrics, ServerName serverName, MultiResponse resp) (package private) static void
validatePut
(Put put, int maxKeyValueSize) (package private) static void
validatePutsInRowMutations
(RowMutations rowMutations, int maxKeyValueSize)
-
Field Details
-
LOG
-
HBASE_CLIENT_CONNECTION_IMPL
Key for configuration in Configuration whose value is the class we implement making a new Connection instance.- See Also:
-
NO_NONCE_GENERATOR
Dummy nonce generator for disabled nonces. -
MAX_BYTE_ARRAY
-
SLEEP_DELTA_NS
-
MY_ADDRESS
-
-
Constructor Details
-
ConnectionUtils
private ConnectionUtils()
-
-
Method Details
-
getPauseTime
Calculate pause time. Built onHConstants.RETRY_BACKOFF
.- Parameters:
pause
- time to pausetries
- amount of tries- Returns:
- How long to wait after
tries
retries
-
setServerSideHConnectionRetriesConfig
public static void setServerSideHConnectionRetriesConfig(org.apache.hadoop.conf.Configuration c, String sn, org.slf4j.Logger log) Changes the configuration to set the number of retries needed when using Connection internally, e.g. for updating catalog tables, etc. Call this method before we create any Connections.- Parameters:
c
- The Configuration instance to set the retries into.log
- Used to log what we set in here.
-
getStubKey
Get a unique key for the rpc stub to the given server. -
retries2Attempts
Return retires + 1. The returned value will be in range [1, Integer.MAX_VALUE]. -
checkHasFamilies
-
createClosestRowAfter
Create the closest row after the specified row -
createCloseRowBefore
Create a row before the specified row and very close to the specified row. -
isEmptyStartRow
-
isEmptyStopRow
-
resetController
static void resetController(HBaseRpcController controller, long timeoutNs, int priority, TableName tableName) -
translateException
-
calcEstimatedSize
-
filterCells
-
toCheckExistenceOnly
-
toCheckExistenceOnly
-
getLocateType
-
noMoreResultsForScan
-
noMoreResultsForReverseScan
-
createScanResultCache
-
getMyAddress
-
isRemote
-
incRPCCallsMetrics
-
incRPCRetriesMetrics
-
updateResultsMetrics
static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote) -
updateServerSideMetrics
static void updateServerSideMetrics(ScanMetrics scanMetrics, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse response) Use the scan metrics returned by the server to add to the identically named counters in the client side metrics. If a counter does not exist with the same name as the server side metric, the attempt to increase the counter will fail. -
incRegionCountMetrics
-
connect
private static <T> void connect(CompletableFuture<T> srcFuture, CompletableFuture<T> dstFuture, Optional<MetricsConnection> metrics) Connect the two futures, if the src future is done, then mark the dst future as done. And if the dst future is done, then cancel the src future. This is used for timeline consistent read. Pass empty metrics if you want to link the primary future and the dst future so we will not increase the hedge read related metrics. -
sendRequestsToSecondaryReplicas
private static <T> void sendRequestsToSecondaryReplicas(Function<Integer, CompletableFuture<T>> requestReplica, RegionLocations locs, CompletableFuture<T> future, Optional<MetricsConnection> metrics) -
timelineConsistentRead
static <T> CompletableFuture<T> timelineConsistentRead(AsyncRegionLocator locator, TableName tableName, Query query, byte[] row, RegionLocateType locateType, Function<Integer, CompletableFuture<T>> requestReplica, long rpcTimeoutNs, long primaryCallTimeoutNs, org.apache.hbase.thirdparty.io.netty.util.Timer retryTimer, Optional<MetricsConnection> metrics) -
validatePut
-
validatePutsInRowMutations
-
calcPriority
Select the priority for the rpc call. The rules are:- If user set a priority explicitly, then just use it.
- For system table, use
HConstants.SYSTEMTABLE_QOS
. - For other tables, use
HConstants.NORMAL_QOS
.
- Parameters:
priority
- the priority set by user, can beHConstants.PRIORITY_UNSET
.tableName
- the table we operate on
-
getPriority
-
getOrFetch
static <T> CompletableFuture<T> getOrFetch(AtomicReference<T> cacheRef, AtomicReference<CompletableFuture<T>> futureRef, boolean reload, Supplier<CompletableFuture<T>> fetch, Predicate<T> validator, String type) -
updateStats
static void updateStats(Optional<ServerStatisticTracker> optStats, Optional<MetricsConnection> optMetrics, ServerName serverName, MultiResponse resp) -
call
static <REQ,PREQ, CompletableFuture<RESP> callPRESP, RESP> (HBaseRpcController controller, HRegionLocation loc, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.Interface stub, REQ req, ConnectionUtils.Converter<PREQ, byte[], REQ> reqConvert, ConnectionUtils.RpcCall<PRESP, PREQ> rpcCall, ConnectionUtils.Converter<RESP, HBaseRpcController, PRESP> respConverter) -
shutdownPool
-
setCoprocessorError
static void setCoprocessorError(org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, Throwable error) -
isUnexpectedPreambleHeaderException
-