Class PurgeTxnLog

java.lang.Object
org.apache.zookeeper.server.PurgeTxnLog

@Public public class PurgeTxnLog extends Object
this class is used to clean up the snapshot and data log dir's. This is usually run as a cronjob on the zookeeper server machine. Invocation of this class will clean up the datalogdir files and snapdir files keeping the last "-n" snapshot files and the corresponding logs.
  • Constructor Details

    • PurgeTxnLog

      public PurgeTxnLog()
  • Method Details

    • purge

      public static void purge(File dataDir, File snapDir, int num) throws IOException
      Purges the snapshot and logs keeping the last num snapshots and the corresponding logs. If logs are rolling or a new snapshot is created during this process, these newest N snapshots or any data logs will be excluded from current purging cycle.
      Parameters:
      dataDir - the dir that has the logs
      snapDir - the dir that has the snapshots
      num - the number of snapshots to keep
      Throws:
      IOException
    • main

      public static void main(String[] args) throws IOException
      Parameters:
      args - dataLogDir [snapDir] -n count dataLogDir -- path to the txn log directory snapDir -- path to the snapshot directory count -- the number of old snaps/logs you want to keep, value should be greater than or equal to 3
      Throws:
      IOException