CacheableFactory
, ModuleControl
, PropertySetCallback
, AccessFactory
RllRAMAccessManager
public abstract class RAMAccessManager extends java.lang.Object implements AccessFactory, CacheableFactory, ModuleControl, PropertySetCallback
Modifier and Type | Field | Description |
---|---|---|
private CacheManager |
conglom_cache |
Cache of Conglomerate objects, keyed by conglom id.
|
protected ConglomerateFactory[] |
conglom_map |
A map of the implementation specific id to conglomerate object.
|
private long |
conglom_nextid |
Routines to map to/from conglomid/containerid:
|
private java.util.Hashtable<UUID,MethodFactory> |
formathash |
Hash table on primary format.
|
private java.util.Hashtable<java.lang.String,MethodFactory> |
implhash |
Hash table on primary implementation type.
|
private PropertyFactory |
pf |
|
private RawStoreFactory |
rawstore |
The raw store that this access manager uses.
|
protected LockingPolicy[] |
record_level_policy |
|
private java.util.Properties |
serviceProperties |
Service properties.
|
(package private) LockingPolicy |
system_default_locking_policy |
Default locking policy for the entire system.
|
protected LockingPolicy[] |
table_level_policy |
|
private PropertyConglomerate |
xactProperties |
The object providing the properties like behaviour
that is transactional.
|
MODULE
Constructor | Description |
---|---|
RAMAccessManager() |
Constructors for This class:
|
Modifier and Type | Method | Description |
---|---|---|
private void |
addPropertySetNotification(PropertySetCallback who,
TransactionController tc) |
|
Serviceable |
apply(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p) |
Apply a property change.
|
void |
backup(java.lang.String backupDir,
boolean wait) |
Backup the database to backupDir.
|
void |
backupAndEnableLogArchiveMode(java.lang.String backupDir,
boolean deleteOnlineArchivedLogFiles,
boolean wait) |
Backup the database to a backup directory and enable the log archive
mode that will keep the archived log files required for roll-forward
from this version backup.
|
void |
boot(boolean create,
java.util.Properties startParams) |
Public Methods implementing ModuleControl Interface:
|
private void |
boot_load_conglom_map() |
|
protected abstract void |
bootLookupSystemLockLevel(TransactionController tc) |
Query property system to get the System lock level.
|
private static java.lang.Object |
bootServiceModule(boolean create,
java.lang.Object serviceModule,
java.lang.String factoryInterface,
java.lang.String identifier,
java.util.Properties properties) |
Privileged startup.
|
private static java.lang.Object |
bootServiceModule(boolean create,
java.lang.Object serviceModule,
java.lang.String factoryInterface,
java.util.Properties properties) |
Privileged startup.
|
void |
checkpoint() |
Checkpoints the database, that is, flushes all dirty data to disk.
|
(package private) void |
conglomCacheAddEntry(long conglomid,
Conglomerate conglom) |
Add a newly created conglomerate to the cache.
|
(package private) Conglomerate |
conglomCacheFind(long conglomid) |
Find a conglomerate by conglomid in the cache.
|
private void |
conglomCacheInit() |
Initialize the conglomerate cache.
|
protected void |
conglomCacheInvalidate() |
Invalide the current Conglomerate Cache.
|
(package private) void |
conglomCacheRemoveEntry(long conglomid) |
Remove an entry from the cache.
|
void |
createFinished() |
Database creation finished.
|
void |
createReadMeFiles() |
DERBY-5996(Create readme files (cautioning users against modifying
database files) at database hard upgrade time)
This gets called during hard upgrade.
|
void |
disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles) |
disables the log archival process, i.e No old log files
will be kept around for a roll-forward recovery.
|
void |
failover(java.lang.String dbname) |
Start the failover for this database.
|
MethodFactory |
findMethodFactoryByFormat(UUID format) |
Find an access method that implements a format type.
|
MethodFactory |
findMethodFactoryByImpl(java.lang.String impltype) |
Find an access method that implements an implementation type.
|
private static java.lang.Object |
findServiceModule(java.lang.Object serviceModule,
java.lang.String factoryInterface) |
Privileged startup.
|
void |
freeze() |
Freeze the database temporarily so a backup can be taken.
|
TransactionController |
getAndNameTransaction(ContextManager cm,
java.lang.String transName) |
Get a transaction.
|
private static Context |
getContext(java.lang.String contextID) |
Privileged lookup of a Context.
|
private static ContextService |
getContextService() |
Privileged lookup of the ContextService.
|
(package private) RAMTransactionContext |
getCurrentTransactionContext() |
Get the current transaction context.
|
protected LockingPolicy |
getDefaultLockingPolicy() |
Return the default locking policy for this access manager.
|
(package private) ConglomerateFactory |
getFactoryFromConglomId(long conglom_id) |
Given a conglomid, return the factory which "owns" it.
|
LockFactory |
getLockFactory() |
Get the LockFactory to use with this store.
|
private static ModuleFactory |
getMonitor() |
Privileged Monitor lookup.
|
protected long |
getNextConglomId(int factory_type) |
Return next conglomid to try to add the container with.
|
(package private) RawStoreFactory |
getRawStore() |
|
protected abstract int |
getSystemLockLevel() |
Return the locking level of the system.
|
TransactionController |
getTransaction(ContextManager cm) |
Get a transaction controller with which to manipulate data within
the access manager.
|
(package private) PropertyConglomerate |
getTransactionalProperties() |
|
TransactionInfo[] |
getTransactionInfo() |
Return a snap shot of all transactions in the db.
|
java.lang.Object |
getXAResourceManager() |
Return the XAResourceManager associated with this AccessFactory.
|
void |
init(boolean dbOnly,
java.util.Dictionary p) |
Initialize the properties for this callback.
|
boolean |
isReadOnly() |
Is the store read-only.
|
java.io.Serializable |
map(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p) |
Map a proposed new value for a property to an official value.
|
Cacheable |
newCacheable(CacheManager cm) |
|
void |
registerAccessMethod(MethodFactory factory) |
Register an access method that this access manager can use.
|
void |
startReplicationMaster(java.lang.String dbmaster,
java.lang.String host,
int port,
java.lang.String replicationMode) |
Start the replication master role for this database.
|
private static java.lang.Object |
startSystemModule(java.lang.String factoryInterface) |
Privileged startup.
|
java.lang.Object |
startXATransaction(ContextManager cm,
int format_id,
byte[] global_id,
byte[] branch_id) |
Start a global transaction.
|
void |
stop() |
Stop the module.
|
void |
stopReplicationMaster() |
Stop the replication master role for this database.
|
void |
unfreeze() |
Unfreeze the database after a backup has been taken.
|
boolean |
validate(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p) |
Validate a property change.
|
void |
waitForPostCommitToFinishWork() |
private RawStoreFactory rawstore
private java.util.Hashtable<java.lang.String,MethodFactory> implhash
private java.util.Hashtable<UUID,MethodFactory> formathash
private java.util.Properties serviceProperties
LockingPolicy system_default_locking_policy
private PropertyConglomerate xactProperties
private PropertyFactory pf
protected LockingPolicy[] table_level_policy
protected LockingPolicy[] record_level_policy
protected ConglomerateFactory[] conglom_map
A map of the implementation specific id to conglomerate object. The id is encoded into the conglomerate number, and then used to pick the right implementation of the conglomerate. It is then up to the conglomerate implementation to retrieve it's stored representation from disk. An internal mapping of the encoding of conglomerate identity in the conglomerate number to the actual conglomerate implementation. Encoding this means that we can't dynamically add conglomerate implementations into the system, so when we want to do that this mapping will have to be more dynamic - but for now store knows exactly what implementations there are.
private CacheManager conglom_cache
private long conglom_nextid
protected LockingPolicy getDefaultLockingPolicy()
RawStoreFactory getRawStore()
PropertyConglomerate getTransactionalProperties()
private void boot_load_conglom_map() throws StandardException
StandardException
protected abstract int getSystemLockLevel()
This routine controls the lowest level of locking enabled for all locks for all tables accessed through this accessmanager. The concrete implementation may set this value always to table level locking for a client configuration, or it may set it to row level locking for a server configuration.
If TransactionController.MODE_RECORD is returned table may either be locked at table or row locking depending on the type of access expected (ie. level 3 will require table locking for heap scans.)
protected abstract void bootLookupSystemLockLevel(TransactionController tc) throws StandardException
This routine will be called during boot after access has booted far enough, to allow access to the property conglomerate. This routine will call the property system and set the value to be returned by getSystemLockLevel().
StandardException
- Standard exception policy.protected long getNextConglomId(int factory_type) throws StandardException
The conglomerate number has 2 parts. The low 4 bits are used to encode the factory which "owns" the conglomerate. The high 60 bits are used as a normal unique id mechanism.
So for example if the next id to assign is 0x54 the following will be the conglomid: if a HEAP (factory 0) - 0x540 if a BTREE (factory 1) - 0x541 And the next id assigned will be: if a HEAP (factory 0) - 0x550 if a BTREE (factory 1) - 0x551
factory_type
- factory id as gotten from getConglomerateFactoryId()StandardException
- Standard exception policy.ConglomerateFactory getFactoryFromConglomId(long conglom_id) throws StandardException
A simple lookup on the boot time built table which maps the low order 4 bits into which factory owns the conglomerate.
conglom_id
- The conglomerate id of the conglomerate to look up.StandardException
- Standard exception policy.private void conglomCacheInit() throws StandardException
Simply calls the cache manager to create the cache with some hard coded defaults for size.
StandardException
- Standard exception policy.Conglomerate conglomCacheFind(long conglomid) throws StandardException
Look for a conglomerate given a conglomid. If in cache return it, otherwise fault in an entry by asking the owning factory to produce an entry.
conglomid
- The conglomerate id of the conglomerate to look up.StandardException
- Standard exception policy.protected void conglomCacheInvalidate() throws StandardException
Abort of certain operations will invalidate the contents of the cache. Longer term we could just invalidate those entries, but for now just invalidate the whole cache.
StandardException
- Standard exception policy.void conglomCacheAddEntry(long conglomid, Conglomerate conglom) throws StandardException
conglomid
- The conglomid of conglomerate to replace.conglom
- The Conglom to add.StandardException
- Standard exception policy.void conglomCacheRemoveEntry(long conglomid) throws StandardException
conglomid
- The conglomid of conglomerate to replace.StandardException
- Standard exception policy.RAMTransactionContext getCurrentTransactionContext()
Get the current transaction context.
If there is an internal transaction on the context stack, return the internal transaction. Otherwise, if there is a nested user transaction on the context stack, return the nested transaction. Otherwise, return the current user transaction.
public void createFinished() throws StandardException
createFinished
in interface AccessFactory
StandardException
- standard Derby error policypublic MethodFactory findMethodFactoryByFormat(UUID format)
findMethodFactoryByFormat
in interface AccessFactory
AccessFactory.findMethodFactoryByFormat(org.apache.derby.catalog.UUID)
public MethodFactory findMethodFactoryByImpl(java.lang.String impltype) throws StandardException
findMethodFactoryByImpl
in interface AccessFactory
StandardException
- Standard exception policy.AccessFactory.findMethodFactoryByImpl(java.lang.String)
public LockFactory getLockFactory()
AccessFactory
getLockFactory
in interface AccessFactory
public TransactionController getTransaction(ContextManager cm) throws StandardException
AccessFactory
getTransaction
in interface AccessFactory
cm
- The context manager for the current context.StandardException
- Standard exception policy.TransactionController
public TransactionController getAndNameTransaction(ContextManager cm, java.lang.String transName) throws StandardException
AccessFactory
getAndNameTransaction
in interface AccessFactory
cm
- The context manager for the current context.transName
- If a new transaction is started, it will be given
this name. The name is displayed in the
transactiontable VTI.StandardException
- Standard exception policy.TransactionController
,
AccessFactory.getTransaction(org.apache.derby.iapi.services.context.ContextManager)
public java.lang.Object startXATransaction(ContextManager cm, int format_id, byte[] global_id, byte[] branch_id) throws StandardException
Get a transaction controller with which to manipulate data within the access manager. Implicitly creates an access context.
Must only be called if no other transaction context exists in the current context manager. If another transaction exists in the context an exception will be thrown.
The (format_id, global_id, branch_id) triplet is meant to come exactly from a javax.transaction.xa.Xid. We don't use Xid so that the system can be delivered on a non-1.2 vm system and not require the javax classes in the path.
startXATransaction
in interface AccessFactory
cm
- The context manager for the current context.format_id
- the format id part of the Xid - ie. Xid.getFormatId().global_id
- the global transaction identifier part of XID - ie.
Xid.getGlobalTransactionId().branch_id
- The branch qualifier of the Xid - ie.
Xid.getBranchQaulifier()StandardException
- Standard exception policy.TransactionController
public java.lang.Object getXAResourceManager() throws StandardException
Returns an object which can be used to implement the "offline" 2 phase commit interaction between the accessfactory and outstanding transaction managers taking care of in-doubt transactions.
getXAResourceManager
in interface AccessFactory
StandardException
- Standard exception policy.public void registerAccessMethod(MethodFactory factory)
AccessFactory
registerAccessMethod
in interface AccessFactory
public boolean isReadOnly()
AccessFactory
isReadOnly
in interface AccessFactory
public void createReadMeFiles() throws StandardException
createReadMeFiles
in interface AccessFactory
StandardException
private void addPropertySetNotification(PropertySetCallback who, TransactionController tc)
public TransactionInfo[] getTransactionInfo()
AccessFactory
Take a snap shot of all transactions currently in the database and make a record of their information.
getTransactionInfo
in interface AccessFactory
public void startReplicationMaster(java.lang.String dbmaster, java.lang.String host, int port, java.lang.String replicationMode) throws StandardException
startReplicationMaster
in interface AccessFactory
dbmaster
- The master database that is being replicated.host
- The hostname for the slaveport
- The port the slave is listening onreplicationMode
- The type of replication contract.
Currently only asynchronous replication is supported, but
1-safe/2-safe/very-safe modes may be added later.StandardException
- Standard Derby exception policy,
thrown on error.public void failover(java.lang.String dbname) throws StandardException
AccessFactory
failover
in interface AccessFactory
dbname
- the replication database that is being failed over.StandardException
- Standard Derby exception policy,
1) If the failover succeeds, an exception is
thrown to indicate that the master database
was shutdown after a successful failover
2) If a failure occurs during network
communication with slave.public void stopReplicationMaster() throws StandardException
stopReplicationMaster
in interface AccessFactory
StandardException
- Standard Derby exception policy,
thrown on error.public void freeze() throws StandardException
AccessFactory
Please see Derby on line documentation on backup and restore.
freeze
in interface AccessFactory
StandardException
- Thrown on errorpublic void unfreeze() throws StandardException
AccessFactory
Please see Derby on line documentation on backup and restore.
unfreeze
in interface AccessFactory
StandardException
- Thrown on errorpublic void backup(java.lang.String backupDir, boolean wait) throws StandardException
AccessFactory
Please see Derby on line documentation on backup and restore.
backup
in interface AccessFactory
backupDir
- the name of the directory where the backup should be
stored.wait
- if true, waits for all the backup blocking
operations in progress to finish.StandardException
- Thrown on errorpublic void backupAndEnableLogArchiveMode(java.lang.String backupDir, boolean deleteOnlineArchivedLogFiles, boolean wait) throws StandardException
AccessFactory
backupAndEnableLogArchiveMode
in interface AccessFactory
backupDir
- the directory name where the
database backup should go. This
directory will be created if not it
does not exist.deleteOnlineArchivedLogFiles
- If true deletes online archived log
files that exist before this backup,
delete will occur only after backup
is complete.wait
- if true, waits for all the
backup blocking operations in
progress to finish.StandardException
- Thrown on errorpublic void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles) throws StandardException
AccessFactory
disableLogArchiveMode
in interface AccessFactory
deleteOnlineArchivedLogFiles
- If true deletes all online archived
log files that exist before this
call immediately; Only restore that
can be performed after disabling log
archive mode is version recovery.StandardException
- Thrown on errorpublic void checkpoint() throws StandardException
AccessFactory
checkpoint
in interface AccessFactory
StandardException
- Thrown on errorpublic void waitForPostCommitToFinishWork()
waitForPostCommitToFinishWork
in interface AccessFactory
public void boot(boolean create, java.util.Properties startParams) throws StandardException
boot
in interface ModuleControl
StandardException
- Module cannot be started.Monitor
,
ModuleFactory
public void stop()
ModuleControl
stop
in interface ModuleControl
Monitor
,
ModuleFactory
public void init(boolean dbOnly, java.util.Dictionary p)
PropertySetCallback
Code within an init() method should use the 3 argument PropertyUtil method getPropertyFromSet() to obtain a property's value.
init
in interface PropertySetCallback
dbOnly
- true if only per-database properties are to be looked atp
- the complete set of per-database properties.public boolean validate(java.lang.String key, java.io.Serializable value, java.util.Dictionary p) throws StandardException
PropertySetCallback
validate
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.StandardException
- Oh well.public Serviceable apply(java.lang.String key, java.io.Serializable value, java.util.Dictionary p) throws StandardException
PropertySetCallback
apply
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.StandardException
- Oh well.public java.io.Serializable map(java.lang.String key, java.io.Serializable value, java.util.Dictionary p) throws StandardException
PropertySetCallback
map
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.StandardException
- Oh well.public Cacheable newCacheable(CacheManager cm)
newCacheable
in interface CacheableFactory
private static ContextService getContextService()
private static Context getContext(java.lang.String contextID)
private static ModuleFactory getMonitor()
private static java.lang.Object startSystemModule(java.lang.String factoryInterface) throws StandardException
StandardException
private static java.lang.Object bootServiceModule(boolean create, java.lang.Object serviceModule, java.lang.String factoryInterface, java.util.Properties properties) throws StandardException
StandardException
private static java.lang.Object bootServiceModule(boolean create, java.lang.Object serviceModule, java.lang.String factoryInterface, java.lang.String identifier, java.util.Properties properties) throws StandardException
StandardException
private static java.lang.Object findServiceModule(java.lang.Object serviceModule, java.lang.String factoryInterface) throws StandardException
StandardException
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.