Package 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 Description static class
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
All Methods Instance Methods Concrete Methods 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.
-
-
-
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 directorydataLogDir
- transaction log directorysnapRetainCount
- number of snapshots to be retained after purgepurgeInterval
- purge interval in hours
-
-
Method Detail
-
start
public void start()
Validates the purge configuration and schedules the purge task. Purge task keeps the most recentsnapRetainCount
number of snapshots and deletes the remaining for everypurgeInterval
hour(s).purgeInterval
of0
ornegative 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.
-
-