Class BundleFsPersistenceManager
- java.lang.Object
-
- org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
-
- org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager
-
- All Implemented Interfaces:
CacheAccessListener
,CachingPersistenceManager
,ConsistencyChecker
,IterablePersistenceManager
,PersistenceManager
public class BundleFsPersistenceManager extends AbstractBundlePersistenceManager
This is a generic persistence manager that stores theNodePropBundle
s in a filesystem.Configuration:
- <param name="
blobFSBlockSize
" value="0"/> - <param name="
minBlobSize
" value="4096"/> - <param name="
errorHandling
" value=""/>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
BundleFsPersistenceManager.CloseableBLOBStore
Helper interface for closeable stores
-
Field Summary
Fields Modifier and Type Field Description protected BundleBinding
binding
the bundle bindingprotected BundleFsPersistenceManager.CloseableBLOBStore
blobStore
file system where BLOB data is storedprotected ErrorHandling
errorHandling
flag for error handlingprotected boolean
initialized
flag indicating if this manager was initialized-
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 BundleFsPersistenceManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringBuffer
buildNodeFilePath(StringBuffer buf, NodeId id)
Creates the file path for the given node id that is suitable for storing node states in a filesystem.protected StringBuffer
buildNodeReferencesFilePath(StringBuffer buf, NodeId id)
Creates the file path for the given references id that is suitable for storing reference states in a filesystem.void
close()
Closes the persistence manager.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 bigger, int maxCount)
Get all node ids.String
getBlobFSBlockSize()
Returns the configured block size of the blob cqfsprotected BLOBStore
getBlobStore()
Returns the BLOB store used by this persistence manager.String
getErrorHandling()
Returns the error handling configuration of this managerprotected NodeId
getIdFromFileName(String fileName)
String
getMinBlobSize()
Returns the mininum blob size.void
init(PMContext context)
Initializes the persistence manager.protected NodePropBundle
loadBundle(NodeId id)
Loads a bundle from the underlying system.NodeReferences
loadReferencesTo(NodeId targetId)
Load the persisted references to the node with the given identifier.protected void
logException(String message, SQLException se)
logs an sql exceptionvoid
setBlobFSBlockSize(String size)
Sets the block size of the blob fs and controls how blobs are handled.void
setErrorHandling(String errorHandling)
Sets the error handling behaviour of this manager.void
setMinBlobSize(String minBlobSize)
Sets the minimum blob size.void
store(NodeReferences refs)
Stores a node references to the underlying system.protected void
storeBundle(NodePropBundle bundle)
Stores a bundle to the underlying system.String
toString()
boolean
useLocalFsBlobStore()
Returnstrue
if the blobs are stored in the local fs.-
Methods inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
buildBlobFilePath, buildNodeFolderPath, 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
-
blobStore
protected BundleFsPersistenceManager.CloseableBLOBStore blobStore
file system where BLOB data is stored
-
errorHandling
protected ErrorHandling errorHandling
flag for error handling
-
binding
protected BundleBinding binding
the bundle binding
-
-
Method Detail
-
getBlobFSBlockSize
public String getBlobFSBlockSize()
Returns the configured block size of the blob cqfs- Returns:
- the block size.
-
setBlobFSBlockSize
public void setBlobFSBlockSize(String size)
Sets the block size of the blob fs and controls how blobs are handled.
If the size is 0, the blobs are stored within the workspace's physical filesystem.
Otherwise, the blobs are stored within the item filesystem.
Please note that not all binary properties are considered as blobs. They are only stored in the respective blob store, if their size exceedsgetMinBlobSize()
.- Parameters:
size
- the block size
-
useLocalFsBlobStore
public boolean useLocalFsBlobStore()
Returnstrue
if the blobs are stored in the local fs.- Returns:
true
if the blobs are stored in the local fs.
-
getMinBlobSize
public String getMinBlobSize()
Returns the mininum blob size.- Returns:
- the mininum blob size.
-
setMinBlobSize
public void setMinBlobSize(String minBlobSize)
Sets the minimum blob size. This size defines the threshold of which size a property is included in the bundle or is stored in the blob store. Very high values decrease the performance.- Parameters:
minBlobSize
-
-
setErrorHandling
public void setErrorHandling(String errorHandling)
Sets the error handling behaviour of this manager. SeeErrorHandling
for details about the flags.- Parameters:
errorHandling
-
-
getErrorHandling
public String getErrorHandling()
Returns the error handling configuration of this manager- Returns:
- the error handling configuration of this manager
-
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 interfacePersistenceManager
- Overrides:
init
in classAbstractBundlePersistenceManager
- Parameters:
context
- persistence manager context- Throws:
Exception
- if the persistence manager initialization failed
-
getBlobStore
protected BLOBStore getBlobStore()
Returns the BLOB store used by this persistence manager.- Specified by:
getBlobStore
in classAbstractBundlePersistenceManager
- Returns:
- BLOB store
-
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 interfacePersistenceManager
- Overrides:
close
in classAbstractBundlePersistenceManager
- Throws:
Exception
- if the persistence manager failed to close properly
-
loadBundle
protected NodePropBundle loadBundle(NodeId id) throws ItemStateException
Loads a bundle from the underlying system.- Specified by:
loadBundle
in classAbstractBundlePersistenceManager
- Parameters:
id
- the node id of the bundle- Returns:
- the loaded bundle or
null
if the bundle does not exist. - Throws:
ItemStateException
- if an error while loading occurs.
-
buildNodeFilePath
protected StringBuffer buildNodeFilePath(StringBuffer buf, NodeId id)
Creates the file path for the given node id that is suitable for storing node states in a filesystem.- Overrides:
buildNodeFilePath
in classAbstractBundlePersistenceManager
- Parameters:
buf
- buffer to append to ornull
id
- the id of the node- Returns:
- the buffer with the appended data.
-
buildNodeReferencesFilePath
protected StringBuffer buildNodeReferencesFilePath(StringBuffer buf, NodeId id)
Creates the file path for the given references id that is suitable for storing reference states in a filesystem.- Overrides:
buildNodeReferencesFilePath
in classAbstractBundlePersistenceManager
- Parameters:
buf
- buffer to append to ornull
id
- the id of the node- Returns:
- the buffer with the appended data.
-
storeBundle
protected void storeBundle(NodePropBundle bundle) throws ItemStateException
Stores a bundle to the underlying system.- Specified by:
storeBundle
in 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:
destroyBundle
in classAbstractBundlePersistenceManager
- Parameters:
bundle
- the bundle to destroy- Throws:
ItemStateException
- if an error while destroying occurs.
-
loadReferencesTo
public NodeReferences loadReferencesTo(NodeId targetId) throws NoSuchItemStateException, ItemStateException
Load the persisted references to the node with the given identifier.- Parameters:
targetId
- reference target node id- Throws:
NoSuchItemStateException
- if the target node does not existItemStateException
- if another error occurs
-
store
public void store(NodeReferences refs) throws ItemStateException
Stores a node references to the underlying system.- Specified by:
store
in classAbstractBundlePersistenceManager
- Parameters:
refs
- the node references to store.- Throws:
ItemStateException
- if an error while storing occurs.
-
destroy
public void destroy(NodeReferences refs) throws ItemStateException
Deletes the node references from the underlying system.- Specified by:
destroy
in classAbstractBundlePersistenceManager
- Parameters:
refs
- the node references to destroy.- Throws:
ItemStateException
- if an error while destroying occurs.
-
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
-
logException
protected void logException(String message, SQLException se)
logs an sql exception- Parameters:
message
-se
-
-
getAllNodeIds
public List<NodeId> getAllNodeIds(NodeId bigger, int maxCount) throws ItemStateException
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:
bigger
- 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.
-
-