001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.client; 019 020import static org.apache.hadoop.hbase.client.ConnectionUtils.retries2Attempts; 021 022import java.util.concurrent.TimeUnit; 023 024import org.apache.yetus.audience.InterfaceAudience; 025 026/** 027 * For creating {@link AsyncAdmin}. The implementation should have default configurations set before 028 * returning the builder to user. So users are free to only set the configs they care about to 029 * create a new AsyncAdmin instance. 030 * @since 2.0.0 031 */ 032@InterfaceAudience.Public 033public interface AsyncAdminBuilder { 034 035 /** 036 * Set timeout for a whole admin operation. Operation timeout and max attempt times(or max retry 037 * times) are both limitations for retrying, we will stop retrying when we reach any of the 038 * limitations. 039 * @param timeout 040 * @param unit 041 * @return this for invocation chaining 042 */ 043 AsyncAdminBuilder setOperationTimeout(long timeout, TimeUnit unit); 044 045 /** 046 * Set timeout for each rpc request. 047 * @param timeout 048 * @param unit 049 * @return this for invocation chaining 050 */ 051 AsyncAdminBuilder setRpcTimeout(long timeout, TimeUnit unit); 052 053 /** 054 * Set the base pause time for retrying. We use an exponential policy to generate sleep time when 055 * retrying. 056 * @param timeout 057 * @param unit 058 * @return this for invocation chaining 059 */ 060 AsyncAdminBuilder setRetryPause(long timeout, TimeUnit unit); 061 062 /** 063 * Set the max retry times for an admin operation. Usually it is the max attempt times minus 1. 064 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying, 065 * we will stop retrying when we reach any of the limitations. 066 * @param maxRetries 067 * @return this for invocation chaining 068 */ 069 default AsyncAdminBuilder setMaxRetries(int maxRetries) { 070 return setMaxAttempts(retries2Attempts(maxRetries)); 071 } 072 073 /** 074 * Set the max attempt times for an admin operation. Usually it is the max retry times plus 1. 075 * Operation timeout and max attempt times(or max retry times) are both limitations for retrying, 076 * we will stop retrying when we reach any of the limitations. 077 * @param maxAttempts 078 * @return this for invocation chaining 079 */ 080 AsyncAdminBuilder setMaxAttempts(int maxAttempts); 081 082 /** 083 * Set the number of retries that are allowed before we start to log. 084 * @param startLogErrorsCnt 085 * @return this for invocation chaining 086 */ 087 AsyncAdminBuilder setStartLogErrorsCnt(int startLogErrorsCnt); 088 089 /** 090 * Create a {@link AsyncAdmin} instance. 091 * @return a {@link AsyncAdmin} instance 092 */ 093 AsyncAdmin build(); 094}