HBASE-8460 [replication] Fix the three TODOs in TestReplicationStateBasic.testReplicationQueues (Chris Trezzo)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1478104 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf1126de2b
commit
1d8ec61f64
|
@ -120,6 +120,10 @@ public class ReplicationQueuesZKImpl extends ReplicationStateZKBase implements R
|
|||
@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 extends ReplicationStateZKBase implements R
|
|||
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 extends ReplicationStateZKBase implements R
|
|||
* @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 =
|
||||
|
|
|
@ -94,13 +94,11 @@ public abstract class TestReplicationStateBasic {
|
|||
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 TestReplicationStateBasic {
|
|||
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());
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.hadoop.hbase.replication;
|
|||
|
||||
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;
|
|||
@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 extends TestReplicationStateBasic {
|
|||
|
||||
@Override
|
||||
public void abort(String why, Throwable e) {
|
||||
LOG.info("Aborting " + serverName);
|
||||
this.isAborted = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue