use of org.apache.accumulo.master.Master in project accumulo by apache.
the class MasterReplicationCoordinatorTest method invalidOffset.
@Test(expected = IllegalArgumentException.class)
public void invalidOffset() {
Master master = EasyMock.createMock(Master.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
Instance inst = EasyMock.createMock(Instance.class);
EasyMock.expect(master.getInstance()).andReturn(inst);
EasyMock.expect(inst.getInstanceID()).andReturn("1234");
EasyMock.replay(master, reader, inst);
MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
Assert.assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 1));
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class MasterReplicationCoordinatorTest method randomServerFromMany.
@Test
public void randomServerFromMany() {
Master master = EasyMock.createMock(Master.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
Instance inst = EasyMock.createMock(Instance.class);
EasyMock.expect(master.getInstance()).andReturn(inst).anyTimes();
EasyMock.expect(inst.getInstanceID()).andReturn("1234").anyTimes();
EasyMock.replay(master, reader, inst);
MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
EasyMock.verify(master, reader, inst);
TreeSet<TServerInstance> instances = new TreeSet<>();
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
instances.add(inst1);
TServerInstance inst2 = new TServerInstance(HostAndPort.fromParts("host2", 1234), "session");
instances.add(inst2);
Assert.assertEquals(inst1, coordinator.getRandomTServer(instances, 0));
Assert.assertEquals(inst2, coordinator.getRandomTServer(instances, 1));
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class MasterReplicationCoordinatorTest method randomServer.
@Test
public void randomServer() {
Master master = EasyMock.createMock(Master.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
Instance inst = EasyMock.createMock(Instance.class);
EasyMock.expect(master.getInstance()).andReturn(inst);
EasyMock.expect(inst.getInstanceID()).andReturn("1234");
EasyMock.replay(master, reader, inst);
MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
Assert.assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 0));
}
Aggregations