PurgeTxnLog (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server

## Class PurgeTxnLog

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

-     @InterfaceAudience.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 Summary

    Constructors
    Constructor and Description
    `PurgeTxnLog()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(String[] args)`
    `static void` | `purge(File dataDir, File snapDir, int num)` Purges the snapshot and logs keeping the last num snapshots and the corresponding logs.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PurgeTxnLog

          public PurgeTxnLog()

  - ### Method Detail

    - #### 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`

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.