HBASE-8408; addendum for new HConnection API
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1511885 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b94a48d104
commit
d28f8564ad
|
@ -97,6 +97,19 @@ public interface HConnection extends Abortable, Closeable {
|
|||
*/
|
||||
public HTableInterface getTable(byte[] tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve an HTableInterface implementation for access to a table.
|
||||
* The returned HTableInterface 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 HTableInterface
|
||||
* is neither required nor desired.
|
||||
* Note that the HConnection needs to be unmanaged
|
||||
* (created with {@link HConnectionManager#createConnection(Configuration)}).
|
||||
* @param tableName
|
||||
* @return an HTable to use for interactions with this table
|
||||
*/
|
||||
public HTableInterface getTable(TableName tableName) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve an HTableInterface implementation for access to a table.
|
||||
* The returned HTableInterface is not thread safe, a new instance should
|
||||
|
@ -125,6 +138,20 @@ public interface HConnection extends Abortable, Closeable {
|
|||
*/
|
||||
public HTableInterface getTable(byte[] tableName, ExecutorService pool) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve an HTableInterface implementation for access to a table.
|
||||
* The returned HTableInterface 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 HTableInterface
|
||||
* is neither required nor desired.
|
||||
* Note that the HConnection needs to be unmanaged
|
||||
* (created with {@link HConnectionManager#createConnection(Configuration)}).
|
||||
* @param tableName
|
||||
* @param pool The thread pool to use for batch operations, null to use a default pool.
|
||||
* @return an HTable to use for interactions with this table
|
||||
*/
|
||||
public HTableInterface getTable(TableName tableName, ExecutorService pool) throws IOException;
|
||||
|
||||
/** @return - true if the master server is running */
|
||||
boolean isMasterRunning()
|
||||
throws MasterNotRunningException, ZooKeeperConnectionException;
|
||||
|
|
|
@ -653,21 +653,31 @@ public class HConnectionManager {
|
|||
|
||||
@Override
|
||||
public HTableInterface getTable(String tableName) throws IOException {
|
||||
return getTable(Bytes.toBytes(tableName));
|
||||
return getTable(TableName.valueOf(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(byte[] tableName) throws IOException {
|
||||
return getTable(TableName.valueOf(tableName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(TableName tableName) throws IOException {
|
||||
return getTable(tableName, getBatchPool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(String tableName, ExecutorService pool) throws IOException {
|
||||
return getTable(Bytes.toBytes(tableName), pool);
|
||||
return getTable(TableName.valueOf(tableName), pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(byte[] tableName, ExecutorService pool) throws IOException {
|
||||
return getTable(TableName.valueOf(tableName), pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(TableName tableName, ExecutorService pool) throws IOException {
|
||||
if (managed) {
|
||||
throw new IOException("The connection has to be unmanaged.");
|
||||
}
|
||||
|
|
|
@ -72,6 +72,11 @@ public class HConnectionWrapper implements HConnection {
|
|||
return hconnection.getTable(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(TableName tableName) throws IOException {
|
||||
return hconnection.getTable(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(String tableName, ExecutorService pool) throws IOException {
|
||||
return hconnection.getTable(tableName, pool);
|
||||
|
@ -82,6 +87,11 @@ public class HConnectionWrapper implements HConnection {
|
|||
return hconnection.getTable(tableName, pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HTableInterface getTable(TableName tableName, ExecutorService pool) throws IOException {
|
||||
return hconnection.getTable(tableName, pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abort(String why, Throwable e) {
|
||||
hconnection.abort(why, e);
|
||||
|
|
|
@ -148,6 +148,11 @@ public class TestHCM {
|
|||
assertTrue(otherPool == t.getPool());
|
||||
t.close();
|
||||
|
||||
t = (HTable)con2.getTable(TableName.valueOf(tableName));
|
||||
// try other API too
|
||||
assertTrue(otherPool == t.getPool());
|
||||
t.close();
|
||||
|
||||
t = (HTable)con1.getTable(tableName);
|
||||
ExecutorService pool = ((HConnectionImplementation)con1).getCurrentBatchPool();
|
||||
// make sure an internal pool was created
|
||||
|
|
Loading…
Reference in New Issue