Package org.apache.zookeeper.server

Examples of org.apache.zookeeper.server.ZooKeeperServer


            // TODO This is necessary as zookeeper does not delete the log dir when it shuts down. Remove as soon as zookeeper shutdown works
            zookeeperBaseDir = new File("./target/zookeeper" + count++);
            if (clearServerData) {
                cleanZookeeperDir();
            }
            zkServer = new ZooKeeperServer();
            File dataDir = new File(zookeeperBaseDir, "log");
            File snapDir = new File(zookeeperBaseDir, "data");
            FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
            zkServer.setTxnLogFactory(ftxn);
            zkServer.setTickTime(1000);
View Full Code Here


                deleteDir(working);
                if (working.exists()) {
                    throw new Exception("Could not delete Test Zookeeper Server working dir ./target/zookeeper");
                }
            }
            zkServer = new ZooKeeperServer();
            File dataDir = new File("./target/zookeeper/log");
            File snapDir = new File("./target/zookeeper/data");
            FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
            zkServer.setTxnLogFactory(ftxn);
            zkServer.setTickTime(1000);
View Full Code Here

    if (this.tickTime > 0) {
      tickTimeToUse = this.tickTime;
    } else {
      tickTimeToUse = TICK_TIME;
    }
    ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
    while (true) {
      try {
        standaloneServerFactory =
          new NIOServerCnxn.Factory(new InetSocketAddress(clientPort));
      } catch (BindException e) {
View Full Code Here

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

    ActiveStandbyElector elector = electors[0];
   
    // Let the first elector become active
    elector.ensureParentZNode();
    elector.joinElection(appData);
    ZooKeeperServer zks = getServer(serverFactory);
    ActiveStandbyElectorTestUtil.waitForActiveLockData(null,
        zks, PARENT_DIR, appData);
    Mockito.verify(cb, Mockito.timeout(1000)).becomeActive();
    checkFatalsAndReset();
   
    LOG.info("========================== Expiring session");
    zks.closeSession(elector.getZKSessionIdForTests());

    // Should enter neutral mode when disconnected
    Mockito.verify(cb, Mockito.timeout(1000)).enterNeutralMode();

    // Should re-join the election and regain active
View Full Code Here

  @Test(timeout=15000)
  public void testHandleSessionExpirationOfStandby() throws Exception {
    // Let elector 0 be active
    electors[0].ensureParentZNode();
    electors[0].joinElection(appDatas[0]);
    ZooKeeperServer zks = getServer(serverFactory);
    ActiveStandbyElectorTestUtil.waitForActiveLockData(null,
        zks, PARENT_DIR, appDatas[0]);
    Mockito.verify(cbs[0], Mockito.timeout(1000)).becomeActive();
    checkFatalsAndReset();
   
    // Let elector 1 be standby
    electors[1].joinElection(appDatas[1]);
    ActiveStandbyElectorTestUtil.waitForElectorState(null, electors[1],
        State.STANDBY);
   
    LOG.info("========================== Expiring standby's session");
    zks.closeSession(electors[1].getZKSessionIdForTests());

    // Should enter neutral mode when disconnected
    Mockito.verify(cbs[1], Mockito.timeout(1000)).enterNeutralMode();

    // Should re-join the election and go back to STANDBY
View Full Code Here

    static ServerCnxnFactory createNewServerInstance(File dataDir,
            ServerCnxnFactory factory, String hostPort, int maxCnxns)
        throws IOException, InterruptedException
    {
        ZooKeeperServer zks = new ZooKeeperServer(dataDir, dataDir, 3000);
        final int PORT = getPort(hostPort);
        if (factory == null) {
            factory = ServerCnxnFactory.createFactory(PORT, maxCnxns);
        }
        factory.startup(zks);
View Full Code Here

            String hostPort)
    {
        if (factory != null) {
            ZKDatabase zkDb;
            {
                ZooKeeperServer zs = getServer(factory);
       
                zkDb = zs.getZKDatabase();
            }
            factory.shutdown();
            try {
                zkDb.close();
            } catch (IOException ie) {
View Full Code Here

        serverFactory = null;
    }


    protected static ZooKeeperServer getServer(ServerCnxnFactory fac) {
        ZooKeeperServer zs = ServerCnxnFactoryAccessor.getZkServer(fac);

        return zs;
    }
View Full Code Here

    ZkTmpDir = File.createTempFile("zookeeper", "test");
        ZkTmpDir.delete();
        ZkTmpDir.mkdir();
       
    try {
      zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
      serverFactory =  new NIOServerCnxn.Factory(new InetSocketAddress(ZooKeeperDefaultPort));
      serverFactory.startup(zks);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      LOG.fatal("Exception while instantiating ZooKeeper", e);
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.ZooKeeperServer

Copyright © 2018 www.massapicom. 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.