Interface DataStoreGarbageCollector


  • public interface 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();
     gc.mark();
     gc.sweep();
     
    • 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
      • close

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