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 int
testDelay
-
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 void
close()
protected void
finalize()
Auto-close in case the application didn't call it explicitly.int
getConcurrentThreadSize()
DataStore
getDataStore()
Get the data store if one is used.long
getMinSplitSize()
long
getSleepBetweenNodes()
boolean
isPersistenceManagerScan()
void
mark()
void
setConcurrentThreadSize(int concurrentThreadSize)
void
setMarkEventListener(MarkEventListener callback)
void
setMinSplitSize(long minSplitSize)
void
setPersistenceManagerScan(boolean allow)
void
setSleepBetweenNodes(long millis)
void
setTestDelay(int testDelay)
When testing the garbage collection, a delay is used instead of simulating concurrent access.void
stopScan()
Reset modifiedDateOnAccess to 0 and stop the observation listener if any are installed.int
sweep()
-
-
-
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:
setSleepBetweenNodes
in interfaceDataStoreGarbageCollector
-
getSleepBetweenNodes
public long getSleepBetweenNodes()
- Specified by:
getSleepBetweenNodes
in 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:
setMarkEventListener
in interfaceDataStoreGarbageCollector
-
mark
public void mark() throws RepositoryException
- Specified by:
mark
in interfaceDataStoreGarbageCollector
- Throws:
RepositoryException
-
setPersistenceManagerScan
public void setPersistenceManagerScan(boolean allow)
- Specified by:
setPersistenceManagerScan
in interfaceDataStoreGarbageCollector
-
isPersistenceManagerScan
public boolean isPersistenceManagerScan()
- Specified by:
isPersistenceManagerScan
in interfaceDataStoreGarbageCollector
-
stopScan
public void stopScan() throws RepositoryException
Reset modifiedDateOnAccess to 0 and stop the observation listener if any are installed.- Throws:
RepositoryException
-
sweep
public int sweep() throws RepositoryException
- Specified by:
sweep
in 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:
close
in interfaceDataStoreGarbageCollector
-
-