You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/10/29 17:03:30 UTC

svn commit: r1194900 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/ServerName.java src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java

Author: stack
Date: Sat Oct 29 15:03:30 2011
New Revision: 1194900

URL: http://svn.apache.org/viewvc?rev=1194900&view=rev
Log:
HBASE-4701 TestMasterObserver fails up on jenkins

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1194900&r1=1194899&r2=1194900&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Oct 29 15:03:30 2011
@@ -425,6 +425,7 @@ Release 0.92.0 - Unreleased
    HBASE-4641  Block cache can be mistakenly instantiated on Master (jgray)
    HBASE-4687  regionserver may miss zk-heartbeats to master when replaying
                edits at region open (prakash via jgray)
+   HBASE-4701  TestMasterObserver fails up on jenkins
 
   TESTS
    HBASE-4450  test for number of blocks read: to serve as baseline for expected

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java?rev=1194900&r1=1194899&r2=1194900&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/ServerName.java Sat Oct 29 15:03:30 2011
@@ -75,7 +75,8 @@ public class ServerName implements Compa
   private final long startcode;
 
   /**
-   * Cached bytes of this ServerName instance.
+   * Cached versioned bytes of this ServerName instance.
+   * @see #getVersionedBytes()
    */
   private byte [] bytes;
 
@@ -121,7 +122,7 @@ public class ServerName implements Compa
 
   /**
    * @return {@link #getServerName()} as bytes with a short-sized prefix with
-   * the {@link ServerName#VERSION} of this class.
+   * the ServerName#VERSION of this class.
    */
   public synchronized byte [] getVersionedBytes() {
     if (this.bytes == null) {

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java?rev=1194900&r1=1194899&r2=1194900&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java Sat Oct 29 15:03:30 2011
@@ -29,8 +29,12 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.NavigableMap;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.CoprocessorEnvironment;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -38,8 +42,6 @@ import org.apache.hadoop.hbase.HServerAd
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.UnknownRegionException;
-import org.apache.hadoop.hbase.CoprocessorEnvironment;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -56,6 +58,7 @@ import org.junit.Test;
  * interface hooks at all appropriate times during normal HMaster operations.
  */
 public class TestMasterObserver {
+  private static final Log LOG = LogFactory.getLog(TestMasterObserver.class);
 
   public static class CPMasterObserver implements MasterObserver {
 
@@ -642,27 +645,37 @@ public class TestMasterObserver {
 
     HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
     UTIL.createMultiRegions(table, TEST_FAMILY);
-
-    Map<HRegionInfo,HServerAddress> regions = table.getRegionsInfo();
-    assertFalse(regions.isEmpty());
-    Map.Entry<HRegionInfo, HServerAddress> firstRegion =
-        regions.entrySet().iterator().next();
-
-    // try to force a move
+    NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
+    Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
+    for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
+      if (e.getValue() != null) {
+        firstGoodPair = e;
+        break;
+      }
+    }
+    assertNotNull("Found a non-null entry", firstGoodPair);
+    LOG.info("Found " + firstGoodPair.toString());
+    // Try to force a move
     Collection<ServerName> servers = master.getClusterStatus().getServers();
     String destName = null;
+    String firstRegionHostnamePortStr = firstGoodPair.getValue().toString();
+    LOG.info("firstRegionHostnamePortStr=" + firstRegionHostnamePortStr);
+    boolean found = false;
+    // Find server that is NOT carrying the first region
     for (ServerName info : servers) {
-      HServerAddress hsa =
-        new HServerAddress(info.getHostname(), info.getPort());
-      if (!hsa.equals(firstRegion.getValue())) {
+      LOG.info("ServerName=" + info);
+      if (!firstRegionHostnamePortStr.equals(info.getHostAndPort())) {
         destName = info.toString();
+        found = true;
         break;
       }
     }
-    master.move(firstRegion.getKey().getEncodedNameAsBytes(),
-        Bytes.toBytes(destName));
+    assertTrue("Found server", found);
+    LOG.info("Found " + destName);
+    master.move(firstGoodPair.getKey().getEncodedNameAsBytes(),
+      Bytes.toBytes(destName));
     assertTrue("Coprocessor should have been called on region move",
-        cp.wasMoveCalled());
+      cp.wasMoveCalled());
 
     // make sure balancer is on
     master.balanceSwitch(true);