Java 类org.apache.zookeeper.server.DatadirCleanupManager 实例源码

项目:https-github.com-apache-zookeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:ZooKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:StreamProcessingInfrastructure    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:bigstreams    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:zookeeper-src-learning    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:SecureKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:SecureKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:StreamBench    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:NeverwinterDP-Commons    文件:ZookeeperClusterService.java   
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
      zkConfig.getDataDir(), 
      zkConfig.getDataLogDir(), 
      zkConfig.getSnapRetainCount(), 
      zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    logger.warn(
      "Either no config or no quorum defined in config, running in standalone mode"
    );
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig) ;
  }
}
项目:LoadBalanced_zk    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:LoadBalanced_zk    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:Scribengin    文件:EmbededZKServer.java   
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr =
      new DatadirCleanupManager(zkConfig.getDataDir(), zkConfig.getDataLogDir(),
          zkConfig.getSnapRetainCount(), zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    System.out
        .println("Either no config or no quorum defined in config, running in standalone mode");
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig);
  }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:spliceengine    文件:SpliceZoo.java   
@Override
public void run() {
       DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
               .getDataDir(), config.getDataLogDir(), config
               .getSnapRetainCount(), config.getPurgeInterval());
       purgeMgr.start();
       SpliceLogUtils.trace(LOG, "Client Address: %s",config.getClientPortAddress());
    try {
         peer.start();
         SpliceLogUtils.trace(LOG, "Attempting to Join: %s",config.getClientPortAddress());
         peer.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:zookeeper-pkg    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:fuck_zookeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    /**
     * 解析配置文件,默认的配置文件为上一级目录
     * config/zookeeper.properties或者config/zookeeper.cfg
     */
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }
    /**
     * 启动安排清除任务,定时清理历史数据(事务日志,以及快照数据)
     * since3.4.0
     */
    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    /**
     * 重要点
     * 解析服务器配置地址列表,判断是集群,还是单机模式
     */
    // 集群分支
    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        // 单机分支,standalone(机器里的单身狗;我就是一个孤独患者,有何不可?)
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        //骚气的代码,太露骨了!
        ZooKeeperServerMain.main(args);
    }
}
项目:zookeeper-cli    文件:LocalZooKeeperServer.java   
public void start() throws IOException, ConfigException, InterruptedException {
    log.info("Starting Zookeeper on port {}", port);

    Properties properties = new Properties();
    properties.setProperty("dataDir", getDataDir().getAbsolutePath());
    properties.setProperty("clientPort", Integer.toString(getPort()));

    QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
    quorumConfig.parseProperties(properties);

    cleanupManager = new DatadirCleanupManager(quorumConfig.getDataDir(), quorumConfig.getDataLogDir(),
            quorumConfig.getSnapRetainCount(), quorumConfig.getPurgeInterval());
    cleanupManager.start();

    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(quorumConfig);

    zkServer = new ZooKeeperServer();
    zkServer.setTickTime(serverConfig.getTickTime());
    zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

    transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
            new File(serverConfig.getDataDir().toString()));
    zkServer.setTxnLogFactory(transactionLog);

    connectionFactory = ServerCnxnFactory.createFactory();
    connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
    connectionFactory.startup(zkServer);
}
项目:zookeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        // 解析zoo.cfg配置文件
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    // 自动清理管理
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    // 启动并调度自动清理任务
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        // 集群方式启动
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:ACaZoo    文件:ZooStandalone.java   
@Override
public void init() {

    LOG.info("ZooStandalone init called!");

    @SuppressWarnings("unused")
    ZooStandalone zoo = new ZooStandalone();
    System.setProperty("jute.maxbuffer", "104857600");

    String[] args = ZooArguments;
    QuorumPeerConfig config = new QuorumPeerConfig();

    if (args.length == 1) {
        try {
            config.parse(args[0]);
        } catch (ConfigException e) {
            LOG.error("Error parsing configuration file!");
        }
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
            config.getDataDir(), config.getDataLogDir(),
            config.getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();
    LOG.info("No quorum defined in config, running "
            + " in standalone mode");
    ZooKeeperServerMain.main(args);

}
项目:ACaZoo    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args) throws ConfigException,
        IOException {

    /*
     * pgaref
     */
    args = ZooArguments;
    QuorumPeerConfig config = new QuorumPeerConfig();
    Thread mymod = new Thread(new Myclass(1));

    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
            config.getDataDir(), config.getDataLogDir(),
            config.getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();
    mymod.start();
    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone

        ZooKeeperServerMain.main(args);

    }
    mymod.start();
}
项目:LoadBalanced_zk    文件:ZooStandalone.java   
@Override
public void init() {
    LOG.info("ZooStandalone init called!");

    @SuppressWarnings("unused")
    ZooStandalone zoo = new ZooStandalone();
    System.setProperty("jute.maxbuffer", "104857600");

    String[] args = ZooArguments;
    QuorumPeerConfig config = new QuorumPeerConfig();

    if (args.length == 1) {
        try {
            config.parse(args[0]);
        } catch (ConfigException e) {
            LOG.error("Error parsing configuration file!");
        }
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
            config.getDataDir(), config.getDataLogDir(),
            config.getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();
    LOG.info("No quorum defined in config, running "
            + " in standalone mode");
    ZooKeeperServerMain.main(args);

}
项目:LoadBalanced_zk    文件:ZooStandalone.java   
@Override
public void init() {
    LOG.info("ZooStandalone init called!");

    @SuppressWarnings("unused")
    ZooStandalone zoo = new ZooStandalone();
    System.setProperty("jute.maxbuffer", "104857600");

    String[] args = ZooArguments;
    QuorumPeerConfig config = new QuorumPeerConfig();

    if (args.length == 1) {
        try {
            config.parse(args[0]);
        } catch (ConfigException e) {
            LOG.error("Error parsing configuration file!");
        }
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
            config.getDataDir(), config.getDataLogDir(),
            config.getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();
    LOG.info("No quorum defined in config, running "
            + " in standalone mode");
    ZooKeeperServerMain.main(args);

}
项目:oryx2    文件:LocalZKServer.java   
/**
 * Starts Zookeeper.
 *
 * @throws IOException if an error occurs during initialization
 * @throws InterruptedException if an error occurs during initialization
 */
public synchronized void start() throws IOException, InterruptedException {
  log.info("Starting Zookeeper on port {}", port);

  dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName());
  dataDir.toFile().deleteOnExit();

  QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
  try {
    quorumConfig.parseProperties(ConfigUtils.keyValueToProperties(
        "dataDir", dataDir.toAbsolutePath(),
        "clientPort", port
    ));
  } catch (QuorumPeerConfig.ConfigException e) {
    throw new IllegalArgumentException(e);
  }

  purgeManager =
      new DatadirCleanupManager(quorumConfig.getDataDir(),
                                quorumConfig.getDataLogDir(),
                                quorumConfig.getSnapRetainCount(),
                                quorumConfig.getPurgeInterval());
  purgeManager.start();

  ServerConfig serverConfig = new ServerConfig();
  serverConfig.readFrom(quorumConfig);

  zkServer = new ZooKeeperServer();
  zkServer.setTickTime(serverConfig.getTickTime());
  zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
  zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

  // These two ServerConfig methods returned String in 3.4.x and File in 3.5.x
  transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
                                      new File(serverConfig.getDataDir().toString()));
  zkServer.setTxnLogFactory(transactionLog);

  connectionFactory = ServerCnxnFactory.createFactory();
  connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
  connectionFactory.startup(zkServer);
}