Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.xact

public Class Xact

Additional top-level class in compilation unit: LockCount.

extends RawTransaction
implements Limit, LockOwner
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.locks.LockOwner, org.apache.derby.iapi.services.locks.Limit
Known Direct Subclasses
org.apache.derby.impl.store.raw.xact.InternalXact
Imports
org.apache.derby.shared.common.reference.SQLState, .Property, org.apache.derby.iapi.store.raw.ContainerKey, .ContainerHandle, .Compensation, .GlobalTransactionId, .LockingPolicy, .Loggable, .RecordHandle, .StreamContainerHandle, .Transaction, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.daemon.Serviceable, org.apache.derby.iapi.services.locks.LockFactory, .Limit, .CompatibilitySpace, .LockOwner, org.apache.derby.iapi.store.raw.data.DataFactory, .RawContainerHandle, org.apache.derby.iapi.store.raw.xact.RawTransaction, .TransactionId, org.apache.derby.iapi.store.raw.log.LogFactory, .LogInstant, .Logger, org.apache.derby.iapi.store.access.FileResource, .RowSource, .TransactionController, org.apache.derby.shared.common.error.ExceptionSeverity, .StandardException, org.apache.derby.iapi.types.DataValueFactory, org.apache.derby.iapi.services.property.PersistentSet, .PropertyUtil, java.util.Stack, .Enumeration, .Properties, .ArrayList, .List, .Dictionary, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream, .LimitObjectInput, org.apache.derby.iapi.util.ByteArray

A transaction has five states
  1. CLOSED - cannot be used
  2. IDLE - no reads have been performed by the transaction.
  3. ACTIVE - at least one read has been attempted by the transaction
  4. UPDATE - at least one update has been attempted by the transaction
  5. PREPARED - the transaction is ready to commit (FUTURE).

Transaction identifiers are re-used for transactions that do not enter the UPDATE state during their lifetime.
See Also
Transaction

Field Summary

Modifier and TypeField and Description
protected static final int
private boolean
protected static final int
private static final int
private static final int
private static final int
COMMIT_SYNC

private static - make sure these bits don't overwrite bits in Transaction.commit commitflag

private final CompatibilitySpace
protected final DataFactory
protected final DataValueFactory
private LockingPolicy
private boolean
dontWaitForLocks

Tells if lock requests should time out immediately if they cannot be granted without waiting.

public static final int
public static final int
public static final int
private boolean
protected static final int
private Integer
private boolean
public static final int
private boolean
pack-priv DynamicByteArrayOutputStream
protected final LogFactory
protected Logger
private LogInstant
private LogInstant
private GlobalTransactionId
private volatile TransactionId
private boolean
public static final int
private volatile TransactionId
protected List<Serviceable>
protected List<Serviceable>
private boolean
protected List<Serviceable>
protected static final int
private boolean
public static final int
private boolean
private boolean
private int
private Stack<SavePoint>
private boolean
protected volatile int
private String
protected static final int
protected final XactFactory
protected XactContext
Inherited from org.apache.derby.iapi.store.raw.xact.RawTransaction:
ABORTCOMMITLOCK_ESCALATEobserverExceptionSAVEPOINT_ROLLBACK

Constructor Summary

AccessConstructor and Description
protected
Xact(XactFactory xactFactory, Xact parentTransaction, LogFactory logFactory, DataFactory dataFactory, DataValueFactory dataValueFactory, boolean readOnly, CompatibilitySpace compatibilitySpace, boolean flush_log_on_xact_end)

Method Summary

Modifier and TypeMethod and Description
public void
abort()

Implements org.apache.derby.iapi.store.raw.Transaction.abort.

Abort all changes made by this transaction since the last commit, abort or the point the transaction was started, whichever is the most recent.

public long
addAndLoadStreamContainer(long segmentId, Properties tableProperties, RowSource rowSource)

Implements org.apache.derby.iapi.store.raw.Transaction.addAndLoadStreamContainer.

