private static class TxWrapper.WorkArea extends java.lang.Object implements Commitable, Resettable, Scopeable
BufferManager, and these require scope notification and management for each
important block.| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<Database,MutableInteger> |
activeDatabases
Counter of in-use buffers for each database.
|
private TxWrapper.AggresiveFlushWrapper |
aggressiveFlusher
The singleton of
TxWrapper.AggresiveFlushWrapper for this instance. |
private java.util.BitSet |
aggressiveFlushScopes
The scopes which require an
TxWrapper.AggresiveFlushWrapper to be registered as commitable. |
private BufferManager |
bm
The buffer manager instance.
|
private ConnectionManager |
connMgr
Connection manager
|
private TailScopedDictionary<RecordBuffer,java.lang.Boolean> |
dirtyBuffers
The buffers touched via a Create, Update, Copy or Delete operation, in each scope.
|
private java.util.BitSet |
emptyDirtyScopes
Bitset with a flag indicating which scope was not yet loaded, for
dirtyBuffers. |
private java.util.BitSet |
emptyLoadedScopes
Bitset with a flag indicating which scope was not yet loaded, for
loadedBuffers. |
private java.util.Map<FastFindCache,java.util.Set<java.lang.Long>> |
ffCacheChanges
FastFindCache instances which need to have the specified DMOs invalidated. |
private java.util.Map<Database,TxWrapper> |
inactiveTxWrappers
Transaction wrappers not yet activated
|
private ScopedDictionary<RecordBuffer,java.lang.Boolean> |
loadedBuffers
Scoped dictionary which key set contains all buffers into which a new record was loaded (or
the old record was reloaded) into corresponding scopes.
|
private ProcedureManager.ProcedureHelper |
pm
Helper to use the ProcedureManager without any context local lookups.
|
private int |
scopeDepth
The real scope depth counter, as
loadedBuffers and dirtyBuffers push scopes only
when they are used. |
private long |
scopeTransitions
Counter of the number of scope transitions (push or pop)
|
private long |
transactionCount
Counter of the number of application-level transactions
|
private int |
transactionDepth
Block depth at which full application transaction began, or -1 if not in a transaction
|
private TransactionManager.TransactionHelper |
txHelper
Transaction helper
|
private java.util.Map<Database,TxWrapper> |
txWrapperMap
Database to transaction wrapper instance map
|
private UniqueTracker.Context |
uniqueTrackerCtx
Context-local access to unique constraint tracker
|
private Finalizable |
xactFin
Transaction finalizable to manage transaction state locally (avoid context-local calls)
|
| Constructor and Description |
|---|
WorkArea()
Initialize this instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
beginTx(boolean inTx,
boolean fullTx,
boolean aggresiveFlush,
int blockDepth)
Executes logic to explicitly begin a transaction.
|
private void |
checkDirtyScopes()
Check the
emptyDirtyScopes and ensure that the entire dirtyBuffers scope stack
is populated. |
private void |
checkLoadedScopes()
Check the
emptyLoadedScopes and ensure that the entire loadedBuffers scope stack
is populated. |
void |
commit(boolean transaction)
A full transaction or sub-transaction is committing.
|
private TxWrapper |
createTxWrapper(Database database)
Create an inactive transaction wrapper for the given database.
|
void |
deregisterDynamicBuffer(RecordBuffer buffer)
Deregister the given, dynamic record buffer by removing it from the buffer manager's tracking.
|
void |
endTx(boolean inTx,
boolean fullTx)
Executes logic to explicitly end a transaction.
|
void |
endTxPost()
Executes logic required after a full transaction has ended.
|
ScopeId |
getScopeId()
Get the
ScopeId for the instance. |
long |
getScopeTransitions()
Get the number of block scope transitions made.
|
long |
getTransactionCount()
Get the current counter value of application-leve transactions which have been opened.
|
private void |
invalidateFastFindCache()
Invalidate all DMOs with
ffCacheChanges. |
boolean |
isImportantBlockTransition()
Indicate whether the current block is "important" from the standpoint of transitioning into
or out of its scope.
|
boolean |
isTransaction()
Check whether the current block is within an application-level transaction.
|
void |
maybeActivateTxWrapper(Database database)
Given a database which has one or more buffers with an open scope operating within an application
level transaction, possibly activate the transaction wrapper associated with that database.
|
void |
notifyRecordWasLoaded(RecordBuffer recordBuffer)
Notify the buffer manager that a new record was loaded (or the old record was reloaded)
into the specified record buffer.
|
void |
registerDirtyBuffer(RecordBuffer recordBuffer)
Register this buffer as 'dirty' in the current scope.
|
void |
resetState(boolean clearOnly)
Releases the buffers into which a new record was loaded (or the old
record was reloaded) into the current or deeper scopes, or only clears
the list of buffers pending to be released.
|
void |
rollback(boolean transaction)
A full transaction or sub-transaction is rolling back.
|
void |
scopeDeleted()
Provides a notification that an external scope is about to be deleted.
|
void |
scopeFinished()
Provides a notification that a scope is about to be exited.
|
void |
scopeStart(BlockDefinition block)
Provides a notification that a new scope is about to be entered.
|
void |
trackDatabase(RecordBuffer buffer,
boolean add)
Track the buffer's database.
|
void |
validate(boolean transaction,
boolean aggressiveFlush)
A block is exiting or iterating normally within a transaction.
|
private final java.util.Map<Database,TxWrapper> txWrapperMap
private final TransactionManager.TransactionHelper txHelper
private final ProcedureManager.ProcedureHelper pm
private BufferManager bm
private final ConnectionManager connMgr
private final java.util.Map<Database,TxWrapper> inactiveTxWrappers
private final Finalizable xactFin
private final UniqueTracker.Context uniqueTrackerCtx
private int scopeDepth
loadedBuffers and dirtyBuffers push scopes only
when they are used.private java.util.BitSet emptyLoadedScopes
loadedBuffers.private java.util.BitSet emptyDirtyScopes
dirtyBuffers.private long scopeTransitions
private int transactionDepth
private long transactionCount
private final java.util.Map<Database,MutableInteger> activeDatabases
private final ScopedDictionary<RecordBuffer,java.lang.Boolean> loadedBuffers
private final TailScopedDictionary<RecordBuffer,java.lang.Boolean> dirtyBuffers
committed or rolled back, then the buffers will be merged
in the previous scope.private final java.util.BitSet aggressiveFlushScopes
TxWrapper.AggresiveFlushWrapper to be registered as commitable.private final TxWrapper.AggresiveFlushWrapper aggressiveFlusher
TxWrapper.AggresiveFlushWrapper for this instance.private final java.util.Map<FastFindCache,java.util.Set<java.lang.Long>> ffCacheChanges
FastFindCache instances which need to have the specified DMOs invalidated.public void commit(boolean transaction)
commit in interface Commitabletransaction - true if full transaction; false if sub-transaction.public void rollback(boolean transaction)
rollback in interface Commitabletransaction - true if full transaction; false if sub-transaction.public void validate(boolean transaction,
boolean aggressiveFlush)
validate in interface Commitabletransaction - true if full transaction; false if sub-transaction.aggressiveFlush - true if transaction manager is in aggressive subtransaction
flush mode, indicating that any transient buffers should be validated and
flushed, regardless of other state.public void registerDirtyBuffer(RecordBuffer recordBuffer)
This registration doesn't mean that at the time of commit(boolean), rollback(boolean), or
validate(boolean, boolean) the buffer's record is still 'dirty' - this is used to limit the set of buffers
receiving such notifications, to avoid iterating over all BufferManager.openBuffers.
recordBuffer - The record buffer.public void deregisterDynamicBuffer(RecordBuffer buffer)
buffer - Dynamic record buffer to be removed.public void notifyRecordWasLoaded(RecordBuffer recordBuffer)
recordBuffer - The record buffer in which a record was loaded (or the old record was reloaded).public long getScopeTransitions()
public void trackDatabase(RecordBuffer buffer, boolean add)
activeDatabases counter when a new buffer
is activated, and decrement it when it exists its scope.buffer - The buffer to track.add - Flag indicating if the buffer is opening or closing the scope.java.lang.IllegalStateException - If we are removing an active buffer and there is no entry for it in activeDatabases.public void maybeActivateTxWrapper(Database database)
If the transaction wrapper for the given database already is active, do nothing.
database - Database with at least one buffer with an open scope.public boolean isTransaction()
true if we are in a transaction, else false.public long getTransactionCount()
private TxWrapper createTxWrapper(Database database)
database - Database for which this transaction wrapper is created.public void beginTx(boolean inTx,
boolean fullTx,
boolean aggresiveFlush,
int blockDepth)
inTx - Flag indicating if we are in a transaction.fullTx - Flag indicating if we are in a full transaction.aggresiveFlush - Flag indicating if the block isn't a transaction but it still needs to aggressively flush.blockDepth - The current block depth (all blocks tracked by the TransactionManager).public void endTx(boolean inTx,
boolean fullTx)
inTx - Flag indicating if we are in a transaction.fullTx - Flag indicating if we are in a full transaction.public void endTxPost()
public boolean isImportantBlockTransition()
This notion of importance is used to determine whether the various scoped data structures managed by this class need to add or delete a scope when transitioning into or out of the block, respectively, and whether we need to perform processing (e.g., copying/moving data between scopes) associated with such transitions.
true if the block is considered "important" by the above criteria, else
false.public void resetState(boolean clearOnly)
resetState in interface ResettableclearOnly - If true then clear the list of buffers pending to be
released, otherwise perform release of these buffers and clear
the list after that.public void scopeStart(BlockDefinition block)
scopeStart in interface Scopeableblock - The explicit block definition which required this notification.public void scopeFinished()
scopeFinished in interface Scopeablepublic void scopeDeleted()
scopeDeleted in interface Scopeablepublic ScopeId getScopeId()
ScopeId for the instance.getScopeId in interface Scopeablenull for cases when the scope notification is not done via
BlockDefinition.scopeList.private void checkLoadedScopes()
emptyLoadedScopes and ensure that the entire loadedBuffers scope stack
is populated.private void checkDirtyScopes()
emptyDirtyScopes and ensure that the entire dirtyBuffers scope stack
is populated.private void invalidateFastFindCache()
ffCacheChanges.