From cc8d45bd4779cf764760c83cec834193c8883adc Mon Sep 17 00:00:00 2001 From: Jim Kellerman Date: Tue, 12 Jun 2007 21:08:27 +0000 Subject: [PATCH] HADOOP-1469 Asychronous table creation git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@546635 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/java/org/apache/hadoop/hbase/HClient.java | 58 +++++++++++-------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7df0c0aa055..a874f513b40 100644 --- a/CHANGES.txt +++ b/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 diff --git a/src/java/org/apache/hadoop/hbase/HClient.java b/src/java/org/apache/hadoop/hbase/HClient.java index 5e1a4ec92a0..c13f279a243 100644 --- a/src/java/org/apache/hadoop/hbase/HClient.java +++ b/src/java/org/apache/hadoop/hbase/HClient.java @@ -207,39 +207,49 @@ 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 { + public synchronized void createTable(HTableDescriptor desc) + throws IOException { + createTableAsync(desc); + + // Save the current table + SortedMap 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) { + } catch (RemoteException e) { handleRemoteException(e); } - - // Save the current table - - SortedMap 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; - } - } } /**