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 / AsyncTableBuilder.java
blob4c883a8332d7466ead6ce2c2dfb60a1cdb0f1668
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.yetus.audience.InterfaceAudience;
26 /**
27 * For creating {@link AsyncTable}.
28 * <p>
29 * The implementation should have default configurations set before returning the builder to user.
30 * So users are free to only set the configs they care about to create a new
31 * AsyncTable/RawAsyncTable instance.
32 * @since 2.0.0
34 @InterfaceAudience.Public
35 public interface AsyncTableBuilder<C extends ScanResultConsumerBase> {
37 /**
38 * Set timeout for a whole operation such as get, put or delete. Notice that scan will not be
39 * effected by this value, see scanTimeoutNs.
40 * <p>
41 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying,
42 * we will stop retrying when we reach any of the limitations.
43 * @see #setMaxAttempts(int)
44 * @see #setMaxRetries(int)
45 * @see #setScanTimeout(long, TimeUnit)
47 AsyncTableBuilder<C> setOperationTimeout(long timeout, TimeUnit unit);
49 /**
50 * As now we have heartbeat support for scan, ideally a scan will never timeout unless the RS is
51 * crash. The RS will always return something before the rpc timed out or scan timed out to tell
52 * the client that it is still alive. The scan timeout is used as operation timeout for every
53 * operation in a scan, such as openScanner or next.
54 * @see #setScanTimeout(long, TimeUnit)
56 AsyncTableBuilder<C> setScanTimeout(long timeout, TimeUnit unit);
58 /**
59 * Set timeout for each rpc request.
60 * <p>
61 * Notice that this will <strong>NOT</strong> change the rpc timeout for read(get, scan) request
62 * and write request(put, delete).
64 AsyncTableBuilder<C> setRpcTimeout(long timeout, TimeUnit unit);
66 /**
67 * Set timeout for each read(get, scan) rpc request.
69 AsyncTableBuilder<C> setReadRpcTimeout(long timeout, TimeUnit unit);
71 /**
72 * Set timeout for each write(put, delete) rpc request.
74 AsyncTableBuilder<C> setWriteRpcTimeout(long timeout, TimeUnit unit);
76 /**
77 * Set the base pause time for retrying. We use an exponential policy to generate sleep time when
78 * retrying.
79 * @see #setRetryPauseForCQTBE(long, TimeUnit)
81 AsyncTableBuilder<C> setRetryPause(long pause, TimeUnit unit);
83 /**
84 * Set the base pause time for retrying when we hit {@code CallQueueTooBigException}. We use an
85 * exponential policy to generate sleep time when retrying.
86 * <p/>
87 * This value should be greater than the normal pause value which could be set with the above
88 * {@link #setRetryPause(long, TimeUnit)} method, as usually {@code CallQueueTooBigException}
89 * means the server is overloaded. We just use the normal pause value for
90 * {@code CallQueueTooBigException} if here you specify a smaller value.
91 * @see #setRetryPause(long, TimeUnit)
93 AsyncTableBuilder<C> setRetryPauseForCQTBE(long pause, TimeUnit unit);
95 /**
96 * Set the max retry times for an operation. Usually it is the max attempt times minus 1.
97 * <p>
98 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying,
99 * we will stop retrying when we reach any of the limitations.
100 * @see #setMaxAttempts(int)
101 * @see #setOperationTimeout(long, TimeUnit)
103 default AsyncTableBuilder<C> setMaxRetries(int maxRetries) {
104 return setMaxAttempts(retries2Attempts(maxRetries));
108 * Set the max attempt times for an operation. Usually it is the max retry times plus 1. Operation
109 * timeout and max attempt times(or max retry times) are both limitations for retrying, we will
110 * stop retrying when we reach any of the limitations.
111 * @see #setMaxRetries(int)
112 * @see #setOperationTimeout(long, TimeUnit)
114 AsyncTableBuilder<C> setMaxAttempts(int maxAttempts);
117 * Set the number of retries that are allowed before we start to log.
119 AsyncTableBuilder<C> setStartLogErrorsCnt(int startLogErrorsCnt);
122 * Create the {@link AsyncTable} instance.
124 AsyncTable<C> build();