org.apache.jackrabbit.core.persistence.pool
Class DerbyPersistenceManager

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

public class DerbyPersistenceManager
extends BundleDbPersistenceManager

Extends the BundleDbPersistenceManager by derby specific code.

Configuration:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager
BundleDbPersistenceManager.CloseableBLOBStore, BundleDbPersistenceManager.DbBlobStore, BundleDbPersistenceManager.FSBlobStore
 
Field Summary
static String DERBY_EMBEDDED_DRIVER
          name of the embedded driver
 
Fields inherited from class org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager
binding, blobStore, blockOnConnectionLoss, bundleDeleteSQL, bundleInsertSQL, bundleSelectAllIdsFromSQL, bundleSelectAllIdsSQL, bundleSelectSQL, bundleUpdateSQL, conHelper, consistencyCheck, consistencyFix, databaseType, dataSourceName, driver, errorHandling, externalBLOBs, INITIAL_BUFFER_SIZE, initialized, nodeReferenceDeleteSQL, nodeReferenceInsertSQL, nodeReferenceSelectSQL, nodeReferenceUpdateSQL, password, schemaObjectPrefix, SM_BINARY_KEYS, SM_LONGLONG_KEYS, url, user
 
Fields inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
context, NODEFILENAME, NODEREFSFILENAME, RES_NAME_INDEX, RES_NS_INDEX
 
Constructor Summary
DerbyPersistenceManager()
           
 
Method Summary
 void close()
          Closes the given connection by shutting down the embedded Derby database.
protected  ConnectionHelper createConnectionHelper(DataSource dataSrc)
          This method is called from the BundleDbPersistenceManager.init(PMContext) method of this class and returns a ConnectionHelper instance which is assigned to the conHelper field.
 String getDerbyStorageInitialPages()
           
 String getDerbyStorageMinimumRecordSize()
           
 String getDerbyStoragePageCacheSize()
           
 String getDerbyStoragePageReservedSpace()
           
 String getDerbyStoragePageSize()
           
 int getStorageModel()
          returns the storage model
 void init(PMContext context)
          Initializes the persistence manager.
 void setDerbyStorageInitialPages(String derbyStorageInitialPages)
          The on-disk size of a Derby table grows by one page at a time until eight pages of user data (or nine pages of total disk use, one is used for overhead) have been allocated.
 void setDerbyStorageMinimumRecordSize(String derbyStorageMinimumRecordSize)
          Indicates the minimum user row size in bytes for on-disk database pages for tables when you are creating a table.
 void setDerbyStoragePageCacheSize(String derbyStoragePageCacheSize)
          Defines the size, in number of pages, of the database's data page cache (data pages kept in memory).
 void setDerbyStoragePageReservedSpace(String derbyStoragePageReservedSpace)
          Defines the percentage of space reserved for updates on an on-disk database page for tables only (not indexes); indicates the percentage of space to keep free on a page when inserting.
 void setDerbyStoragePageSize(String derbyStoragePageSize)
          Defines the page size, in bytes, for on-disk database pages for tables or indexes used during table or index creation.
 
Methods inherited from class org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager
buildSQLStatements, checkBundleConsistency, checkConsistency, createBlobStore, createCheckSchemaOperation, createDBBlobStore, createDbNameIndex, createLocalFSBlobStore, createParams, destroy, destroyBundle, existsReferencesTo, getAllNodeIds, getBlobStore, getBlockOnConnectionLoss, getConsistencyCheck, getConsistencyFix, getDatabaseType, getDataSourceName, getDriver, getErrorHandling, getKey, getMinBlobSize, getNameIndex, getPassword, getSchema, getSchemaObjectPrefix, getUrl, getUser, isExternalBLOBs, isSchemaCheckEnabled, loadBundle, loadReferencesTo, setBlockOnConnectionLoss, setConnectionFactory, setConsistencyCheck, setConsistencyFix, setDatabaseType, setDataSourceName, setDriver, setErrorHandling, setExternalBLOBs, setMinBlobSize, setPassword, setSchema, setSchemaCheckEnabled, setSchemaObjectPrefix, setUrl, setUser, store, store, storeBundle, toString, useDbBlobStore, useLocalFsBlobStore
 
Methods inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
buildBlobFilePath, buildNodeFilePath, buildNodeFolderPath, buildNodeReferencesFilePath, buildPropFilePath, createNew, createNew, evictBundle, exists, exists, getBundleCacheSize, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DERBY_EMBEDDED_DRIVER

public static final String DERBY_EMBEDDED_DRIVER
name of the embedded driver

See Also:
Constant Field Values
Constructor Detail

DerbyPersistenceManager

public DerbyPersistenceManager()
Method Detail

getDerbyStorageInitialPages

public String getDerbyStorageInitialPages()
Returns:
the initial pages property
See Also:
setDerbyStorageInitialPages(java.lang.String)

setDerbyStorageInitialPages

public void setDerbyStorageInitialPages(String derbyStorageInitialPages)
The on-disk size of a Derby table grows by one page at a time until eight pages of user data (or nine pages of total disk use, one is used for overhead) have been allocated. Then it will grow by eight pages at a time if possible.

A Derby table or index can be created with a number of pages already pre-allocated. To do so, specify the property prior to the CREATE TABLE or CREATE INDEX statement.

