Class IgniteTxAdapter
- java.lang.Object
-
- org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
-
- org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter
-
- All Implemented Interfaces:
IgniteInternalTx
- Direct Known Subclasses:
GridDistributedTxRemoteAdapter,IgniteTxLocalAdapter
public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implements IgniteInternalTx
Managed transaction adapter.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
GridMetadataAwareAdapter.EntryKey
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
IgniteInternalTx.FinalizationStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected GridCacheSharedContext<?,?>cctxCache registry.protected TransactionConcurrencyconcurrencyConcurrency.protected ConsistentIdMapperconsistentIdMapperUUID to consistent id mapper.protected IgniteUuiddeploymentLdrIdDeployment class loader id which will be used for deserialization of entries on a distributed task.protected booleanimplicitImplicit flag.protected booleaninvalidateInvalidate flag.protected booleanisDoneDone marker.protected TransactionIsolationisolationIsolation.protected static IgniteLoggerlogLogger.protected UUIDnodeIdNode ID.protected booleanonePhaseCommitOne phase commit flag.protected longstartTimeTransaction start time.protected StringtaskNameTask name.protected longthreadIdThread ID.protected AffinityTopologyVersiontopVerTopology version.protected Map<UUID,Collection<UUID>>txNodesprotected inttxSizeprotected GridCacheVersionxidVerTransaction ID.
-
Constructor Summary
Constructors Modifier Constructor Description protectedIgniteTxAdapter(GridCacheSharedContext<?,?> cctx, UUID nodeId, GridCacheVersion xidVer, long threadId, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, int txSize, @Nullable UUID subjId, int taskNameHash)protectedIgniteTxAdapter(GridCacheSharedContext<?,?> cctx, GridCacheVersion xidVer, boolean implicit, boolean loc, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean invalidate, boolean storeEnabled, boolean onePhaseCommit, int txSize, @Nullable UUID subjId, int taskNameHash)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddActiveCache(GridCacheContext<?,?> cacheCtx, boolean recovery)Adds cache to the list of active caches in transaction.voidaddInvalidPartition(int cacheId, int part)protected IgniteBiTuple<GridCacheOperation,CacheObject>applyTransformClosures(IgniteTxEntry txEntry, boolean metrics, @Nullable GridCacheReturn ret)protected voidapplyTxSizes()Makes cache sizes changes accumulated during transaction visible outside of transaction.protected voidbatchStoreCommit(Iterable<IgniteTxEntry> writeEntries)Performs batch database operations.booleanchainState(TransactionState state)Changing state for this transaction as well as chained(parent) transactions.protected booleancheckInternal(IgniteTxKey key)booleancolocated()GridCacheVersioncommitVersion()voidcommitVersion(GridCacheVersion commitVer)voidcompletedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> txs)TransactionConcurrencyconcurrency()Cache transaction concurrency mode.protected IgniteBiTuple<GridCacheOperation,GridCacheVersionConflictContext>conflictResolve(GridCacheOperation op, IgniteTxEntry txEntry, CacheObject newVal, GridCacheVersion newVer, GridCacheEntryEx old)Resolve DR conflict.GridCacheSharedContext<?,?>context()@Nullable IgniteInternalFuture<?>currentPrepareFuture()booleandht()booleandone()booleanequals(Object o)voiderrorWhenCommitting()Changes transaction state from COMMITTING to MARKED_ROLLBACK.protected booleanevictNearEntry(IgniteTxEntry e, boolean primaryOnly)@Nullable IgniteInternalTx.FinalizationStatusfinalizationStatus()IgniteInternalFuture<IgniteInternalTx>finishFuture()inthashCode()IgniteCheckedExceptionheuristicException(Throwable ex)booleanimplicit()Flag indicating whether transaction was started automatically by the system or not.booleanimplicitSingle()UUIDincrementalSnapshotId()voidincrementalSnapshotId(UUID id)booleaninternal()voidinvalidate(boolean invalidate)Map<Integer,Set<Integer>>invalidPartitions()byteioPolicy()booleanisInvalidate()Get invalidation flag for this transaction.protected booleanisNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly)TransactionIsolationisolation()Cache transaction isolation level.booleanisRollbackOnly()If transaction was marked as rollback-only.abstract booleanisStarted()booleanisSystemInvalidate()protected booleanisWriteToStoreFromDhtValid(Collection<CacheStoreManager> stores)booleanlocal()booleanlocalResult()protected IgniteLoggerlog()voidlogTxFinishErrorSafe(@Nullable IgniteLogger log, boolean commit, Throwable e)booleanmarkFinalizing(IgniteInternalTx.FinalizationStatus status)booleannear()@Nullable GridCacheVersionnearXidVersion()booleanneedReturnValue()voidneedReturnValue(boolean needRetVal)booleanneedsCompletedVersions()UUIDnodeId()ID of the node on which this transaction started.booleanonePhaseCommit()voidonePhaseCommit(boolean onePhaseCommit)booleanoptimistic()Collection<IgniteTxEntry>optimisticLockEntries()Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.UUIDotherNodeId()Gets ID of additional node involved.GridCacheVersionownedVersion(IgniteTxKey key)Gets owned version for near remote transaction.booleanownsLock(GridCacheEntryEx entry)booleanownsLockUnsafe(GridCacheEntryEx entry)booleanpessimistic()booleanreadCommitted()protected voidrecordStateChangedEvent(int type)longremainingTime()Gets remaining allowed transaction time.booleanremote()booleanrepeatableRead()StringresolveTaskName()IgniteCheckedExceptionrollbackException()booleanserializable()protected voidsessionEnd(Collection<CacheStoreManager> stores, boolean commit)voidsetParentTx(GridNearTxLocal parentTx)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()booleanskipCompletedVersions()voidskipCompletedVersions(boolean skipCompletedVers)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)protected booleanstate(TransactionState state, boolean timedOut)booleanstoreEnabled()voidstoreEnabled(boolean storeEnabled)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.IgniteCheckedExceptiontimeoutException()IgniteCheckedExceptiontimeoutException(String msg)AffinityTopologyVersiontopologyVersion()AffinityTopologyVersiontopologyVersion(AffinityTopologyVersion topVer)Attempts to set topology version and returns the current value.AffinityTopologyVersiontopologyVersionSnapshot()StringtoString()@Nullable Map<UUID,Collection<UUID>>transactionNodes()voidtransactionNodes(Map<UUID,Collection<UUID>> txNodes)TxCounterstxCounters(boolean createIfAbsent)protected voiduncommit()Uncommits transaction by invalidating all of its entries.protected booleanupdateNearCache(GridCacheContext<?,?> cacheCtx, KeyCacheObject key, AffinityTopologyVersion topVer)Checks whether near cache should be updated.booleanuser()GridCacheVersionwriteVersion()voidwriteVersion(GridCacheVersion writeVer)Sets write version.IgniteUuidxid()Gets unique identifier for this transaction.GridCacheVersionxidVersion()-
Methods inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, removeAllMeta, removeMeta, removeMeta, replaceMeta
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
activeCachesDeploymentEnabled, activeCachesDeploymentEnabled, addMeta, allEntries, alternateVersions, commitAsync, commitError, empty, entry, eventNodeId, hasWriteKey, label, masterNodeIds, meta, onOwnerChanged, originatingNodeId, peek, readEntries, readMap, readSet, removeMeta, rollbackAsync, salvageTx, seal, txState, writeEntries, writeMap, writeSet
-
-
-
-
Field Detail
-
log
protected static IgniteLogger log
Logger.
-
xidVer
@GridToStringInclude protected final GridCacheVersion xidVer
Transaction ID.
-
implicit
@GridToStringInclude protected final boolean implicit
Implicit flag.
-
threadId
@GridToStringInclude protected long threadId
Thread ID.
-
startTime
@GridToStringInclude protected final long startTime
Transaction start time.
-
nodeId
@GridToStringInclude protected final UUID nodeId
Node ID.
-
cctx
@GridToStringExclude protected final GridCacheSharedContext<?,?> cctx
Cache registry.
-
isolation
@GridToStringInclude protected final TransactionIsolation isolation
Isolation.
-
concurrency
@GridToStringInclude protected final TransactionConcurrency concurrency
Concurrency.
-
deploymentLdrId
@GridToStringExclude protected final IgniteUuid deploymentLdrId
Deployment class loader id which will be used for deserialization of entries on a distributed task.
-
invalidate
protected volatile boolean invalidate
Invalidate flag.
-
onePhaseCommit
protected boolean onePhaseCommit
One phase commit flag.
-
isDone
protected volatile boolean isDone
Done marker.
-
txSize
protected final int txSize
-
topVer
@GridToStringInclude protected volatile AffinityTopologyVersion topVer
Topology version.
-
txNodes
protected Map<UUID,Collection<UUID>> txNodes
-
taskName
protected final String taskName
Task name.
-
consistentIdMapper
protected final ConsistentIdMapper consistentIdMapper
UUID to consistent id mapper.
-
-
Constructor Detail
-
IgniteTxAdapter
protected IgniteTxAdapter(GridCacheSharedContext<?,?> cctx, GridCacheVersion xidVer, boolean implicit, boolean loc, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean invalidate, boolean storeEnabled, boolean onePhaseCommit, int txSize, @Nullable @Nullable UUID subjId, int taskNameHash)
- Parameters:
cctx- Cache registry.xidVer- Transaction ID.implicit- Implicit flag.loc- Local flag.sys- System transaction flag.plc- IO policy.concurrency- Concurrency.isolation- Isolation.timeout- Timeout.txSize- Transaction size.
-
IgniteTxAdapter
protected IgniteTxAdapter(GridCacheSharedContext<?,?> cctx, UUID nodeId, GridCacheVersion xidVer, long threadId, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, int txSize, @Nullable @Nullable UUID subjId, int taskNameHash)
- Parameters:
cctx- Cache registry.nodeId- Node ID.xidVer- Transaction ID.threadId- Thread ID.sys- System transaction flag.plc- IO policy.concurrency- Concurrency.isolation- Isolation.timeout- Timeout.txSize- Transaction size.
-
-
Method Detail
-
incrementalSnapshotId
public UUID incrementalSnapshotId()
- Specified by:
incrementalSnapshotIdin interfaceIgniteInternalTx- Returns:
- ID of incremental snapshot after which this transaction commits,
nullif snapshot isn't running.
-
incrementalSnapshotId
public void incrementalSnapshotId(UUID id)
- Specified by:
incrementalSnapshotIdin interfaceIgniteInternalTx- Parameters:
id- ID of incremental snapshot after which this transaction commits,nullif snapshot isn't running.
-
setParentTx
public void setParentTx(GridNearTxLocal parentTx)
- Parameters:
parentTx- Transaction from which this transaction was copied by.
-
skipCompletedVersions
public boolean skipCompletedVersions()
- Returns:
Trueif tx should skip adding itself to completed version map on finish.
-
skipCompletedVersions
public void skipCompletedVersions(boolean skipCompletedVers)
- Parameters:
skipCompletedVers-Trueif tx should skip adding itself to completed version map on finish.
-
context
public GridCacheSharedContext<?,?> context()
- Returns:
- Shared cache context.
-
localResult
public boolean localResult()
- Specified by:
localResultin interfaceIgniteInternalTx- Returns:
Trueif transaction started on the node initiated cache operation.
-
updateNearCache
protected boolean updateNearCache(GridCacheContext<?,?> cacheCtx, KeyCacheObject key, AffinityTopologyVersion topVer)
Checks whether near cache should be updated.- Returns:
- Flag indicating whether near cache should be updated.
-
optimisticLockEntries
public Collection<IgniteTxEntry> optimisticLockEntries()
Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.- Specified by:
optimisticLockEntriesin interfaceIgniteInternalTx- Returns:
- List of tx entries for optimistic locking.
-
storeEnabled
public boolean storeEnabled()
- Specified by:
storeEnabledin interfaceIgniteInternalTx- Returns:
Trueif transaction is allowed to use store.
-
storeEnabled
public void storeEnabled(boolean storeEnabled)
- Parameters:
storeEnabled- Store enabled flag.
-
system
public 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.- Specified by:
systemin interfaceIgniteInternalTx- Returns:
Trueif transaction is started for system cache.
-
ioPolicy
public byte ioPolicy()
- Specified by:
ioPolicyin interfaceIgniteInternalTx- Returns:
- Pool where message for the given transaction must be processed.
-
storeWriteThrough
public boolean storeWriteThrough()
- Specified by:
storeWriteThroughin interfaceIgniteInternalTx- Returns:
Trueif transaction is allowed to use store and transactions spans one or more caches with store enabled.
-
uncommit
protected void uncommit()
Uncommits transaction by invalidating all of its entries. Courtesy to minimize inconsistency.
-
otherNodeId
public UUID otherNodeId()
Gets ID of additional node involved. For example, in DHT case, other node is near node ID.- Specified by:
otherNodeIdin interfaceIgniteInternalTx- Returns:
- Parent node IDs.
-
subjectId
public UUID subjectId()
- Specified by:
subjectIdin interfaceIgniteInternalTx- Returns:
- Subject ID initiated this transaction.
-
taskNameHash
public int taskNameHash()
Task name hash in case if transaction was initiated within task execution.- Specified by:
taskNameHashin interfaceIgniteInternalTx- Returns:
- Task name hash.
-
topologyVersion
public AffinityTopologyVersion topologyVersion()
- Specified by:
topologyVersionin interfaceIgniteInternalTx- Returns:
- Last recorded topology version.
-
topologyVersionSnapshot
public final AffinityTopologyVersion topologyVersionSnapshot()
- Specified by:
topologyVersionSnapshotin interfaceIgniteInternalTx- Returns:
- Topology version snapshot.
-
topologyVersion
public final 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).- Specified by:
topologyVersionin interfaceIgniteInternalTx- Parameters:
topVer- Topology version.- Returns:
- Recorded topology version.
-
markFinalizing
public final boolean markFinalizing(IgniteInternalTx.FinalizationStatus status)
- Specified by:
markFinalizingin interfaceIgniteInternalTx- Parameters:
status- Finalization status to set.- Returns:
Trueif marked.
-
finalizationStatus
@Nullable public @Nullable IgniteInternalTx.FinalizationStatus finalizationStatus()
- Specified by:
finalizationStatusin interfaceIgniteInternalTx- Returns:
- Finalization status.
-
isStarted
public abstract boolean isStarted()
- Returns:
Trueif transaction has at least one key enlisted.
-
size
public int size()
- Specified by:
sizein interfaceIgniteInternalTx- Returns:
- Size of the transaction.
-
log
protected IgniteLogger log()
- Returns:
- Logger.
-
remote
public boolean remote()
- Returns:
- True if transaction reflects changes in primary -> backup direction.
-
near
public boolean near()
- Specified by:
nearin interfaceIgniteInternalTx- Returns:
Trueif near transaction.
-
implicit
public 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.- Specified by:
implicitin interfaceIgniteInternalTx- Returns:
Trueif transaction was started implicitly.
-
implicitSingle
public boolean implicitSingle()
- Specified by:
implicitSinglein interfaceIgniteInternalTx- Returns:
- Flag indicating whether transaction is implicit with only one key.
-
local
public boolean local()
- Specified by:
localin interfaceIgniteInternalTx- Returns:
Trueif transaction is local,falseif it's remote.
-
user
public final boolean user()
- Specified by:
userin interfaceIgniteInternalTx- Returns:
Trueif transaction is user transaction, which means:- Explicit
- Local
- Not DHT
-
dht
public boolean dht()
- Specified by:
dhtin interfaceIgniteInternalTx- Returns:
Trueif DHT transaction.
-
colocated
public boolean colocated()
- Specified by:
colocatedin interfaceIgniteInternalTx- Returns:
Trueif dht colocated transaction.
-
xid
public IgniteUuid xid()
Gets unique identifier for this transaction.- Specified by:
xidin interfaceIgniteInternalTx- Returns:
- Transaction UID.
-
invalidPartitions
public Map<Integer,Set<Integer>> invalidPartitions()
- Specified by:
invalidPartitionsin interfaceIgniteInternalTx- Returns:
- Invalid partitions.
-
addInvalidPartition
public void addInvalidPartition(int cacheId, int part)- Specified by:
addInvalidPartitionin interfaceIgniteInternalTx- Parameters:
cacheId- Cache id.part- Invalid partition.
-
ownedVersion
public GridCacheVersion ownedVersion(IgniteTxKey key)
Gets owned version for near remote transaction.- Specified by:
ownedVersionin interfaceIgniteInternalTx- Parameters:
key- Key to get version for.- Returns:
- Owned version, if any.
-
startTime
public long startTime()
Start time of this transaction.- Specified by:
startTimein interfaceIgniteInternalTx- Returns:
- Start time of this transaction on this node.
-
startTimeNanos
public long startTimeNanos()
Start time of this transaction in nanoseconds to measure duration.- Specified by:
startTimeNanosin interfaceIgniteInternalTx- Returns:
- Start time of this transaction in nanoseconds.
-
needReturnValue
public boolean needReturnValue()
- Returns:
- Flag indicating whether transaction needs return value.
-
needReturnValue
public void needReturnValue(boolean needRetVal)
- Parameters:
needRetVal- Need return value flag.
-
remainingTime
public long remainingTime()
Gets remaining allowed transaction time.- Specified by:
remainingTimein interfaceIgniteInternalTx- Returns:
- Remaining transaction time.
0if timeout isn't specified.-1if time is out.
-
timeoutException
public final IgniteCheckedException timeoutException()
- Returns:
- Transaction timeout exception with the message of lock acquire failure.
-
timeoutException
public final IgniteCheckedException timeoutException(String msg)
- Parameters:
msg- Message text to put to the timeout exception.- Returns:
- Transaction timeout exception with the provided message.
-
rollbackException
public final IgniteCheckedException rollbackException()
- Returns:
- Rollback exception.
-
heuristicException
public final IgniteCheckedException heuristicException(Throwable ex)
- Parameters:
ex- Root cause.
-
logTxFinishErrorSafe
public void logTxFinishErrorSafe(@Nullable @Nullable IgniteLogger log, boolean commit, Throwable e)- Parameters:
log- Log.commit- Commit.e- Exception.
-
xidVersion
public GridCacheVersion xidVersion()
- Specified by:
xidVersionin interfaceIgniteInternalTx- Returns:
- Transaction version.
-
threadId
public long threadId()
ID of the thread in which this transaction started.- Specified by:
threadIdin interfaceIgniteInternalTx- Returns:
- Thread ID.
-
nodeId
public UUID nodeId()
ID of the node on which this transaction started.- Specified by:
nodeIdin interfaceIgniteInternalTx- Returns:
- Originating node ID.
-
isolation
public TransactionIsolation isolation()
Cache transaction isolation level.- Specified by:
isolationin interfaceIgniteInternalTx- Returns:
- Isolation level.
-
concurrency
public TransactionConcurrency concurrency()
Cache transaction concurrency mode.- Specified by:
concurrencyin interfaceIgniteInternalTx- Returns:
- Concurrency mode.
-
timeout
public long timeout()
Gets timeout value in milliseconds for this transaction. If transaction times out prior to it's completion,IgniteTxTimeoutCheckedExceptionwill be thrown.- Specified by:
timeoutin interfaceIgniteInternalTx- Returns:
- Transaction timeout value.
-
timeout
public long timeout(long timeout)
Sets transaction timeout value. This value can be set only before a first operation on transaction has been performed.- Specified by:
timeoutin interfaceIgniteInternalTx- Parameters:
timeout- Transaction timeout value.- Returns:
- Previous timeout.
-
ownsLock
public boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException
- Specified by:
ownsLockin interfaceIgniteInternalTx- Parameters:
entry- Entry to check.- Returns:
Trueif lock is owned.- Throws:
GridCacheEntryRemovedException- If entry has been removed.
-
ownsLockUnsafe
public boolean ownsLockUnsafe(GridCacheEntryEx entry)
- Specified by:
ownsLockUnsafein interfaceIgniteInternalTx- Parameters:
entry- Entry to check.- Returns:
Trueif lock is owned.
-
state
public TransactionState state()
Gets current transaction state value.- Specified by:
statein interfaceIgniteInternalTx- Returns:
- Current transaction state.
-
errorWhenCommitting
public final void errorWhenCommitting()
Changes transaction state from COMMITTING to MARKED_ROLLBACK. Must be called only from thread committing transaction.- Specified by:
errorWhenCommittingin interfaceIgniteInternalTx
-
setRollbackOnly
public 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.- Specified by:
setRollbackOnlyin interfaceIgniteInternalTx- 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
public boolean isRollbackOnly()
Description copied from interface:IgniteInternalTxIf transaction was marked as rollback-only.- Specified by:
isRollbackOnlyin interfaceIgniteInternalTx- Returns:
Trueif rollback only flag is set.
-
done
public boolean done()
- Specified by:
donein interfaceIgniteInternalTx- Returns:
Trueif transaction had completed successfully or unsuccessfully.
-
commitVersion
public GridCacheVersion commitVersion()
- Specified by:
commitVersionin interfaceIgniteInternalTx- Returns:
- Commit version.
-
commitVersion
public void commitVersion(GridCacheVersion commitVer)
- Specified by:
commitVersionin interfaceIgniteInternalTx- Parameters:
commitVer- Commit version.
-
needsCompletedVersions
public boolean needsCompletedVersions()
- Specified by:
needsCompletedVersionsin interfaceIgniteInternalTx- Returns:
Trueif transaction needs completed versions for processing.
-
completedVersions
public void completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> txs)
- Specified by:
completedVersionsin interfaceIgniteInternalTx- Parameters:
base- Base for committed versions.committed- Committed transactions relative to base.txs- Rolled back transactions relative to base.
-
internal
public boolean internal()
- Specified by:
internalin interfaceIgniteInternalTx- Returns:
Trueif transaction has at least one internal entry.
-
checkInternal
protected boolean checkInternal(IgniteTxKey key)
- Parameters:
key- Key.- Returns:
Trueif key is internal.
-
onePhaseCommit
public void onePhaseCommit(boolean onePhaseCommit)
- Parameters:
onePhaseCommit-Trueif transaction commit should be performed in short-path way.
-
onePhaseCommit
public boolean onePhaseCommit()
- Specified by:
onePhaseCommitin interfaceIgniteInternalTx- Returns:
- Fast commit flag.
-
optimistic
public boolean optimistic()
- Specified by:
optimisticin interfaceIgniteInternalTx- Returns:
Truefor OPTIMISTIC transactions.
-
pessimistic
public boolean pessimistic()
- Specified by:
pessimisticin interfaceIgniteInternalTx- Returns:
Truefor PESSIMISTIC transactions.
-
serializable
public boolean serializable()
- Specified by:
serializablein interfaceIgniteInternalTx- Returns:
Trueif serializable.
-
repeatableRead
public boolean repeatableRead()
- Specified by:
repeatableReadin interfaceIgniteInternalTx- Returns:
Trueif repeatable-read.
-
readCommitted
public boolean readCommitted()
- Specified by:
readCommittedin interfaceIgniteInternalTx- Returns:
Trueif read-committed.
-
state
public boolean state(TransactionState state)
- Specified by:
statein interfaceIgniteInternalTx- Parameters:
state- Transaction state.- Returns:
Trueif transition was valid,falseotherwise.
-
chainState
public boolean chainState(TransactionState state)
Changing state for this transaction as well as chained(parent) transactions.- Parameters:
state- Transaction state.- Returns:
Trueif transition was valid,falseotherwise.
-
finishFuture
public IgniteInternalFuture<IgniteInternalTx> finishFuture()
- Specified by:
finishFuturein interfaceIgniteInternalTx- Returns:
- Future for transaction completion.
-
currentPrepareFuture
@Nullable public @Nullable IgniteInternalFuture<?> currentPrepareFuture()
- Specified by:
currentPrepareFuturein interfaceIgniteInternalTx- Returns:
- Future for transaction prepare if prepare is in progress.
-
state
protected final boolean state(TransactionState state, boolean timedOut)
- Parameters:
state- State to set.timedOut- Timeout flag.- Returns:
Trueif state changed.
-
recordStateChangedEvent
protected void recordStateChangedEvent(int type)
- Parameters:
type- Event type.
-
writeVersion
public GridCacheVersion writeVersion()
- Specified by:
writeVersionin interfaceIgniteInternalTx- Returns:
- Transaction write version. For all transactions except DHT transactions, will be equal to
IgniteInternalTx.xidVersion().
-
writeVersion
public void writeVersion(GridCacheVersion writeVer)
Sets write version.- Specified by:
writeVersionin interfaceIgniteInternalTx- Parameters:
writeVer- Write version.
-
timedOut
public boolean timedOut()
- Specified by:
timedOutin interfaceIgniteInternalTx- Returns:
Trueif transaction timed out.
-
invalidate
public void invalidate(boolean invalidate)
- Specified by:
invalidatein interfaceIgniteInternalTx- Parameters:
invalidate- Invalidate flag.
-
isInvalidate
public 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.
- Specified by:
isInvalidatein interfaceIgniteInternalTx- Returns:
- Invalidation flag.
-
isSystemInvalidate
public final boolean isSystemInvalidate()
- Specified by:
isSystemInvalidatein interfaceIgniteInternalTx- Returns:
- System invalidate flag.
-
systemInvalidate
public final void systemInvalidate(boolean sysInvalidate)
- Specified by:
systemInvalidatein interfaceIgniteInternalTx- Parameters:
sysInvalidate- System invalidate flag.
-
transactionNodes
@Nullable public @Nullable Map<UUID,Collection<UUID>> transactionNodes()
- Specified by:
transactionNodesin interfaceIgniteInternalTx- Returns:
- Transaction nodes mapping (primary node -> related backup nodes).
-
transactionNodes
public void transactionNodes(Map<UUID,Collection<UUID>> txNodes)
- Parameters:
txNodes- Transaction nodes.
-
nearXidVersion
@Nullable public @Nullable GridCacheVersion nearXidVersion()
- Specified by:
nearXidVersionin interfaceIgniteInternalTx- Returns:
- Near transaction ID.
-
isWriteToStoreFromDhtValid
protected boolean isWriteToStoreFromDhtValid(Collection<CacheStoreManager> stores)
- Parameters:
stores- Store managers.- Returns:
- If
isWriteToStoreFromDhtvalue same for all stores.
-
sessionEnd
protected void sessionEnd(Collection<CacheStoreManager> stores, boolean commit) throws IgniteCheckedException
- Parameters:
stores- Store managers.commit- Commit flag.- Throws:
IgniteCheckedException- In case of error.
-
batchStoreCommit
protected final void batchStoreCommit(Iterable<IgniteTxEntry> writeEntries) throws IgniteCheckedException
Performs batch database operations. This commit must be called before cache update. This way if there is a DB failure, cache transaction can still be rolled back.- Parameters:
writeEntries- Transaction write set.- Throws:
IgniteCheckedException- If batch update failed.
-
applyTransformClosures
protected IgniteBiTuple<GridCacheOperation,CacheObject> applyTransformClosures(IgniteTxEntry txEntry, boolean metrics, @Nullable @Nullable GridCacheReturn ret) throws GridCacheEntryRemovedException, IgniteCheckedException
- Parameters:
txEntry- Entry to process.metrics-Trueif metrics should be updated.ret- Optional return value to initialize.- Returns:
- Tuple containing transformation results.
- Throws:
IgniteCheckedException- If failed to get previous value for transform.GridCacheEntryRemovedException- If entry was concurrently deleted.
-
resolveTaskName
public String resolveTaskName()
- Returns:
- Resolves task name.
-
conflictResolve
protected IgniteBiTuple<GridCacheOperation,GridCacheVersionConflictContext> conflictResolve(GridCacheOperation op, IgniteTxEntry txEntry, CacheObject newVal, GridCacheVersion newVer, GridCacheEntryEx old) throws IgniteCheckedException, GridCacheEntryRemovedException
Resolve DR conflict.- Parameters:
op- Initially proposed operation.txEntry- TX entry being updated.newVal- New value.newVer- New version.old- Old entry.- Returns:
- Tuple with adjusted operation type and conflict context.
- Throws:
IgniteCheckedException- In case of eny exception.GridCacheEntryRemovedException- If entry got removed.
-
isNearLocallyMapped
protected boolean isNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly)
- Parameters:
e- Transaction entry.primaryOnly- Flag to include backups into check or not.- Returns:
Trueif entry is locally mapped as a primary or back up node.
-
evictNearEntry
protected boolean evictNearEntry(IgniteTxEntry e, boolean primaryOnly)
- Parameters:
e- Entry to evict if it qualifies for eviction.primaryOnly- Flag to try to evict only on primary node.- Returns:
Trueif attempt was made to evict the entry.
-
addActiveCache
public abstract void addActiveCache(GridCacheContext<?,?> cacheCtx, boolean recovery) throws IgniteCheckedException
Adds cache to the list of active caches in transaction.- Parameters:
cacheCtx- Cache context to add.recovery- Recovery flag. SeeCacheOperationContext.setRecovery(boolean).- Throws:
IgniteCheckedException- If caches already enlisted in this transaction are not compatible with given cache (e.g. they have different stores).
-
txCounters
public TxCounters txCounters(boolean createIfAbsent)
- Specified by:
txCountersin interfaceIgniteInternalTx- Parameters:
createIfAbsent-Trueif non-null instance is needed.- Returns:
- Transaction counters.
-
applyTxSizes
protected void applyTxSizes()
Makes cache sizes changes accumulated during transaction visible outside of transaction.
-
-