Class DerbyPersistenceManager
- java.lang.Object
-
- org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
-
- org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager
-
- org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager
-
- All Implemented Interfaces:
CacheAccessListener
,CachingPersistenceManager
,ConsistencyChecker
,IterablePersistenceManager
,PersistenceManager
,DatabaseAware
public class DerbyPersistenceManager extends BundleDbPersistenceManager
Extends theBundleDbPersistenceManager
by derby specific code.Configuration:
- <param name="
bundleCacheSize
" value="8"/> - <param name="
consistencyCheck
" value="false"/> - <param name="
minBlobSize
" value="16384"/> - <param name="
driver
" value="org.apache.derby.jdbc.EmbeddedDriver"/> - <param name="
url
" value="jdbc:derby:${wsp.home}/db/itemState;create=true"/> - <param name="
user
" value=""/> - <param name="
password
" value=""/> - <param name="
schema
" value="derby"/> - <param name="
schemaObjectPrefix
" value=""/> - <param name="
errorHandling
" value=""/> - <param name="
derbyStorageInitialPages
" value="16"/> - <param name="
derbyStorageMinimumRecordSize
" value="256"/> - <param name="
derbyStoragePageCacheSize
" value="1024"/> - <param name="
derbyStoragePageReservedSpace
" value="20"/> - <param name="
derbyStoragePageSize
" value="16384"/>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager
BundleDbPersistenceManager.CloseableBLOBStore, BundleDbPersistenceManager.DbBlobStore, BundleDbPersistenceManager.FSBlobStore
-
-
Field Summary
Fields Modifier and Type Field Description 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, bundleSelectAllBundlesFromSQL, bundleSelectAllBundlesSQL, 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
-
Fields inherited from interface org.apache.jackrabbit.core.cache.CacheAccessListener
ACCESS_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description DerbyPersistenceManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the given connection by shutting down the embedded Derby database.protected ConnectionHelper
createConnectionHelper(DataSource dataSrc)
This method is called from theBundleDbPersistenceManager.init(PMContext)
method of this class and returns aConnectionHelper
instance which is assigned to theconHelper
field.String
getDerbyStorageInitialPages()
String
getDerbyStorageMinimumRecordSize()
String
getDerbyStoragePageCacheSize()
String
getDerbyStoragePageReservedSpace()
String
getDerbyStoragePageSize()
int
getStorageModel()
returns the storage modelvoid
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, createBlobStore, createCheckSchemaOperation, createDBBlobStore, createDbNameIndex, createLocalFSBlobStore, createParams, destroy, destroyBundle, existsReferencesTo, getAllNodeIds, getAllNodeInfos, 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, cacheAccessed, check, checkConsistency, createNew, createNew, disposeCache, evictBundle, exists, exists, getBundleCacheSize, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize, setEventChannel
-
-
-
-
Field Detail
-
DERBY_EMBEDDED_DRIVER
public static final String DERBY_EMBEDDED_DRIVER
name of the embedded driver- See Also:
- Constant Field Values
-
-
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:- the size of the cache (configured with
setDerbyStoragePageCacheSize(java.lang.String)
) - the size of the pages (configured with
setDerbyStoragePageSize(java.lang.String)
) - overhead (varies with JVMs)
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
- the size of the cache (configured with
-
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 interfacePersistenceManager
- Overrides:
init
in classBundleDbPersistenceManager
- Parameters:
context
- persistence manager context- Throws:
Exception
- if the persistence manager initialization failed
-
createConnectionHelper
protected ConnectionHelper createConnectionHelper(DataSource dataSrc)
This method is called from theBundleDbPersistenceManager.init(PMContext)
method of this class and returns aConnectionHelper
instance which is assigned to theconHelper
field. Subclasses may override it to return a specialized connection helper.- Overrides:
createConnectionHelper
in classBundleDbPersistenceManager
- Parameters:
dataSrc
- theDataSource
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 classBundleDbPersistenceManager
- 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 interfacePersistenceManager
- Overrides:
close
in classBundleDbPersistenceManager
- Throws:
SQLException
- if an error occursException
- if the persistence manager failed to close properly
-
-