Package org.apache.jackrabbit.core.gc
Class GarbageCollector
- java.lang.Object
-
- org.apache.jackrabbit.core.gc.GarbageCollector
-
- All Implemented Interfaces:
DataStoreGarbageCollector
public class GarbageCollector extends Object implements DataStoreGarbageCollector
Garbage collector for DataStore. This implementation iterates through all nodes and reads the binary properties. To detect nodes that are moved while the scan runs, event listeners are started. Like the well known garbage collection in Java, the items that are still in use are marked. Currently this is achieved by updating the modified date of the entries. Newly added entries are detected because the modified date is changed when they are added.Example code to run the data store garbage collection:
JackrabbitRepositoryFactory jf = (JackrabbitRepositoryFactory) factory; RepositoryManager m = jf.getRepositoryManager((JackrabbitRepository) repository); GarbageCollector gc = m.createDataStoreGarbageCollector(); try { gc.mark(); gc.sweep(); } finally { gc.close(); }
-
-
Field Summary
Fields Modifier and Type Field Description protected inttestDelay
-
Constructor Summary
Constructors Constructor Description GarbageCollector(RepositoryContext context, DataStore dataStore, IterablePersistenceManager[] list, SessionImpl[] sessionList)Create a new garbage collector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidfinalize()Auto-close in case the application didn't call it explicitly.intgetConcurrentThreadSize()DataStoregetDataStore()Get the data store if one is used.longgetMinSplitSize()longgetSleepBetweenNodes()booleanisPersistenceManagerScan()voidmark()voidsetConcurrentThreadSize(int concurrentThreadSize)voidsetMarkEventListener(MarkEventListener callback)voidsetMinSplitSize(long minSplitSize)voidsetPersistenceManagerScan(boolean allow)voidsetSleepBetweenNodes(long millis)voidsetTestDelay(int testDelay)When testing the garbage collection, a delay is used instead of simulating concurrent access.voidstopScan()Reset modifiedDateOnAccess to 0 and stop the observation listener if any are installed.intsweep()
-
-
-
Constructor Detail
-
GarbageCollector
public GarbageCollector(RepositoryContext context, DataStore dataStore, IterablePersistenceManager[] list, SessionImpl[] sessionList)
Create a new garbage collector. This method is usually not called by the application, it is called by SessionImpl.createDataStoreGarbageCollector().- Parameters:
context- repository contextdataStore- the data store to be garbage-collectedlist- the persistence managerssessionList- the sessions to access the workspaces
-
-
Method Detail
-
setSleepBetweenNodes
public void setSleepBetweenNodes(long millis)
- Specified by:
setSleepBetweenNodesin interfaceDataStoreGarbageCollector
-
getSleepBetweenNodes
public long getSleepBetweenNodes()
- Specified by:
getSleepBetweenNodesin interfaceDataStoreGarbageCollector
-
getMinSplitSize
public long getMinSplitSize()
-
setMinSplitSize
public void setMinSplitSize(long minSplitSize)
-
getConcurrentThreadSize
public int getConcurrentThreadSize()
-
setConcurrentThreadSize
public void setConcurrentThreadSize(int concurrentThreadSize)
-
setTestDelay
public void setTestDelay(int testDelay)
When testing the garbage collection, a delay is used instead of simulating concurrent access.- Parameters:
testDelay- the delay in milliseconds
-
setMarkEventListener
public void setMarkEventListener(MarkEventListener callback)
- Specified by:
setMarkEventListenerin interfaceDataStoreGarbageCollector
-
mark
public void mark() throws RepositoryException- Specified by:
markin interfaceDataStoreGarbageCollector- Throws:
RepositoryException
-
setPersistenceManagerScan
public void setPersistenceManagerScan(boolean allow)
- Specified by:
setPersistenceManagerScanin interfaceDataStoreGarbageCollector
-
isPersistenceManagerScan
public boolean isPersistenceManagerScan()
- Specified by:
isPersistenceManagerScanin interfaceDataStoreGarbageCollector
-
stopScan
public void stopScan() throws RepositoryExceptionReset modifiedDateOnAccess to 0 and stop the observation listener if any are installed.- Throws:
RepositoryException
-
sweep
public int sweep() throws RepositoryException- Specified by:
sweepin interfaceDataStoreGarbageCollector- Throws:
RepositoryException
-
getDataStore
public DataStore getDataStore()
Get the data store if one is used.- Returns:
- the data store, or null
-
close
public void close()
- Specified by:
closein interfaceDataStoreGarbageCollector
-
-