Index: src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java =================================================================== --- src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java (revision 598499) +++ src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java (working copy) @@ -31,7 +31,8 @@ public class TestHTable extends HBaseClusterTestCase implements HConstants { private static final HColumnDescriptor column = new HColumnDescriptor(COLUMN_FAMILY.toString()); - + + private static final Text nosuchTable = new Text("nosuchTable"); private static final Text tableAname = new Text("tableA"); private static final Text tableBname = new Text("tableB"); @@ -42,6 +43,19 @@ * @throws IOException */ public void testHTable() throws IOException { + byte[] value = "value".getBytes(UTF8_ENCODING); + + try { + new HTable(conf, nosuchTable); + + } catch (TableNotFoundException e) { + // expected + + } catch (IOException e) { + e.printStackTrace(); + fail(); + } + HTableDescriptor tableAdesc = new HTableDescriptor(tableAname.toString()); tableAdesc.addFamily(column); @@ -56,8 +70,6 @@ // put some data into table A - byte[] value = "value".getBytes(UTF8_ENCODING); - HTable a = new HTable(conf, tableAname); long lockid = a.startUpdate(row); a.put(lockid, COLUMN_FAMILY, value); @@ -82,6 +94,7 @@ b.put(lockid, e.getKey(), e.getValue()); } b.commit(lockid); + b.abort(lockid); } } finally { s.close(); Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java (revision 598499) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java (working copy) @@ -738,7 +738,10 @@ regionInfo, new HServerAddress(serverAddress))); } } catch (IOException e) { - if (tries == numRetries - 1) { // no retries left + if (e instanceof TableNotFoundException) { + throw e; // don't retry + } + if (tries == numRetries - 1) { // no retries left if (e instanceof RemoteException) { e = RemoteExceptionHandler.decodeRemoteException((RemoteException) e); } Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (revision 598499) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (working copy) @@ -57,12 +57,17 @@ protected Random rand; protected volatile SortedMap tableServers; protected AtomicReference batch; + + protected volatile boolean tableDoesNotExist; // For row mutation operations protected volatile boolean closed; protected void checkClosed() { + if (tableDoesNotExist) { + throw new IllegalStateException("table does not exist: " + tableName); + } if (closed) { throw new IllegalStateException("table is closed"); } @@ -77,13 +82,15 @@ */ public HTable(HBaseConfiguration conf, Text tableName) throws IOException { closed = true; + tableDoesNotExist = true; this.connection = HConnectionManager.getConnection(conf); this.tableName = tableName; this.pause = conf.getLong("hbase.client.pause", 10 * 1000); this.numRetries = conf.getInt("hbase.client.retries.number", 5); this.rand = new Random(); + this.batch = new AtomicReference(); tableServers = connection.getTableServers(tableName); - this.batch = new AtomicReference(); + tableDoesNotExist = false; closed = false; } @@ -685,8 +692,7 @@ */ public synchronized void abort(long lockid) { checkClosed(); - updateInProgress(true); - if (batch.get().getLockid() != lockid) { + if (batch.get() != null && batch.get().getLockid() != lockid) { throw new IllegalArgumentException("invalid lock id " + lockid); } batch.set(null);