public class XactFactory extends java.lang.Object implements TransactionFactory, ModuleControl, ModuleSupportable
Modifier and Type | Field and Description |
---|---|
private long |
backupBlockingOperations |
private java.lang.Object |
backupSemaphore |
protected ContextService |
contextFactory |
protected DataFactory |
dataFactory |
protected DataValueFactory |
dataValueFactory |
private boolean |
inBackup |
private boolean |
inCreateNoLog |
protected static java.lang.String |
INTERNAL_CONTEXT_ID |
protected LockFactory |
lockFactory |
private LockingPolicy[][] |
lockingPolicies |
protected LogFactory |
logFactory |
protected static java.lang.String |
NESTED_READONLY_USER_CONTEXT_ID |
protected static java.lang.String |
NESTED_UPDATE_USER_CONTEXT_ID |
protected static java.lang.String |
NTT_CONTEXT_ID |
protected DaemonService |
rawStoreDaemon |
protected RawStoreFactory |
rawStoreFactory |
private java.util.concurrent.atomic.AtomicLong |
tranId
The id of the next transaction to be started.
|
TransactionTable |
ttab |
protected static java.lang.String |
USER_CONTEXT_ID |
private UUIDFactory |
uuidFactory |
private java.lang.Object |
xa_resource |
MODULE
Constructor and Description |
---|
XactFactory() |
Modifier and Type | Method and Description |
---|---|
protected void |
add(Xact xact,
boolean excludeMe) |
protected void |
addUpdateTransaction(TransactionId id,
RawTransaction t,
int transactionStatus)
Add a transaction to the list of transactions that has updated
the raw store.
|
protected boolean |
blockBackup(boolean wait)
Block the online backup.
|
boolean |
blockBackupBlockingOperations(boolean wait)
Checks if there are any backup blocking operations in progress and
prevents new ones from starting until the backup is finished.
|
void |
boot(boolean create,
java.util.Properties properties)
Boot this module with the given properties.
|
private static java.lang.Object |
bootServiceModule(boolean create,
java.lang.Object serviceModule,
java.lang.String factoryInterface,
java.util.Properties properties)
Privileged startup.
|
boolean |
canSupport(java.util.Properties startParams)
See if this implementation can support any attributes that are listed in properties.
|
void |
createFinished()
Database creation finished
|
private static java.lang.Object |
findServiceModule(java.lang.Object serviceModule,
java.lang.String factoryInterface)
Privileged startup.
|
boolean |
findTransaction(TransactionId id,
RawTransaction tran)
Find the TransactionTableEntry with the given ID and make the passed in
transaction assume the identity and properties of that
TransactionTableEntry.
|
RawTransaction |
findUserTransaction(RawStoreFactory rsf,
ContextManager contextMgr,
java.lang.String transName)
Find a user transaction within the given raw store and the given
contextMgr.
|
LogInstant |
firstUpdateInstant()
Get the earliest log instant that is still active, ie, the first log
record logged by the earliest transaction that is still active.
|
private static ContextService |
getContextService()
Privileged lookup of the ContextService.
|
LockFactory |
getLockFactory()
Get the LockFactory to use with this store.
|
(package private) LockingPolicy |
getLockingPolicy(int mode,
int isolation,
boolean stricterOk)
Get a locking policy for a transaction.
|
private static ModuleFactory |
getMonitor()
Privileged Monitor lookup.
|
TransactionInfo[] |
getTransactionInfo() |
Formatable |
getTransactionTable()
Return the transaction table to be logged with the checkpoint operation
|
java.lang.Object |
getXAResourceManager()
Return the module providing XAresource interface to the transaction
table.
|
void |
handlePreparedXacts(RawStoreFactory rsf)
Run through all prepared transactions known to this factory
and restore their state such that they remain after recovery, and
can be found and handled by a XA transaction manager.
|
boolean |
hasPreparedXact()
Check if there are any prepared transanctions in the
transaction table.
|
boolean |
inDatabaseCreation() |
UUID |
makeNewUUID()
Make a new UUID for whomever that wants it
|
StandardException |
markCorrupt(StandardException originalError)
Really this is just a convience routine for callers that might not
have access to a log factory.
|
boolean |
noActiveUpdateTransaction()
Returns true if there is no in flight updating tranasaction.
|
protected void |
prepareTransaction(TransactionId id)
Change state of transaction to prepared.
|
protected void |
pushTransactionContext(ContextManager cm,
java.lang.String contextName,
Xact xact,
boolean abortAll,
RawStoreFactory rsf,
boolean excludeMe)
Create a new RawTransaction, a context for it and push the context
onto the current context manager.
|
protected boolean |
remove(TransactionId xactId)
remove the transaction Id an return false iff the transaction is found
in the table and it doesn't need exclusion from quiesce state
|
protected void |
removeUpdateTransaction(TransactionId id)
Remove a transaction from the list of transactions that has updated the
raw store.
|
void |
resetTranId()
Set the shortTranId, this is called by the log factory after recovery
|
void |
rollbackAllTransactions(RawTransaction recoveryTransaction,
RawStoreFactory rsf)
Rollback all active transactions that has updated the raw store.
|
void |
setNewTransactionId(TransactionId oldxid,
Xact t) |
void |
setRawStoreFactory(RawStoreFactory rsf)
make Transaction factory aware of which raw store factory it belongs to
|
private Xact |
startCommonTransaction(RawStoreFactory rsf,
Xact parentTransaction,
ContextManager cm,
boolean readOnly,
CompatibilitySpace compatibilitySpace,
java.lang.String xact_context_id,
java.lang.String transName,
boolean excludeMe,
boolean flush_log_on_xact_end)
Common work done to create local or global transactions.
|
RawTransaction |
startGlobalTransaction(RawStoreFactory rsf,
ContextManager cm,
int format_id,
byte[] global_id,
byte[] branch_id)
Start a new transaction within the given raw store.
|
RawTransaction |
startInternalTransaction(RawStoreFactory rsf,
ContextManager cm)
Start a new internal transaction within the given raw store.
|
RawTransaction |
startNestedReadOnlyUserTransaction(RawStoreFactory rsf,
RawTransaction parentTransaction,
CompatibilitySpace compatibilitySpace,
ContextManager cm,
java.lang.String transName)
Start a new read only transaction within the given raw store.
|
RawTransaction |
startNestedTopTransaction(RawStoreFactory rsf,
ContextManager cm)
Start a new nested top transaction within the given raw store.
|
RawTransaction |
startNestedUpdateUserTransaction(RawStoreFactory rsf,
RawTransaction parentTransaction,
ContextManager cm,
java.lang.String transName,
boolean flush_log_on_xact_end)
Start a new update transaction within the given raw store.
|
RawTransaction |
startTransaction(RawStoreFactory rsf,
ContextManager cm,
java.lang.String transName)
Start a new transaction within the given raw store.
|
void |
stop()
Stop the module.
|
boolean |
submitPostCommitWork(Serviceable work)
Submit this post commit work to the post commit daemon
|
protected void |
unblockBackup()
Unblock the backup, a backup blocking operation finished.
|
void |
unblockBackupBlockingOperations()
Backup completed.
|
void |
useTransactionTable(Formatable transactionTable)
Use this transaction table, which is gotten from a checkpoint
operation.
|
protected static final java.lang.String USER_CONTEXT_ID
protected static final java.lang.String NESTED_READONLY_USER_CONTEXT_ID
protected static final java.lang.String NESTED_UPDATE_USER_CONTEXT_ID
protected static final java.lang.String INTERNAL_CONTEXT_ID
protected static final java.lang.String NTT_CONTEXT_ID
protected DaemonService rawStoreDaemon
private UUIDFactory uuidFactory
protected ContextService contextFactory
protected LockFactory lockFactory
protected LogFactory logFactory
protected DataFactory dataFactory
protected DataValueFactory dataValueFactory
protected RawStoreFactory rawStoreFactory
public TransactionTable ttab
private final java.util.concurrent.atomic.AtomicLong tranId
private LockingPolicy[][] lockingPolicies
private boolean inCreateNoLog
private java.lang.Object xa_resource
private java.lang.Object backupSemaphore
private long backupBlockingOperations
private boolean inBackup
public boolean canSupport(java.util.Properties startParams)
ModuleSupportable
The module can check for attributes in the properties to
see if it can fulfill the required behaviour. E.g. the raw
store may define an attribute called RawStore.Recoverable.
If a temporary raw store is required the property RawStore.recoverable=false
would be added to the properties before calling bootServiceModule. If a
raw store cannot support this attribute its canSupport method would
return null. Also see the Monitor class's prologue to see how the
identifier is used in looking up properties.
Actually a better way maybe to have properties of the form
RawStore.Attributes.mandatory=recoverable,smallfootprint and
RawStore.Attributes.requested=oltp,fast
canSupport
in interface ModuleSupportable
public void boot(boolean create, java.util.Properties properties) throws StandardException
ModuleControl
An implementation's boot method can throw StandardException. If it is thrown the module is not registered by the monitor and therefore cannot be found through a findModule(). In this case the module's stop() method is not called, thus throwing this exception must free up any resources.
When create is true the contents of the properties object
will be written to the service.properties of the persistent
service. Thus any code that requires an entry in service.properties
must explicitly place the value in this properties set
using the put method.
Typically the properties object contains one or more default
properties sets, which are not written out to service.properties.
These default sets are how callers modify the create process. In a
JDBC connection database create the first set of defaults is a properties
object that contains the attributes that were set on the jdbc:derby: URL.
This attributes properties set has the second default properties set as
its default. This set (which could be null) contains the properties
that the user set on their DriverManager.getConnection() call, and are thus
not owned by Derby code, and thus must not be modified by Derby
code.
When create is false the properties object contains all the properties set in the service.properties file plus a limited number of attributes from the JDBC URL attributes or connection properties set. This avoids properties set by the user compromising the boot process. An example of a property passed in from the JDBC world is the bootPassword for encrypted databases.
Code should not hold onto the passed in properties reference after boot time as its contents may change underneath it. At least after the complete boot is completed, the links to all the default sets will be removed.
boot
in interface ModuleControl
StandardException
- Module cannot be started.Monitor
,
ModuleFactory
public void stop()
ModuleControl
stop
in interface ModuleControl
Monitor
,
ModuleFactory
public LockFactory getLockFactory()
getLockFactory
in interface TransactionFactory
public void createFinished() throws StandardException
createFinished
in interface TransactionFactory
StandardException
- standard Derby error policyprivate Xact startCommonTransaction(RawStoreFactory rsf, Xact parentTransaction, ContextManager cm, boolean readOnly, CompatibilitySpace compatibilitySpace, java.lang.String xact_context_id, java.lang.String transName, boolean excludeMe, boolean flush_log_on_xact_end) throws StandardException
rsf
- the raw store factory creating this xact.parentTransaction
- parent transaction (if this is a nested user transaction)cm
- the current context manager to associate the xact with.compatibilitySpace
- if null, use the transaction being created, else if
non-null use this compatibilitySpace.StandardException
- Standard exception policy.public RawTransaction startTransaction(RawStoreFactory rsf, ContextManager cm, java.lang.String transName) throws StandardException
TransactionFactory
startTransaction
in interface TransactionFactory
cm
- is the context manager to use. It must be the current
context manager.transName
- is the transaction name. It will be displayed in the
transactiontable VTI.StandardException
- Standard Derby error policy.RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
public RawTransaction startNestedReadOnlyUserTransaction(RawStoreFactory rsf, RawTransaction parentTransaction, CompatibilitySpace compatibilitySpace, ContextManager cm, java.lang.String transName) throws StandardException
TransactionFactory
startNestedReadOnlyUserTransaction
in interface TransactionFactory
rsf
- the RawStoreFactoryparentTransaction
- the parent transactioncompatibilitySpace
- compatibility space to use for locks.cm
- is the context manager to use. It must be
the current context manager.transName
- is the transaction name. It will be
displayed in the transactiontable VTI.StandardException
- Standard Derby error policy.RawStoreFactory.startNestedReadOnlyUserTransaction(org.apache.derby.iapi.store.raw.Transaction, org.apache.derby.iapi.services.locks.CompatibilitySpace, org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
public RawTransaction startNestedUpdateUserTransaction(RawStoreFactory rsf, RawTransaction parentTransaction, ContextManager cm, java.lang.String transName, boolean flush_log_on_xact_end) throws StandardException
TransactionFactory
startNestedUpdateUserTransaction
in interface TransactionFactory
rsf
- the RawStoreFactoryparentTransaction
- the parent transactioncm
- is the context manager to use. It must
be the current context manager.transName
- is the transaction name. It will be
displayed in the transactiontable VTI.flush_log_on_xact_end
- By default should the transaction commit
and abort be synced to the log. Normal
usage should pick true, unless there
is specific performance need and usage
works correctly if a commit can be
lost on system crash.StandardException
- Standard Derby error policy.RawStoreFactory.startNestedUpdateUserTransaction(org.apache.derby.iapi.store.raw.Transaction, org.apache.derby.iapi.services.context.ContextManager, java.lang.String, boolean)
public RawTransaction startGlobalTransaction(RawStoreFactory rsf, ContextManager cm, int format_id, byte[] global_id, byte[] branch_id) throws StandardException
TransactionFactory
startGlobalTransaction
in interface TransactionFactory
cm
- is the context manager to use. It must be the current
context manager.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 Derby error policy.RawStoreFactory.startGlobalTransaction(org.apache.derby.iapi.services.context.ContextManager, int, byte[], byte[])
public RawTransaction findUserTransaction(RawStoreFactory rsf, ContextManager contextMgr, java.lang.String transName) throws StandardException
TransactionFactory
findUserTransaction
in interface TransactionFactory
StandardException
- Standard Derby error policy.RawStoreFactory.findUserTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
,
RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
public RawTransaction startNestedTopTransaction(RawStoreFactory rsf, ContextManager cm) throws StandardException
TransactionFactory
startNestedTopTransaction
in interface TransactionFactory
StandardException
- Standard Derby error policy.RawStoreFactory.startTransaction(ContextManager, String)
public RawTransaction startInternalTransaction(RawStoreFactory rsf, ContextManager cm) throws StandardException
TransactionFactory
startInternalTransaction
in interface TransactionFactory
StandardException
- Standard Derby error policy.RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
public boolean findTransaction(TransactionId id, RawTransaction tran)
findTransaction
in interface TransactionFactory
public void rollbackAllTransactions(RawTransaction recoveryTransaction, RawStoreFactory rsf) throws StandardException
Transactions are rolled back in the following order:
rollbackAllTransactions
in interface TransactionFactory
recoveryTransaction
- use this transaction to do all the user
transaction workStandardException
- any exception thrown during rollbackpublic void handlePreparedXacts(RawStoreFactory rsf) throws StandardException
handlePreparedXacts
in interface TransactionFactory
StandardException
- Derby Standard Error policypublic LogInstant firstUpdateInstant()
firstUpdateInstant
in interface TransactionFactory
public StandardException markCorrupt(StandardException originalError)
markCorrupt
in interface Corruptable
public void setNewTransactionId(TransactionId oldxid, Xact t)
public void resetTranId()
resetTranId
in interface TransactionFactory
protected void pushTransactionContext(ContextManager cm, java.lang.String contextName, Xact xact, boolean abortAll, RawStoreFactory rsf, boolean excludeMe) throws StandardException
contextName
- the name of the transaction contextxact
- the Transaction objectabortAll
- if true, then any error will abort the whole
transaction. Otherwise, let XactContext.cleanupOnError decide what to
dorsf
- the raw store factoryexcludeMe
- during systeme quiesce, i.e., this transaction should
not be allowed to be active during a quiesce state.StandardException
- Standard Derby error policyprotected void addUpdateTransaction(TransactionId id, RawTransaction t, int transactionStatus)
This is called underneath the BeginXact log operation's doMe method. The logging system must guarentee that transactions are added in the true order they are started, as defined by the order of beginXact log record in the log.
protected void removeUpdateTransaction(TransactionId id)
protected void prepareTransaction(TransactionId id)
public boolean submitPostCommitWork(Serviceable work)
submitPostCommitWork
in interface TransactionFactory
public void setRawStoreFactory(RawStoreFactory rsf) throws StandardException
TransactionFactory
setRawStoreFactory
in interface TransactionFactory
StandardException
public boolean noActiveUpdateTransaction()
noActiveUpdateTransaction
in interface TransactionFactory
public boolean hasPreparedXact()
hasPreparedXact
in interface TransactionFactory
protected boolean remove(TransactionId xactId)
protected void add(Xact xact, boolean excludeMe)
public UUID makeNewUUID()
final LockingPolicy getLockingPolicy(int mode, int isolation, boolean stricterOk)
public Formatable getTransactionTable()
getTransactionTable
in interface TransactionFactory
public void useTransactionTable(Formatable transactionTable) throws StandardException
useTransactionTable
in interface TransactionFactory
StandardException
- Standard Derby exception policy.public TransactionInfo[] getTransactionInfo()
getTransactionInfo
in interface TransactionFactory
AccessFactory.getTransactionInfo()
public boolean inDatabaseCreation()
public java.lang.Object getXAResourceManager() throws StandardException
getXAResourceManager
in interface TransactionFactory
StandardException
- Standard Derby exception policy.protected boolean blockBackup(boolean wait)
wait
- if true, waits until the backup
is blocked.protected void unblockBackup()
public boolean blockBackupBlockingOperations(boolean wait)
wait
parameter value is true, then it will wait for the current
backup blocking operations to finish.
A Consistent backup can not be made if there are any backup
blocking operations (like unlogged operations) are in progressblockBackupBlockingOperations
in interface TransactionFactory
wait
- if true, waits for the current backup blocking
operation in progress to finish.java.lang.RuntimeException
- if runtime exception occurs, in which case
other threads blocked on backupSemaphore are notifiedpublic void unblockBackupBlockingOperations()
unblockBackupBlockingOperations
in interface TransactionFactory
private static ContextService getContextService()
private static ModuleFactory getMonitor()
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 findServiceModule(java.lang.Object serviceModule, java.lang.String factoryInterface) throws StandardException
StandardException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.