Class InMemBundlePersistenceManager
- java.lang.Object
-
- org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
-
- org.apache.jackrabbit.core.persistence.mem.InMemBundlePersistenceManager
-
- All Implemented Interfaces:
CacheAccessListener,CachingPersistenceManager,ConsistencyChecker,IterablePersistenceManager,PersistenceManager
public class InMemBundlePersistenceManager extends AbstractBundlePersistenceManager
BundleInMemPersistenceManageris aHashMap-basedPersistenceManagerfor Jackrabbit that keeps all data in memory and that is capable of storing and loading its contents using a simple custom binary serialization format (seeSerializer).It is configured through the following properties:
initialCapacity: initial capacity of the hash map used to store the dataloadFactor: load factor of the hash map used to store the datapersistent: iftruethe contents of the hash map is loaded on startup and stored on shutdown; iffalsenothing is persisteduseFileBlobStore: iftruethe contents of the blobs will be directly stored on the file system instead of in memory.minBlobSizeuse blob store for binaries properties larger than minBlobSite (bytes). Default is 4096.
Please note that this class should only be used for testing purposes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceInMemBundlePersistenceManager.CloseableBLOBStoreHelper interface for closeable storesprotected classInMemBundlePersistenceManager.InMemBLOBStore
-
Field Summary
Fields Modifier and Type Field Description protected BundleBindingbindingthe bundle bindingprotected FileSystemblobFSFile system where BLOB data is stored.protected static StringBLOBS_FILE_PATHPath where blobs are stored on shutdown.protected BLOBStoreblobStoreBlob store.protected static StringBUNDLE_FILE_PATHPath where bundles are stored on shutdown.protected Map<NodeId,byte[]>bundleStoreBundle memory store.protected ErrorHandlingerrorHandlingFlag for error handling.protected static intINITIAL_BUFFER_SIZEInitial size of buffer used to serialize objects.protected intinitialCapacityinitial capacityprotected booleaninitializedflag indicating if this manager was initializedprotected floatloadFactorload factor for the hash mapprotected booleanpersistentShould hash map be persisted?protected static StringREFS_FILE_PATHPath where references are stored on shutdown.protected Map<NodeId,byte[]>refsStoreReferences memory store.protected booleanuseFileBlobStoreStore blobs on file system instead of memory.protected FileSystemwspFSFile system where the content of the hash maps are read from/written to (ifpersistent==true)-
Fields inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
context, NODEFILENAME, NODEREFSFILENAME, RES_NAME_INDEX, RES_NS_INDEX
-
Fields inherited from interface org.apache.jackrabbit.core.cache.CacheAccessListener
ACCESS_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description InMemBundlePersistenceManager()Creates a newInMemBundlePersistenceManagerinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the persistence manager.protected voiddestroy(NodeReferences refs)Deletes the node references from the underlying system.protected voiddestroyBundle(NodePropBundle bundle)Deletes the bundle from the underlying system.booleanexistsReferencesTo(NodeId targetId)Checks whether references of the identified target node exist.List<NodeId>getAllNodeIds(NodeId after, int maxCount)Get all node ids.protected BLOBStoregetBlobStore()Returns the BLOB store used by this persistence manager.StringgetInitialCapacity()StringgetLoadFactor()StringgetMinBlobSize()voidinit(PMContext context)Initializes the persistence manager.booleanisPersistent()protected NodePropBundleloadBundle(NodeId id)Loads a bundle from the underlying system.voidloadContents()Reads the content of the hash maps from the file systemNodeReferencesloadReferencesTo(NodeId id)Load the persisted references to the node with the given identifier.voidsetInitialCapacity(int initialCapacity)voidsetInitialCapacity(String initialCapacity)voidsetLoadFactor(float loadFactor)voidsetLoadFactor(String loadFactor)voidsetMinBlobSize(String minBlobSize)voidsetPersistent(boolean persistent)voidsetPersistent(String persistent)voidsetUseFileBlobStore(boolean useFileBlobStore)voidsetUseFileBlobStore(String useFileBlobStore)protected voidstore(NodeReferences refs)Stores a node references to the underlying system.protected voidstoreBundle(NodePropBundle bundle)Stores a bundle to the underlying system.voidstoreContents()Writes the content of the hash maps stores to the file system.-
Methods inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
buildBlobFilePath, buildNodeFilePath, buildNodeFolderPath, buildNodeReferencesFilePath, buildPropFilePath, cacheAccessed, check, checkConsistency, createNew, createNew, disposeCache, evictBundle, exists, exists, getAllNodeInfos, getBundleCacheSize, getNameIndex, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize, setEventChannel, store
-
-
-
-
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. (ifpersistent==true)- See Also:
- Constant Field Values
-
BLOBS_FILE_PATH
protected static final String BLOBS_FILE_PATH
Path where blobs are stored on shutdown. (ifpersistent==trueanduseFileBlobStore==false)- See Also:
- Constant Field Values
-
REFS_FILE_PATH
protected static final String REFS_FILE_PATH
Path where references are stored on shutdown. (ifpersistent==true)- See Also:
- Constant Field Values
-
wspFS
protected FileSystem wspFS
File system where the content of the hash maps are read from/written to (ifpersistent==true)
-
blobFS
protected FileSystem blobFS
File system where BLOB data is stored. (ifuseFileBlobStore==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.
-
binding
protected BundleBinding binding
the bundle binding
-
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.
-
-
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 ExceptionReads the content of the hash maps from the file system- Throws:
Exception- if an error occurs
-
storeContents
public void storeContents() throws ExceptionWrites 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:
initin interfacePersistenceManager- Overrides:
initin classAbstractBundlePersistenceManager- Parameters:
context- persistence manager context- Throws:
Exception- if the persistence manager initialization failed
-
close
public void close() throws ExceptionCloses 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:
closein interfacePersistenceManager- Overrides:
closein classAbstractBundlePersistenceManager- Throws:
Exception- if the persistence manager failed to close properly
-
loadReferencesTo
public NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException
Load the persisted references to the node with the given identifier.- Parameters:
id- reference target node id- Throws:
NoSuchItemStateException- if the target node does not existItemStateException- if another error occurs
-
store
protected void store(NodeReferences refs) throws ItemStateException
Stores a node references to the underlying system.- Specified by:
storein classAbstractBundlePersistenceManager- Parameters:
refs- the node references to store.- Throws:
ItemStateException- if an error while storing occurs.
-
existsReferencesTo
public boolean existsReferencesTo(NodeId targetId) throws ItemStateException
Checks whether references of the identified target node exist.- Parameters:
targetId- target node id- Returns:
trueif the references exist,falseotherwise- Throws:
ItemStateException- on persistence manager errors
-
destroy
protected void destroy(NodeReferences refs) throws ItemStateException
Deletes the node references from the underlying system.- Specified by:
destroyin classAbstractBundlePersistenceManager- Parameters:
refs- the node references to destroy.- Throws:
ItemStateException- if an error while destroying occurs.
-
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.
-
loadBundle
protected NodePropBundle loadBundle(NodeId id) throws ItemStateException
Loads a bundle from the underlying system.- Specified by:
loadBundlein classAbstractBundlePersistenceManager- Parameters:
id- the node id of the bundle- Returns:
- the loaded bundle or
nullif the bundle does not exist. - Throws:
ItemStateException- if an error while loading occurs.
-
storeBundle
protected void storeBundle(NodePropBundle bundle) throws ItemStateException
Stores a bundle to the underlying system.- Specified by:
storeBundlein classAbstractBundlePersistenceManager- Parameters:
bundle- the bundle to store- Throws:
ItemStateException- if an error while storing occurs.
-
destroyBundle
protected void destroyBundle(NodePropBundle bundle) throws ItemStateException
Deletes the bundle from the underlying system.- Specified by:
destroyBundlein classAbstractBundlePersistenceManager- Parameters:
bundle- the bundle to destroy- Throws:
ItemStateException- if an error while destroying occurs.
-
getBlobStore
protected BLOBStore getBlobStore()
Returns the BLOB store used by this persistence manager.- Specified by:
getBlobStorein classAbstractBundlePersistenceManager- Returns:
- BLOB store
-
-