public final class BufferManager extends java.lang.Object implements Scopeable, BatchListener, StopConditionVetoHandler
TransactionManager, the
persistence service layer which manages database resources, and multiple
record buffers opened by client code.
A record buffer registers itself with the buffer manager when client code opens a new buffer scope. If a transaction is active, that buffer is immediately registered with the transaction manager for commit processing. This allows the buffer to synchronize its state with the persistence service when a transaction or subtransaction commit occurs. If a transaction is not active when a new buffer scope is opened, the buffer manager keeps track of the open buffer, and the block scope at which it was opened. When a full transaction subsequently is opened, all buffers with open scopes are batch registered for commit processing.
Also, when a full transaction begins, the buffer manager takes stock of
all databases referred to by open buffer scopes, and begins a new,
database-level transaction for each one. The database transaction's life
cycle is managed by an inner class, TxWrapper.
This inner class registers itself for master commit and finish processing
with the transaction manager, such that it can reflect an application
level commit/rollback back to the underlying database transaction.
Updates made to existing records are tracked for undo purposes by this class. A scoped dictionary of reversible updates by DMO type is managed by the context local instance of this class, for all open buffers in the current client context.
| Modifier and Type | Class and Description |
|---|---|
private static class |
BufferManager.BatchModeData
Container for batch assign mode information.
|
private class |
BufferManager.PersistentProcScope
Buffer-related data for a certain persistent procedure, surviving after its external
procedure is finished.
|
private class |
BufferManager.StaticDefinitionKey
A temp-table key contains the lowercase legacy name of the dataset/table and the procedure where it
was created.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set<Persistence.Context> |
activePersistenceContexts
Active persistence contexts (those which have an open database session)
|
private ScopedDictionary<java.lang.String,RecordBuffer> |
allBuffers
Scoped dictionary in which all defined record buffers are stored.
|
private Finalizable |
batchCleaner
Finalizable which clears batch mode at the appropriate times
|
private java.util.ArrayDeque<BufferManager.BatchModeData> |
batchModeStack
Stack of batch mode data
|
private ScopedDictionary<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> |
byLegacyName
Scoped dictionary in which all defined record buffers are stored.
|
private ChangeBroker |
changeBroker
Change broker instance.
|
(package private) java.util.Map<BufferType,MutableInteger> |
changeScopes
Map of buffer types to high-water block depths of any change to any record of that type
|
private static java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>> |
classBufferFields
A cache of buffer-related fields defined in a specific legacy-converted class.
|
private ConnectionManager |
connMgr
Connection manager
|
private static ContextLocal<BufferManager> |
context
Stores context local instances of this class
|
private LRUCache<java.lang.String,java.lang.String> |
convertedNames
Buffer names already converted.
|
private ScopedDictionary<BufferManager.StaticDefinitionKey,DataSet> |
dataSetRegistry
The registry with all static
Datasets mapped by their name. |
private static CentralLogger |
LOG
Logger
|
private NameConverter |
nc
The cached name converter.
|
private boolean |
nestedQueryError
Does a nested query error condition currently exist?
|
private Stack<java.lang.Integer> |
nextExtScope
Track the external scopes pushed on
BufferManager. |
private ScopedList<RecordBuffer> |
openBuffers
Scoped dictionary in which open record buffers are stored
|
private ScopedDictionary<BufferManager.StaticDefinitionKey,StaticTempTable> |
openStaticTempTables
Scoped dictionary which contains currently active static temp tables (i.e.
|
private java.util.Map<RecordBuffer,java.lang.Class<?>> |
pendingBufferClasses
The defining class of a pending buffer, used when initializing an OE class and/or external program.
|
private java.util.Set<RecordBuffer> |
pendingBuffers
The buffers which will be registered on the next scope entry.
|
private java.util.Map<Persistence,java.util.Set<java.lang.Long>> |
pendingReclaimedKeys
Primary keys pending reclamation
|
private java.util.Map<StaticTempTable,java.lang.Boolean> |
pendingStaticTempTables
A map of static temp-tables pending registration.
|
private java.util.Map<java.lang.Object,BufferManager.PersistentProcScope> |
persistProcScopes
Map with buffer-related data surviving a persistent proc's external procedure.
|
private ProcedureManager.ProcedureHelper |
pm
Helper to use the ProcedureManager without any context local lookups.
|
private int |
queryDepth
Number of nested queries being processed
|
private ScopedDictionary<OutputTableHandleCopier,java.lang.Integer> |
thOutputParameters
Scoped dictionary which contains the maps of output copiers for a procedure/function to
their 0-based indexes in the set of all TABLE-HANDLE parameters for the procedure/function
(excluding other types of parameters).
|
private TransactionManager.TransactionHelper |
txHelper
Transaction helper
|
private TxWrapper.TxWrapperHelper |
txWrapperHelper
Tx wrapper helper.
|
private java.util.Map<RecordBuffer,java.lang.Boolean> |
uninitializedOpenBuffers
Buffers whose scopes have been opened, but are not yet initialized
|
private boolean |
unknownMode
Unknown mode is
true while evaluating query parameters |
| Modifier | Constructor and Description |
|---|---|
private |
BufferManager()
Constructor; instances of this class are context-local and must be accessed using the static
get() method. |
| Modifier and Type | Method and Description |
|---|---|
(package private) java.util.Iterator<RecordBuffer> |
activeBuffers(Persistence persistence)
Get an iterator on all open buffers which contain non-
null
current records for the given persistence object, within the current
client context. |
(package private) java.util.Iterator<RecordBuffer> |
activeBuffers(Persistence persistence,
boolean includeTransient)
Get an iterator on all open buffers which contain non-
null
current records for the given persistence object, within the current
client context. |
(package private) void |
addDirtyBatchBuffer(RecordBuffer buffer)
If we currently are in batch assignment mode, add the given record
buffer to the set of buffers requiring validation at the end of the
batch.
|
(package private) void |
addPendingReclaimedKeys(Persistence persistence,
java.util.List<java.lang.Long> keys)
Add potentially unused keys to be reclaimed after the end of the current transaction or
as buffer scopes are closed after a transaction.
|
(package private) void |
addToAllBuffersArray(int blockDepth,
RecordBuffer buffer)
Add the target buffer to the set of all buffers at the specified block depth.
|
void |
batchNotify(boolean start)
Provides a notification that a batch is starting or ending.
|
void |
beginTx(boolean inTx,
boolean fullTx,
int blockDepth)
Executes logic to explicitly begin a transaction.
|
(package private) boolean |
bufferInitialized(RecordBuffer buffer)
A buffer was initialized.
|
private void |
checkLegacyNames(java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> dst,
java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> src)
Add the source buffers to the destination map.
|
(package private) void |
checkNestedQuery(java.util.function.Supplier<java.lang.Boolean> isFindByRowid)
Check whether the current query depth is non-zero, indicating that we are processing a query within
the context of another query.
|
static void |
cleanupPending()
Cleanup of pending resources.
|
(package private) boolean |
decrementDepth()
Decrement the query depth.
|
private void |
deregisterByLegacy(java.lang.String lkey,
java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> refs)
Deregister the buffer from all the defined record buffers stored by the lowercased legacy name.
|
(package private) void |
deregisterDynamicBuffer(RecordBuffer buffer,
java.lang.Object referent)
Deregister the given, dynamic record buffer by removing it from the buffer manager's
tracking.
|
(package private) java.util.Set<RecordBuffer> |
endBatchAssignMode()
End batch assignment mode if we are currently in batch assignment mode
and we are in the same scope at which batch assignment mode was
started.
|
void |
endTx(boolean inTx,
boolean fullTx)
Executes logic to explicitly end a transaction.
|
void |
endTxPost()
Executes logic required after a full transaction has ended.
|
(package private) boolean |
evictDMOIfUnused(Persistence persistence,
Persistence.Context local,
Record dmo)
Evict the given DMO from the current ORM session if it is not referenced by any buffer or being
tracked for UNDO purposes.
|
int |
findNearestExternal()
Find the nearest external block (from the bottom of the stack).
|
(package private) java.lang.String |
generateUniqueBufferName(java.lang.String legacyBufferName)
Generate unique (across the session) name (DMO alias) for a dynamic buffer.
|
static BufferManager |
get()
Retrieve the context-local instance of this class, instantiating it first if necessary.
|
(package private) java.util.Collection<RecordBuffer> |
getOpenBuffers()
Get the open buffers from the current scope.
|
int |
getOpenBufferScopes()
Query the scope level which currently is open.
|
java.lang.Class<?> |
getPendingBufferClass(RecordBuffer buffer)
Get the defining class for a pending buffer.
|
ProcedureManager.ProcedureHelper |
getProcedureHelper()
Convenient method to retrieve the procedure helper.
|
ScopeId |
getScopeId()
Get the
ScopeId for the instance. |
long |
getScopeTransitions()
Get the number of block scope transitions made.
|
(package private) DataSet |
getStaticDataSet(java.lang.Class<?> defType,
java.lang.String name,
java.lang.Object referent)
Get definition for the active static dataset with the given name.
|
(package private) StaticTempTable |
getStaticTempTable(java.lang.Class<?> defType,
java.lang.String name)
Get definition for the active static temp table with the given name.
|
(package private) StaticTempTable |
getStaticTempTable(java.lang.Class<?> defType,
java.lang.String name,
java.lang.Object referent)
Get definition for the active static temp table with the given name.
|
(package private) int |
getStaticTempTableDepth(StaticTempTable stt)
Get the depth of the scope at which the static temp table was opened.
|
(package private) int |
getStaticTempTableDepth(java.lang.String name)
Get the depth of the scope at which the static temp table was opened.
|
(package private) int |
getStaticTempTableDepth(java.lang.String name,
java.lang.Object referent)
Get the depth of the scope at which the static temp table was opened.
|
(package private) long |
getTransactionCount()
Get the current counter value of application-leve transactions which have been opened.
|
(package private) TransactionManager.TransactionHelper |
getTxHelper()
Get the transaction helper object used by this context.
|
(package private) TxWrapper.TxWrapperHelper |
getTxWrapperHelper()
Get the
transaction wrapper used by this context. |
(package private) boolean |
incrementDepth()
Increment the query depth.
|
(package private) boolean |
isActiveBuffer(RecordBuffer buffer,
Persistence persistence,
boolean includeTransient)
Check if the given buffer contains a non-
null current record for
the given persistence object, within the current client context. |
(package private) boolean |
isBatchAssignMode()
Indicate whether we currently are in batch assignment mode.
|
boolean |
isImportantBlockTransition()
Indicate whether the current block is "important" from the standpoint of transitioning into
or out of its scope.
|
(package private) boolean |
isNestedQueryError()
Indicate whether a nested query error has been detected and has not yet been cleared.
|
boolean |
isOutputTableHandle(handle h)
Check if the specified handle instance is registered as an OUTPUT argument.
|
boolean |
isTransaction()
Check whether the current block is within an application-level transaction.
|
(package private) boolean |
isUnknownMode()
Checks whether the unknown mode is active.
|
(package private) RecordBuffer |
lookupBuffer(java.lang.String alias)
Find the record buffer associated with the given DMO alias.
|
(package private) RecordBuffer |
lookupByName(java.lang.String legacyName)
Find the record buffer associated with the given legacy name, which is the variable name
with which the buffer was defined.
|
(package private) 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.
|
private void |
maybeCloseSessions()
Iterate all active persistence contexts and close any open session, if there are no longer
any dependencies on it.
|
(package private) 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.
|
(package private) void |
openScope(RecordBuffer buffer)
Called by
RecordBuffer when a new buffer scope is opened. |
(package private) void |
openScopeAt(int openScopeDepth,
RecordBuffer buffer)
Called by
TemporaryBuffer when a new dynamic buffer scope is opened to register the
open scope with the buffer manager, so that the buffer can receive block scope start and
stop notifications, and be registered for commit processing when a full transaction is
begun. |
boolean |
postponeTableHandleDelete(TempTable tempTable)
Marks the table for postponed delete, if it is possible.
|
(package private) void |
reclaimPendingKeys(Persistence persistence,
java.util.Set<java.lang.Long> released)
Reclaim unused keys collected during the transaction which just ended or from the buffer
scope which just closed.
|
(package private) void |
registerBuffer(RecordBuffer buffer)
Register a newly defined record buffer in the current scope.
|
(package private) void |
registerDataSet(java.lang.Class<?> type,
java.lang.String name,
java.lang.Object ref,
DataSet dataset)
Register this static dataset definition.
|
void |
registerDirtyBuffer(RecordBuffer recordBuffer)
Register this buffer as 'dirty' in the current scope.
|
(package private) void |
registerOutputTableHandleCopier(OutputTableHandleCopier copier)
Register the output table copier.
|
(package private) void |
registerPending(java.lang.Class<?> def,
RecordBuffer buffer)
Register as pending the newly defined record buffer.
|
void |
registerPendingBufferClass(RecordBuffer buffer,
java.lang.Class<?> cls)
Register a pending buffer's defining class.
|
static void |
registerPendingScopeable(BufferManager bufferManager)
Register the
BufferManager instance as pending scopeable, to be added to the next block. |
(package private) void |
registerPendingStaticTempTable(StaticTempTable table,
boolean global)
Register static temp table, when the external program gets executed.
|
(package private) void |
registerPersistenceContext(Persistence.Context pc)
Register an active persistence context, indicating a database session has been opened.
|
static void |
registerScopeable(BufferManager bufferManager)
Register the
BufferManager instance as for scope notifications at the current block. |
(package private) void |
registerStaticTempTable(StaticTempTable table,
boolean global)
Register static temp-table when its scope is opened.
|
static void |
registerTxScopeable(BufferManager bufferManager)
Register the
TxWrapper scopeable as pending for the next opened block. |
void |
resolvePendingBufferClasses(java.lang.Object referent)
Resolve the defining Java class for all Java fields which define a buffer.
|
void |
scopeDeleted()
Provides notification that the external procedure scope has been deleted.
|
void |
scopeFinished()
Process a notification that a scope is about to be exited.
|
void |
scopeStart(BlockDefinition block)
Process a notification that a new block scope has been entered.
|
(package private) boolean |
setUnknownMode(boolean unknownMode)
Changes the unknown mode.
|
(package private) void |
startBatchAssignMode(boolean internal)
Begin batch assignment mode.
|
private void |
trackDatabase(RecordBuffer buffer,
boolean add)
Track the buffer's database.
|
(package private) void |
unregisterOutputTableHandleCopier(OutputTableHandleCopier copier)
Unregister the output table copier in the current scope.
|
boolean |
vetoStop(StopConditionException exc)
Check the specified exception and determine whether we want to allow it
to be honored by the
TransactionManager, or whether we want to
veto the STOP at this scope. |
private static final CentralLogger LOG
private static final ContextLocal<BufferManager> context
private static final java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.reflect.Field>> classBufferFields
final java.util.Map<BufferType,MutableInteger> changeScopes
private final Finalizable batchCleaner
private final java.util.Set<RecordBuffer> pendingBuffers
private final java.util.Map<RecordBuffer,java.lang.Class<?>> pendingBufferClasses
private final ScopedDictionary<java.lang.String,RecordBuffer> allBuffers
private final ScopedDictionary<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> byLegacyName
Note: only the static buffers are kept in this structure. The dynamic resources cannot be stored here as their NAME attribute is mutable and will possible collide with other existing buffers.
private final java.util.Map<RecordBuffer,java.lang.Boolean> uninitializedOpenBuffers
private final ScopedList<RecordBuffer> openBuffers
private final ScopedDictionary<BufferManager.StaticDefinitionKey,StaticTempTable> openStaticTempTables
TempTableKey compound from the legacy table
name and the procedure where the temp table was defined.private ScopedDictionary<BufferManager.StaticDefinitionKey,DataSet> dataSetRegistry
Datasets mapped by their name.private final java.util.Map<StaticTempTable,java.lang.Boolean> pendingStaticTempTables
private final ScopedDictionary<OutputTableHandleCopier,java.lang.Integer> thOutputParameters
private final java.util.Set<Persistence.Context> activePersistenceContexts
private final java.util.ArrayDeque<BufferManager.BatchModeData> batchModeStack
private final java.util.Map<java.lang.Object,BufferManager.PersistentProcScope> persistProcScopes
private final java.util.Map<Persistence,java.util.Set<java.lang.Long>> pendingReclaimedKeys
private final ProcedureManager.ProcedureHelper pm
private final TransactionManager.TransactionHelper txHelper
private TxWrapper.TxWrapperHelper txWrapperHelper
private final ChangeBroker changeBroker
private final LRUCache<java.lang.String,java.lang.String> convertedNames
private final Stack<java.lang.Integer> nextExtScope
BufferManager.private ConnectionManager connMgr
private int queryDepth
private boolean unknownMode
true while evaluating query parametersprivate boolean nestedQueryError
private NameConverter nc
private BufferManager()
get() method.public static BufferManager get()
public static void registerScopeable(BufferManager bufferManager)
BufferManager instance as for scope notifications at the current block.bufferManager - The BufferManager instance.public static void registerPendingScopeable(BufferManager bufferManager)
BufferManager instance as pending scopeable, to be added to the next block.bufferManager - The BufferManager instance.public static void registerTxScopeable(BufferManager bufferManager)
TxWrapper scopeable as pending for the next opened block.bufferManager - The BufferManager instance.public static void cleanupPending()
public void registerDirtyBuffer(RecordBuffer recordBuffer)
This registration doesn't mean that at the time of TxWrapper.commit(boolean), TxWrapper.rollback(boolean),
or TxWrapper.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 openBuffers.
recordBuffer - The record buffer.public void registerPendingBufferClass(RecordBuffer buffer, java.lang.Class<?> cls)
buffer - The newly constructed buffer instance.cls - The Java class associated with an external program or legacy OE class, where it
was defined.public java.lang.Class<?> getPendingBufferClass(RecordBuffer buffer)
buffer - The newly constructed buffer instance.public void resolvePendingBufferClasses(java.lang.Object referent)
referent - The instance associated with an external program or legacy OE class.public int getOpenBufferScopes()
TransactionManager.public int findNearestExternal()
public boolean vetoStop(StopConditionException exc)
TransactionManager, or whether we want to
veto the STOP at this scope.
This implementation is interested only in STOP conditions which have
been generated by database connection errors. STOP processing at the
current scope is vetoed iff the exception is an instance of DatabaseConnectionException AND either of the following criteria are
met:
Otherwise, normal STOP processing is allowed to continue.
vetoStop in interface StopConditionVetoHandlerexc - The exception to be checked.true if STOP should be vetoed;
false if the STOP should be allowed.public void beginTx(boolean inTx,
boolean fullTx,
int blockDepth)
inTx - Flag indicating if we are in a transaction.fullTx - Flag indicating if we are in a full transaction.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 void scopeStart(BlockDefinition block)
scopeStart in interface Scopeableblock - The explicit block definition which required this notification.ErrorConditionException - if there is an error flushing pending changes to the database
as we open a new database transaction.public void scopeFinished()
scopeFinished in interface Scopeablepublic void scopeDeleted()
If we are deleting a persistent procedure, clean all its data from the global scope for the
following dictionaries: openBuffers, allBuffers, openStaticTempTables.
scopeDeleted in interface Scopeablepublic ScopeId getScopeId()
ScopeId for the instance.getScopeId in interface ScopeableScopeId.BUFFER_MANAGER.public void batchNotify(boolean start)
start.batchNotify in interface BatchListenerstart - true if this is the start of a batch, otherwise
false.RecordBuffer.startBatch(com.goldencode.p2j.persist.BufferManager, boolean),
RecordBuffer.endBatch(com.goldencode.p2j.persist.BufferManager, boolean)public boolean postponeTableHandleDelete(TempTable tempTable)
tempTable - Temporary table to be marked for postponed delete.true if the table was postponed for deletion. false if
this can't be done.public boolean isTransaction()
true if we are in a transaction, else false.public long getScopeTransitions()
public ProcedureManager.ProcedureHelper getProcedureHelper()
java.util.Collection<RecordBuffer> getOpenBuffers()
long getTransactionCount()
TxWrapper.TxWrapperHelper getTxWrapperHelper()
transaction wrapper used by this context.TransactionManager.TransactionHelper getTxHelper()
void registerPersistenceContext(Persistence.Context pc)
pc - Persistence context.void registerDataSet(java.lang.Class<?> type,
java.lang.String name,
java.lang.Object ref,
DataSet dataset)
type - The definition type.name - The legacy name.ref - The instance where it is defined.dataset - The dataset instance to register.void registerBuffer(RecordBuffer buffer)
buffer - Buffer to be registered.void registerPending(java.lang.Class<?> def,
RecordBuffer buffer)
pendingBuffers will be registered with
that scope. Buffers are deregistered implicitly when the scope in which
they were registered ends.def - The Java class defining this buffer.buffer - Buffer pending to be registered.void deregisterDynamicBuffer(RecordBuffer buffer, java.lang.Object referent)
buffer - Dynamic record buffer to be removed.referent - The persistent procedure where the buffer was defined; may be null.private void deregisterByLegacy(java.lang.String lkey,
java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> refs)
lkey - Lowercased legacy name keyrefs - Scoped dictionary that uses the lowercased legacy name as keys in which
all defined record buffers are stored.void startBatchAssignMode(boolean internal)
internal - Use false for a programmer required batch assign mode. These can be started at most one
at each scope depth.true for a FWD internal maintenance batch block when some data must be processed
"in batch". In this case the depth, is not checked. Only one level of this can be added as the
top-level. This mode must be be ended before starting any new batch.java.lang.IllegalStateException - if batch mode is already active in the current block or was started but never
ended in a previous block.RecordBuffer.startBatch(com.goldencode.p2j.persist.BufferManager, boolean),
RecordBuffer.endBatch(com.goldencode.p2j.persist.BufferManager, boolean),
RecordBuffer.cleanupBatchMode(com.goldencode.p2j.persist.BufferManager)java.util.Set<RecordBuffer> endBatchAssignMode()
null, indicating
either we are not in batch mode, or we are not in the proper
scope to end it, or the buffers already have been processed, or
the program is ending and we are in cleanup mode.RecordBuffer.startBatch(com.goldencode.p2j.persist.BufferManager, boolean),
RecordBuffer.endBatch(com.goldencode.p2j.persist.BufferManager, boolean),
RecordBuffer.cleanupBatchMode(com.goldencode.p2j.persist.BufferManager)boolean isBatchAssignMode()
true if in batch assignment mode, else
false.startBatchAssignMode(boolean),
endBatchAssignMode()void addDirtyBatchBuffer(RecordBuffer buffer)
buffer - Buffer to be added to the set of dirty batch mode buffers.startBatchAssignMode(boolean),
endBatchAssignMode()boolean incrementDepth()
This method MUST be invoked in balanced pairs that involve a subsequent call to
decrementDepth(). Calls may be nested, but they must be balanced, such that
at the end of all nested calls, queryDepth must be 0.
true if the starting depth is 0.boolean decrementDepth()
This method MUST be invoked in balanced pairs that involve a subsequent call to
incrementDepth(). Calls may be nested, but they must be balanced, such that
at the end of all nested calls, queryDepth must be 0.
true if the resulting depth is 0.void checkNestedQuery(java.util.function.Supplier<java.lang.Boolean> isFindByRowid)
isFindByRowid - A lambda expression which should return true if the current database operation
represents a legacy FIND by RECID/ROWID, else false.boolean isNestedQueryError()
true if a nested query error has been detected, else false.boolean setUnknownMode(boolean unknownMode)
unknownMode - The new unknown mode.Runnable which should be called in a finally block, paired with the call to
this method, which restores the unknown mode to its previous value.boolean isUnknownMode()
void addPendingReclaimedKeys(Persistence persistence, java.util.List<java.lang.Long> keys)
persistence - Persistence helper object for a particular database.keys - Keys to be reclaimed.void reclaimPendingKeys(Persistence persistence, java.util.Set<java.lang.Long> released)
persistence - Persistence helper object for a particular database.released - Keys actually released, due to the corresponding locks on them being released
(as opposed to downgraded).void openScope(RecordBuffer buffer)
RecordBuffer when a new buffer scope is opened. It registers the open scope with the
buffer manager, so that the buffer can receive block scope start and stop notifications, and be
registered for commit/rollback/validate processing when a full transaction is begun.buffer - Buffer for which a new scope is being opened.void registerStaticTempTable(StaticTempTable table, boolean global)
table - The static temp-table.global - Indicates if it is a global temp-table (declared as SHARED GLOBAL).void registerPendingStaticTempTable(StaticTempTable table, boolean global)
table - The static temp-table.global - Indicates if it is a global temp table (declared as SHARED GLOBAL).public boolean isOutputTableHandle(handle h)
h - The handle instance.true if the handle originates from the caller as an OUTPUT argument.void registerOutputTableHandleCopier(OutputTableHandleCopier copier)
copier - Copier to register.void unregisterOutputTableHandleCopier(OutputTableHandleCopier copier)
copier - Copier to unregister.StaticTempTable getStaticTempTable(java.lang.Class<?> defType, java.lang.String name)
defType - The type where this call is being made from.name - Legacy name of the target static temp table.null if
there is no active table with the given name.DataSet getStaticDataSet(java.lang.Class<?> defType, java.lang.String name, java.lang.Object referent)
The lookup is done first from super-classes and after that in dataSetRegistry.
defType - The type where this call is being made from.name - Legacy name of the target static dataset.referent - The reference used to lookup this dataset by name.StaticTempTable getStaticTempTable(java.lang.Class<?> defType, java.lang.String name, java.lang.Object referent)
defType - The type where this call is being made from.name - Legacy name of the target static temp table.referent - The external program where it was defined.null if
there is no active table with the given name.int getStaticTempTableDepth(java.lang.String name)
name - Legacy name of the target static temp table.-1 is returned.int getStaticTempTableDepth(StaticTempTable stt)
stt - The static temp-table instance.-1 is returned.int getStaticTempTableDepth(java.lang.String name,
java.lang.Object referent)
name - Legacy name of the target static temp table.referent - The external program where it was defined.-1 is returned.void addToAllBuffersArray(int blockDepth,
RecordBuffer buffer)
blockDepth - Zero-based depth of the block (starting from the outermost block) at which the
buffer was opened.buffer - Buffer to add.void openScopeAt(int openScopeDepth,
RecordBuffer buffer)
TemporaryBuffer when a new dynamic buffer scope is opened to register the
open scope with the buffer manager, so that the buffer can receive block scope start and
stop notifications, and be registered for commit processing when a full transaction is
begun.openScopeDepth - Zero-based depth of the open scopes (starting from the outermost scope) at which this
buffer scope is opened.buffer - Buffer for which a new scope is being opened.boolean bufferInitialized(RecordBuffer buffer)
buffer - Record buffer which was initialized.true if this was properly registered as an open buffer. false if this couldn't
be properly registered because the scope wasn't opened properly beforehand.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.RecordBuffer lookupBuffer(java.lang.String alias)
alias - Buffer DMO alias in business logic. (AKA Java name)null if not found.RecordBuffer lookupByName(java.lang.String legacyName)
pendingBuffers.legacyName - Buffer variable's legacy name in business logic.null if not found.java.util.Iterator<RecordBuffer> activeBuffers(Persistence persistence)
null
current records for the given persistence object, within the current
client context. Auto-commit record buffers associated with a pending,
reversible rollback are not included in the iteration. Records that
represent copies of DMOs from other sessions, obtained from a DirtyShareContext, are likewise excluded.persistence - Persistence object which manages sessions. Only record
buffers associated with this persistence object are returned.java.util.Iterator<RecordBuffer> activeBuffers(Persistence persistence, boolean includeTransient)
null
current records for the given persistence object, within the current
client context. Auto-commit record buffers associated with a pending,
reversible rollback are not included in the iteration. Records that
represent copies of DMOs from other sessions, obtained from a DirtyShareContext, are likewise excluded.persistence - Persistence object which manages sessions. Only record
buffers associated with this persistence object are returned.includeTransient - true to include transient records in the result set.boolean isActiveBuffer(RecordBuffer buffer, Persistence persistence, boolean includeTransient)
null current record for
the given persistence object, within the current client context. Auto-commit
record buffers associated with a pending, reversible rollback are not included
in the iteration. Records that represent copies of DMOs from other sessions,
obtained from a DirtyShareContext, are likewise excluded.buffer - RecordBuffer that is checked.persistence - Persistence object which manages sessions. Only record
buffers associated with this persistence object are returned.includeTransient - true to include transient records in the result set.true if the buffer has a non-null current
record, false otherwise.boolean evictDMOIfUnused(Persistence persistence, Persistence.Context local, Record dmo) throws PersistenceException
persistence - Persistence object which manages sessions.local - Current user persistence context.dmo - DMO instance whose reference count is to be decremented.true if the DMO was evicted; false if it was in use.PersistenceException - if an error occurs detaching dmo from the persistence session.void notifyRecordWasLoaded(RecordBuffer recordBuffer)
recordBuffer - The record buffer in which a record was loaded (or the old record was reloaded).java.lang.String generateUniqueBufferName(java.lang.String legacyBufferName)
__{unique number} postfix. This guarantees that the name will not contain
invalid characters and will be unique.legacyBufferName - Legacy name of the buffer.private void maybeCloseSessions()
private void checkLegacyNames(java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> dst, java.util.Map<java.lang.Object,java.util.Map<java.lang.String,RecordBuffer>> src)
dst - The destination map.src - The source map.private void trackDatabase(RecordBuffer buffer, boolean add)
TxWrapper.WorkArea.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
TxWrapper.WorkArea.activeDatabases.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.