Class SharedConnection

java.lang.Object
org.apache.hadoop.hbase.SharedConnection
All Implemented Interfaces:
Closeable, AutoCloseable, Abortable, Connection

@Private public class SharedConnection extends Object implements Connection
Wraps a Connection to make it can't be closed or aborted.
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Connection
      Throws:
      IOException
    • isClosed

      public boolean isClosed()
      Description copied from interface: Connection
      Returns whether the connection is closed or not.
      Specified by:
      isClosed in interface Connection
      Returns:
      true if this connection is closed
    • abort

      public void abort(String why, Throwable e)
      Description copied from interface: Abortable
      Abort the server or client.
      Specified by:
      abort in interface Abortable
      Parameters:
      why - Why we're aborting.
      e - Throwable that caused abort. Can be null.
    • isAborted

      public boolean isAborted()
      Description copied from interface: Abortable
      Check if the server or client was aborted.
      Specified by:
      isAborted in interface Abortable
      Returns:
      true if the server or client was aborted, false otherwise
    • getConfiguration

      public org.apache.hadoop.conf.Configuration getConfiguration()
      Description copied from interface: Connection
      Returns Configuration instance being used by this Connection instance.
      Specified by:
      getConfiguration in interface Connection
    • getBufferedMutator

      Description copied from interface: Connection

      Retrieve a BufferedMutator for performing client-side buffering of writes. The BufferedMutator returned by this method is thread-safe. This accessor will create a new ThreadPoolExecutor and will be shutdown once we close the BufferedMutator. This object can be used for long lived operations.

      The caller is responsible for calling BufferedMutator.close() on the returned BufferedMutator instance.

      Specified by:
      getBufferedMutator in interface Connection
      Parameters:
      tableName - the name of the table
      Returns:
      a BufferedMutator for the supplied tableName.
      Throws:
      IOException
    • getBufferedMutator

      Description copied from interface: Connection
      Retrieve a BufferedMutator for performing client-side buffering of writes. The BufferedMutator returned by this method is thread-safe. This object can be used for long lived table operations. If user passes ThreadPool in BufferedMutatorParams then we will use that otherwise we will create for the user. For user specified ThreadPool, it is the user's responsibility to shutdown. For ThreadPool created by us, we will shutdown when user calls BufferedMutator.close(). The caller is responsible for calling BufferedMutator.close() on the returned BufferedMutator instance.
      Specified by:
      getBufferedMutator in interface Connection
      Parameters:
      params - details on how to instantiate the BufferedMutator.
      Returns:
      a BufferedMutator for the supplied tableName.
      Throws:
      IOException
    • getRegionLocator

      Description copied from interface: Connection
      Retrieve a RegionLocator implementation to inspect region information on a table. The returned RegionLocator is not thread-safe, so a new instance should be created for each using thread. This is a lightweight operation. Pooling or caching of the returned RegionLocator is neither required nor desired.
      The caller is responsible for calling Closeable.close() on the returned RegionLocator instance. RegionLocator needs to be unmanaged
      Specified by:
      getRegionLocator in interface Connection
      Parameters:
      tableName - Name of the table who's region is to be examined
      Returns:
      A RegionLocator instance
      Throws:
      IOException
    • getAdmin

      public Admin getAdmin() throws IOException
      Description copied from interface: Connection
      Retrieve an Admin implementation to administer an HBase cluster. The returned Admin is not guaranteed to be thread-safe. A new instance should be created for each using thread. This is a lightweight operation. Pooling or caching of the returned Admin is not recommended.
      The caller is responsible for calling Admin.close() on the returned Admin instance.
      Specified by:
      getAdmin in interface Connection
      Returns:
      an Admin instance for cluster administration
      Throws:
      IOException
    • getTableBuilder

      Description copied from interface: Connection
      Returns an TableBuilder for creating Table.
      Specified by:
      getTableBuilder in interface Connection
      Parameters:
      tableName - the name of the table
      pool - the thread pool to use for requests like batch and scan
    • clearRegionLocationCache

      public void clearRegionLocationCache()
      Description copied from interface: Connection
      Clear all the entries in the region location cache, for all the tables.

      If you only want to clear the cache for a specific table, use RegionLocator.clearRegionLocationCache().

      This may cause performance issue so use it with caution.

      Specified by:
      clearRegionLocationCache in interface Connection
    • getHbck

      public Hbck getHbck() throws IOException
      Description copied from interface: Connection
      Retrieve an Hbck implementation to fix an HBase cluster. The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance is not recommended.
      The caller is responsible for calling Closeable.close() on the returned Hbck instance.
      This will be used mostly by hbck tool.
      Specified by:
      getHbck in interface Connection
      Returns:
      an Hbck instance for active master. Active master is fetched from the zookeeper.
      Throws:
      IOException
    • getHbck

      public Hbck getHbck(ServerName masterServer) throws IOException
      Description copied from interface: Connection
      Retrieve an Hbck implementation to fix an HBase cluster. The returned Hbck is not guaranteed to be thread-safe. A new instance should be created by each thread. This is a lightweight operation. Pooling or caching of the returned Hbck instance is not recommended.
      The caller is responsible for calling Closeable.close() on the returned Hbck instance.
      This will be used mostly by hbck tool. This may only be used to by pass getting registered master from ZK. In situations where ZK is not available or active master is not registered with ZK and user can get master address by other means, master can be explicitly specified.
      Specified by:
      getHbck in interface Connection
      Parameters:
      masterServer - explicit ServerName for master server
      Returns:
      an Hbck instance for a specified master server
      Throws:
      IOException
    • getClusterId

      public String getClusterId()
      Description copied from interface: Connection
      Returns the cluster ID unique to this HBase cluster.
      The default implementation is added to keep client compatibility.
      Specified by:
      getClusterId in interface Connection