Package org.nuxeo.ecm.core.blob
Class LocalBlobStore.LocalBlobGarbageCollector
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.LocalBlobStore.LocalBlobGarbageCollector
-
- All Implemented Interfaces:
BinaryGarbageCollector
- Enclosing class:
- LocalBlobStore
public class LocalBlobStore.LocalBlobGarbageCollector extends Object implements BinaryGarbageCollector
-
-
Field Summary
Fields Modifier and Type Field Description booleanmarkInMemoryprotected longstartTimeprotected BinaryManagerStatusstatusstatic longTIME_RESOLUTIONWindows FAT filesystems have a time resolution of 2s.protected Set<String>toDelete
-
Constructor Summary
Constructors Constructor Description LocalBlobGarbageCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcomputeToDelete(File file, long minTime)protected voiddeleteOld(File file, long minTime, int depth, boolean delete)StringgetId()Gets a unique identifier for this garbage collector.BinaryManagerStatusgetStatus()Gets the status of the binaries to GC and of those that won't be.booleanisInProgress()Checks if a GC is in progress.voidmark(String key)Marks a binary as being in use.protected voidremoveUnmarkedBlobsAndUpdateStatus(boolean delete)voidstart()Starts the garbage collection process.voidstop(boolean delete)Stops the garbage collection process and deletes all binaries that have not been marked (sweep).protected voidtouch(File file)Sets the last modification date to now on a file.
-
-
-
Field Detail
-
TIME_RESOLUTION
public static final long TIME_RESOLUTION
Windows FAT filesystems have a time resolution of 2s. Other common filesystems have 1s.- See Also:
- Constant Field Values
-
startTime
protected volatile long startTime
-
status
protected BinaryManagerStatus status
-
markInMemory
public volatile boolean markInMemory
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:BinaryGarbageCollectorGets a unique identifier for this garbage collector. Two garbage collectors that would impact the same files must have the same identifier.- Specified by:
getIdin interfaceBinaryGarbageCollector- Returns:
- a unique identifier
-
getStatus
public BinaryManagerStatus getStatus()
Description copied from interface:BinaryGarbageCollectorGets the status of the binaries to GC and of those that won't be.Available after
BinaryGarbageCollector.stop(boolean).- Specified by:
getStatusin interfaceBinaryGarbageCollector- Returns:
- the status
-
isInProgress
public boolean isInProgress()
Description copied from interface:BinaryGarbageCollectorChecks if a GC is in progress.A GC is in progress is
#starthas been called but not#stop.It's only useful to call this from a separate thread from the one that calls
BinaryGarbageCollector.mark(java.lang.String).- Specified by:
isInProgressin interfaceBinaryGarbageCollector- Returns:
trueif a GC is in progress
-
start
public void start()
Description copied from interface:BinaryGarbageCollectorStarts the garbage collection process.After this, all active binaries must be fed to the
BinaryGarbageCollector.mark(java.lang.String)method.- Specified by:
startin interfaceBinaryGarbageCollector
-
computeToDelete
protected void computeToDelete(File file, long minTime)
-
mark
public void mark(String key)
Description copied from interface:BinaryGarbageCollectorMarks a binary as being in use.- Specified by:
markin interfaceBinaryGarbageCollector- Parameters:
key- the binary's digest
-
stop
public void stop(boolean delete)
Description copied from interface:BinaryGarbageCollectorStops the garbage collection process and deletes all binaries that have not been marked (sweep).- Specified by:
stopin interfaceBinaryGarbageCollector- Parameters:
delete-trueif actual deletion must be performed,falseif the binaries to delete should simply be counted in the status
-
removeUnmarkedBlobsAndUpdateStatus
protected void removeUnmarkedBlobsAndUpdateStatus(boolean delete)
-
deleteOld
protected void deleteOld(File file, long minTime, int depth, boolean delete)
-
touch
protected void touch(File file)
Sets the last modification date to now on a file.
-
-