Class MockConnection
- java.lang.Object
-
- org.apache.hadoop.hbase.client.mock.MockConnection
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.hadoop.hbase.Abortable
,org.apache.hadoop.hbase.client.Connection
public class MockConnection extends Object implements org.apache.hadoop.hbase.client.Connection
-
-
Constructor Summary
Constructors Constructor Description MockConnection(org.apache.hadoop.conf.Configuration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(String why, Throwable e)
Abort the server or client.void
clearRegionLocationCache()
Clear all the entries in the region location cache, for all the tables.void
close()
org.apache.hadoop.hbase.client.Admin
getAdmin()
Retrieve an Admin implementation to administer an HBase cluster.org.apache.hadoop.hbase.client.BufferedMutator
getBufferedMutator(org.apache.hadoop.hbase.client.BufferedMutatorParams params)
Retrieve aBufferedMutator
for performing client-side buffering of writes.org.apache.hadoop.hbase.client.BufferedMutator
getBufferedMutator(org.apache.hadoop.hbase.TableName tableName)
Retrieve aBufferedMutator
for performing client-side buffering of writes.org.apache.hadoop.conf.Configuration
getConfiguration()
org.apache.hadoop.hbase.client.RegionLocator
getRegionLocator(org.apache.hadoop.hbase.TableName tableName)
Retrieve a RegionLocator implementation to inspect region information on a table.org.apache.hadoop.hbase.client.Table
getTable(org.apache.hadoop.hbase.TableName tableName)
Retrieve a Table implementation for accessing a table.org.apache.hadoop.hbase.client.Table
getTable(org.apache.hadoop.hbase.TableName tableName, ExecutorService pool)
Retrieve a Table implementation for accessing a table.org.apache.hadoop.hbase.client.TableBuilder
getTableBuilder(org.apache.hadoop.hbase.TableName tableName, ExecutorService pool)
Returns anTableBuilder
for creatingTable
.boolean
isAborted()
Check if the server or client was aborted.boolean
isClosed()
Returns whether the connection is closed or not.
-
-
-
Method Detail
-
getConfiguration
public org.apache.hadoop.conf.Configuration getConfiguration()
- Specified by:
getConfiguration
in interfaceorg.apache.hadoop.hbase.client.Connection
- Returns:
- Configuration instance being used by this Connection instance.
-
getTable
public org.apache.hadoop.hbase.client.Table getTable(org.apache.hadoop.hbase.TableName tableName) throws IOException
Retrieve a Table implementation for accessing a table. The returned Table is not thread safe, a new instance should be created for each using thread. This is a lightweight operation, pooling or caching of the returned Table is neither required nor desired.The caller is responsible for calling
Table.close()
on the returned table instance.Since 0.98.1 this method no longer checks table existence. An exception will be thrown if the table does not exist only when the first operation is attempted.
- Specified by:
getTable
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
tableName
- the name of the table- Returns:
- a Table to use for interactions with this table
- Throws:
IOException
-
getTable
public org.apache.hadoop.hbase.client.Table getTable(org.apache.hadoop.hbase.TableName tableName, ExecutorService pool) throws IOException
Retrieve a Table implementation for accessing a table. The returned Table is not thread safe, a new instance should be created for each using thread. This is a lightweight operation, pooling or caching of the returned Table is neither required nor desired.The caller is responsible for calling
Table.close()
on the returned table instance.Since 0.98.1 this method no longer checks table existence. An exception will be thrown if the table does not exist only when the first operation is attempted.
- Specified by:
getTable
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
tableName
- the name of the tablepool
- The thread pool to use for batch operations, null to use a default pool.- Returns:
- a Table to use for interactions with this table
- Throws:
IOException
-
getBufferedMutator
public org.apache.hadoop.hbase.client.BufferedMutator getBufferedMutator(org.apache.hadoop.hbase.TableName tableName) throws IOException
Retrieve a
BufferedMutator
for performing client-side buffering of writes. TheBufferedMutator
returned by this method is thread-safe. This BufferedMutator will use the Connection's ExecutorService. This object can be used for long lived operations.The caller is responsible for calling
BufferedMutator.close()
on the returnedBufferedMutator
instance.This accessor will use the connection's ExecutorService and will throw an exception in the main thread when an asynchronous exception occurs.
- Specified by:
getBufferedMutator
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
tableName
- the name of the table- Returns:
- a
BufferedMutator
for the supplied tableName. - Throws:
IOException
-
getBufferedMutator
public org.apache.hadoop.hbase.client.BufferedMutator getBufferedMutator(org.apache.hadoop.hbase.client.BufferedMutatorParams params) throws IOException
Retrieve aBufferedMutator
for performing client-side buffering of writes. TheBufferedMutator
returned by this method is thread-safe. This object can be used for long lived table operations. The caller is responsible for callingBufferedMutator.close()
on the returnedBufferedMutator
instance.- Specified by:
getBufferedMutator
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
params
- details on how to instantiate theBufferedMutator
.- Returns:
- a
BufferedMutator
for the supplied tableName. - Throws:
IOException
-
getRegionLocator
public org.apache.hadoop.hbase.client.RegionLocator getRegionLocator(org.apache.hadoop.hbase.TableName tableName) throws IOException
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 callingCloseable.close()
on the returned RegionLocator instance. RegionLocator needs to be unmanaged- Specified by:
getRegionLocator
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
tableName
- Name of the table who's region is to be examined- Returns:
- A RegionLocator instance
- Throws:
IOException
-
clearRegionLocationCache
public void clearRegionLocationCache()
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 interfaceorg.apache.hadoop.hbase.client.Connection
-
getAdmin
public org.apache.hadoop.hbase.client.Admin getAdmin() throws IOException
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 callingAdmin.close()
on the returned Admin instance.- Specified by:
getAdmin
in interfaceorg.apache.hadoop.hbase.client.Connection
- Returns:
- an Admin instance for cluster administration
- Throws:
IOException
-
abort
public void abort(String why, Throwable e)
Abort the server or client.- Specified by:
abort
in interfaceorg.apache.hadoop.hbase.Abortable
- Parameters:
why
- Why we're aborting.e
- Throwable that caused abort. Can be null.
-
isAborted
public boolean isAborted()
Check if the server or client was aborted.- Specified by:
isAborted
in interfaceorg.apache.hadoop.hbase.Abortable
- Returns:
- true if the server or client was aborted, false otherwise
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.apache.hadoop.hbase.client.Connection
- Throws:
IOException
-
isClosed
public boolean isClosed()
Returns whether the connection is closed or not.- Specified by:
isClosed
in interfaceorg.apache.hadoop.hbase.client.Connection
- Returns:
- true if this connection is closed
-
getTableBuilder
public org.apache.hadoop.hbase.client.TableBuilder getTableBuilder(org.apache.hadoop.hbase.TableName tableName, ExecutorService pool)
Returns anTableBuilder
for creatingTable
.- Specified by:
getTableBuilder
in interfaceorg.apache.hadoop.hbase.client.Connection
- Parameters:
tableName
- the name of the tablepool
- the thread pool to use for requests like batch and scan
-
-