# 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
Description
`static enum`
`DatadirCleanupManager.PurgeTaskStatus`
Status of the dataDir purge task

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
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 Object

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

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