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 org.apache.hadoop.hbase.TableName;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * Base class for all table builders.
025 */
026@InterfaceAudience.Private
027abstract class TableBuilderBase implements TableBuilder {
028
029  protected TableName tableName;
030
031  protected int operationTimeout;
032
033  protected int rpcTimeout;
034
035  protected int readRpcTimeout;
036
037  protected int writeRpcTimeout;
038
039  TableBuilderBase(TableName tableName, ConnectionConfiguration connConf) {
040    if (tableName == null) {
041      throw new IllegalArgumentException("Given table name is null");
042    }
043    this.tableName = tableName;
044    this.operationTimeout = tableName.isSystemTable() ? connConf.getMetaOperationTimeout()
045        : connConf.getOperationTimeout();
046    this.rpcTimeout = connConf.getRpcTimeout();
047    this.readRpcTimeout = connConf.getReadRpcTimeout();
048    this.writeRpcTimeout = connConf.getWriteRpcTimeout();
049  }
050
051  @Override
052  public TableBuilderBase setOperationTimeout(int timeout) {
053    this.operationTimeout = timeout;
054    return this;
055  }
056
057  @Override
058  public TableBuilderBase setRpcTimeout(int timeout) {
059    this.rpcTimeout = timeout;
060    return this;
061  }
062
063  @Override
064  public TableBuilderBase setReadRpcTimeout(int timeout) {
065    this.readRpcTimeout = timeout;
066    return this;
067  }
068
069  @Override
070  public TableBuilderBase setWriteRpcTimeout(int timeout) {
071    this.writeRpcTimeout = timeout;
072    return this;
073  }
074}