Package org.apache.zookeeper.server.persistence

Examples of org.apache.zookeeper.server.persistence.FileTxnSnapLog


            public ZooKeeperServer createServer() throws IOException {
                // create a file logger url from the command line args
                ZooKeeperServer zks = new ZooKeeperServer();
                zks.setClientPort(ServerConfig.getClientPort());

               FileTxnSnapLog ftxn = new FileTxnSnapLog(new
                       File(ServerConfig.getDataLogDir()),
                        new File(ServerConfig.getDataDir()));
               zks.setTxnLogFactory(ftxn);
               return zks;
            }
View Full Code Here


     * test code.
     * It defaults to FileLogProvider persistence provider.
     */
    public ZooKeeperServer(File snapDir, File logDir, int tickTime)
            throws IOException {
        this(new FileTxnSnapLog(snapDir,logDir),
                tickTime,new BasicDataTreeBuilder());
    }
View Full Code Here

        this.electionType = electionType;
        this.myid = myid;
        this.tickTime = tickTime;
        this.initLimit = initLimit;
        this.syncLimit = syncLimit;       
        this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
        QuorumStats.getInstance().setStatsProvider(this);
    }
View Full Code Here

          NIOServerCnxn.Factory cnxnFactory =
              new NIOServerCnxn.Factory(config.getClientPort(), config.getMaxClientCnxns());
 
          quorumPeer = new QuorumPeer();
          quorumPeer.setClientPort(config.getClientPort());
          quorumPeer.setTxnFactory(new FileTxnSnapLog(
                      new File(config.getDataLogDir()),
                      new File(config.getDataDir())));
          quorumPeer.setQuorumPeers(config.getServers());
          quorumPeer.setElectionType(config.getElectionAlg());
          quorumPeer.setMyid(config.getServerId());
View Full Code Here

        // an old snapshot
        UpgradeSnapShotV1 upgrade = new UpgradeSnapShotV1(bkupdataDir,
                bkupsnapShotDir);
        LOG.info("Creating new data tree");
        DataTree dt = upgrade.getNewDataTree();
        FileTxnSnapLog filesnapLog = new FileTxnSnapLog(dataDir,
                snapShotDir);
        LOG.info("snapshotting the new datatree");
        filesnapLog.save(dt, upgrade.getSessionWithTimeOuts());
        //done saving.
        LOG.info("Upgrade is complete");
    }
View Full Code Here

            // so rather than spawning another thread, we will just call
            // run() in this thread.
            // create a file logger url from the command line args
            ZooKeeperServer zkServer = new ZooKeeperServer();

            FileTxnSnapLog ftxn = new FileTxnSnapLog(new
                   File(config.dataLogDir), new File(config.dataDir));
            zkServer.setTxnLogFactory(ftxn);
            zkServer.setTickTime(config.tickTime);
            cnxnFactory = new NIOServerCnxn.Factory(config.clientPort, config.getMaxClientCnxns());
            cnxnFactory.startup(zkServer);
View Full Code Here

     * test code.
     * It defaults to FileLogProvider persistence provider.
     */
    public ZooKeeperServer(File snapDir, File logDir, int tickTime)
            throws IOException {
        this(new FileTxnSnapLog(snapDir,logDir),
                tickTime,new BasicDataTreeBuilder());
    }
View Full Code Here

        this.electionType = electionType;
        this.myid = myid;
        this.tickTime = tickTime;
        this.initLimit = initLimit;
        this.syncLimit = syncLimit;       
        this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
        if(quorumConfig == null)
            this.quorumConfig = new QuorumMaj(quorumPeers.size());
        else this.quorumConfig = quorumConfig;
    }
View Full Code Here

    public static void purge(File dataDir, File snapDir, int num) throws IOException {
        if (num < 3) {
            throw new IllegalArgumentException("count should be greater than 3");
        }

        FileTxnSnapLog txnLog = new FileTxnSnapLog(dataDir, snapDir);
       
        // found any valid recent snapshots?
       
        // files to exclude from deletion
        Set<File> exc=new HashSet<File>();
        List<File> snaps = txnLog.findNRecentSnapshots(num);
        if (snaps.size() == 0)
            return;
        File snapShot = snaps.get(snaps.size() -1);
        for (File f: snaps) {
            exc.add(f);
        }
        long zxid = Util.getZxidFromName(snapShot.getName(),"snapshot");
        exc.addAll(Arrays.asList(txnLog.getSnapshotLogs(zxid)));

        final Set<File> exclude=exc;
        class MyFileFilter implements FileFilter{
            private final String prefix;
            MyFileFilter(String prefix){
                this.prefix=prefix;
            }
            public boolean accept(File f){
                if(!f.getName().startsWith(prefix) || exclude.contains(f))
                    return false;
                return true;
            }
        }
        // add all non-excluded log files
        List<File> files=new ArrayList<File>(
                Arrays.asList(txnLog.getDataDir().listFiles(new MyFileFilter("log."))));
        // add all non-excluded snapshot files to the deletion list
        files.addAll(Arrays.asList(txnLog.getSnapDir().listFiles(new MyFileFilter("snapshot."))));
        // remove the old files
        for(File f: files)
        {
            System.out.println("Removing file: "+
                DateFormat.getDateTimeInstance().format(f.lastModified())+
View Full Code Here

        FileSupport.toRichFile(data_dir()).recursiveDelete();

        System.out.println("Starting ZooKeeper");
        ZooKeeperServer zk_server = new ZooKeeperServer();
        zk_server.setTickTime(500);
        zk_server.setTxnLogFactory(new FileTxnSnapLog(new File(data_dir(), "zk-log"), new File(data_dir(), "zk-data")));
        connector = new NIOServerCnxnFactory();
        connector.configure(new InetSocketAddress(0), 100);
        connector.startup(zk_server);
        System.out.println("ZooKeeper started");
    }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.persistence.FileTxnSnapLog

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.