1
0
Prechádzať zdrojové kódy

HADOOP-1469 Asychronous table creation

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@546635 13f79535-47bb-0310-9956-ffa450edef68
Jim Kellerman 18 rokov pred
rodič
commit
ba80a24194

+ 1 - 0
src/contrib/hbase/CHANGES.txt

@@ -30,3 +30,4 @@ Trunk (unreleased changes)
      visibility (HADOOP-1466)
  16. HADOOP-1479 Fix NPE in HStore#get if store file only has keys < passed key.
  17. HADOOP-1476 Distributed version of 'Performance Evaluation' script
+ 18. HADOOP-1469 Asychronous table creation

+ 28 - 18
src/contrib/hbase/src/java/org/apache/hadoop/hbase/HClient.java

@@ -207,40 +207,50 @@ public class HClient implements HConstants {
   /**
    * Creates a new table
    * 
-   * @param desc - table descriptor for table
+   * @param desc table descriptor for table
    * 
-   * @throws IllegalArgumentException - if the table name is reserved
-   * @throws MasterNotRunningException - if master is not running
-   * @throws NoServerForRegionException - if root region is not being served
+   * @throws IllegalArgumentException if the table name is reserved
+   * @throws MasterNotRunningException if master is not running
+   * @throws NoServerForRegionException if root region is not being served
    * @throws IOException
    */
-  public synchronized void createTable(HTableDescriptor desc) throws IOException {
-    checkReservedTableName(desc.getName());
-    checkMaster();
-    try {
-      this.master.createTable(desc);
-      
-    } catch(RemoteException e) {
-      handleRemoteException(e);
-    }
+  public synchronized void createTable(HTableDescriptor desc)
+  throws IOException {
+    createTableAsync(desc);
 
     // Save the current table
-    
     SortedMap<Text, RegionLocation> oldServers = this.tableServers;
-
     try {
       // Wait for new table to come on-line
-
       findServersForTable(desc.getName());
-      
     } finally {
       if(oldServers != null && oldServers.size() != 0) {
         // Restore old current table if there was one
-      
         this.tableServers = oldServers;
       }
     }
   }
+  
+  /**
+   * Creates a new table but does not block and wait for it to come online.
+   * 
+   * @param desc table descriptor for table
+   * 
+   * @throws IllegalArgumentException if the table name is reserved
+   * @throws MasterNotRunningException if master is not running
+   * @throws NoServerForRegionException if root region is not being served
+   * @throws IOException
+   */
+  public synchronized void createTableAsync(HTableDescriptor desc)
+      throws IOException {
+    checkReservedTableName(desc.getName());
+    checkMaster();
+    try {
+      this.master.createTable(desc);
+    } catch (RemoteException e) {
+      handleRemoteException(e);
+    }
+  }
 
   /**
    * Deletes a table