Interface IgniteInternalTx
-
- All Known Subinterfaces:
IgniteTxLocalEx,IgniteTxRemoteEx
- All Known Implementing Classes:
GridDhtTxLocal,GridDhtTxLocalAdapter,GridDhtTxRemote,GridDistributedTxRemoteAdapter,GridNearTxLocal,GridNearTxRemote,IgniteTxAdapter,IgniteTxLocalAdapter
public interface IgniteInternalTxTransaction managed by cache ('Ex'stands for external).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIgniteInternalTx.FinalizationStatus
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanactiveCachesDeploymentEnabled()voidactiveCachesDeploymentEnabled(boolean depEnabled)voidaddInvalidPartition(int cacheId, int part)<T> TaddMeta(int key, T val)Adds a new metadata.Collection<IgniteTxEntry>allEntries()Collection<GridCacheVersion>alternateVersions()booleancolocated()IgniteInternalFuture<IgniteInternalTx>commitAsync()Asynchronously commits this transaction by initiatingtwo-phase-commitprocess.voidcommitError(Throwable e)GridCacheVersioncommitVersion()voidcommitVersion(GridCacheVersion commitVer)voidcompletedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> rolledback)TransactionConcurrencyconcurrency()Cache transaction concurrency mode.@Nullable IgniteInternalFuture<?>currentPrepareFuture()booleandht()booleandone()booleanempty()@Nullable IgniteTxEntryentry(IgniteTxKey key)voiderrorWhenCommitting()Changes transaction state from COMMITTING to MARKED_ROLLBACK.UUIDeventNodeId()@Nullable IgniteInternalTx.FinalizationStatusfinalizationStatus()IgniteInternalFuture<IgniteInternalTx>finishFuture()booleanhasWriteKey(IgniteTxKey key)booleanimplicit()Flag indicating whether transaction was started automatically by the system or not.booleanimplicitSingle()@Nullable UUIDincrementalSnapshotId()voidincrementalSnapshotId(@Nullable UUID id)booleaninternal()voidinvalidate(boolean invalidate)Map<Integer,Set<Integer>>invalidPartitions()byteioPolicy()booleanisInvalidate()Get invalidation flag for this transaction.TransactionIsolationisolation()Cache transaction isolation level.booleanisRollbackOnly()If transaction was marked as rollback-only.booleanisSystemInvalidate()@Nullable Stringlabel()Returns label of transactions.booleanlocal()booleanlocalResult()booleanmarkFinalizing(IgniteInternalTx.FinalizationStatus status)Collection<UUID>masterNodeIds()<T> Tmeta(int key)Gets metadata by key.booleannear()@Nullable GridCacheVersionnearXidVersion()booleanneedsCompletedVersions()UUIDnodeId()ID of the node on which this transaction started.booleanonePhaseCommit()booleanonOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)Callback invoked whenever there is a lock that has been acquired by this transaction for any of the participating entries.booleanoptimistic()Collection<IgniteTxEntry>optimisticLockEntries()Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.UUIDoriginatingNodeId()Gets node ID which directly started this transaction.@Nullable UUIDotherNodeId()Gets ID of additional node involved.@Nullable GridCacheVersionownedVersion(IgniteTxKey key)Gets owned version for near remote transaction.booleanownsLock(GridCacheEntryEx entry)booleanownsLockUnsafe(GridCacheEntryEx entry)@Nullable GridTuple<CacheObject>peek(GridCacheContext ctx, boolean failFast, KeyCacheObject key)booleanpessimistic()booleanreadCommitted()Collection<IgniteTxEntry>readEntries()Map<IgniteTxKey,IgniteTxEntry>readMap()Set<IgniteTxKey>readSet()longremainingTime()Gets allowed remaining time for this transaction.<T> TremoveMeta(int key)Removes metadata by key.booleanrepeatableRead()IgniteInternalFuture<IgniteInternalTx>rollbackAsync()Asynchronously rollback this transaction.@Nullable IgniteInternalFuture<?>salvageTx()voidseal()Seals transaction for updates.booleanserializable()booleansetRollbackOnly()Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.intsize()longstartTime()Start time of this transaction.longstartTimeNanos()Start time of this transaction in nanoseconds to measure duration.TransactionStatestate()Gets current transaction state value.booleanstate(TransactionState state)booleanstoreEnabled()booleanstoreWriteThrough()UUIDsubjectId()booleansystem()Checks if this is system cache transaction.voidsystemInvalidate(boolean sysInvalidate)inttaskNameHash()Task name hash in case if transaction was initiated within task execution.longthreadId()ID of the thread in which this transaction started.booleantimedOut()longtimeout()Gets timeout value in milliseconds for this transaction.longtimeout(long timeout)Sets transaction timeout value.AffinityTopologyVersiontopologyVersion()AffinityTopologyVersiontopologyVersion(AffinityTopologyVersion topVer)Attempts to set topology version and returns the current value.AffinityTopologyVersiontopologyVersionSnapshot()@Nullable Map<UUID,Collection<UUID>>transactionNodes()@Nullable TxCounterstxCounters(boolean createIfAbsent)IgniteTxStatetxState()booleanuser()Collection<IgniteTxEntry>writeEntries()Map<IgniteTxKey,IgniteTxEntry>writeMap()Set<IgniteTxKey>writeSet()GridCacheVersionwriteVersion()voidwriteVersion(GridCacheVersion ver)Sets write version.IgniteUuidxid()Gets unique identifier for this transaction.GridCacheVersionxidVersion()
-
-
-
Method Detail
-
localResult
boolean localResult()
- Returns:
Trueif transaction started on the node initiated cache operation.
-
xid
IgniteUuid xid()
Gets unique identifier for this transaction.- Returns:
- Transaction UID.
-
nodeId
UUID nodeId()
ID of the node on which this transaction started.- Returns:
- Originating node ID.
-
threadId
long threadId()
ID of the thread in which this transaction started.- Returns:
- Thread ID.
-
startTime
long startTime()
Start time of this transaction.- Returns:
- Start time of this transaction on this node.
-
startTimeNanos
long startTimeNanos()
Start time of this transaction in nanoseconds to measure duration.- Returns:
- Start time of this transaction in nanoseconds.
-
isolation
TransactionIsolation isolation()
Cache transaction isolation level.- Returns:
- Isolation level.
-
concurrency
TransactionConcurrency concurrency()
Cache transaction concurrency mode.- Returns:
- Concurrency mode.
-
implicit
boolean implicit()
Flag indicating whether transaction was started automatically by the system or not. System will start transactions implicitly whenever any cacheput(..)orremove(..)operation is invoked outside of transaction.- Returns:
Trueif transaction was started implicitly.
-
isInvalidate
boolean isInvalidate()
Get invalidation flag for this transaction. If set totrue, then remote values will beinvalidated(set tonull) instead of updated.Invalidation messages don't carry new values, so they are a lot lighter than update messages. However, when a value is accessed on a node after it's been invalidated, it must be loaded from persistent store.
- Returns:
- Invalidation flag.
-
state
TransactionState state()
Gets current transaction state value.- Returns:
- Current transaction state.
-
timeout
long timeout()
Gets timeout value in milliseconds for this transaction. If transaction times out prior to it's completion,IgniteTxTimeoutCheckedExceptionwill be thrown.- Returns:
- Transaction timeout value.
-
timeout
long timeout(long timeout)
Sets transaction timeout value. This value can be set only before a first operation on transaction has been performed.- Parameters:
timeout- Transaction timeout value.- Returns:
- Previous timeout.
-
errorWhenCommitting
void errorWhenCommitting()
Changes transaction state from COMMITTING to MARKED_ROLLBACK. Must be called only from thread committing transaction.
-
setRollbackOnly
boolean setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.- Returns:
Trueif rollback-only flag was set as a result of this operation,falseif it was already set prior to this call or could not be set because transaction is already finishing up committing or rolling back.
-
isRollbackOnly
boolean isRollbackOnly()
If transaction was marked as rollback-only.- Returns:
Trueif transaction can only be rolled back.
-
removeMeta
@Nullable <T> T removeMeta(int key)
Removes metadata by key.- Type Parameters:
T- Type of the value.- Parameters:
key- Key of the metadata to remove.- Returns:
- Value of removed metadata or
null.
-
meta
@Nullable <T> T meta(int key)
Gets metadata by key.- Type Parameters:
T- Type of the value.- Parameters:
key- Metadata key.- Returns:
- Metadata value or
null.
-
addMeta
@Nullable <T> T addMeta(int key, T val)Adds a new metadata.- Type Parameters:
T- Type of the value.- Parameters:
key- Metadata key.val- Metadata value.- Returns:
- Metadata previously associated with given name, or
nullif there was none.
-
size
int size()
- Returns:
- Size of the transaction.
-
storeEnabled
boolean storeEnabled()
- Returns:
Trueif transaction is allowed to use store.
-
storeWriteThrough
boolean storeWriteThrough()
- Returns:
Trueif transaction is allowed to use store and transactions spans one or more caches with store enabled.
-
system
boolean system()
Checks if this is system cache transaction. System transactions are isolated from user transactions because some of the public API methods may be invoked inside user transactions and internally start system cache transactions.- Returns:
Trueif transaction is started for system cache.
-
ioPolicy
byte ioPolicy()
- Returns:
- Pool where message for the given transaction must be processed.
-
topologyVersion
AffinityTopologyVersion topologyVersion()
- Returns:
- Last recorded topology version.
-
topologyVersionSnapshot
AffinityTopologyVersion topologyVersionSnapshot()
- Returns:
- Topology version snapshot.
-
implicitSingle
boolean implicitSingle()
- Returns:
- Flag indicating whether transaction is implicit with only one key.
-
txState
IgniteTxState txState()
- Returns:
- Transaction state.
-
activeCachesDeploymentEnabled
boolean activeCachesDeploymentEnabled()
- Returns:
trueorfalseif the deployment is enabled or disabled for all active caches involved in this transaction.
-
activeCachesDeploymentEnabled
void activeCachesDeploymentEnabled(boolean depEnabled)
- Parameters:
depEnabled- Flag indicating whether deployment is enabled for caches from this transaction or not.
-
topologyVersion
AffinityTopologyVersion topologyVersion(AffinityTopologyVersion topVer)
Attempts to set topology version and returns the current value. If topology version was previously set, then it's value will be returned (but not updated).- Parameters:
topVer- Topology version.- Returns:
- Recorded topology version.
-
empty
boolean empty()
- Returns:
Trueif transaction is empty.
-
markFinalizing
boolean markFinalizing(IgniteInternalTx.FinalizationStatus status)
- Parameters:
status- Finalization status to set.- Returns:
Trueif could mark was set.
-
finalizationStatus
@Nullable @Nullable IgniteInternalTx.FinalizationStatus finalizationStatus()
- Returns:
- Finalization status.
-
addInvalidPartition
void addInvalidPartition(int cacheId, int part)- Parameters:
cacheId- Cache id.part- Invalid partition.
-
ownedVersion
@Nullable @Nullable GridCacheVersion ownedVersion(IgniteTxKey key)
Gets owned version for near remote transaction.- Parameters:
key- Key to get version for.- Returns:
- Owned version, if any.
-
otherNodeId
@Nullable @Nullable UUID otherNodeId()
Gets ID of additional node involved. For example, in DHT case, other node is near node ID.- Returns:
- Parent node IDs.
-
eventNodeId
UUID eventNodeId()
- Returns:
- Event node ID.
-
originatingNodeId
UUID originatingNodeId()
Gets node ID which directly started this transaction. In case of DHT local transaction it will be near node ID, in case of DHT remote transaction it will be primary node ID.- Returns:
- Originating node ID.
-
masterNodeIds
Collection<UUID> masterNodeIds()
- Returns:
- Master node IDs.
-
nearXidVersion
@Nullable @Nullable GridCacheVersion nearXidVersion()
- Returns:
- Near transaction ID.
-
transactionNodes
@Nullable @Nullable Map<UUID,Collection<UUID>> transactionNodes()
- Returns:
- Transaction nodes mapping (primary node -> related backup nodes).
-
ownsLock
boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException
- Parameters:
entry- Entry to check.- Returns:
Trueif lock is owned.- Throws:
GridCacheEntryRemovedException- If entry has been removed.
-
ownsLockUnsafe
boolean ownsLockUnsafe(GridCacheEntryEx entry)
- Parameters:
entry- Entry to check.- Returns:
Trueif lock is owned.
-
near
boolean near()
- Returns:
Trueif near transaction.
-
dht
boolean dht()
- Returns:
Trueif DHT transaction.
-
colocated
boolean colocated()
- Returns:
Trueif dht colocated transaction.
-
local
boolean local()
- Returns:
Trueif transaction is local,falseif it's remote.
-
subjectId
UUID subjectId()
- Returns:
- Subject ID initiated this transaction.
-
taskNameHash
int taskNameHash()
Task name hash in case if transaction was initiated within task execution.- Returns:
- Task name hash.
-
user
boolean user()
- Returns:
Trueif transaction is user transaction, which means:- Explicit
- Local
- Not DHT
-
hasWriteKey
boolean hasWriteKey(IgniteTxKey key)
- Parameters:
key- Key to check.- Returns:
Trueif key is present.
-
readSet
Set<IgniteTxKey> readSet()
- Returns:
- Read set.
-
writeSet
Set<IgniteTxKey> writeSet()
- Returns:
- Write set.
-
allEntries
Collection<IgniteTxEntry> allEntries()
- Returns:
- All transaction entries.
-
writeEntries
Collection<IgniteTxEntry> writeEntries()
- Returns:
- Write entries.
-
readEntries
Collection<IgniteTxEntry> readEntries()
- Returns:
- Read entries.
-
writeMap
Map<IgniteTxKey,IgniteTxEntry> writeMap()
- Returns:
- Transaction write map.
-
readMap
Map<IgniteTxKey,IgniteTxEntry> readMap()
- Returns:
- Transaction read map.
-
optimisticLockEntries
Collection<IgniteTxEntry> optimisticLockEntries()
Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.- Returns:
- List of tx entries for optimistic locking.
-
seal
void seal()
Seals transaction for updates.
-
entry
@Nullable @Nullable IgniteTxEntry entry(IgniteTxKey key)
- Parameters:
key- Key for the entry.- Returns:
- Entry for the key (either from write set or read set).
-
peek
@Nullable @Nullable GridTuple<CacheObject> peek(GridCacheContext ctx, boolean failFast, KeyCacheObject key) throws GridCacheFilterFailedException
- Parameters:
ctx- Cache context.failFast- Fail-fast flag.key- Key to look up.- Returns:
- Current value for the key within transaction.
- Throws:
GridCacheFilterFailedException- If filter failed and failFast istrue.
-
xidVersion
GridCacheVersion xidVersion()
- Returns:
- Transaction version.
-
commitVersion
GridCacheVersion commitVersion()
- Returns:
- Version created at commit time.
-
commitVersion
void commitVersion(GridCacheVersion commitVer)
- Parameters:
commitVer- Commit version.
-
salvageTx
@Nullable @Nullable IgniteInternalFuture<?> salvageTx()
- Returns:
- Future.
-
writeVersion
GridCacheVersion writeVersion()
- Returns:
- Transaction write version. For all transactions except DHT transactions, will be equal to
xidVersion().
-
writeVersion
void writeVersion(GridCacheVersion ver)
Sets write version.- Parameters:
ver- Write version.
-
finishFuture
IgniteInternalFuture<IgniteInternalTx> finishFuture()
- Returns:
- Future for transaction completion.
-
currentPrepareFuture
@Nullable @Nullable IgniteInternalFuture<?> currentPrepareFuture()
- Returns:
- Future for transaction prepare if prepare is in progress.
-
state
boolean state(TransactionState state)
- Parameters:
state- Transaction state.- Returns:
Trueif transition was valid,falseotherwise.
-
invalidate
void invalidate(boolean invalidate)
- Parameters:
invalidate- Invalidate flag.
-
systemInvalidate
void systemInvalidate(boolean sysInvalidate)
- Parameters:
sysInvalidate- System invalidate flag.
-
isSystemInvalidate
boolean isSystemInvalidate()
- Returns:
- System invalidate flag.
-
rollbackAsync
IgniteInternalFuture<IgniteInternalTx> rollbackAsync()
Asynchronously rollback this transaction.- Returns:
- Rollback future.
-
commitAsync
IgniteInternalFuture<IgniteInternalTx> commitAsync()
Asynchronously commits this transaction by initiatingtwo-phase-commitprocess.- Returns:
- Future for commit operation.
-
onOwnerChanged
boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)
Callback invoked whenever there is a lock that has been acquired by this transaction for any of the participating entries.- Parameters:
entry- Cache entry.owner- Lock candidate that won ownership of the lock.- Returns:
Trueif transaction cared about notification.
-
timedOut
boolean timedOut()
- Returns:
Trueif transaction timed out.
-
done
boolean done()
- Returns:
Trueif transaction had completed successfully or unsuccessfully.
-
optimistic
boolean optimistic()
- Returns:
Truefor OPTIMISTIC transactions.
-
pessimistic
boolean pessimistic()
- Returns:
Truefor PESSIMISTIC transactions.
-
readCommitted
boolean readCommitted()
- Returns:
Trueif read-committed.
-
repeatableRead
boolean repeatableRead()
- Returns:
Trueif repeatable-read.
-
serializable
boolean serializable()
- Returns:
Trueif serializable.
-
remainingTime
long remainingTime() throws IgniteTxTimeoutCheckedExceptionGets allowed remaining time for this transaction.- Returns:
- Remaining time.
- Throws:
IgniteTxTimeoutCheckedException- If transaction timed out.
-
alternateVersions
Collection<GridCacheVersion> alternateVersions()
- Returns:
- Alternate transaction versions.
-
needsCompletedVersions
boolean needsCompletedVersions()
- Returns:
Trueif transaction needs completed versions for processing.
-
completedVersions
void completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> rolledback)
- Parameters:
base- Base for committed versions.committed- Committed transactions relative to base.rolledback- Rolled back transactions relative to base.
-
internal
boolean internal()
- Returns:
Trueif transaction has at least one internal entry.
-
onePhaseCommit
boolean onePhaseCommit()
- Returns:
Trueif transaction is a one-phase-commit transaction.
-
commitError
void commitError(Throwable e)
- Parameters:
e- Commit error.
-
label
@Nullable @Nullable String label()
Returns label of transactions.- Returns:
- Label of transaction or
nullif there was not set.
-
incrementalSnapshotId
@Nullable @Nullable UUID incrementalSnapshotId()
- Returns:
- ID of incremental snapshot after which this transaction commits,
nullif snapshot isn't running.
-
incrementalSnapshotId
void incrementalSnapshotId(@Nullable @Nullable UUID id)- Parameters:
id- ID of incremental snapshot after which this transaction commits,nullif snapshot isn't running.
-
txCounters
@Nullable @Contract("true -> !null;") @Nullable TxCounters txCounters(boolean createIfAbsent)- Parameters:
createIfAbsent-Trueif non-null instance is needed.- Returns:
- Transaction counters.
-
-