Add a new stream container to the segment and load the stream container.

public long
addContainer(long
segment to create the container in.
segmentId
,
long
If not equal to 0 then this container id will be used to create the container, else if set to 0 then the raw store will assign a number.
containerid
,
int
mode description in @see ContainerHandle. This mode is only effective for the duration of the addContainer call and not stored persistently for the lifetime of the container.
mode
,
Properties
Implementation-specific properties of the conglomerate.
tableProperties
,
int temporaryFlag)

Implements org.apache.derby.iapi.store.raw.Transaction.addContainer.

Add a new container to the segment.

public void
addPostAbortWork(Serviceable
the post commit work that is added
work
)

Implements org.apache.derby.iapi.store.raw.Transaction.addPostAbortWork.

Add to the list of post abort work that may be processed after this transaction aborts.

public void
addPostCommitWork(Serviceable
the post commit work that is added
work
)

Implements org.apache.derby.iapi.store.raw.Transaction.addPostCommitWork.

Add to the list of post commit work that may be processed after this transaction commits.

public void
addPostTerminationWork(Serviceable
the post termination work that is added
work
)

Implements org.apache.derby.iapi.store.raw.Transaction.addPostTerminationWork.

Add to the list of post termination work that may be processed after this transaction commits or aborts.

public void
addUpdateTransaction(int transactionStatus)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.addUpdateTransaction.

Add this to the xactFactory list of update transaction.

public boolean
anyoneBlocked()

Implements org.apache.derby.iapi.store.raw.Transaction.anyoneBlocked.

Return true if any transaction is currently blocked, even if not by this transaction.

protected void
assumeGlobalXactIdentity(TransactionTableEntry
The original entry we are assuming the identity of.
ent
)

Assume complete identity of the given Transaction Table Entry.

protected void
assumeIdentity(TransactionTableEntry ent)

Transform this identity to the one stored in transaction table entry.

public boolean

Returns:

true if the transaction blocked the backup. false otherwise.
blockBackup
(boolean
if true, waits until the transaction can block the backup.
wait
)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.blockBackup.

Make the transaction block the online backup.

private void
public void
checkpointInRollForwardRecovery(LogInstant
The LogInstant of the checkpoint
cinstant
,
long
Redo Low Water Mark in the check point record
redoLWM
,
long
Undo Low Water Mark in the checkpoint
undoLWM
)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.checkpointInRollForwardRecovery.

Perform a checkpoint during rollforward recovery.

public void
close()

Implements org.apache.derby.iapi.store.raw.Transaction.close.

Close this transaction, the transaction must be idle.

public LogInstant
commit()

Implements org.apache.derby.iapi.store.raw.Transaction.commit.

Commit this transaction.

private LogInstant
commit(int commitflag)

public LogInstant
commitNoSync(int commitflag)

Implements org.apache.derby.iapi.store.raw.Transaction.commitNoSync.

"Commit" this transaction without sync'ing the log.

private void
completeCommit(int
various flavors of commit.
commitflag
)

Do work to complete a commit which is not just a prepare.

public void
createXATransactionFromLocalTransaction(int
the format id part of the Xid - ie. Xid.getFormatId().
format_id
,
byte[]
the global transaction identifier part of XID - ie. Xid.getGlobalTransactionId().
global_id
,
byte[]
The branch qualifier of the Xid - ie. Xid.getBranchQaulifier()
branch_id
)

Implements org.apache.derby.iapi.store.raw.Transaction.createXATransactionFromLocalTransaction.

Convert a local transaction to a global transaction.

public final LockingPolicy
public void
destroy()

Implements org.apache.derby.iapi.store.raw.Transaction.destroy.

If this transaction is not idle, abort it.

protected void
doComplete(Integer commitOrAbort)

protected boolean
doPostCommitWorkInTran()

If this is a user transaction (not an internal or nested top transaction), and this is not already taking care of post commit work, and not an XA transaction, then take care of hi prioirty work right now using this thread and this context manager.

