@InterfaceAudience.Private public final class ConnectionUtils extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ConnectionUtils.MasterlessConnection
Some tests shut down the master.
|
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
(package private) static byte[] |
MAX_BYTE_ARRAY |
private static String |
MY_ADDRESS |
(package private) static NonceGenerator |
NO_NONCE_GENERATOR
Dummy nonce generator for disabled nonces.
|
(package private) static long |
SLEEP_DELTA_NS |
Modifier | Constructor and Description |
---|---|
private |
ConnectionUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static long |
calcEstimatedSize(Result rs) |
(package private) static int |
calcPriority(int priority,
TableName tableName)
Select the priority for the rpc call.
|
(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 row
|
static ScanResultCache |
createScanResultCache(Scan scan) |
(package private) static Result |
filterCells(Result result,
Cell keepCellsAfter) |
(package private) static RegionLocateType |
getLocateType(Scan scan) |
private static String |
getMyAddress() |
(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) |
static NonceGenerator |
injectNonceGeneratorForTesting(ClusterConnection conn,
NonceGenerator cnm)
Inject a nonce generator for testing.
|
(package private) static boolean |
isEmptyStartRow(byte[] row) |
(package private) static boolean |
isEmptyStopRow(byte[] row) |
(package private) static boolean |
isRemote(String host) |
(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) |
(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) |
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.
|
static void |
setupMasterlessConnection(org.apache.hadoop.conf.Configuration conf)
Setup the connection class, so that it will not depend on master being online.
|
(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) |
(package private) static Get |
toCheckExistenceOnly(Get get) |
(package private) static List<Get> |
toCheckExistenceOnly(List<Get> gets) |
(package private) static Throwable |
translateException(Throwable t) |
(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) |
private static final org.slf4j.Logger LOG
static final NonceGenerator NO_NONCE_GENERATOR
static final byte[] MAX_BYTE_ARRAY
static final long SLEEP_DELTA_NS
private static final String MY_ADDRESS
private ConnectionUtils()
public static long getPauseTime(long pause, int tries)
HConstants.RETRY_BACKOFF
.pause
- time to pausetries
- amount of triestries
retriespublic static NonceGenerator injectNonceGeneratorForTesting(ClusterConnection conn, NonceGenerator cnm)
conn
- The connection for which to replace the generator.cnm
- Replaces the nonce generator used, for testing.public static void setServerSideHConnectionRetriesConfig(org.apache.hadoop.conf.Configuration c, String sn, org.slf4j.Logger log)
c
- The Configuration instance to set the retries into.log
- Used to log what we set in here.public static void setupMasterlessConnection(org.apache.hadoop.conf.Configuration conf)
conf
- configuration to setstatic String getStubKey(String serviceName, ServerName serverName)
static int retries2Attempts(int retries)
static void checkHasFamilies(Mutation mutation)
static byte[] createClosestRowAfter(byte[] row)
static byte[] createCloseRowBefore(byte[] row)
static boolean isEmptyStartRow(byte[] row)
static boolean isEmptyStopRow(byte[] row)
static void resetController(HBaseRpcController controller, long timeoutNs, int priority)
static Throwable translateException(Throwable t)
static long calcEstimatedSize(Result rs)
static Result filterCells(Result result, Cell keepCellsAfter)
static Get toCheckExistenceOnly(Get get)
static List<Get> toCheckExistenceOnly(List<Get> gets)
static RegionLocateType getLocateType(Scan scan)
static boolean noMoreResultsForScan(Scan scan, RegionInfo info)
static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info)
public static ScanResultCache createScanResultCache(Scan scan)
private static String getMyAddress()
static void incRPCCallsMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote)
static void incRPCRetriesMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote)
static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs, boolean isRegionServerRemote)
static void updateServerSideMetrics(ScanMetrics scanMetrics, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse response)
static void incRegionCountMetrics(ScanMetrics scanMetrics)
private static <T> void connect(CompletableFuture<T> srcFuture, CompletableFuture<T> dstFuture, Optional<MetricsConnection> metrics)
private static <T> void sendRequestsToSecondaryReplicas(Function<Integer,CompletableFuture<T>> requestReplica, RegionLocations locs, CompletableFuture<T> future, Optional<MetricsConnection> metrics)
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)
static void validatePut(Put put, int maxKeyValueSize)
static void validatePutsInRowMutations(RowMutations rowMutations, int maxKeyValueSize)
static int calcPriority(int priority, TableName tableName)
HConstants.SYSTEMTABLE_QOS
.HConstants.NORMAL_QOS
.priority
- the priority set by user, can be HConstants.PRIORITY_UNSET
.tableName
- the table we operate onstatic int getPriority(TableName tableName)
static <T> CompletableFuture<T> getOrFetch(AtomicReference<T> cacheRef, AtomicReference<CompletableFuture<T>> futureRef, boolean reload, Supplier<CompletableFuture<T>> fetch, Predicate<T> validator, String type)
static void updateStats(Optional<ServerStatisticTracker> optStats, Optional<MetricsConnection> optMetrics, ServerName serverName, MultiResponse resp)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.