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
;
27 * For creating {@link AsyncAdmin}. The implementation should have default configurations set before
28 * returning the builder to user. So users are free to only set the configs they care about to
29 * create a new AsyncAdmin instance.
32 @InterfaceAudience.Public
33 public interface AsyncAdminBuilder
{
36 * Set timeout for a whole admin operation. Operation timeout and max attempt times(or max retry
37 * times) are both limitations for retrying, we will stop retrying when we reach any of the
39 * @return this for invocation chaining
41 AsyncAdminBuilder
setOperationTimeout(long timeout
, TimeUnit unit
);
44 * Set timeout for each rpc request.
45 * @return this for invocation chaining
47 AsyncAdminBuilder
setRpcTimeout(long timeout
, TimeUnit unit
);
50 * Set the base pause time for retrying. We use an exponential policy to generate sleep time when
52 * @return this for invocation chaining
53 * @see #setRetryPauseForCQTBE(long, TimeUnit)
55 AsyncAdminBuilder
setRetryPause(long timeout
, TimeUnit unit
);
58 * Set the base pause time for retrying when we hit {@code CallQueueTooBigException}. We use an
59 * exponential policy to generate sleep time when retrying.
61 * This value should be greater than the normal pause value which could be set with the above
62 * {@link #setRetryPause(long, TimeUnit)} method, as usually {@code CallQueueTooBigException}
63 * means the server is overloaded. We just use the normal pause value for
64 * {@code CallQueueTooBigException} if here you specify a smaller value.
65 * @see #setRetryPause(long, TimeUnit)
67 AsyncAdminBuilder
setRetryPauseForCQTBE(long pause
, TimeUnit unit
);
70 * Set the max retry times for an admin operation. Usually it is the max attempt times minus 1.
71 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying,
72 * we will stop retrying when we reach any of the limitations.
73 * @return this for invocation chaining
75 default AsyncAdminBuilder
setMaxRetries(int maxRetries
) {
76 return setMaxAttempts(retries2Attempts(maxRetries
));
80 * Set the max attempt times for an admin operation. Usually it is the max retry times plus 1.
81 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying,
82 * we will stop retrying when we reach any of the limitations.
83 * @return this for invocation chaining
85 AsyncAdminBuilder
setMaxAttempts(int maxAttempts
);
88 * Set the number of retries that are allowed before we start to log.
89 * @return this for invocation chaining
91 AsyncAdminBuilder
setStartLogErrorsCnt(int startLogErrorsCnt
);
94 * Create a {@link AsyncAdmin} instance.
95 * @return a {@link AsyncAdmin} instance