hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r612141 - in /lucene/hadoop/trunk/src/contrib/hbase: ./ src/java/org/apache/hadoop/hbase/ src/test/org/apache/hadoop/hbase/
Date Tue, 15 Jan 2008 15:51:33 GMT
Author: stack
Date: Tue Jan 15 07:51:29 2008
New Revision: 612141

URL: http://svn.apache.org/viewvc?rev=612141&view=rev
Log:
HADOOP-2579 initializing a new HTable object against a nonexistent table
throws a NoServerForRegionException instead of a TableNotFoundException
when a different table has been created previously

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/HRegion.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HStore.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=612141&r1=612140&r2=612141&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Tue Jan 15 07:51:29 2008
@@ -126,6 +126,10 @@
    HADOOP-2587 Splits blocked by compactions cause region to be offline for
                duration of compaction. 
                (Bryan Duxbury via Stack)
+   HADOOP-2579 Initializing a new HTable object against a nonexistent table
+               throws a NoServerForRegionException instead of a
+               TableNotFoundException when a different table has been created
+               previously (Bryan Duxbury via Stack)
    
   IMPROVEMENTS
    HADOOP-2401 Add convenience put method that takes writable

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=612141&r1=612140&r2=612141&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 Jan 15 07:51:29 2008
@@ -409,6 +409,11 @@
             metaLocation.getRegionInfo().getRegionName(), 
             metaKey, HConstants.LATEST_TIMESTAMP);
 
+          if (regionInfoRow == null) {
+            throw new TableNotFoundException("Table '" + tableName + 
+              "' does not exist.");
+          }
+
           // convert the MapWritable into a Map we can use
           SortedMap<Text, byte[]> results = 
             sortedMapFromMapWritable(regionInfoRow);

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java?rev=612141&r1=612140&r2=612141&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java Tue
Jan 15 07:51:29 2008
@@ -1074,6 +1074,10 @@
           key = new HStoreKey(closestKey, ts);
         }
       }
+
+      if (key == null) {
+        return null;
+      }
           
       // now that we've found our key, get the values
       TreeMap<Text, byte []> result = new TreeMap<Text, byte[]>();

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java?rev=612141&r1=612140&r2=612141&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
Tue Jan 15 07:51:29 2008
@@ -1430,6 +1430,9 @@
       // ask the region for all the data 
       Map<Text, byte[]> map = region.getClosestRowBefore(row, ts);
       // convert to a MapWritable
+      if (map == null) {
+        return null;
+      }
       for (Map.Entry<Text, byte []> es: map.entrySet()) {
         result.put(new HStoreKey(row, es.getKey()),
             new ImmutableBytesWritable(es.getValue()));

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HStore.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HStore.java?rev=612141&r1=612140&r2=612141&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HStore.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HStore.java Tue
Jan 15 07:51:29 2008
@@ -191,7 +191,7 @@
     private void internalGetFull(SortedMap<HStoreKey, byte []> map, HStoreKey key,

         SortedMap<Text, byte []> results) {
 
-      if (map.isEmpty()) {
+      if (map.isEmpty() || key == null) {
         return;
       }
 
@@ -1595,6 +1595,10 @@
   void getFull(HStoreKey key, TreeMap<Text, byte []> results)
     throws IOException {
     Map<Text, List<Long>> deletes = new HashMap<Text, List<Long>>();
+    
+    if (key == null) {
+      return;
+    }
     
     this.lock.readLock().lock();
     memcache.getFull(key, results);

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=612141&r1=612140&r2=612141&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
Jan 15 07:51:29 2008
@@ -89,6 +89,7 @@
     this.numRetries = conf.getInt("hbase.client.retries.number", 5);
     this.rand = new Random();
     this.batch = new AtomicReference<BatchUpdate>();
+    this.connection.locateRegion(tableName, EMPTY_START_ROW);
     tableDoesNotExist = false;
     closed = false;
   }

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=612141&r1=612140&r2=612141&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 Jan 15 07:51:29 2008
@@ -25,10 +25,15 @@
 
 import org.apache.hadoop.io.Text;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
 /**
  * Tests HTable
  */
 public class TestHTable extends HBaseClusterTestCase implements HConstants {
+  private static final Log LOG = LogFactory.getLog(TestHTable.class);
   private static final HColumnDescriptor column =
     new HColumnDescriptor(COLUMN_FAMILY.toString());
 
@@ -134,4 +139,47 @@
     // to be reloaded.
     
   }
+  
+  /**
+    * For HADOOP-2579
+    */
+  public void testTableNotFoundExceptionWithoutAnyTables() {
+    try {
+      new HTable(conf, new Text("notATable"));
+      fail("Should have thrown a TableNotFoundException");
+    } catch (TableNotFoundException e) {
+      // expected
+    } catch (IOException e) {
+      e.printStackTrace();
+      fail("Should have thrown a TableNotFoundException instead of a " +
+        e.getClass());
+    }
+  }
+  
+  /**
+    * For HADOOP-2579
+    */
+  public void testTableNotFoundExceptionWithATable() {
+    try {
+      HColumnDescriptor column =
+        new HColumnDescriptor(COLUMN_FAMILY.toString());
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      HTableDescriptor testTableADesc =
+        new HTableDescriptor("table");
+      testTableADesc.addFamily(column);
+      admin.createTable(testTableADesc);
+
+      // This should throw a TableNotFoundException, it has not been created
+      new HTable(conf, new Text("notATable"));
+      
+      fail("Should have thrown a TableNotFoundException");
+    } catch (TableNotFoundException e) {
+      // expected
+    } catch (IOException e) {
+      e.printStackTrace();
+      fail("Should have thrown a TableNotFoundException instead of a " +
+        e.getClass());
+    }
+  }
+  
 }



Mime
View raw message