Search in sources :

Example 1 with ReplicationQueuesClientZKImpl

use of org.apache.hadoop.hbase.replication.ReplicationQueuesClientZKImpl in project hbase by apache.

the class TestLogsCleaner method testZnodeCversionChange.

@Test(timeout = 5000)
public void testZnodeCversionChange() throws Exception {
    Configuration conf = TEST_UTIL.getConfiguration();
    ReplicationLogCleaner cleaner = new ReplicationLogCleaner();
    cleaner.setConf(conf);
    ReplicationQueuesClientZKImpl rqcMock = Mockito.mock(ReplicationQueuesClientZKImpl.class);
    Mockito.when(rqcMock.getQueuesZNodeCversion()).thenReturn(1, 2, 3, 4);
    Field rqc = ReplicationLogCleaner.class.getDeclaredField("replicationQueues");
    rqc.setAccessible(true);
    rqc.set(cleaner, rqcMock);
    // This should return eventually when cversion stabilizes
    cleaner.getDeletableFiles(new LinkedList<>());
}
Also used : Field(java.lang.reflect.Field) Configuration(org.apache.hadoop.conf.Configuration) ReplicationLogCleaner(org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner) ReplicationQueuesClientZKImpl(org.apache.hadoop.hbase.replication.ReplicationQueuesClientZKImpl) Test(org.junit.Test)

Example 2 with ReplicationQueuesClientZKImpl

use of org.apache.hadoop.hbase.replication.ReplicationQueuesClientZKImpl in project hbase by apache.

the class TestReplicationSourceManagerZkImpl method testFailoverDeadServerCversionChange.

@Test
public void testFailoverDeadServerCversionChange() throws Exception {
    final Server s0 = new DummyServer("cversion-change0.example.org");
    ReplicationQueues repQueues = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(conf, s0, s0.getZooKeeper()));
    repQueues.init(s0.getServerName().toString());
    // populate some znodes in the peer znode
    files.add("log1");
    files.add("log2");
    for (String file : files) {
        repQueues.addLog("1", file);
    }
    // simulate queue transfer
    Server s1 = new DummyServer("cversion-change1.example.org");
    ReplicationQueues rq1 = ReplicationFactory.getReplicationQueues(new ReplicationQueuesArguments(s1.getConfiguration(), s1, s1.getZooKeeper()));
    rq1.init(s1.getServerName().toString());
    ReplicationQueuesClientZKImpl client = (ReplicationQueuesClientZKImpl) ReplicationFactory.getReplicationQueuesClient(new ReplicationQueuesClientArguments(s1.getConfiguration(), s1, s1.getZooKeeper()));
    int v0 = client.getQueuesZNodeCversion();
    List<String> queues = rq1.getUnClaimedQueueIds(s0.getServerName().getServerName());
    for (String queue : queues) {
        rq1.claimQueue(s0.getServerName().getServerName(), queue);
    }
    rq1.removeReplicatorIfQueueIsEmpty(s0.getServerName().getServerName());
    int v1 = client.getQueuesZNodeCversion();
    // cversion should increase by 1 since a child node is deleted
    assertEquals(v0 + 1, v1);
    s0.stop("");
}
Also used : ReplicationQueues(org.apache.hadoop.hbase.replication.ReplicationQueues) ReplicationQueuesArguments(org.apache.hadoop.hbase.replication.ReplicationQueuesArguments) Server(org.apache.hadoop.hbase.Server) ReplicationQueuesClientZKImpl(org.apache.hadoop.hbase.replication.ReplicationQueuesClientZKImpl) ReplicationQueuesClientArguments(org.apache.hadoop.hbase.replication.ReplicationQueuesClientArguments) Test(org.junit.Test)

Aggregations

ReplicationQueuesClientZKImpl (org.apache.hadoop.hbase.replication.ReplicationQueuesClientZKImpl)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 Configuration (org.apache.hadoop.conf.Configuration)1 Server (org.apache.hadoop.hbase.Server)1 ReplicationQueues (org.apache.hadoop.hbase.replication.ReplicationQueues)1 ReplicationQueuesArguments (org.apache.hadoop.hbase.replication.ReplicationQueuesArguments)1 ReplicationQueuesClientArguments (org.apache.hadoop.hbase.replication.ReplicationQueuesClientArguments)1 ReplicationLogCleaner (org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner)1