HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down. ...
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / client / AsyncTableBuilderBase.java
blob399d9ddfaffe2d653dc4952a58a903f2d615070a
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.client.ConnectionUtils.retries2Attempts;
22 import java.util.concurrent.TimeUnit;
24 import org.apache.hadoop.hbase.TableName;
25 import org.apache.yetus.audience.InterfaceAudience;
27 /**
28 * Base class for all asynchronous table builders.
30 @InterfaceAudience.Private
31 abstract class AsyncTableBuilderBase<C extends ScanResultConsumerBase>
32 implements AsyncTableBuilder<C> {
34 protected TableName tableName;
36 protected long operationTimeoutNs;
38 protected long scanTimeoutNs;
40 protected long rpcTimeoutNs;
42 protected long readRpcTimeoutNs;
44 protected long writeRpcTimeoutNs;
46 protected long pauseNs;
48 protected long pauseForCQTBENs;
50 protected int maxAttempts;
52 protected int startLogErrorsCnt;
54 AsyncTableBuilderBase(TableName tableName, AsyncConnectionConfiguration connConf) {
55 this.tableName = tableName;
56 this.operationTimeoutNs = tableName.isSystemTable() ? connConf.getMetaOperationTimeoutNs()
57 : connConf.getOperationTimeoutNs();
58 this.scanTimeoutNs = connConf.getScanTimeoutNs();
59 this.rpcTimeoutNs = connConf.getRpcTimeoutNs();
60 this.readRpcTimeoutNs = connConf.getReadRpcTimeoutNs();
61 this.writeRpcTimeoutNs = connConf.getWriteRpcTimeoutNs();
62 this.pauseNs = connConf.getPauseNs();
63 this.pauseForCQTBENs = connConf.getPauseForCQTBENs();
64 this.maxAttempts = retries2Attempts(connConf.getMaxRetries());
65 this.startLogErrorsCnt = connConf.getStartLogErrorsCnt();
68 @Override
69 public AsyncTableBuilderBase<C> setOperationTimeout(long timeout, TimeUnit unit) {
70 this.operationTimeoutNs = unit.toNanos(timeout);
71 return this;
74 @Override
75 public AsyncTableBuilderBase<C> setScanTimeout(long timeout, TimeUnit unit) {
76 this.scanTimeoutNs = unit.toNanos(timeout);
77 return this;
80 @Override
81 public AsyncTableBuilderBase<C> setRpcTimeout(long timeout, TimeUnit unit) {
82 this.rpcTimeoutNs = unit.toNanos(timeout);
83 return this;
86 @Override
87 public AsyncTableBuilderBase<C> setReadRpcTimeout(long timeout, TimeUnit unit) {
88 this.readRpcTimeoutNs = unit.toNanos(timeout);
89 return this;
92 @Override
93 public AsyncTableBuilderBase<C> setWriteRpcTimeout(long timeout, TimeUnit unit) {
94 this.writeRpcTimeoutNs = unit.toNanos(timeout);
95 return this;
98 @Override
99 public AsyncTableBuilderBase<C> setRetryPause(long pause, TimeUnit unit) {
100 this.pauseNs = unit.toNanos(pause);
101 return this;
104 @Override
105 public AsyncTableBuilderBase<C> setRetryPauseForCQTBE(long pause, TimeUnit unit) {
106 this.pauseForCQTBENs = unit.toNanos(pause);
107 return this;
110 @Override
111 public AsyncTableBuilderBase<C> setMaxAttempts(int maxAttempts) {
112 this.maxAttempts = maxAttempts;
113 return this;
116 @Override
117 public AsyncTableBuilderBase<C> setStartLogErrorsCnt(int startLogErrorsCnt) {
118 this.startLogErrorsCnt = startLogErrorsCnt;
119 return this;