HBASE-7673 Incorrect error logging when a replication peer

is removed (Gabriel Reid via JD)


git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1439635 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2013-01-28 21:07:46 +00:00
parent 92bc4bd87c
commit 938a6e7ccd
3 changed files with 37 additions and 5 deletions

View File

@ -996,6 +996,15 @@ public class ReplicationZookeeper implements Closeable {
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
* @param fullPath Path to extract the id from

View File

@ -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,9 +504,11 @@ public class ReplicationSourceManager {
if (peers == null) {
return;
}
if (zkHelper.isPeerPath(path)) {
String id = ReplicationZookeeper.getZNodeName(path);
removePeer(id);
}
}
/**
* Called when an existing node has a child node added or removed.

View File

@ -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.MediumTests;
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 {
@ -75,6 +78,24 @@ public class TestReplicationZookeeper {
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 {
@Override