Search in sources :

Example 1 with NodeFailoverWorker

use of org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.NodeFailoverWorker in project hbase by apache.

the class TestReplicationSourceManager method testCleanupFailoverQueues.

@Test
public void testCleanupFailoverQueues() throws Exception {
    final Server server = new DummyServer("hostname1.example.org");
    ReplicationQueues rq = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(server.getConfiguration(), server, server.getZooKeeper()));
    rq.init(server.getServerName().toString());
    // populate some znodes in the peer znode
    SortedSet<String> files = new TreeSet<>();
    String group = "testgroup";
    String file1 = group + ".log1";
    String file2 = group + ".log2";
    files.add(file1);
    files.add(file2);
    for (String file : files) {
        rq.addLog("1", file);
    }
    Server s1 = new DummyServer("dummyserver1.example.org");
    ReplicationQueues rq1 = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(s1.getConfiguration(), s1, s1.getZooKeeper()));
    rq1.init(s1.getServerName().toString());
    ReplicationPeers rp1 = ReplicationFactory.getReplicationPeers(s1.getZooKeeper(), s1.getConfiguration(), s1);
    rp1.init();
    NodeFailoverWorker w1 = manager.new NodeFailoverWorker(server.getServerName().getServerName(), rq1, rp1, new UUID(new Long(1), new Long(2)));
    w1.run();
    assertEquals(1, manager.getWalsByIdRecoveredQueues().size());
    String id = "1-" + server.getServerName().getServerName();
    assertEquals(files, manager.getWalsByIdRecoveredQueues().get(id).get(group));
    manager.cleanOldLogs(file2, id, true);
    // log1 should be deleted
    assertEquals(Sets.newHashSet(file2), manager.getWalsByIdRecoveredQueues().get(id).get(group));
}
Also used : ReplicationQueues(org.apache.hadoop.hbase.replication.ReplicationQueues) ReplicationQueuesArguments(org.apache.hadoop.hbase.replication.ReplicationQueuesArguments) NodeFailoverWorker(org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.NodeFailoverWorker) Server(org.apache.hadoop.hbase.Server) TreeSet(java.util.TreeSet) UUID(java.util.UUID) ReplicationPeers(org.apache.hadoop.hbase.replication.ReplicationPeers) Test(org.junit.Test)

Example 2 with NodeFailoverWorker

use of org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.NodeFailoverWorker in project hbase by apache.

the class TestReplicationSourceManager method testCleanupUnknownPeerZNode.

@Test
public void testCleanupUnknownPeerZNode() throws Exception {
    final Server server = new DummyServer("hostname2.example.org");
    ReplicationQueues rq = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(server.getConfiguration(), server, server.getZooKeeper()));
    rq.init(server.getServerName().toString());
    // populate some znodes in the peer znode
    // add log to an unknown peer
    String group = "testgroup";
    rq.addLog("2", group + ".log1");
    rq.addLog("2", group + ".log2");
    NodeFailoverWorker w1 = manager.new NodeFailoverWorker(server.getServerName().getServerName());
    w1.run();
    // The log of the unknown peer should be removed from zk
    for (String peer : manager.getAllQueues()) {
        assertTrue(peer.startsWith("1"));
    }
}
Also used : ReplicationQueues(org.apache.hadoop.hbase.replication.ReplicationQueues) ReplicationQueuesArguments(org.apache.hadoop.hbase.replication.ReplicationQueuesArguments) NodeFailoverWorker(org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.NodeFailoverWorker) Server(org.apache.hadoop.hbase.Server) Test(org.junit.Test)

Aggregations

Server (org.apache.hadoop.hbase.Server)2 ReplicationQueues (org.apache.hadoop.hbase.replication.ReplicationQueues)2 ReplicationQueuesArguments (org.apache.hadoop.hbase.replication.ReplicationQueuesArguments)2 NodeFailoverWorker (org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.NodeFailoverWorker)2 Test (org.junit.Test)2 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 ReplicationPeers (org.apache.hadoop.hbase.replication.ReplicationPeers)1