You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2007/10/17 02:09:56 UTC

svn commit: r585293 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java src/test/org/apache/hadoop/hbase/MultiRegionTable.java

Author: stack
Date: Tue Oct 16 17:09:55 2007
New Revision: 585293

URL: http://svn.apache.org/viewvc?rev=585293&view=rev
Log:
HADOOP-2064 TestSplit assertion and NPE failures (Patch build #952 and #953)

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MultiRegionTable.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=585293&r1=585292&r2=585293&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Tue Oct 16 17:09:55 2007
@@ -12,6 +12,7 @@
   BUG FIXES
    HADOOP-2059 In tests, exceptions in min dfs shutdown should not fail test
                (e.g. nightly #272)
+   HADOOP-2064 TestSplit assertion and NPE failures (Patch build #952 and #953)
 
   IMPROVEMENTS
     HADOOP-2401 Add convenience put method that takes writable

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java?rev=585293&r1=585292&r2=585293&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java Tue Oct 16 17:09:55 2007
@@ -51,8 +51,8 @@
   private boolean shutdownDFS;
   private Path parentdir;
   private MasterThread masterThread = null;
-  ArrayList<RegionServerThread> regionThreads =
-    new ArrayList<RegionServerThread>();
+  List<RegionServerThread> regionThreads =
+    java.util.Collections.synchronizedList(new ArrayList<RegionServerThread>());
   private boolean deleteOnExit = true;
 
   /**
@@ -460,7 +460,7 @@
     }
   }
 
-  public ArrayList<RegionServerThread> getRegionThreads() {
+  public List<RegionServerThread> getRegionThreads() {
     return this.regionThreads;
   }
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MultiRegionTable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MultiRegionTable.java?rev=585293&r1=585292&r2=585293&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MultiRegionTable.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MultiRegionTable.java Tue Oct 16 17:09:55 2007
@@ -40,10 +40,10 @@
   static final Log LOG = LogFactory.getLog(MultiRegionTable.class.getName());
 
   /**
-   * Make a multi-region table.  Presumption is that table already exists.
-   * Makes it multi-region by filling with data and provoking splits.
-   * Asserts parent region is cleaned up after its daughter splits release all
-   * references.
+   * Make a multi-region table.  Presumption is that table already exists and
+   * that there is only one regionserver. Makes it multi-region by filling with
+   * data and provoking splits. Asserts parent region is cleaned up after its
+   * daughter splits release all references.
    * @param conf
    * @param cluster
    * @param localFs
@@ -75,14 +75,28 @@
     int count = count(meta, tableName);
     HTable t = new HTable(conf, new Text(tableName));
     addContent(new HTableIncommon(t), columnName);
+    LOG.info("Finished content loading");
     
     // All is running in the one JVM so I should be able to get the single
     // region instance and bring on a split.
-    HRegionInfo hri =
-      t.getRegionLocation(HConstants.EMPTY_START_ROW).getRegionInfo();
-    HRegion r = cluster.regionThreads.get(0).getRegionServer().
-      onlineRegions.get(hri.getRegionName());
-    
+    // Presumption is that there is only one regionserver.
+    HRegionInfo hri = null;
+    HRegion r = null;
+    for (int i = 0; i < 30; i++) {
+      hri = t.getRegionLocation(HConstants.EMPTY_START_ROW).getRegionInfo();
+      LOG.info("Region location: " + hri);
+      r = cluster.getRegionThreads().get(0).getRegionServer().
+          onlineRegions.get(hri.getRegionName());
+      if (r != null) {
+        break;
+      }
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException e) {
+        LOG.warn("Waiting on region to come online", e);
+      }
+    }
+
     // Flush will provoke a split next time the split-checker thread runs.
     r.flushcache(false);
     
@@ -109,6 +123,7 @@
     Map<Text, byte []> data = getSplitParentInfo(meta, hri);
     HRegionInfo parent =
       Writables.getHRegionInfoOrNull(data.get(HConstants.COL_REGIONINFO));
+    LOG.info("Found parent region: " + parent);
     assertTrue(parent.isOffline());
     assertTrue(parent.isSplit());
     HRegionInfo splitA =
@@ -227,7 +242,8 @@
         }
         // Make sure I get the parent.
         if (hri.getRegionName().toString().
-            equals(parent.getRegionName().toString())) {
+            equals(parent.getRegionName().toString()) &&
+              hri.getRegionId() == parent.getRegionId()) {
           return curVals;
         }
       }