org.apache.jackrabbit.api.management
Interface DataStoreGarbageCollector


public interface DataStoreGarbageCollector

Garbage collector for DataStore. This implementation is 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 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:

 DataStoreGarbageCollector gc = ((JackrabbitSession)session).createDataStoreGarbageCollector();
 gc.mark();
 gc.sweep();
 


Method Summary
 void close()
          Cleanup resources used internally by this instance.
 long getSleepBetweenNodes()
          Get the delay between scanning items.
 boolean isPersistenceManagerScan()
          Check if using the IterablePersistenceManager interface is allowed.
 void mark()
          Scan the repository.
 void setMarkEventListener(MarkEventListener callback)
          Set the event listener.
 void setPersistenceManagerScan(boolean allow)
          Enable or disable using the IterablePersistenceManager interface to scan the items.
 void setSleepBetweenNodes(long millis)
          Set the delay between scanning items.
 int sweep()
          Delete all unused items in the data store.
 

Method Detail

setSleepBetweenNodes

void setSleepBetweenNodes(long millis)
Set the delay between scanning items. The main scan loop sleeps this many milliseconds after scanning a node. The default is 0, meaning the scan should run at full speed.

Parameters:
millis - the number of milliseconds to sleep

getSleepBetweenNodes

long getSleepBetweenNodes()
Get the delay between scanning items.

Returns:
the number of milliseconds to sleep

setMarkEventListener

void setMarkEventListener(MarkEventListener callback)
Set the event listener. If set, the event listener will be called for each item that is scanned. This mechanism can be used to display the progress.

Parameters:
callback - if set, this is called while scanning

setPersistenceManagerScan

void setPersistenceManagerScan(boolean allow)
Enable or disable using the IterablePersistenceManager interface to scan the items. This is important for clients that need the complete Node implementation in the ScanEventListener callback.

Parameters:
allow - true if using the IterablePersistenceManager interface is allowed

isPersistenceManagerScan

boolean isPersistenceManagerScan()
Check if using the IterablePersistenceManager interface is allowed.

Returns:
true if using IterablePersistenceManager is possible.

mark

void mark()
          throws RepositoryException
Scan the repository. The garbage collector will iterate over all nodes in the repository and update the last modified date. If all persistence managers implement the IterablePersistenceManager interface, this mechanism is used; if not, the garbage collector scans the repository using the JCR API starting from the root node.

Throws:
RepositoryException

sweep

int sweep()
          throws RepositoryException
Delete all unused items in the data store.

Returns:
the number of deleted items
Throws:
RepositoryException

close

void close()
Cleanup resources used internally by this instance.



Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.