Search in sources :

Example 86 with ZooKeeperServer

use of org.apache.zookeeper.server.ZooKeeperServer in project zookeeper by apache.

the class ThrottledOpQuorumTest method testThrottledOpFollower.

@Test
public void testThrottledOpFollower() throws IOException, InterruptedException, KeeperException {
    ZooKeeper zk = null;
    try {
        int clientPort = (getLeaderClientPort() == portClient1) ? portClient2 : portClient1;
        zk = createClient("localhost:" + clientPort);
        QuorumPeer qp = (getLeaderClientPort() == portClient1) ? s2 : s1;
        ZooKeeperServer zs = qp.getActiveServer();
        ThrottledOpHelper test = new ThrottledOpHelper();
        test.testThrottledOp(zk, zs);
    } finally {
        if (zk != null) {
            zk.close();
        }
    }
}
Also used : ZooKeeper(org.apache.zookeeper.ZooKeeper) QuorumPeer(org.apache.zookeeper.server.quorum.QuorumPeer) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) Test(org.junit.jupiter.api.Test)

Example 87 with ZooKeeperServer

use of org.apache.zookeeper.server.ZooKeeperServer in project zookeeper by apache.

the class ThrottledOpQuorumTest method testThrottledAclFollower.

@Test
public void testThrottledAclFollower() throws Exception {
    ZooKeeper zk = null;
    try {
        int clientPort = (getLeaderClientPort() == portClient1) ? portClient2 : portClient1;
        zk = createClient("localhost:" + clientPort);
        QuorumPeer qp = (getLeaderClientPort() == portClient1) ? s2 : s1;
        ZooKeeperServer zs = qp.getActiveServer();
        ThrottledOpHelper test = new ThrottledOpHelper();
        test.testThrottledAcl(zk, zs);
    } finally {
        if (zk != null) {
            zk.close();
        }
    }
}
Also used : ZooKeeper(org.apache.zookeeper.ZooKeeper) QuorumPeer(org.apache.zookeeper.server.quorum.QuorumPeer) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) Test(org.junit.jupiter.api.Test)

Example 88 with ZooKeeperServer

use of org.apache.zookeeper.server.ZooKeeperServer in project zookeeper by apache.

the class ThrottledOpObserverTest method testThrottledAclObserver.

@Test
public void testThrottledAclObserver() throws Exception {
    ZooKeeper zk = null;
    try {
        zk = createClient("localhost:" + getFirstObserverClientPort());
        ZooKeeperServer zs = getFirstObserver().getActiveServer();
        ThrottledOpHelper test = new ThrottledOpHelper();
        test.testThrottledAcl(zk, zs);
    } finally {
        if (zk != null) {
            zk.close();
        }
    }
}
Also used : ZooKeeper(org.apache.zookeeper.ZooKeeper) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) Test(org.junit.jupiter.api.Test)

Example 89 with ZooKeeperServer

use of org.apache.zookeeper.server.ZooKeeperServer in project zookeeper by apache.

the class ThrottledOpStandaloneTest method testThrottledAcl.

@Test
public void testThrottledAcl() throws Exception {
    ZooKeeper zk = null;
    try {
        zk = createClient(hostPort);
        ZooKeeperServer zs = serverFactory.getZooKeeperServer();
        ThrottledOpHelper test = new ThrottledOpHelper();
        test.testThrottledAcl(zk, zs);
    } finally {
        if (zk != null) {
            zk.close();
        }
    }
}
Also used : ZooKeeper(org.apache.zookeeper.ZooKeeper) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) Test(org.junit.jupiter.api.Test)

Example 90 with ZooKeeperServer

use of org.apache.zookeeper.server.ZooKeeperServer in project incubator-pulsar by apache.

the class ZookeeperServerTest method start.

public void start() throws IOException {
    try {
        zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperServer.DEFAULT_TICK_TIME);
        zks.setMaxSessionTimeout(20000);
        serverFactory = new NIOServerCnxnFactory();
        serverFactory.configure(new InetSocketAddress(zkPort), 1000);
        serverFactory.startup(zks);
    } catch (Exception e) {
        log.error("Exception while instantiating ZooKeeper", e);
    }
    LocalBookkeeperEnsemble.waitForServerUp(hostPort, 30000);
    log.info("ZooKeeper started at {}", hostPort);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) NIOServerCnxnFactory(org.apache.zookeeper.server.NIOServerCnxnFactory) ZooKeeperServer(org.apache.zookeeper.server.ZooKeeperServer) IOException(java.io.IOException)

Aggregations

ZooKeeperServer (org.apache.zookeeper.server.ZooKeeperServer)96 File (java.io.File)39 Test (org.junit.jupiter.api.Test)33 ZooKeeper (org.apache.zookeeper.ZooKeeper)31 InetSocketAddress (java.net.InetSocketAddress)28 IOException (java.io.IOException)27 ServerCnxnFactory (org.apache.zookeeper.server.ServerCnxnFactory)26 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)25 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)10 Stat (org.apache.zookeeper.data.Stat)9 ZKDatabase (org.apache.zookeeper.server.ZKDatabase)8 ArrayList (java.util.ArrayList)6 ServerConfig (org.apache.zookeeper.server.ServerConfig)6 InterruptedIOException (java.io.InterruptedIOException)4 BindException (java.net.BindException)4 KeeperException (org.apache.zookeeper.KeeperException)4 Test (org.junit.Test)4 Field (java.lang.reflect.Field)3 ACL (org.apache.zookeeper.data.ACL)3 Proposal (org.apache.zookeeper.server.quorum.Leader.Proposal)3