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
Nested ClassesModifier and TypeClassDescription(package private) static interface(package private) static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey 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 NonceGeneratorDummy nonce generator for disabled nonces.static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static long(package private) static intcalcPriority(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 voidcheckHasFamilies(Mutation mutation) private static <T> voidconnect(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 ScanResultCachecreateScanResultCache(Scan scan) (package private) static ResultfilterCells(Result result, ExtendedCell keepCellsAfter) (package private) static RegionLocateTypegetLocateType(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 longgetPauseTime(long pause, int tries) Calculate pause time.(package private) static intgetPriority(TableName tableName) (package private) static StringgetStubKey(String serviceName, ServerName serverName) Get a unique key for the rpc stub to the given server.(package private) static voidincRegionCountMetrics(ScanMetrics scanMetrics) (package private) static voidincRPCCallsMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) (package private) static voidincRPCRetriesMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) (package private) static booleanisEmptyStartRow(byte[] row) (package private) static booleanisEmptyStopRow(byte[] row) (package private) static booleanstatic boolean(package private) static booleannoMoreResultsForReverseScan(Scan scan, RegionInfo info) (package private) static booleannoMoreResultsForScan(Scan scan, RegionInfo info) (package private) static voidresetController(HBaseRpcController controller, long timeoutNs, int priority, TableName tableName) (package private) static intretries2Attempts(int retries) Return retires + 1.private static <T> voidsendRequestsToSecondaryReplicas(Function<Integer, CompletableFuture<T>> requestReplica, RegionLocations locs, CompletableFuture<T> future, Optional<MetricsConnection> metrics) (package private) static voidsetCoprocessorError(org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, Throwable error) static voidsetServerSideHConnectionRetriesConfig(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 voidshutdownPool(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 GettoCheckExistenceOnly(Get get) (package private) static Throwable(package private) static voidupdateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote) (package private) static voidupdateServerSideMetrics(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 voidupdateStats(Optional<ServerStatisticTracker> optStats, Optional<MetricsConnection> optMetrics, ServerName serverName, MultiResponse resp) (package private) static voidvalidatePut(Put put, int maxKeyValueSize) (package private) static voidvalidatePutsInRowMutations(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
triesretries
-
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
-