HBASE-18420 Some methods of Admin don't use ColumnFamilyDescriptor
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / client / AsyncConnectionConfiguration.java
blob83caea276a20a506988110939577e23dafe4c611
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT;
21 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_PAUSE;
22 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER;
23 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING;
24 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE;
25 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD;
26 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_META_SCANNER_CACHING;
27 import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_RPC_TIMEOUT;
28 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_META_OPERATION_TIMEOUT;
29 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_OPERATION_TIMEOUT;
30 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_PAUSE;
31 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER;
32 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_SCANNER_CACHING;
33 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY;
34 import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD;
35 import static org.apache.hadoop.hbase.HConstants.HBASE_META_SCANNER_CACHING;
36 import static org.apache.hadoop.hbase.HConstants.HBASE_REGIONSERVER_LEASE_PERIOD_KEY;
37 import static org.apache.hadoop.hbase.HConstants.HBASE_RPC_READ_TIMEOUT_KEY;
38 import static org.apache.hadoop.hbase.HConstants.HBASE_RPC_TIMEOUT_KEY;
39 import static org.apache.hadoop.hbase.HConstants.HBASE_RPC_WRITE_TIMEOUT_KEY;
40 import static org.apache.hadoop.hbase.client.AsyncProcess.DEFAULT_START_LOG_ERRORS_AFTER_COUNT;
41 import static org.apache.hadoop.hbase.client.AsyncProcess.START_LOG_ERRORS_AFTER_COUNT_KEY;
43 import java.util.concurrent.TimeUnit;
45 import org.apache.hadoop.conf.Configuration;
46 import org.apache.hadoop.hbase.HBaseConfiguration;
47 import org.apache.hadoop.hbase.classification.InterfaceAudience;
49 /**
50 * Timeout configs.
52 @InterfaceAudience.Private
53 class AsyncConnectionConfiguration {
55 private final long metaOperationTimeoutNs;
57 // timeout for a whole operation such as get, put or delete. Notice that scan will not be effected
58 // by this value, see scanTimeoutNs.
59 private final long operationTimeoutNs;
61 // timeout for each rpc request. Can be overridden by a more specific config, such as
62 // readRpcTimeout or writeRpcTimeout.
63 private final long rpcTimeoutNs;
65 // timeout for each read rpc request
66 private final long readRpcTimeoutNs;
68 // timeout for each write rpc request
69 private final long writeRpcTimeoutNs;
71 private final long pauseNs;
73 private final int maxRetries;
75 /** How many retries are allowed before we start to log */
76 private final int startLogErrorsCnt;
78 // As now we have heartbeat support for scan, ideally a scan will never timeout unless the RS is
79 // crash. The RS will always return something before the rpc timeout or scan timeout to tell the
80 // client that it is still alive. The scan timeout is used as operation timeout for every
81 // operations in a scan, such as openScanner or next.
82 private final long scanTimeoutNs;
84 private final int scannerCaching;
86 private final int metaScannerCaching;
88 private final long scannerMaxResultSize;
90 @SuppressWarnings("deprecation")
91 AsyncConnectionConfiguration(Configuration conf) {
92 this.metaOperationTimeoutNs = TimeUnit.MILLISECONDS.toNanos(
93 conf.getLong(HBASE_CLIENT_META_OPERATION_TIMEOUT, DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT));
94 this.operationTimeoutNs = TimeUnit.MILLISECONDS.toNanos(
95 conf.getLong(HBASE_CLIENT_OPERATION_TIMEOUT, DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT));
96 this.rpcTimeoutNs = TimeUnit.MILLISECONDS
97 .toNanos(conf.getLong(HBASE_RPC_TIMEOUT_KEY, DEFAULT_HBASE_RPC_TIMEOUT));
98 this.readRpcTimeoutNs =
99 TimeUnit.MILLISECONDS.toNanos(conf.getLong(HBASE_RPC_READ_TIMEOUT_KEY, rpcTimeoutNs));
100 this.writeRpcTimeoutNs =
101 TimeUnit.MILLISECONDS.toNanos(conf.getLong(HBASE_RPC_WRITE_TIMEOUT_KEY, rpcTimeoutNs));
102 this.pauseNs =
103 TimeUnit.MILLISECONDS.toNanos(conf.getLong(HBASE_CLIENT_PAUSE, DEFAULT_HBASE_CLIENT_PAUSE));
104 this.maxRetries = conf.getInt(HBASE_CLIENT_RETRIES_NUMBER, DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
105 this.startLogErrorsCnt =
106 conf.getInt(START_LOG_ERRORS_AFTER_COUNT_KEY, DEFAULT_START_LOG_ERRORS_AFTER_COUNT);
107 this.scanTimeoutNs = TimeUnit.MILLISECONDS
108 .toNanos(HBaseConfiguration.getInt(conf, HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD,
109 HBASE_REGIONSERVER_LEASE_PERIOD_KEY, DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD));
110 this.scannerCaching =
111 conf.getInt(HBASE_CLIENT_SCANNER_CACHING, DEFAULT_HBASE_CLIENT_SCANNER_CACHING);
112 this.metaScannerCaching = conf.getInt(HBASE_META_SCANNER_CACHING, DEFAULT_HBASE_META_SCANNER_CACHING);
113 this.scannerMaxResultSize = conf.getLong(HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
114 DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE);
117 long getMetaOperationTimeoutNs() {
118 return metaOperationTimeoutNs;
121 long getOperationTimeoutNs() {
122 return operationTimeoutNs;
125 long getRpcTimeoutNs() {
126 return rpcTimeoutNs;
129 long getReadRpcTimeoutNs() {
130 return readRpcTimeoutNs;
133 long getWriteRpcTimeoutNs() {
134 return writeRpcTimeoutNs;
137 long getPauseNs() {
138 return pauseNs;
141 int getMaxRetries() {
142 return maxRetries;
145 int getStartLogErrorsCnt() {
146 return startLogErrorsCnt;
149 long getScanTimeoutNs() {
150 return scanTimeoutNs;
153 int getScannerCaching() {
154 return scannerCaching;
157 int getMetaScannerCaching(){
158 return metaScannerCaching;
161 long getScannerMaxResultSize() {
162 return scannerMaxResultSize;