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 java.util.concurrent.TimeUnit; 021import org.apache.yetus.audience.InterfaceAudience; 022 023/** 024 * Base class for all asynchronous admin builders. 025 */ 026@InterfaceAudience.Private 027abstract class AsyncAdminBuilderBase implements AsyncAdminBuilder { 028 029 protected long rpcTimeoutNs; 030 031 protected long operationTimeoutNs; 032 033 protected long pauseNs; 034 035 protected long pauseNsForServerOverloaded; 036 037 protected int maxAttempts; 038 039 protected int startLogErrorsCnt; 040 041 AsyncAdminBuilderBase(AsyncConnectionConfiguration connConf) { 042 this.rpcTimeoutNs = connConf.getRpcTimeoutNs(); 043 this.operationTimeoutNs = connConf.getOperationTimeoutNs(); 044 this.pauseNs = connConf.getPauseNs(); 045 this.pauseNsForServerOverloaded = connConf.getPauseNsForServerOverloaded(); 046 this.maxAttempts = connConf.getMaxRetries(); 047 this.startLogErrorsCnt = connConf.getStartLogErrorsCnt(); 048 } 049 050 @Override 051 public AsyncAdminBuilder setOperationTimeout(long timeout, TimeUnit unit) { 052 this.operationTimeoutNs = unit.toNanos(timeout); 053 return this; 054 } 055 056 @Override 057 public AsyncAdminBuilder setRpcTimeout(long timeout, TimeUnit unit) { 058 this.rpcTimeoutNs = unit.toNanos(timeout); 059 return this; 060 } 061 062 @Override 063 public AsyncAdminBuilder setRetryPause(long timeout, TimeUnit unit) { 064 this.pauseNs = unit.toNanos(timeout); 065 return this; 066 } 067 068 @Override 069 public AsyncAdminBuilder setRetryPauseForServerOverloaded(long timeout, TimeUnit unit) { 070 this.pauseNsForServerOverloaded = unit.toNanos(timeout); 071 return this; 072 } 073 074 @Override 075 public AsyncAdminBuilder setMaxAttempts(int maxAttempts) { 076 this.maxAttempts = maxAttempts; 077 return this; 078 } 079 080 @Override 081 public AsyncAdminBuilder setStartLogErrorsCnt(int startLogErrorsCnt) { 082 this.startLogErrorsCnt = startLogErrorsCnt; 083 return this; 084 } 085}