Examples of ZooKeeperServer


Examples of org.apache.zookeeper.server.ZooKeeperServer

        private final ZooKeeperServer zks;

        public ZKS() throws IOException, InterruptedException {
            snapdir = Files.createTempDir();
            logdir = Files.createTempDir();
            zks = new ZooKeeperServer(snapdir, logdir, 100);
            NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(new InetSocketAddress(PORT));
            f.startup(zks);
            waitForServerUp(PORT, 1000);
        }
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

  public ServerCnxnFactory mkInprocessZookeeper(String localdir, int port)
      throws IOException, InterruptedException {
    LOG.info("Starting inprocess zookeeper at port " + port + " and dir "
        + localdir);
    File localfile = new File(localdir);
    ZooKeeperServer zk = new ZooKeeperServer(localfile, localfile, 2000);
    ServerCnxnFactory factory =NIOServerCnxnFactory.createFactory(
        new InetSocketAddress(port),60);
    factory.startup(zk);
    return factory;
  }
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

      if (this.tickTime > 0) {
        tickTimeToUse = this.tickTime;
      } else {
        tickTimeToUse = TICK_TIME;
      }
      ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
      NIOServerCnxnFactory standaloneServerFactory;
      while (true) {
        try {
          standaloneServerFactory = new NIOServerCnxnFactory();
          standaloneServerFactory.configure(
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

    @Test
    public void testPRequest() throws Exception {
        File tmpDir = ClientBase.createTmpDir();
        ClientBase.setupTestEnv();
        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
        SyncRequestProcessor.setSnapCount(100);
        final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
        ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
        f.startup(zks);
        Assert.assertTrue("waiting for server being up ",
                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
        zks.sessionTracker = new MySessionTracker();
        PrepRequestProcessor processor = new PrepRequestProcessor(zks, new MyRequestProcessor());
        Request foo = new Request(null, 1l, 1, OpCode.create, ByteBuffer.allocate(3), null);
        processor.pRequest(foo);
        testEnd.await(5, java.util.concurrent.TimeUnit.SECONDS);
        f.shutdown();
        zks.shutdown();
    }
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

        final int CLIENT_PORT = PortAssignment.unique();
        final String HOSTPORT = "127.0.0.1:" + CLIENT_PORT;

        File tmpDir = ClientBase.createTmpDir();
        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);

        ServerCnxnFactory f = ServerCnxnFactory.createFactory(CLIENT_PORT, -1);
        f.startup(zks);
        Assert.assertTrue("waiting for server being up ", ClientBase
                .waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));

        CountdownWatcher watcher = new CountdownWatcher();
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, watcher);
        watcher.waitForConnected(CONNECTION_TIMEOUT);

        List<String> joiners = new ArrayList<String>();
        joiners.add("server.2=localhost:1234:1235;1236");
        // generate some transactions that will get logged
        try {
            zk.reconfig(joiners, null, null, -1, new Stat());
            Assert.fail("Reconfiguration in standalone should trigger " +
                        "UnimplementedException");
        } catch (KeeperException.UnimplementedException ex) {
            // expected
        }
        zk.close();

        zks.shutdown();
        f.shutdown();
        Assert.assertTrue("waiting for server being down ", ClientBase
                .waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
    }
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

        ZkTmpDir = File.createTempFile("zookeeper", "test");
        ZkTmpDir.delete();
        ZkTmpDir.mkdir();

        try {
            zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
            serverFactory =  new NIOServerCnxnFactory();
            serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), maxCC);
            serverFactory.startup(zks);
        } catch (Exception e) {
            // TODO Auto-generated catch block
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

        ClientBase.setupTestEnv();
        File zkTmpDir = File.createTempFile("zookeeper", "test");
        zkTmpDir.delete();
        zkTmpDir.mkdir();

        ZooKeeperServer zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, 2181);

        NIOServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
        serverFactory.configure(new InetSocketAddress(2181), 100);
        serverFactory.startup(zks);

        boolean b = ClientBase.waitForServerUp("127.0.0.1:2181", 5000);
        ServerConfiguration serverConf = new ServerConfiguration();
        serverConf.loadConf(hedwigConfigFile.toURI().toURL());

        logger.info("Zookeeper server up and running!");

        ZooKeeper zkc = new ZooKeeper("127.0.0.1", 2181, null);

        // initialize the zk client with (fake) values
        zkc.create("/ledgers", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zkc.create("/ledgers/available", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

        zkc.close();
        PubSubServer hedwigServer = null;
        try {
            logger.info("starting hedwig broker!");
            hedwigServer = new PubSubServer(serverConf);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Assert.assertNotNull("failed to instantiate hedwig pub sub server", hedwigServer);

        hedwigServer.shutdown();
        serverFactory.shutdown();

        zks.shutdown();

        zkTmpDir.delete();

        ClientBase.waitForServerDown("localhost:2181", 10000);
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

            ClientBase.setupTestEnv();
            ZkTmpDir = File.createTempFile("zookeeper", "test");
            ZkTmpDir.delete();
            ZkTmpDir.mkdir();

            zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
            serverFactory = new NIOServerCnxnFactory();
            serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 100);
            serverFactory.startup(zks);

            boolean b = ClientBase.waitForServerUp(HOSTPORT, ClientBase.CONNECTION_TIMEOUT);
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

            CommTestUtils.deleteDirectoryContents(zkDataDir);
        } else {
            zkDataDir.mkdirs();
        }

        ZooKeeperServer zks = new ZooKeeperServer(zkDataDir, zkDataDir, 3000);
        NIOServerCnxn.Factory nioZookeeperConnectionFactory = new NIOServerCnxn.Factory(new InetSocketAddress(ZK_PORT));
        nioZookeeperConnectionFactory.startup(zks);
        Assert.assertTrue("waiting for server being up", waitForServerUp("localhost", ZK_PORT, 4000));
        return nioZookeeperConnectionFactory;
View Full Code Here

Examples of org.apache.zookeeper.server.ZooKeeperServer

      int maxconnections = 1000;

      File dataFile = new File(logdir, "zookeeper_data").getAbsoluteFile();
      File snapFile = new File(logdir, "zookeeper_snap").getAbsoluteFile();

      server = new ZooKeeperServer(
          new FileTxnSnapLog(dataFile, snapFile),
          new BasicDataTreeBuilder());

      connection = new NIOServerCnxnFactory();
      connection.configure(new InetSocketAddress(port), maxconnections);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.