public void
public void
dropStreamContainer(long segmentId, long containerId)

Implements org.apache.derby.iapi.store.raw.Transaction.dropStreamContainer.

Drop a stream container.

public String

Returns:

The a string which identifies the transaction.
getActiveStateTxIdString
()

Implements org.apache.derby.iapi.store.raw.Transaction.getActiveStateTxIdString.

Get string id of the transaction that would be when the Transaction is IN active state.

public final CompatibilitySpace

Returns:

The compatibility space of the transaction.
getCompatibilitySpace
()

Implements org.apache.derby.iapi.store.raw.Transaction.getCompatibilitySpace.

Get the compatibility space of the transaction.

public final String
getContextId()

Get my transaction context Id

public final ContextManager
getContextManager()

Implements org.apache.derby.iapi.store.raw.Transaction.getContextManager.

Return the context manager this transaction is associated with.

public final DataFactory
getDataFactory()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getDataFactory.

Get the data factory to be used during this transaction.

public DataValueFactory

Returns:

a booted data value factory.
getDataValueFactory
()

Implements org.apache.derby.iapi.store.raw.Transaction.getDataValueFactory.

Get DataValueFactory.

public LockingPolicy

Returns:

The current default locking policy in this transaction.
getDefaultLockingPolicy
()

Implements org.apache.derby.iapi.store.raw.Transaction.getDefaultLockingPolicy.

Get the current default locking policy for all operations within this transaction.

public FileResource
getFileHandler()

Implements org.apache.derby.iapi.store.raw.Transaction.getFileHandler.

Get an object to handle non-transactional files.

public LogInstant
getFirstLogInstant()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getFirstLogInstant.

Get the log instant for the first log record written by this transaction.

public final GlobalTransactionId
getGlobalId()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getGlobalId.

Implements org.apache.derby.iapi.store.raw.Transaction.getGlobalId.

get the Global (external to raw store) transaction id that is unique across all raw stores

public final TransactionId
getId()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getId.

get the short (internal to raw store) transaction id that is unique only for this raw store

protected final TransactionId
getIdNoCheck()

Get the transaction id without sanity check, this should only be called by a cloned TransactionTableEntry

public LogInstant
getLastLogInstant()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getLastLogInstant.

Get the log instant for the last log record written by this transaction.

public final LockFactory
getLockFactory()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getLockFactory.

Get the lock factory to be used during this transaction.

public DynamicByteArrayOutputStream
getLogBuffer()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.getLogBuffer.

Get the log buffer to be used during this transaction.

public final LogFactory
private void
getLogger()

Get the Logger object used to write log records to the transaction log.

private int
getSavePointPosition(String name, Object kindOfSavepoint, boolean forRollbackOrRelease)

Does a save point exist in the stack with the given name.

pack-priv String
public String
public boolean
handlesPostTerminationWork()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.handlesPostTerminationWork.

Can this transaction handles post termination work

public boolean
inAbort()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.inAbort.

Is the transaction in the middle of an abort.

public boolean
inRollForwardRecovery()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.inRollForwardRecovery.

Is the transaction in rollforward recovery

public final boolean

Returns:

true if this transaction is not in idle or closed state
isActive
()

see if this transaction has ever done anything.

public boolean

Returns:

true if this transaction is blocking the backup, otherwise false
isBlockingBackup
()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.isBlockingBackup.

Check if the transaction is blocking the backup ?

public boolean

Returns:

true if it is idle, otherwise false
isIdle
()

Implements org.apache.derby.iapi.store.raw.Transaction.isIdle.

See if this transaction is in the idle state, called by other thread to test the state of this transaction.

public boolean
isNestedOwner()

Implements org.apache.derby.iapi.services.locks.LockOwner.isNestedOwner.

Return true if this is a nested owner, e.g., a nested user transaction.

public final boolean

Returns:

true if this transaction is in PREPARED state.
isPrepared
()