Define the number of user pages the table or index is to be created with. The purpose of this property is to preallocate a table or index of reasonable size if the user expects that a large amount of data will be inserted into the table or index. A table or index that has the pre-allocated pages will enjoy a small performance improvement over a table or index that has no pre-allocated pages when the data are loaded.

The total desired size of the table or index should be

(1+derby.storage.initialPages) * derby.storage.pageSize bytes.

When you create a table or an index after setting this property, Derby attempts to preallocate the requested number of user pages. However, the operations do not fail even if they are unable to preallocate the requested number of pages, as long as they allocate at least one page.

Default is 16

Parameters:
derbyStorageInitialPages - the number of initial pages

getDerbyStorageMinimumRecordSize

public String getDerbyStorageMinimumRecordSize()
Returns:
the minimum record size
See Also:
setDerbyStorageMinimumRecordSize(java.lang.String)

setDerbyStorageMinimumRecordSize

public void setDerbyStorageMinimumRecordSize(String derbyStorageMinimumRecordSize)
Indicates the minimum user row size in bytes for on-disk database pages for tables when you are creating a table. This property ensures that there is enough room for a row to grow on a page when updated without having to overflow. This is generally most useful for VARCHAR and VARCHAR FOR BIT DATA data types and for tables that are updated a lot, in which the rows start small and grow due to updates. Reserving the space at the time of insertion minimizes row overflow due to updates, but it can result in wasted space. Set the property prior to issuing the CREATE TABLE statement.

Default is 256

Parameters:
derbyStorageMinimumRecordSize - the minimum record size

getDerbyStoragePageCacheSize

public String getDerbyStoragePageCacheSize()
Returns:
the page cache size
See Also:
setDerbyStoragePageCacheSize(java.lang.String)

setDerbyStoragePageCacheSize

public void setDerbyStoragePageCacheSize(String derbyStoragePageCacheSize)
Defines the size, in number of pages, of the database's data page cache (data pages kept in memory). The actual amount of memory the page cache will use depends on the following: When increasing the size of the page cache, you typically have to allow more memory for the Java heap when starting the embedding application (taking into consideration, of course, the memory needs of the embedding application as well). For example, using the default page size of 4K, a page cache size of 2000 pages will require at least 8 MB of memory (and probably more, given the overhead).

The minimum value is 40 pages. If you specify a lower value, Derby uses the default value.

Default is 1024 (which gives about 16mb memory usage given the default of 16384 as page size).

Parameters:
derbyStoragePageCacheSize - the page cache size

getDerbyStoragePageReservedSpace

public String getDerbyStoragePageReservedSpace()
Returns:
the page reserved space
See Also:
setDerbyStoragePageReservedSpace(java.lang.String)

setDerbyStoragePageReservedSpace

public void setDerbyStoragePageReservedSpace(String derbyStoragePageReservedSpace)
Defines the percentage of space reserved for updates on an on-disk database page for tables only (not indexes); indicates the percentage of space to keep free on a page when inserting. Leaving reserved space on a page can minimize row overflow (and the associated performance hit) during updates. Once a page has been filled up to the reserved-space threshold, no new rows are allowed on the page. This reserved space is used only for rows that increase in size when updated, not for new inserts. Set this property prior to issuing the CREATE TABLE statement.

Regardless of the value of derby.storage.pageReservedSpace, an empty page always accepts at least one row.

Default is 20%

Parameters:
derbyStoragePageReservedSpace - the page reserved space

getDerbyStoragePageSize

public String getDerbyStoragePageSize()
Returns:
the page size
See Also:
setDerbyStoragePageSize(java.lang.String)

setDerbyStoragePageSize

public void setDerbyStoragePageSize(String derbyStoragePageSize)
Defines the page size, in bytes, for on-disk database pages for tables or indexes used during table or index creation. Page size can only be one the following values: 4096, 8192, 16384, or 32768. Set this property prior to issuing the CREATE TABLE or CREATE INDEX statement. This value will be used for the lifetime of the newly created conglomerates.

Default is 16384

Parameters:
derbyStoragePageSize - the storage page size

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 BundleDbPersistenceManager
Parameters:
context - persistence manager context
Throws:
Exception - if the persistence manager initialization failed

createConnectionHelper

protected ConnectionHelper createConnectionHelper(DataSource dataSrc)
This method is called from the BundleDbPersistenceManager.init(PMContext) method of this class and returns a ConnectionHelper instance which is assigned to the conHelper field. Subclasses may override it to return a specialized connection helper.

Overrides:
createConnectionHelper in class BundleDbPersistenceManager
Parameters:
dataSrc - the DataSource of this persistence manager
Returns:
a ConnectionHelper

getStorageModel

public int getStorageModel()
returns the storage model Since Derby cannot handle binary indexes, we use long-long keys.

Overrides:
getStorageModel in class BundleDbPersistenceManager
Returns:
BundleDbPersistenceManager.SM_LONGLONG_KEYS

close

public void close()
           throws Exception
Closes the given connection by shutting down the embedded Derby database.

Specified by:
close in interface PersistenceManager
Overrides:
close in class BundleDbPersistenceManager
Throws:
SQLException - if an error occurs
Exception - if the persistence manager failed to close properly
See Also:
DatabasePersistenceManager#closeConnection(Connection)


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