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 theNodePropBundles 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 interfaceBundleFsPersistenceManager.CloseableBLOBStoreHelper interface for closeable stores
-
Field Summary
Fields Modifier and Type Field Description protected BundleBindingbindingthe bundle bindingprotected BundleFsPersistenceManager.CloseableBLOBStoreblobStorefile system where BLOB data is storedprotected ErrorHandlingerrorHandlingflag for error handlingprotected booleaninitializedflag 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 StringBufferbuildNodeFilePath(StringBuffer buf, NodeId id)Creates the file path for the given node id that is suitable for storing node states in a filesystem.protected StringBufferbuildNodeReferencesFilePath(StringBuffer buf, NodeId id)Creates the file path for the given references id that is suitable for storing reference states in a filesystem.voidclose()Closes the persistence manager.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 bigger, int maxCount)Get all node ids.StringgetBlobFSBlockSize()Returns the configured block size of the blob cqfsprotected BLOBStoregetBlobStore()Returns the BLOB store used by this persistence manager.StringgetErrorHandling()Returns the error handling configuration of this managerprotected NodeIdgetIdFromFileName(String fileName)StringgetMinBlobSize()Returns the mininum blob size.voidinit(PMContext context)Initializes the persistence manager.protected NodePropBundleloadBundle(NodeId id)Loads a bundle from the underlying system.NodeReferencesloadReferencesTo(NodeId targetId)Load the persisted references to the node with the given identifier.protected voidlogException(String message, SQLException se)logs an sql exceptionvoidsetBlobFSBlockSize(String size)Sets the block size of the blob fs and controls how blobs are handled.voidsetErrorHandling(String errorHandling)Sets the error handling behaviour of this manager.voidsetMinBlobSize(String minBlobSize)Sets the minimum blob size.voidstore(NodeReferences refs)Stores a node references to the underlying system.protected voidstoreBundle(NodePropBundle bundle)Stores a bundle to the underlying system.StringtoString()booleanuseLocalFsBlobStore()Returnstrueif 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()
Returnstrueif the blobs are stored in the local fs.- Returns:
trueif 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. SeeErrorHandlingfor 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:
initin interfacePersistenceManager- Overrides:
initin 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:
getBlobStorein classAbstractBundlePersistenceManager- Returns:
- BLOB store
-
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
-
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.
-
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:
buildNodeFilePathin classAbstractBundlePersistenceManager- Parameters:
buf- buffer to append to ornullid- 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:
buildNodeReferencesFilePathin classAbstractBundlePersistenceManager- Parameters:
buf- buffer to append to ornullid- 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:
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.
-
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:
storein 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:
destroyin 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:
trueif the references exist,falseotherwise- 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.
-
-