Search in sources :

Example 6 with Master

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));
}
Also used : Master(org.apache.accumulo.master.Master) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Test(org.junit.Test)

Example 7 with Master

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));
}
Also used : Master(org.apache.accumulo.master.Master) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Instance(org.apache.accumulo.core.client.Instance) TreeSet(java.util.TreeSet) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Test(org.junit.Test)

Example 8 with Master

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));
}
Also used : Master(org.apache.accumulo.master.Master) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Test(org.junit.Test)

Aggregations

Master (org.apache.accumulo.master.Master)8 Test (org.junit.Test)6 Instance (org.apache.accumulo.core.client.Instance)5 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)4 ZooReader (org.apache.accumulo.fate.zookeeper.ZooReader)3 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)2 JCommander (com.beust.jcommander.JCommander)1 LinkedHashMap (java.util.LinkedHashMap)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Help (org.apache.accumulo.core.cli.Help)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)1 Credentials (org.apache.accumulo.core.client.impl.Credentials)1 ReplicationOperationsImpl (org.apache.accumulo.core.client.impl.ReplicationOperationsImpl)1 Table (org.apache.accumulo.core.client.impl.Table)1 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)1 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)1