Package org.apache.zookeeper.server

Examples of org.apache.zookeeper.server.ServerConfig


      final TestZookeeperServerIntern server = new TestZookeeperServerIntern();
      try {
         QuorumPeerConfig qpConfig = new QuorumPeerConfig();
         qpConfig.parseProperties(zkConfig);
         final ServerConfig sConfig = new ServerConfig();
         sConfig.readFrom(qpConfig);
        
         Thread t = new Thread(new Runnable() {
        
            @Override
            public void run()  {  try { server.runFromConfig(sConfig); } catch(IOException ioe ) { logger.error(MarkerFactory.getMarker("FATAL"), "", ioe); fail("can't start zookeeper"); } }
View Full Code Here


    if (zkConfig.isDistributed()) {
      QuorumPeerMain qp = new QuorumPeerMain();
      qp.runFromConfig(zkConfig);
    } else {
      ZooKeeperServerMain zk = new ZooKeeperServerMain();
      ServerConfig serverConfig = new ServerConfig();
      serverConfig.readFrom(zkConfig);
      zk.runFromConfig(serverConfig);
    }
  }
View Full Code Here

        final ManagedService.MyZooKeeperServerMain zkMain =
            EasyMock.createMock(ManagedService.MyZooKeeperServerMain.class);
        zkMain.runFromConfig((ServerConfig) EasyMock.anyObject());
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                ServerConfig sc = (ServerConfig) EasyMock.getCurrentArguments()[0];
                assertEquals(new File(tempDir, "zkdata").getCanonicalFile().toString(),
                    sc.getDataDir());
                assertEquals(1234, sc.getClientPort());
                assertEquals(2000, sc.getTickTime());
                return null;
            }
        });
        EasyMock.replay(zkMain);      
       
View Full Code Here

    if (zkConfig.isDistributed()) {
      QuorumPeerMain qp = new QuorumPeerMain();
      qp.runFromConfig(zkConfig);
    } else {
      ZooKeeperServerMain zk = new ZooKeeperServerMain();
      ServerConfig serverConfig = new ServerConfig();
      serverConfig.readFrom(zkConfig);
      zk.runFromConfig(serverConfig);
    }
  }
View Full Code Here

    zkConfProps.setProperty("clientPort", new Integer(zkClientPort).toString());
    zkConfProps.setProperty("maxClientCnxns", "30");
    zkConfProps.store(new FileOutputStream(zkConfFile), "");

    // create config object
    ServerConfig zkConf = new ServerConfig();
    zkConf.parse(ZK_CONF_FILE);

    return zkConf;
  }
View Full Code Here

    return zkConf;
  }

  private static ServerConfig getZooKeeperConf() throws Exception {
    if (new File(ZK_CONF_FILE).exists()) {
      ServerConfig zkConf = new ServerConfig();
      zkConf.parse(ZK_CONF_FILE);

      return zkConf;
    } else {
      return createZooKeeperConf();
    }
View Full Code Here

      return createZooKeeperConf();
    }
  }

  public static boolean clearZooKeeperData() throws Exception {
    ServerConfig zkConf = getZooKeeperConf();
    File dataLogDir = new File(zkConf.getDataLogDir());
    File dataDir = new File(zkConf.getDataDir());
    return (FileUtil.fullyDelete(dataLogDir) && FileUtil.fullyDelete(dataDir));
  }
View Full Code Here

    return (FileUtil.fullyDelete(dataLogDir) && FileUtil.fullyDelete(dataDir));
  }
   
  public static void createAndStartZooKeeper()
    throws IOException, ConfigException, InterruptedException {
    ServerConfig zkConf = createZooKeeperConf();

    zooKeeper = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new
      FileTxnSnapLog(new File(zkConf.getDataLogDir()),
                     new File(zkConf.getDataDir()));
    zooKeeper.setTxnLogFactory(ftxn);
    zooKeeper.setTickTime(zkConf.getTickTime());
    zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
    zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());

    cnxnFactory =
      new NIOServerCnxn.Factory(zkConf.getClientPortAddress(),
                                zkConf.getMaxClientCnxns());
    cnxnFactory.startup(zooKeeper);

  }
View Full Code Here

  }

  public static void startZooKeeper(final Properties properties, boolean format, String path) {
    String realPath = path + "/zk_test";
    properties.setProperty("dataDir", realPath);
    final ServerConfig serverConfig = new ServerConfig();
    QuorumPeerConfig config = new QuorumPeerConfig();
    try {
      config.parseProperties(properties);
    } catch (IOException e) {
      LOG.error(e);
      throw new RuntimeException(e);
    } catch (ConfigException e) {
      LOG.error(e);
      throw new RuntimeException(e);
    }
    serverConfig.readFrom(config);
    rm(new File(realPath));
    serverThread = new Thread(new Runnable() {

      @Override
      public void run() {
View Full Code Here

    if (zkConfig.isDistributed()) {
      QuorumPeerMain qp = new QuorumPeerMain();
      qp.runFromConfig(zkConfig);
    } else {
      ZooKeeperServerMain zk = new ZooKeeperServerMain();
      ServerConfig serverConfig = new ServerConfig();
      serverConfig.readFrom(zkConfig);
      zk.runFromConfig(serverConfig);
    }
  }
View Full Code Here

TOP

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

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.