hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r598555 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/HConnectionManager.java src/java/org/apache/hadoop/hbase/HTable.java src/test/org/apache/hadoop/hbase/TestHTable.java
Date Tue, 27 Nov 2007 08:35:08 GMT
Author: jimk
Date: Tue Nov 27 00:35:08 2007
New Revision: 598555

URL: http://svn.apache.org/viewvc?rev=598555&view=rev
Log:
HADOOP-2262 HADOOP-2261 fail fast on non-existing table, change abort to function after commit
even if commit was successful

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=598555&r1=598554&r2=598555&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Tue Nov 27 00:35:08 2007
@@ -51,6 +51,8 @@
     HADOOP-2139 (phase 2) Make region server more event driven
     HADOOP-2289 Useless efforts of looking for the non-existant table in select
                 command.
+    HADOOP-2262 HADOOP-2261 fail fast on non-existing table, change abort to
+                function after commit even if commit was successful
 
 Release 0.15.1
 Branch 0.15

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java?rev=598555&r1=598554&r2=598555&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
Tue Nov 27 00:35:08 2007
@@ -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);
             }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java?rev=598555&r1=598554&r2=598555&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java Tue
Nov 27 00:35:08 2007
@@ -57,12 +57,17 @@
   protected Random rand;
   protected volatile SortedMap<Text, HRegionLocation> tableServers;
   protected AtomicReference<BatchUpdate> 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();
-    tableServers = connection.getTableServers(tableName);
     this.batch = new AtomicReference<BatchUpdate>();
+    tableServers = connection.getTableServers(tableName);
+    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);

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java?rev=598555&r1=598554&r2=598555&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHTable.java
Tue Nov 27 00:35:08 2007
@@ -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();



Mime
View raw message