see if this transaction is in PREPARED state.

public boolean

Returns:

true if it hasn't done any updates, otherwise false
isPristine
()

Implements org.apache.derby.iapi.store.raw.Transaction.isPristine.

see if this transaction is in a pristine state.

private boolean

Returns:

true if this transaction is a user transaction
isUserTransaction
()

see if this transaction is a user transaction.

public void
logAndDo(Loggable
the operation that is to be applied
operation
)

Implements org.apache.derby.iapi.store.raw.Transaction.logAndDo.

Log the operation and do it.

public void
logAndUndo(Compensation
the Compensation Operation
compensation
,
LogInstant
the LogInstant of the Loggable Operation this compensation operation is going to roll back
undoInstant
,
LimitObjectInput
optional data for the rollback operation
in
)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.logAndUndo.

Log and apply a compensation operation.

public boolean
nestsUnder(LockOwner
The other lock owner
other
)

Implements org.apache.derby.iapi.services.locks.LockOwner.nestsUnder.

Return true if this owner nests under another owner.

public final LockingPolicy
newLockingPolicy(int
A constant of the form LockingPolicy.MODE_*
mode
,
int
A constant of the form LockingPolicy.ISOLATION_*
isolation
,
boolean
True if a stricter level of locking is acceptable, false if an exact match is required.
stricterOk
)

Implements org.apache.derby.iapi.store.raw.Transaction.newLockingPolicy.

Obtain a locking policy for use in openContainer().

public boolean

Returns:

whether waiting for locks should time out immediately
noWait
()

Implements org.apache.derby.iapi.services.locks.LockOwner.noWait.

Tells whether lock requests should time out immediately if they can't be granted without waiting.

public ContainerHandle
openContainer(ContainerKey containerId, int mode)

Implements org.apache.derby.iapi.store.raw.Transaction.openContainer.

Open a container, with the transaction's default locking policy.

public ContainerHandle
openContainer(ContainerKey containerId, LockingPolicy
The lock policy to use, if null then then a no locking policy will be used.
locking
,
int mode)

Implements org.apache.derby.iapi.store.raw.Transaction.openContainer.

Open a container, with the defined locking policy, otherwise as openContainer(int containerId, boolean forUpdate).

public RawContainerHandle
openDroppedContainer(ContainerKey containerId, LockingPolicy locking)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.openDroppedContainer.

Open a container that may already have been dropped.

public StreamContainerHandle
openStreamContainer(long segmentId, long containerId, boolean hold)

Implements org.apache.derby.iapi.store.raw.Transaction.openStreamContainer.

Open a stream container.

protected boolean

Returns:

true if any work is rolled back, false if no work is rolled back
popSavePoints
(int position, boolean release)

Pop all savepoints upto the one with the given name and rollback all changes made since this savepoint was pushed.

protected void
postComplete(int commitflag, Integer commitOrAbort)

private final void
protected void
preComplete(Integer commitOrAbort)

private LogInstant
prepareCommit(int
various flavors of commit.
commitflag
)

Do work of commit that is common to xa_prepare and commit.

public void
prepareTransaction()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.prepareTransaction.

Remove this from the xactFactory list of update transaction.

public void
reached(CompatibilitySpace
lock space the limit was set for
compatibilitySpace
,
Object
lock group the limit was set for
group
,
int
the limit's setting
limit
,
Enumeration<E>
the list of Lockable's in the group
lockList
,
int
the number of locks in the group
lockCount
)

Implements org.apache.derby.iapi.services.locks.Limit.reached.

Called by the lock factory when a limit has been reached.

public void
recoveryTransaction()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.recoveryTransaction.

Make this transaction aware that it is being used by recovery

public void
reCreateContainerForRedoRecovery(long segmentId, long containerId, ByteArray containerInfo)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.reCreateContainerForRedoRecovery.

Recreate a container during redo recovery.

private final void
public int
releaseSavePoint(String
The user provided name of the savepoint, set by the user in the setSavePoint() call.
name
,
Object
A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
kindOfSavepoint
)

