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, 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 static int INITIAL_BUFFER_SIZE
          initial size of buffer used to serialize objects
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.
protected  void closeStream(InputStream ins)
          closes the input stream
 void destroy(NodeReferences refs)
          Deletes the node references from the undelying 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.
 String getBlobFSBlockSize()
          Returns the configured block size of the blob cqfs
 String getBlobFSInitialCacheSize()
          Returns the configured inital cache size of the blobfs.
 String getBlobFSMaximumCacheSize()
          Returns the configured maximal size of the blobfs.
 String getErrorHandling()
          Returns the error handling configuration of this manager
 String getItemFSBlockSize()
          Returns the configured block size of the item cqfs
 String getItemFSInitialCacheSize()
          Returns the configured inital cache size of the itemfs.
 String getItemFSMaximumCacheSize()
          Returns the configured maximal size of the itemfs.
 int getMinBlobSize()
          Returns the miminum blob size.
 void init(PMContext context)
          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.

 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 controlls how blobs are handled.
 void setBlobFSInitialCacheSize(String size)
          Sets the initial cache size of the blob fs.
 void setBlobFSMaximumCacheSize(String size)
          Sets the maximal cache size of the blob fs.
 void setErrorHandling(String errorHandling)
          Sets the error handling behaviour of this manager.
 void setItemFSBlockSize(String size)
          Sets the block size of the item fs.
 void setItemFSInitialCacheSize(String size)
          Sets the initial cache size of the item fs.
 void setItemFSMaximumCacheSize(String size)
          Sets the maximal cache size of the item fs.
 void setMinBlobSize(String minBlobSize)
          Sets the minumum 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 useCqFsBlobStore()
          Returns true if the blobs are stored in the cqfs.
 boolean useItemBlobStore()
          Returns true if the blobs are stored in the DB.
 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, createNew, createNew, 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


INITIAL_BUFFER_SIZE

protected static final int INITIAL_BUFFER_SIZE
initial size of buffer used to serialize objects

See Also:
Constant Field Values

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 controlls how blobs are handled.
If the size is > 0, it must be a power of 2 and is used as blocksize for the cqfs. blobs are then stored within that cqfs. A call to useCqFsBlobStore() will return true.
If the size is 0, the cqfs is not used at all, and the blobs are stored within the workspace's physical filesystem. A call to useLocalFsBlobStore() will return true.
If the size is < 0, the cqfs is not used at all, and the blobls are stored within the item filesystem. A call to useItemBlobStore() will return true.
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

useItemBlobStore

public boolean useItemBlobStore()
Returns true if the blobs are stored in the DB.

Returns:
true if the blobs are stored in the DB.

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.

useCqFsBlobStore

public boolean useCqFsBlobStore()
Returns true if the blobs are stored in the cqfs.

Returns:
true if the blobs are stored in the cqfs.

getBlobFSInitialCacheSize

public String getBlobFSInitialCacheSize()
Returns the configured inital cache size of the blobfs.

Returns:
the configured inital cache size of the blobfs.

setBlobFSInitialCacheSize

public void setBlobFSInitialCacheSize(String size)
Sets the initial cache size of the blob fs. This only applies to cqfs base blobstores, i.e. if useCqFsBlobStore() returns true.

Parameters:
size - the initial size

getBlobFSMaximumCacheSize

public String getBlobFSMaximumCacheSize()
Returns the configured maximal size of the blobfs.

Returns:
the configured maximal size of the blobfs.

setBlobFSMaximumCacheSize

public void setBlobFSMaximumCacheSize(String size)
Sets the maximal cache size of the blob fs. This only applies to cqfs base blobstores, i.e. if useCqFsBlobStore() returns true.

Parameters:
size - the maximal size

getItemFSBlockSize

public String getItemFSBlockSize()
Returns the configured block size of the item cqfs

Returns:
the block size.

setItemFSBlockSize

public void setItemFSBlockSize(String size)
Sets the block size of the item fs.
If the size is > 0, it must be a power of 2 and is used as blocksize for the cqfs. items are then stored within that cqfs.
If the size is 0, the cqfs is not used at all, and the items are stored within the workspace's physical filesystem.

Parameters:
size - the block size

getItemFSInitialCacheSize

public String getItemFSInitialCacheSize()
Returns the configured inital cache size of the itemfs.

Returns:
the configured inital cache size of the itemfs.

setItemFSInitialCacheSize

public void setItemFSInitialCacheSize(String size)
Sets the initial cache size of the item fs. This only applies to cqfs based item stores.

Parameters:
size - the initial size

getItemFSMaximumCacheSize

public String getItemFSMaximumCacheSize()
Returns the configured maximal size of the itemfs.

Returns:
the configured maximal size of the itemfs.

setItemFSMaximumCacheSize

public void setItemFSMaximumCacheSize(String size)
Sets the maximal cache size of the item fs. This only applies to cqfs base item storea.

Parameters:
size - the maximal size

getMinBlobSize

public int getMinBlobSize()
Returns the miminum blob size.

Returns:
the miminum blob size.

setMinBlobSize

public void setMinBlobSize(String minBlobSize)
Sets the minumum blob size. This size defines the threshhold of which size a property is included in the bundle or is stored in the blob store.

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 intialization failed

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.

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 bunlde 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 undelying 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

closeStream

protected void closeStream(InputStream ins)
closes the input stream

Parameters:
ins -

logException

protected void logException(String message,
                            SQLException se)
logs an sql exception

Parameters:
message -
se -

toString

public String toString()
Overrides:
toString in class Object


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