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

org.apache.zookeeper.server

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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DatadirCleanupManager.PurgeTaskStatus` Status of the dataDir purge task

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DatadirCleanupManager(File snapDir, File dataLogDir, int snapRetainCount, int purgeInterval)` Constructor of DatadirCleanupManager.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `File` | `getDataLogDir()` Returns transaction log directory.
    `int` | `getPurgeInterval()` Returns purge interval in hours.
    `DatadirCleanupManager.PurgeTaskStatus` | `getPurgeTaskStatus()` Returns the status of the purge task.
    `File` | `getSnapDir()` Returns the snapshot directory.
    `int` | `getSnapRetainCount()` Returns the number of snapshots to be retained after purge.
    `void` | `shutdown()` Shutdown the purge task.
    `void` | `start()` Validates the purge configuration and schedules the purge task.

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

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

- - ### Constructor Detail

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

    - #### 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:
        `PurgeTxnLog.purge(File, File, int)`

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

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