hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r1439635 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/replication/ main/java/org/apache/hadoop/hbase/replication/regionserver/ test/java/org/apache/hadoop/hbase/replication/
Date Mon, 28 Jan 2013 21:07:47 GMT
Author: jdcryans
Date: Mon Jan 28 21:07:46 2013
New Revision: 1439635

URL: http://svn.apache.org/viewvc?rev=1439635&view=rev
Log:
HBASE-7673  Incorrect error logging when a replication peer
            is removed (Gabriel Reid via JD)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java?rev=1439635&r1=1439634&r2=1439635&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
Mon Jan 28 21:07:46 2013
@@ -995,6 +995,15 @@ public class ReplicationZookeeper implem
   public Map<String, ReplicationPeer> getPeerClusters() {
     return this.peerClusters;
   }
+  
+  /**
+   * Determine if a ZK path points to a peer node.
+   * @param path path to be checked
+   * @return true if the path points to a peer node, otherwise false
+   */
+  public boolean isPeerPath(String path) {
+    return path.split("/").length == peersZNode.split("/").length + 1;
+  }
 
   /**
    * Extracts the znode name of a peer cluster from a ZK path

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java?rev=1439635&r1=1439634&r2=1439635&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
Mon Jan 28 21:07:46 2013
@@ -73,7 +73,7 @@ public class ReplicationSourceManager {
   private final ReplicationZookeeper zkHelper;
   // All about stopping
   private final Stoppable stopper;
-  // All logs we are currently trackign
+  // All logs we are currently tracking
   private final Map<String, SortedSet<String>> hlogsById;
   private final Configuration conf;
   private final FileSystem fs;
@@ -504,8 +504,10 @@ public class ReplicationSourceManager {
       if (peers == null) {
         return;
       }
-      String id = ReplicationZookeeper.getZNodeName(path);
-      removePeer(id);
+      if (zkHelper.isPeerPath(path)) {
+        String id = ReplicationZookeeper.getZNodeName(path);
+        removePeer(id);
+      }
     }
 
     /**

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java?rev=1439635&r1=1439634&r2=1439635&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
Mon Jan 28 21:07:46 2013
@@ -18,6 +18,10 @@
 
 package org.apache.hadoop.hbase.replication;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -28,6 +32,7 @@ import org.apache.hadoop.hbase.MediumTes
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.zookeeper.KeeperException;
 import org.junit.AfterClass;
@@ -35,8 +40,6 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import static org.junit.Assert.assertEquals;
-
 @Category(MediumTests.class)
 public class TestReplicationZookeeper {
 
@@ -74,6 +77,24 @@ public class TestReplicationZookeeper {
     // HBASE-5586 used to get an NPE
     assertEquals(0, repZk.getSlavesAddresses("1").size());
   }
+  
+  @Test
+  public void testIsPeerPath_PathToParentOfPeerNode() {
+    String peerParentNode = repZk.getPeersZNode();
+    assertFalse(repZk.isPeerPath(peerParentNode));
+  }
+  
+  @Test
+  public void testIsPeerPath_PathToChildOfPeerNode() {
+    String peerChild = ZKUtil.joinZNode(ZKUtil.joinZNode(repZk.getPeersZNode(), "1"), "child");
+    assertFalse(repZk.isPeerPath(peerChild));
+  }
+  
+  @Test
+  public void testIsPeerPath_ActualPeerPath() {
+    String peerPath = ZKUtil.joinZNode(repZk.getPeersZNode(), "1");
+    assertTrue(repZk.isPeerPath(peerPath));
+  }
 
   static class DummyServer implements Server {
 



Mime
View raw message