hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1478104 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ hbase-server/src/test/java/org/apache/hadoop/hbase/replication/
Date Wed, 01 May 2013 17:32:25 GMT
Author: sershe
Date: Wed May  1 17:32:25 2013
New Revision: 1478104

URL: http://svn.apache.org/r1478104
Log:
HBASE-8460 [replication] Fix the three TODOs in TestReplicationStateBasic.testReplicationQueues
(Chris Trezzo)

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateBasic.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java?rev=1478104&r1=1478103&r2=1478104&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
(original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
Wed May  1 17:32:25 2013
@@ -120,6 +120,10 @@ public class ReplicationQueuesZKImpl ext
   @Override
   public SortedMap<String, SortedSet<String>> claimQueues(String regionserverZnode)
{
     SortedMap<String, SortedSet<String>> newQueues = new TreeMap<String, SortedSet<String>>();
+    if (ZKUtil.joinZNode(this.queuesZNode, regionserverZnode).equals(this.myQueuesZnode))
{
+      LOG.warn("An attempt was made to claim our own queues on region server " + regionserverZnode);
+      return newQueues;
+    }
     // check whether there is multi support. If yes, use it.
     if (conf.getBoolean(HConstants.ZOOKEEPER_USEMULTI, true)) {
       LOG.info("Atomically moving " + regionserverZnode + "'s hlogs to my queue");
@@ -337,7 +341,8 @@ public class ReplicationQueuesZKImpl ext
           try {
             position = parseHLogPositionFrom(positionBytes);
           } catch (DeserializationException e) {
-            LOG.warn("Failed parse of hlog position from the following znode: " + z);
+            LOG.warn("Failed parse of hlog position from the following znode: " + z
+                + ", Exception: " + e);
           }
           LOG.debug("Creating " + hlog + " with data " + position);
           String child = ZKUtil.joinZNode(newClusterZnode, hlog);
@@ -382,6 +387,9 @@ public class ReplicationQueuesZKImpl ext
    * @throws DeserializationException
    */
   private long parseHLogPositionFrom(final byte[] bytes) throws DeserializationException
{
+    if(bytes == null) {
+      throw new DeserializationException("Unable to parse null HLog position.");
+    }
     if (ProtobufUtil.isPBMagicPrefix(bytes)) {
       int pblen = ProtobufUtil.lengthOfPBMagic();
       ZooKeeperProtos.ReplicationHLogPosition.Builder builder =

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateBasic.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateBasic.java?rev=1478104&r1=1478103&r2=1478104&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateBasic.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateBasic.java
Wed May  1 17:32:25 2013
@@ -94,13 +94,11 @@ public abstract class TestReplicationSta
     rq1.removeLog("bogus", "bogus");
     rq1.removeAllQueues();
     assertNull(rq1.getAllQueues());
-    // TODO fix NPE if getting a log position on a file that does not exist
-    // assertEquals(0, rq1.getLogPosition("bogus", "bogus"));
+    assertEquals(0, rq1.getLogPosition("bogus", "bogus"));
     assertNull(rq1.getLogsInQueue("bogus"));
     assertEquals(0, rq1.claimQueues(new ServerName("bogus", 1234, -1L).toString()).size());
 
-    // TODO test setting a log position on a bogus file
-    // rq1.setLogPosition("bogus", "bogus", 5L);
+    rq1.setLogPosition("bogus", "bogus", 5L);
 
     populateQueues();
 
@@ -124,8 +122,8 @@ public abstract class TestReplicationSta
     assertEquals(5, queues.size());
     assertEquals(1, rq2.getListOfReplicators().size());
 
-    // TODO test claimQueues on yourself
-    // rq2.claimQueues(server2);
+    // Try to claim our own queues
+    assertEquals(0, rq2.claimQueues(server2).size());
 
     assertEquals(6, rq2.getAllQueues().size());
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java?rev=1478104&r1=1478103&r2=1478104&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationStateZKImpl.java
Wed May  1 17:32:25 2013
@@ -20,6 +20,8 @@ package org.apache.hadoop.hbase.replicat
 
 import java.io.IOException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.MediumTests;
@@ -38,6 +40,8 @@ import org.junit.experimental.categories
 @Category(MediumTests.class)
 public class TestReplicationStateZKImpl extends TestReplicationStateBasic {
 
+  private static final Log LOG = LogFactory.getLog(TestReplicationStateZKImpl.class);
+
   private static Configuration conf;
   private static HBaseTestingUtility utility;
   private static ZooKeeperWatcher zkw;
@@ -104,6 +108,7 @@ public class TestReplicationStateZKImpl 
 
     @Override
     public void abort(String why, Throwable e) {
+      LOG.info("Aborting " + serverName);
       this.isAborted = true;
     }
 



Mime
View raw message