Class DatadirCleanupManager

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

public class DatadirCleanupManager extends Object
This class manages the cleanup of snapshots and corresponding transaction logs by scheduling the auto purge task with the specified 'autopurge.purgeInterval'. It keeps the most recent 'autopurge.snapRetainCount' number of snapshots and corresponding transaction logs.
  • Constructor Details

    • DatadirCleanupManager

      public DatadirCleanupManager(File snapDir, File dataLogDir, int snapRetainCount, int purgeInterval)
      Constructor of DatadirCleanupManager. It takes the parameters to schedule the purge task.
      Parameters:
      snapDir - snapshot directory
      dataLogDir - transaction log directory
      snapRetainCount - number of snapshots to be retained after purge
      purgeInterval - purge interval in hours
  • Method Details

    • start

      public void start()
      Validates the purge configuration and schedules the purge task. Purge task keeps the most recent snapRetainCount number of snapshots and deletes the remaining for every purgeInterval hour(s).

      purgeInterval of 0 or negative integer will not schedule the purge task.

      See Also:
    • shutdown

      public void shutdown()
      Shutdown the purge task.
    • getPurgeTaskStatus

      public DatadirCleanupManager.PurgeTaskStatus getPurgeTaskStatus()
      Returns the status of the purge task.
      Returns:
      the status of the purge task
    • getSnapDir

      public File getSnapDir()
      Returns the snapshot directory.
      Returns:
      the snapshot directory.
    • getDataLogDir

      public File getDataLogDir()
      Returns transaction log directory.
      Returns:
      the transaction log directory.
    • getPurgeInterval

      public int getPurgeInterval()
      Returns purge interval in hours.
      Returns:
      the purge interval in hours.
    • getSnapRetainCount

      public int getSnapRetainCount()
      Returns the number of snapshots to be retained after purge.
      Returns:
      the number of snapshots to be retained after purge.