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 dataloadFactor
: load factor of the hash map used to store the datapersistent
: if true
the contents of the hash map
is loaded on startup and stored on shutdown;
if false
nothing is persisteduseFileBlobStore
: 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.
Modifier and Type | Class and Description |
---|---|
protected static interface |
InMemBundlePersistenceManager.CloseableBLOBStore
Helper interface for closeable stores
|
protected class |
InMemBundlePersistenceManager.InMemBLOBStore
|
Modifier and Type | Field and Description |
---|---|
protected BundleBinding |
binding
the bundle binding
|
protected FileSystem |
blobFS
File system where BLOB data is stored.
|
protected static String |
BLOBS_FILE_PATH
Path where blobs are stored on shutdown.
|
protected BLOBStore |
blobStore
Blob store.
|
protected static String |
BUNDLE_FILE_PATH
Path where bundles are stored on shutdown.
|
protected Map<NodeId,byte[]> |
bundleStore
Bundle memory store.
|
protected ErrorHandling |
errorHandling
Flag for error handling.
|
protected static int |
INITIAL_BUFFER_SIZE
Initial size of buffer used to serialize objects.
|
protected int |
initialCapacity
initial capacity
|
protected boolean |
initialized
flag indicating if this manager was initialized
|
protected float |
loadFactor
load factor for the hash map
|
protected boolean |
persistent
Should hash map be persisted?
|
protected static String |
REFS_FILE_PATH
Path where references are stored on shutdown.
|
protected Map<NodeId,byte[]> |
refsStore
References memory store.
|
protected boolean |
useFileBlobStore
Store blobs on file system instead of memory.
|
protected FileSystem |
wspFS
File system where the content of the hash maps are read from/written to
(if
persistent==true ) |
context, NODEFILENAME, NODEREFSFILENAME, RES_NAME_INDEX, RES_NS_INDEX
ACCESS_INTERVAL
Constructor and Description |
---|
InMemBundlePersistenceManager()
Creates a new
InMemBundlePersistenceManager instance. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the persistence manager.
|
protected void |
destroy(NodeReferences refs)
Deletes the node references from the underlying system.
|
protected void |
destroyBundle(NodePropBundle bundle)
Deletes the bundle from the underlying system.
|
boolean |
existsReferencesTo(NodeId targetId)
Checks whether references of the identified target node exist.
|
List<NodeId> |
getAllNodeIds(NodeId after,
int maxCount)
Get all node ids.
|
protected BLOBStore |
getBlobStore()
Returns the BLOB store used by this persistence manager.
|
String |
getInitialCapacity() |
String |
getLoadFactor() |
String |
getMinBlobSize() |
void |
init(PMContext context)
Initializes the persistence manager.
|
boolean |
isPersistent() |
protected NodePropBundle |
loadBundle(NodeId id)
Loads a bundle from the underlying system.
|
void |
loadContents()
Reads the content of the hash maps from the file system
|
NodeReferences |
loadReferencesTo(NodeId id)
Load the persisted references to the node with the given identifier.
|
void |
setInitialCapacity(int initialCapacity) |
void |
setInitialCapacity(String initialCapacity) |
void |
setLoadFactor(float loadFactor) |
void |
setLoadFactor(String loadFactor) |
void |
setMinBlobSize(String minBlobSize) |
void |
setPersistent(boolean persistent) |
void |
setPersistent(String persistent) |
void |
setUseFileBlobStore(boolean useFileBlobStore) |
void |
setUseFileBlobStore(String useFileBlobStore) |
protected void |
store(NodeReferences refs)
Stores a node references to the underlying system.
|
protected void |
storeBundle(NodePropBundle bundle)
Stores a bundle to the underlying system.
|
void |
storeContents()
Writes the content of the hash maps stores to the file system.
|
buildBlobFilePath, buildNodeFilePath, buildNodeFolderPath, buildNodeReferencesFilePath, buildPropFilePath, cacheAccessed, check, checkConsistency, createNew, createNew, disposeCache, evictBundle, exists, exists, getAllNodeInfos, getBundleCacheSize, getNameIndex, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize, setEventChannel, store
protected boolean initialized
protected static final String BUNDLE_FILE_PATH
persistent==true
)protected static final String BLOBS_FILE_PATH
persistent==true
and useFileBlobStore==false
)protected static final String REFS_FILE_PATH
persistent==true
)protected FileSystem wspFS
persistent==true
)protected FileSystem blobFS
useFileBlobStore==true
)protected static final int INITIAL_BUFFER_SIZE
protected ErrorHandling errorHandling
protected BundleBinding binding
protected BLOBStore blobStore
protected int initialCapacity
protected float loadFactor
protected boolean persistent
protected boolean useFileBlobStore
public InMemBundlePersistenceManager()
InMemBundlePersistenceManager
instance.public void setInitialCapacity(int initialCapacity)
public void setInitialCapacity(String initialCapacity)
public String getInitialCapacity()
public void setLoadFactor(float loadFactor)
public void setLoadFactor(String loadFactor)
public String getLoadFactor()
public boolean isPersistent()
public void setPersistent(boolean persistent)
public void setPersistent(String persistent)
public void setUseFileBlobStore(boolean useFileBlobStore)
public void setUseFileBlobStore(String useFileBlobStore)
public String getMinBlobSize()
public void setMinBlobSize(String minBlobSize)
public void loadContents() throws Exception
Exception
- if an error occurspublic void storeContents() throws Exception
Exception
- if an error occurspublic void init(PMContext context) throws Exception
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.
init
in interface PersistenceManager
init
in class AbstractBundlePersistenceManager
context
- persistence manager contextException
- if the persistence manager initialization failedpublic void close() throws Exception
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.
close
in interface PersistenceManager
close
in class AbstractBundlePersistenceManager
Exception
- if the persistence manager failed to close properlypublic NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException
id
- reference target node idNoSuchItemStateException
- if the target node does not existItemStateException
- if another error occursprotected void store(NodeReferences refs) throws ItemStateException
store
in class AbstractBundlePersistenceManager
refs
- the node references to store.ItemStateException
- if an error while storing occurs.public boolean existsReferencesTo(NodeId targetId) throws ItemStateException
targetId
- target node idtrue
if the references exist,
false
otherwiseItemStateException
- on persistence manager errorsprotected void destroy(NodeReferences refs) throws ItemStateException
destroy
in class AbstractBundlePersistenceManager
refs
- the node references to destroy.ItemStateException
- if an error while destroying occurs.public List<NodeId> getAllNodeIds(NodeId after, int maxCount) throws ItemStateException, RepositoryException
after
- the lower limit, or null for no limit.maxCount
- the maximum number of node ids to return, or 0 for no limit.ItemStateException
- if an error while loading occurs.RepositoryException
- if a repository exception occurs.protected NodePropBundle loadBundle(NodeId id) throws ItemStateException
loadBundle
in class AbstractBundlePersistenceManager
id
- the node id of the bundlenull
if the bundle does not
exist.ItemStateException
- if an error while loading occurs.protected void storeBundle(NodePropBundle bundle) throws ItemStateException
storeBundle
in class AbstractBundlePersistenceManager
bundle
- the bundle to storeItemStateException
- if an error while storing occurs.protected void destroyBundle(NodePropBundle bundle) throws ItemStateException
destroyBundle
in class AbstractBundlePersistenceManager
bundle
- the bundle to destroyItemStateException
- if an error while destroying occurs.protected BLOBStore getBlobStore()
getBlobStore
in class AbstractBundlePersistenceManager
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.