org.apache.jackrabbit.core.persistence.bundle
Class BundleFsPersistenceManager

java.lang.Object
  extended by org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
      extended by org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager
All Implemented Interfaces:
CachingPersistenceManager, IterablePersistenceManager, PersistenceManager

public class BundleFsPersistenceManager
extends AbstractBundlePersistenceManager

This is a generic persistence manager that stores the NodePropBundles in a filesystem.

Configuration:


Nested Class Summary
protected static interface BundleFsPersistenceManager.CloseableBLOBStore
          Helper interface for closeable stores
 
Field Summary
protected  BundleBinding binding
          the bundle binding
protected  BundleFsPersistenceManager.CloseableBLOBStore blobStore
          file system where BLOB data is stored
protected  ErrorHandling errorHandling
          flag for error handling
protected  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
 
Constructor Summary
BundleFsPersistenceManager()
           
 
Method Summary
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, NodeReferencesId 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 exists(NodeReferencesId targetId)
          Checks whether references of the identified target node exist.
protected  boolean existsBundle(NodeId id)
          Checks if a bundle exists in the underlying system.
 NodeIdIterator getAllNodeIds(NodeId bigger, int maxCount)
          Get all node ids.
protected  BundleBinding getBinding()
          Returns the bundle binding that is used for serializing the bundles.
 String getBlobFSBlockSize()
          Returns the configured block size of the blob cqfs
 String getErrorHandling()
          Returns the error handling configuration of this manager
 String getMinBlobSize()
          Returns the mininum blob size.
protected  UUID getUUIDFromFileName(String fileName)
          
 void init(PMContext context)
          Initializes the persistence manager.
 NodeReferences load(NodeReferencesId targetId)
          Load the persistent members of a node references object.
protected  NodePropBundle loadBundle(NodeId id)
          Loads a bundle from the underlying system.
protected  void logException(String message, SQLException se)
          logs an sql exception
 void 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()
          Returns true if the blobs are stored in the local fs.
 
Methods inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
buildBlobFilePath, buildNodeFolderPath, buildPropFilePath, checkConsistency, createNew, createNew, evictBundle, exists, exists, getBundleCacheSize, getNameIndex, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

Constructor Detail

BundleFsPersistenceManager

public BundleFsPersistenceManager()
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 exceeds getMinBlobSize().

Parameters:
size - the block size

useLocalFsBlobStore

public boolean useLocalFsBlobStore()
Returns true 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. See ErrorHandling 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 interface PersistenceManager
Overrides:
init in class AbstractBundlePersistenceManager
Parameters:
context - persistence manager context
Throws:
Exception - if the persistence manager initialization failed

getBinding

protected BundleBinding getBinding()
Returns the bundle binding that is used for serializing the bundles.

Specified by:
getBinding in class AbstractBundlePersistenceManager
Returns:
the bundle binding

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 resourecs.

Specified by:
close in interface PersistenceManager
Overrides:
close in class AbstractBundlePersistenceManager
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 class AbstractBundlePersistenceManager
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.

existsBundle

protected boolean existsBundle(NodeId id)
                        throws ItemStateException
Checks if a bundle exists in the underlying system.

Specified by:
existsBundle in class AbstractBundlePersistenceManager
Parameters:
id - the node id of the bundle
Returns:
true if the bundle exists; false otherwise.
Throws:
ItemStateException - if an error while checking 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 class AbstractBundlePersistenceManager
Parameters:
buf - buffer to append to or null
id - the id of the node
Returns:
the buffer with the appended data.

buildNodeReferencesFilePath

protected StringBuffer buildNodeReferencesFilePath(StringBuffer buf,
                                                   NodeReferencesId id)
Creates the file path for the given references id that is suitable for storing reference states in a filesystem.

Overrides:
buildNodeReferencesFilePath in class AbstractBundlePersistenceManager
Parameters:
buf - buffer to append to or null
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 class AbstractBundlePersistenceManager
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 class AbstractBundlePersistenceManager
Parameters:
bundle - the bundle to destroy
Throws:
ItemStateException - if an error while destroying occurs.

load

public NodeReferences load(NodeReferencesId targetId)
                    throws NoSuchItemStateException,
                           ItemStateException
Load the persistent members of a node references object.

Specified by:
load in interface PersistenceManager
Specified by:
load in class AbstractBundlePersistenceManager
Parameters:
targetId - reference target node id
Throws:
NoSuchItemStateException - if the target node does not exist
ItemStateException - if another error occurs

store

public void store(NodeReferences refs)
           throws ItemStateException
Stores a node references to the underlying system.

Specified by:
store in class AbstractBundlePersistenceManager
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 class AbstractBundlePersistenceManager
Parameters:
refs - the node references to destroy.
Throws:
ItemStateException - if an error while destroying occurs.

exists

public boolean exists(NodeReferencesId 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 -

toString

public String toString()
Overrides:
toString in class Object

getAllNodeIds

public NodeIdIterator 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. 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:
an iterator of all bundles.
Throws:
ItemStateException - if an error while loading occurs.

getUUIDFromFileName

protected UUID getUUIDFromFileName(String fileName)



Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.