hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1420333 - in /hbase/branches/0.92/src: main/java/org/apache/hadoop/hbase/catalog/MetaReader.java test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
Date Tue, 11 Dec 2012 18:48:25 GMT
Author: tedyu
Date: Tue Dec 11 18:48:24 2012
New Revision: 1420333

URL: http://svn.apache.org/viewvc?rev=1420333&view=rev
Log:
HBASE-7307 MetaReader.tableExists should not return false if the specified table regions has
been split (Rajesh)


Modified:
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java?rev=1420333&r1=1420332&r2=1420333&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java Tue
Dec 11 18:48:24 2012
@@ -432,7 +432,6 @@ public class MetaReader {
           return true;
         }
         if (!isInsideTable(this.current, tableNameBytes)) return false;
-        if (this.current.isSplitParent()) return true;
         // Else call super and add this Result to the collection.
         super.visit(r);
         // Stop collecting regions from table after we get one.

Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java?rev=1420333&r1=1420332&r2=1420333&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
(original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
Tue Dec 11 18:48:24 2012
@@ -41,9 +41,11 @@ import org.apache.hadoop.hbase.MiniHBase
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.UnknownRegionException;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
+import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.executor.RegionTransitionData;
 import org.apache.hadoop.hbase.master.HMaster;
@@ -592,6 +594,61 @@ public class TestSplitTransactionOnClust
     }
   }
   
+  @Test(timeout = 20000)
+  public void testTableExistsIfTheSpecifiedTableRegionIsSplitParent() throws Exception {
+    final byte[] tableName = 
+        Bytes.toBytes("testTableExistsIfTheSpecifiedTableRegionIsSplitParent");
+    HRegionServer regionServer = null;
+    List<HRegion> regions = null;
+    HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
+    try {
+      // Create table then get the single region for our new table.
+      HTableDescriptor htd = new HTableDescriptor(tableName);
+      htd.addFamily(new HColumnDescriptor("cf"));
+      admin.createTable(htd);
+      HTable t = new HTable(cluster.getConfiguration(), tableName);
+      regions = cluster.getRegions(tableName);
+      int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName());
+      regionServer = cluster.getRegionServer(regionServerIndex);
+      insertData(tableName, admin, t);
+      // Turn off balancer so it doesn't cut in and mess up our placements.
+      cluster.getMaster().setCatalogJanitorEnabled(false);
+      boolean tableExists = MetaReader.tableExists(regionServer.getCatalogTracker(),
+          Bytes.toString(tableName));
+      assertEquals("The specified table should present.", true, tableExists);
+      SplitTransaction st = new SplitTransaction(regions.get(0), Bytes.toBytes("row2"));
+      try {
+        st.prepare();
+        st.createDaughters(regionServer, regionServer);
+      } catch (IOException e) {
+
+      }
+      tableExists = MetaReader.tableExists(regionServer.getCatalogTracker(),
+          Bytes.toString(tableName));
+      assertEquals("The specified table should present.", true, tableExists);
+    } finally {
+      cluster.getMaster().setCatalogJanitorEnabled(true);
+      admin.close();
+    }
+  }
+  
+  private void insertData(final byte[] tableName, HBaseAdmin admin, HTable t) throws IOException,
+      InterruptedException {
+    Put p = new Put(Bytes.toBytes("row1"));
+    p.add(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("1"));
+    t.put(p);
+    p = new Put(Bytes.toBytes("row2"));
+    p.add(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("2"));
+    t.put(p);
+    p = new Put(Bytes.toBytes("row3"));
+    p.add(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("3"));
+    t.put(p);
+    p = new Put(Bytes.toBytes("row4"));
+    p.add(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("4"));
+    t.put(p);
+    admin.flush(tableName);
+  }
+  
   public static class MockedSplitTransaction extends SplitTransaction {
 
     public MockedSplitTransaction(HRegion r, byte[] splitrow) {



Mime
View raw message