use of org.apache.accumulo.core.replication.ReplicationTarget in project accumulo by apache.
the class SequentialWorkAssignerTest method basicZooKeeperCleanup.
@Test
public void basicZooKeeperCleanup() throws Exception {
DistributedWorkQueue workQueue = createMock(DistributedWorkQueue.class);
ZooCache zooCache = createMock(ZooCache.class);
Instance inst = createMock(Instance.class);
Map<String, Map<Table.ID, String>> queuedWork = new TreeMap<>();
Map<Table.ID, String> cluster1Work = new TreeMap<>();
// Two files for cluster1, one for table '1' and another for table '2' we havce assigned work for
cluster1Work.put(Table.ID.of("1"), DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", Table.ID.of("1"))));
cluster1Work.put(Table.ID.of("2"), DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", Table.ID.of("2"))));
queuedWork.put("cluster1", cluster1Work);
assigner.setConnector(conn);
assigner.setZooCache(zooCache);
assigner.setWorkQueue(workQueue);
assigner.setQueuedWork(queuedWork);
expect(conn.getInstance()).andReturn(inst);
expect(inst.getInstanceID()).andReturn("instance");
// file1 replicated
expect(zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/" + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", Table.ID.of("1"))))).andReturn(null);
// file2 still needs to replicate
expect(zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/" + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", Table.ID.of("2"))))).andReturn(new byte[0]);
replay(workQueue, zooCache, conn, inst);
assigner.cleanupFinishedWork();
verify(workQueue, zooCache, conn, inst);
Assert.assertEquals(1, cluster1Work.size());
Assert.assertEquals(DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", Table.ID.of("2"))), cluster1Work.get(Table.ID.of("2")));
}
use of org.apache.accumulo.core.replication.ReplicationTarget in project accumulo by apache.
the class UnorderedWorkAssignerTest method workQueuedUsingFileName.
@Test
public void workQueuedUsingFileName() throws Exception {
ReplicationTarget target = new ReplicationTarget("cluster1", "table1", Table.ID.of("1"));
DistributedWorkQueue workQueue = createMock(DistributedWorkQueue.class);
Set<String> queuedWork = new HashSet<>();
assigner.setQueuedWork(queuedWork);
assigner.setWorkQueue(workQueue);
Path p = new Path("/accumulo/wal/tserver+port/" + UUID.randomUUID());
String expectedQueueKey = p.getName() + DistributedWorkQueueWorkAssignerHelper.KEY_SEPARATOR + target.getPeerName() + DistributedWorkQueueWorkAssignerHelper.KEY_SEPARATOR + target.getRemoteIdentifier() + DistributedWorkQueueWorkAssignerHelper.KEY_SEPARATOR + target.getSourceTableId();
workQueue.addWork(expectedQueueKey, p.toString());
expectLastCall().once();
replay(workQueue);
assigner.queueWork(p, target);
Assert.assertEquals(1, queuedWork.size());
Assert.assertEquals(expectedQueueKey, queuedWork.iterator().next());
}
Aggregations