List of usage examples for org.apache.zookeeper.server DatadirCleanupManager start
public void start()
From source file:com.chiralBehaviors.autoconfigure.ZookeeperLauncher.java
License:Open Source License
/** * Copied from QuorumPeerMain because whomever wrote that crap made things * protected. Because freedom./*from w ww.j ava2s. c om*/ */ 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.getServers().size() > 0) { runFromConfig(config); } else { LOG.warning("Running in standalone mode"); // there is only server in the quorum -- run as standalone ZooKeeperServerMain.main(args); } }
From source file:com.glaf.cluster.catalina.session.QuorumPeerMain.java
License:Apache License
protected void initializeAndRun(String[] args) throws ConfigException, IOException { QuorumPeerConfig config = new QuorumPeerConfig(); if (args.length == 1) { config.parse(args[0]);//from w w w . j ava2 s . c om } // 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.getServers().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); } }
From source file:com.splicemachine.test.SpliceZoo.java
License:Apache License
@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 {//w w w . j a v a 2s.com peer.start(); SpliceLogUtils.trace(LOG, "Attempting to Join: %s", config.getClientPortAddress()); peer.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.dcache.zookeeper.service.ZooKeeperCell.java
License:Open Source License
@Override protected void starting() throws Exception { super.starting(); InetSocketAddress socketAddress = Strings.isNullOrEmpty(address) ? new InetSocketAddress(port) : new InetSocketAddress(address, port); checkArgument(autoPurgeInterval > 0, "zookeeper.auto-purge.purge-interval must be non-negative."); zkServer = new PatchedZooKeeperServer(); txnLog = new FileTxnSnapLog(dataLogDir, dataDir); zkServer.setTxnLogFactory(txnLog);/*ww w. ja v a 2 s . c om*/ zkServer.setTickTime((int) tickTimeUnit.toMillis(tickTime)); zkServer.setMinSessionTimeout( minSessionTimeout == -1 ? -1 : (int) minSessionTimeoutUnit.toMillis(minSessionTimeout)); zkServer.setMaxSessionTimeout( maxSessionTimeout == -1 ? -1 : (int) maxSessionTimeoutUnit.toMillis(maxSessionTimeout)); zkServer.setZKDatabase(new ZKDatabase(txnLog)); // Work-around https://issues.apache.org/jira/browse/ZOOKEEPER-2810 zkServer.createSessionTracker(); // Work around https://issues.apache.org/jira/browse/ZOOKEEPER-2812 ServerCnxnFactory cnxnFactory; cnxnFactory = new NIOServerCnxnFactory() { @Override protected void configureSaslLogin() throws IOException { // ZooKeeper gets confused by dCache configuring a JAAS configuration without a section for ZooKeeper, so // we disable the whole thing. Use a non-embedded ZooKeeper if you want security. } }; cnxnFactory.configure(socketAddress, maxClientConnections); this.cnxnFactory = cnxnFactory; this.cnxnFactory.startup(zkServer); // FileTxnSnapLog constructor creates dataDir and dataLogDir if they // don't already exist, but in a non-thread safe fashion. // Unfortunately, DatadirCleanupManager#start launches an asynchronous // task that runs immediately and creates a FileTxnSnapLog object. This // can creating a race between the constructor above. To avoid this, // we must call DatadirCleanupManager#start after the FileTxnSnapLog // object has been created. int purgeIntervalHours = (int) TimeUnit.HOURS.convert(autoPurgeInterval, autoPurgeIntervalUnit); DatadirCleanupManager purgeMgr = new DatadirCleanupManager(dataDir.getAbsolutePath(), dataLogDir.getAbsolutePath(), autoPurgeRetainCount, purgeIntervalHours); purgeMgr.start(); }