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;
019
020import java.io.IOException;
021import java.util.concurrent.ExecutorService;
022import org.apache.hadoop.conf.Configuration;
023import org.apache.hadoop.hbase.client.Admin;
024import org.apache.hadoop.hbase.client.BufferedMutator;
025import org.apache.hadoop.hbase.client.BufferedMutatorParams;
026import org.apache.hadoop.hbase.client.Connection;
027import org.apache.hadoop.hbase.client.Hbck;
028import org.apache.hadoop.hbase.client.RegionLocator;
029import org.apache.hadoop.hbase.client.TableBuilder;
030import org.apache.yetus.audience.InterfaceAudience;
031
032/**
033 * Wraps a Connection to make it can't be closed or aborted.
034 */
035@InterfaceAudience.Private
036public class SharedConnection implements Connection {
037
038  private final Connection conn;
039
040  public SharedConnection(Connection conn) {
041    this.conn = conn;
042  }
043
044  @Override
045  public void close() throws IOException {
046    throw new UnsupportedOperationException("Shared connection");
047  }
048
049  @Override
050  public boolean isClosed() {
051    return this.conn.isClosed();
052  }
053
054  @Override
055  public void abort(String why, Throwable e) {
056    throw new UnsupportedOperationException("Shared connection");
057  }
058
059  @Override
060  public boolean isAborted() {
061    return this.conn.isAborted();
062  }
063
064  @Override
065  public Configuration getConfiguration() {
066    return this.conn.getConfiguration();
067  }
068
069  @Override
070  public BufferedMutator getBufferedMutator(TableName tableName) throws IOException {
071    return this.conn.getBufferedMutator(tableName);
072  }
073
074  @Override
075  public BufferedMutator getBufferedMutator(BufferedMutatorParams params) throws IOException {
076    return this.conn.getBufferedMutator(params);
077  }
078
079  @Override
080  public RegionLocator getRegionLocator(TableName tableName) throws IOException {
081    return this.conn.getRegionLocator(tableName);
082  }
083
084  @Override
085  public Admin getAdmin() throws IOException {
086    return this.conn.getAdmin();
087  }
088
089  @Override
090  public TableBuilder getTableBuilder(TableName tableName, ExecutorService pool) {
091    return this.conn.getTableBuilder(tableName, pool);
092  }
093
094  @Override
095  public void clearRegionLocationCache() {
096    conn.clearRegionLocationCache();
097  }
098
099  @Override
100  public Hbck getHbck() throws IOException {
101    return conn.getHbck();
102  }
103
104  @Override
105  public Hbck getHbck(ServerName masterServer) throws IOException {
106    return conn.getHbck(masterServer);
107  }
108
109  @Override
110  public String getClusterId() {
111    return conn.getClusterId();
112  }
113}