Search in sources :

Example 16 with ZooReader

use of org.apache.accumulo.fate.zookeeper.ZooReader 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)

Example 17 with ZooReader

use of org.apache.accumulo.fate.zookeeper.ZooReader in project accumulo by apache.

the class MonitorUtil method getLocation.

public static String getLocation(Instance instance) throws KeeperException, InterruptedException {
    ZooReader zr = new ZooReader(instance.getZooKeepers(), 30000);
    byte[] loc = zr.getData(ZooUtil.getRoot(instance) + Constants.ZMONITOR_HTTP_ADDR, null);
    return loc == null ? null : new String(loc, UTF_8);
}
Also used : ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader)

Aggregations

ZooReader (org.apache.accumulo.fate.zookeeper.ZooReader)17 Test (org.junit.Test)11 Connector (org.apache.accumulo.core.client.Connector)6 Instance (org.apache.accumulo.core.client.Instance)6 IOException (java.io.IOException)5 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)4 ZooCache (org.apache.accumulo.fate.zookeeper.ZooCache)4 File (java.io.File)3 ClusterControl (org.apache.accumulo.cluster.ClusterControl)3 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)3 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)3 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)3 Master (org.apache.accumulo.master.Master)3 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)3 Configuration (org.apache.hadoop.conf.Configuration)3 Path (org.apache.hadoop.fs.Path)3 BufferedOutputStream (java.io.BufferedOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 Socket (java.net.Socket)2 ArrayList (java.util.ArrayList)2