Implements org.apache.derby.iapi.store.raw.Transaction.releaseSavePoint.

Release the save point of the given name.

public void
removeUpdateTransaction()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.removeUpdateTransaction.

Remove this from the xactFactory list of update transaction.

public void
reprepare()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.reprepare.

During recovery re-prepare a transaction.

pack-priv void
public int
rollbackToSavePoint(String
The user provided name of the savepoint, set by the user in the setSavePoint() call.
name
,
Object
A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
kindOfSavepoint
)

Implements org.apache.derby.iapi.store.raw.Transaction.rollbackToSavePoint.

Rollback all changes made since the named savepoint was set.

protected final void
public final void
setDefaultLockingPolicy(LockingPolicy
The lock policy to use, if null then then a no locking policy will be installed as the default.
policy
)

Implements org.apache.derby.iapi.store.raw.Transaction.setDefaultLockingPolicy.

Set the default locking policy for all operations within this transaction.

public void
setFirstLogInstant(LogInstant instant)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.setFirstLogInstant.

Set the log instant for the first log record written by this transaction.

protected void
public void
setLastLogInstant(LogInstant instant)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.setLastLogInstant.

Set the log instant for the last log record written by this transaction.

public void
setNoLockWait(boolean
if true never wait for a lock in this transaction, but time out immediately
noWait
)

Implements org.apache.derby.iapi.store.raw.Transaction.setNoLockWait.

Tell this transaction whether it should time out immediately if a lock cannot be granted without waiting.

pack-priv void
setPostComplete()

Set the transaction to issue pre complete work at postComplete time, instead of preComplete time.

protected final void
setPrepareState()

Move the state of the transaction from UPDATE to PREPARE.

public int
setSavePoint(String
The user provided name of the savepoint
name
,
Object
A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
kindOfSavepoint
)

Implements org.apache.derby.iapi.store.raw.Transaction.setSavePoint.

Set a save point in the current transaction.

pack-priv void
setTransactionId(GlobalTransactionId extid, TransactionId localid)

Set my transaction identifier.

public void
setTransactionId(Loggable beginXact, TransactionId localId)

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.setTransactionId.

Set the transactionId (Global and internal) of this transaction using a log record that contains the Global id

public void
public void
setup(PersistentSet set)

Implements org.apache.derby.iapi.store.raw.Transaction.setup.

The default value for LOCKS_ESCALATION_THRESHOLD

private final void
setUpdateState()

Move the transaction into the update state.

public RawTransaction
protected int
statusForBeginXactLog()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.statusForBeginXactLog.

put this into the beginXact log record to help recovery if we needs to rolled back first, put that in

protected int
statusForEndXactLog()

Implements abstract org.apache.derby.iapi.store.raw.xact.RawTransaction.statusForEndXactLog.

put this into the endXact log record to help recovery, nothing to add

private void
public String
public String

Returns:

The xid as a string.
toString
()

Overrides java.lang.Object.toString.

Return the xid as a string.

private void
private void
unblockBackup()

Unblock the backup, if it was blocked by some operation in this transaction.

public void
xa_commit(boolean
If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of current xid.
onePhase
)

Implements org.apache.derby.iapi.store.raw.Transaction.xa_commit.

This method is called to commit the current XA global transaction.

public int

Returns:

A value indicating the resource manager's vote on the the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by throwing an appropriate XAException in the prepare method.
xa_prepare
()

Implements org.apache.derby.iapi.store.raw.Transaction.xa_prepare.

This method is called to ask the resource manager to prepare for a transaction commit of the transaction specified in xid.

public void
xa_rollback()

Implements org.apache.derby.iapi.store.raw.Transaction.xa_rollback.

rollback the current global transaction.

Inherited from org.apache.derby.iapi.store.raw.xact.RawTransaction:
checkLogicalOperationOknotifyObserversrecoveryRollbackFirstsetObserverException