Examples of NIOServerCnxnFactory


Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

        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();
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

            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.NIOServerCnxnFactory

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

      connection = new NIOServerCnxnFactory();
      connection.configure(new InetSocketAddress(port), maxconnections);
      connection.startup(server);

      return connection.getLocalAddress();
    }
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

    }
    File dataDir = createTmpDir(BASETEST);
    zks = new ZooKeeperServer(dataDir, dataDir, 3000);
    final int PORT = Integer.parseInt(hostPort.split(":")[1]);
    if (factory == null) {
      factory = new NIOServerCnxnFactory();
      factory.configure(new InetSocketAddress(PORT), maxCnxns);
    }
    factory.startup(zks);
    Assert.assertTrue("waiting for server up",
        waitForServerUp("127.0.0.1:" + PORT,
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

    zkTmpDir = File.createTempFile("zookeeper", "test");
    zkTmpDir.delete();
    zkTmpDir.mkdir();
    try {
      zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperDefaultPort);
      serverFactory = new NIOServerCnxnFactory();
      serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
      serverFactory.startup(zks);
    } catch (Exception e) {
      LOG.error("Exception while instantiating ZooKeeper", e);
    }
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

    ZkTmpDir.delete();
    ZkTmpDir.mkdir();

    try {
      zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
      serverFactory = new NIOServerCnxnFactory();
      serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
      serverFactory.startup(zks);
    } catch (Exception e) {
      LOG.error("Exception while instantiating ZooKeeper", e);
    }
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

        tickTimeToUse = this.tickTime;
      } else {
        tickTimeToUse = TICK_TIME;
      }
      ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
      NIOServerCnxnFactory standaloneServerFactory;
      while (true) {
        try {
          standaloneServerFactory = new NIOServerCnxnFactory();
          standaloneServerFactory.configure(
            new InetSocketAddress(tentativePort),
            configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS,
              1000));
        } catch (BindException e) {
          LOG.debug("Failed binding ZK Server to client port: " +
              tentativePort, e);
          // We're told to use some port but it's occupied, fail
          if (defaultClientPort > 0) return -1;
          // This port is already in use, try to use another.
          tentativePort = selectClientPort();
          continue;
        }
        break;
      }

      // Start up this ZK server
      standaloneServerFactory.startup(server);
      if (!waitForServerUp(tentativePort, CONNECTION_TIMEOUT)) {
        throw new IOException("Waiting for startup of standalone server");
      }

      // We have selected this port as a client port.
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

      return;
    }

    // shut down all the zk servers
    for (int i = 0; i < standaloneServerFactoryList.size(); i++) {
      NIOServerCnxnFactory standaloneServerFactory =
        standaloneServerFactoryList.get(i);
      int clientPort = clientPortList.get(i);

      standaloneServerFactory.shutdown();
      if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) {
        throw new IOException("Waiting for shutdown of standalone server");
      }
    }
    for (ZooKeeperServer zkServer: zooKeeperServers) {
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

    if (!started || activeZKServerIndex < 0 ) {
      return -1;
    }

    // Shutdown the current active one
    NIOServerCnxnFactory standaloneServerFactory =
      standaloneServerFactoryList.get(activeZKServerIndex);
    int clientPort = clientPortList.get(activeZKServerIndex);

    standaloneServerFactory.shutdown();
    if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) {
      throw new IOException("Waiting for shutdown of standalone server");
    }

    // remove the current active zk server
View Full Code Here

Examples of org.apache.zookeeper.server.NIOServerCnxnFactory

      return ;
    }

    int backupZKServerIndex = activeZKServerIndex+1;
    // Shutdown the current active one
    NIOServerCnxnFactory standaloneServerFactory =
      standaloneServerFactoryList.get(backupZKServerIndex);
    int clientPort = clientPortList.get(backupZKServerIndex);

    standaloneServerFactory.shutdown();
    if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) {
      throw new IOException("Waiting for shutdown of standalone server");
    }

    // remove this backup zk server
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.