Class InMemBundlePersistenceManager

  • All Implemented Interfaces:
    CacheAccessListener, CachingPersistenceManager, ConsistencyChecker, IterablePersistenceManager, PersistenceManager

    public class InMemBundlePersistenceManager
    extends AbstractBundlePersistenceManager
    BundleInMemPersistenceManager is a HashMap-based PersistenceManager for Jackrabbit that keeps all data in memory and that is capable of storing and loading its contents using a simple custom binary serialization format (see Serializer).

    It is configured through the following properties:

    • initialCapacity: initial capacity of the hash map used to store the data
    • loadFactor: load factor of the hash map used to store the data
    • persistent: if true the contents of the hash map is loaded on startup and stored on shutdown; if false nothing is persisted
    • useFileBlobStore: if true the contents of the blobs will be directly stored on the file system instead of in memory.
    • minBlobSize use blob store for binaries properties larger than minBlobSite (bytes). Default is 4096.

    Please note that this class should only be used for testing purposes.

    • Field Detail

      • initialized

        protected boolean initialized
        flag indicating if this manager was initialized
      • BUNDLE_FILE_PATH

        protected static final String BUNDLE_FILE_PATH
        Path where bundles are stored on shutdown. (if persistent==true)
        See Also:
        Constant Field Values
      • BLOBS_FILE_PATH

        protected static final String BLOBS_FILE_PATH
        Path where blobs are stored on shutdown. (if persistent==true and useFileBlobStore==false)
        See Also:
        Constant Field Values
      • REFS_FILE_PATH

        protected static final String REFS_FILE_PATH
        Path where references are stored on shutdown. (if persistent==true)
        See Also:
        Constant Field Values
      • wspFS

        protected FileSystem wspFS
        File system where the content of the hash maps are read from/written to (if persistent==true)
      • blobFS

        protected FileSystem blobFS
        File system where BLOB data is stored. (if useFileBlobStore==true)
      • INITIAL_BUFFER_SIZE

        protected static final int INITIAL_BUFFER_SIZE
        Initial size of buffer used to serialize objects.
        See Also:
        Constant Field Values
      • errorHandling

        protected ErrorHandling errorHandling
        Flag for error handling.
      • bundleStore

        protected Map<NodeId,​byte[]> bundleStore
        Bundle memory store.
      • refsStore

        protected Map<NodeId,​byte[]> refsStore
        References memory store.
      • blobStore

        protected BLOBStore blobStore
        Blob store.
      • initialCapacity

        protected int initialCapacity
        initial capacity
      • loadFactor

        protected float loadFactor
        load factor for the hash map
      • persistent

        protected boolean persistent
        Should hash map be persisted?
      • useFileBlobStore

        protected boolean useFileBlobStore
        Store blobs on file system instead of memory.
    • Constructor Detail

      • InMemBundlePersistenceManager

        public InMemBundlePersistenceManager()
        Creates a new InMemBundlePersistenceManager instance.
    • Method Detail

      • setInitialCapacity

        public void setInitialCapacity​(int initialCapacity)
      • setInitialCapacity

        public void setInitialCapacity​(String initialCapacity)
      • getInitialCapacity

        public String getInitialCapacity()
      • setLoadFactor

        public void setLoadFactor​(float loadFactor)
      • setLoadFactor

        public void setLoadFactor​(String loadFactor)
      • getLoadFactor

        public String getLoadFactor()
      • isPersistent

        public boolean isPersistent()
      • setPersistent

        public void setPersistent​(boolean persistent)
      • setPersistent

        public void setPersistent​(String persistent)
      • setUseFileBlobStore

        public void setUseFileBlobStore​(boolean useFileBlobStore)
      • setUseFileBlobStore

        public void setUseFileBlobStore​(String useFileBlobStore)
      • getMinBlobSize

        public String getMinBlobSize()
      • setMinBlobSize

        public void setMinBlobSize​(String minBlobSize)
      • loadContents

        public void loadContents()
                          throws Exception
        Reads the content of the hash maps from the file system
        Throws:
        Exception - if an error occurs
      • storeContents

        public void storeContents()
                           throws Exception
        Writes the content of the hash maps stores to the file system.
        Throws:
        Exception - if an error occurs
      • init

        public void init​(PMContext context)
                  throws Exception
        Initializes the persistence manager. The persistence manager is permanently bound to the given context, and any required external resources are acquired.

        An appropriate exception is thrown if the persistence manager initialization fails for whatever reason. In this case the state of the persistence manager is undefined and the instance should be discarded. Initializes the internal structures of this abstract persistence manager.

        Specified by:
        init in interface PersistenceManager
        Overrides:
        init in class AbstractBundlePersistenceManager
        Parameters:
        context - persistence manager context
        Throws:
        Exception - if the persistence manager initialization failed
      • close

        public void close()
                   throws Exception
        Closes the persistence manager. The consistency of the persistent storage is guaranteed and all acquired resources are released. It is an error to invoke any methods on a closed persistence manager, and implementations are free to enforce this constraint by throwing IllegalStateExceptions in such cases.

        An appropriate exception is thrown if the persistence manager could not be closed properly. In this case the state of the persistence manager is undefined and the instance should be discarded. Closes the persistence manager, release acquired resources.

        Specified by:
        close in interface PersistenceManager
        Overrides:
        close in class AbstractBundlePersistenceManager
        Throws:
        Exception - if the persistence manager failed to close properly
      • existsReferencesTo

        public boolean existsReferencesTo​(NodeId targetId)
                                   throws ItemStateException
        Checks whether references of the identified target node exist.
        Parameters:
        targetId - target node id
        Returns:
        true if the references exist, false otherwise
        Throws:
        ItemStateException - on persistence manager errors
      • getAllNodeIds

        public List<NodeId> getAllNodeIds​(NodeId after,
                                          int maxCount)
                                   throws ItemStateException,
                                          RepositoryException
        Get all node ids. A typical application will call this method multiple times, where 'after' is the last row read previously. The maxCount parameter defines the maximum number of node ids returned, 0 meaning no limit. The order of the node ids is specific for the given persistent manager. Items that are added concurrently may not be included.
        Parameters:
        after - the lower limit, or null for no limit.
        maxCount - the maximum number of node ids to return, or 0 for no limit.
        Returns:
        a list of all node ids.
        Throws:
        ItemStateException - if an error while loading occurs.
        RepositoryException - if a repository exception occurs.