hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1511890 - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-server/src/test/java/org/apache/hadoop/hbase/client/
Date Thu, 08 Aug 2013 17:26:21 GMT
Author: larsh
Date: Thu Aug  8 17:26:21 2013
New Revision: 1511890

URL: http://svn.apache.org/r1511890
Log:
HBASE-8408; addendum for new HConnection API

Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1511890&r1=1511889&r2=1511890&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
Thu Aug  8 17:26:21 2013
@@ -106,6 +106,19 @@ public interface HConnection extends Abo
    * 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
+   * 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
    */
@@ -125,6 +138,20 @@ public interface HConnection extends Abo
    */
   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;

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1511890&r1=1511889&r2=1511890&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Thu Aug  8 17:26:21 2013
@@ -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.");
       }

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java?rev=1511890&r1=1511889&r2=1511890&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
Thu Aug  8 17:26:21 2013
@@ -73,6 +73,11 @@ public class HConnectionWrapper implemen
   }
 
   @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);
   }
@@ -83,6 +88,11 @@ public class HConnectionWrapper implemen
   }
 
   @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);
   }

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1511890&r1=1511889&r2=1511890&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
Thu Aug  8 17:26:21 2013
@@ -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



Mime
View raw message