Class IgniteTxLocalAdapter
- java.lang.Object
-
- org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
-
- org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter
-
- org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter
-
- All Implemented Interfaces:
IgniteInternalTx,IgniteTxLocalEx
- Direct Known Subclasses:
GridDhtTxLocalAdapter
public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements IgniteTxLocalEx
Transaction adapter for cache transactions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classIgniteTxLocalAdapter.PLC1<T>Post-lock closure alias.protected classIgniteTxLocalAdapter.PLC2<T>Post-lock closure alias.protected classIgniteTxLocalAdapter.PostLockClosure1<T>Post-lock closure.protected classIgniteTxLocalAdapter.PostLockClosure2<T>Post-lock closure.-
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 static AtomicReferenceFieldUpdater<IgniteTxLocalAdapter,Throwable>COMMIT_ERR_UPDCommit error updater.protected static AtomicIntegerFieldUpdater<IgniteTxLocalAdapter>DONE_FLAG_UPDDone flag updater.protected GridCacheReturnimplicitResImplicit transaction result.protected GridCacheVersionminVerMinimal version encountered (either explicit lock or XID of this transaction).protected IgniteTxLocalStatetxState-
Fields inherited from class org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter
cctx, concurrency, consistentIdMapper, deploymentLdrId, implicit, invalidate, isDone, isolation, log, nodeId, onePhaseCommit, startTime, taskName, threadId, topVer, txNodes, txSize, xidVer
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIgniteTxLocalAdapter(GridCacheSharedContext cctx, GridCacheVersion xidVer, boolean implicit, boolean implicitSingle, 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 Concrete Methods Modifier and Type Method Description protected IgniteCacheExpiryPolicyaccessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys)protected IgniteCacheExpiryPolicyaccessPolicy(GridCacheContext ctx, IgniteTxKey key, @Nullable javax.cache.expiry.ExpiryPolicy expiryPlc)booleanactiveCachesDeploymentEnabled()voidactiveCachesDeploymentEnabled(boolean depEnabled)voidaddActiveCache(GridCacheContext<?,?> cacheCtx, boolean recovery)Adds cache to the list of active caches in transaction.IgniteTxEntryaddEntry(GridCacheOperation op, @Nullable CacheObject val, @Nullable javax.cache.processor.EntryProcessor entryProc, Object[] invokeArgs, GridCacheEntryEx entry, @Nullable javax.cache.expiry.ExpiryPolicy expiryPlc, CacheEntryPredicate[] filter, boolean filtersSet, long drTtl, long drExpireTime, @Nullable GridCacheVersion drVer, boolean skipStore, boolean keepBinary, boolean addReader)protected voidaddInvokeResult(IgniteTxEntry txEntry, CacheObject cacheVal, GridCacheReturn ret, GridCacheVersion ver)Collection<IgniteTxEntry>allEntries()Collection<GridCacheVersion>alternateVersions()voidcalculatePartitionUpdateCounters()Calculates partition update counters for current transaction.protected voidcheckValid()Checks transaction expiration.protected voidcheckValid(boolean checkTimeout)Checks transaction expiration.protected booleancommitAfterLock()ThrowablecommitError()voidcommitError(Throwable e)Collection<GridCacheVersion>committedVersions()GridCacheVersioncompletedBase()voidcompletedVersions(GridCacheVersion completedBase, Collection<GridCacheVersion> committedVers, Collection<GridCacheVersion> rolledbackVers)booleanempty()@Nullable IgniteTxEntryentry(IgniteTxKey key)protected GridCacheEntryExentryEx(GridCacheContext cacheCtx, IgniteTxKey key, AffinityTopologyVersion topVer)Gets cache entry for given key and topology version.longentryExpireTime(IgniteTxKey key)longentryTtl(IgniteTxKey key)UUIDeventNodeId()booleanhasInterceptor()booleanhasWriteKey(IgniteTxKey key)voidimplicitSingleResult(GridCacheReturn ret)booleaninit()Initializes read map.protected voidinitResult()Creates result instance.booleanisStarted()Collection<UUID>masterNodeIds()GridCacheVersionminVersion()Gets minimum version present in transaction.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.UUIDoriginatingNodeId()Gets node ID which directly started this transaction.@Nullable GridTuple<CacheObject>peek(GridCacheContext cacheCtx, boolean failFast, KeyCacheObject key)protected voidpostLockWrite(GridCacheContext cacheCtx, Iterable<KeyCacheObject> keys, GridCacheReturn ret, boolean rmv, boolean retval, boolean read, long accessTtl, CacheEntryPredicate[] filter, boolean computeInvoke)Post lock processing for put or remove.Collection<IgniteTxEntry>readEntries()Map<IgniteTxKey,IgniteTxEntry>readMap()Set<IgniteTxKey>readSet()Collection<GridCacheVersion>rolledbackVersions()voidseal()Seals transaction for updates.CacheWriteSynchronizationModesyncMode()voidsyncMode(CacheWriteSynchronizationMode syncMode)voidtmFinish(boolean commit, boolean nodeStop, boolean clearThreadMap)Commits transaction to transaction manager.StringtoString()IgniteTxLocalStatetxState()protected voidupdateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry)Updates explicit version for tx entry based on current entry lock owner.voiduserCommit()voiduserPrepare(@Nullable Collection<IgniteTxEntry> entries)voiduserRollback(boolean clearThreadMap)Collection<IgniteTxEntry>writeEntries()Map<IgniteTxKey,IgniteTxEntry>writeMap()Set<IgniteTxKey>writeSet()-
Methods inherited from class org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter
addInvalidPartition, applyTransformClosures, applyTxSizes, batchStoreCommit, chainState, checkInternal, colocated, commitVersion, commitVersion, concurrency, conflictResolve, context, currentPrepareFuture, dht, done, equals, errorWhenCommitting, evictNearEntry, finalizationStatus, finishFuture, hashCode, heuristicException, implicit, implicitSingle, incrementalSnapshotId, incrementalSnapshotId, internal, invalidate, invalidPartitions, ioPolicy, isInvalidate, isNearLocallyMapped, isolation, isRollbackOnly, isSystemInvalidate, isWriteToStoreFromDhtValid, local, localResult, log, logTxFinishErrorSafe, markFinalizing, near, nearXidVersion, needReturnValue, needReturnValue, needsCompletedVersions, nodeId, onePhaseCommit, onePhaseCommit, optimistic, optimisticLockEntries, otherNodeId, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, readCommitted, recordStateChangedEvent, remainingTime, remote, repeatableRead, resolveTaskName, rollbackException, serializable, sessionEnd, setParentTx, setRollbackOnly, size, skipCompletedVersions, skipCompletedVersions, startTime, startTimeNanos, state, state, state, storeEnabled, storeEnabled, storeWriteThrough, subjectId, system, systemInvalidate, taskNameHash, threadId, timedOut, timeout, timeout, timeoutException, timeoutException, topologyVersion, topologyVersion, topologyVersionSnapshot, transactionNodes, transactionNodes, txCounters, uncommit, updateNearCache, user, writeVersion, writeVersion, xid, xidVersion
-
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
addInvalidPartition, addMeta, colocated, commitAsync, commitVersion, commitVersion, concurrency, currentPrepareFuture, dht, done, errorWhenCommitting, finalizationStatus, finishFuture, implicit, implicitSingle, incrementalSnapshotId, incrementalSnapshotId, internal, invalidate, invalidPartitions, ioPolicy, isInvalidate, isolation, isRollbackOnly, isSystemInvalidate, label, local, localResult, markFinalizing, meta, near, nearXidVersion, needsCompletedVersions, nodeId, onePhaseCommit, optimistic, optimisticLockEntries, otherNodeId, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, readCommitted, remainingTime, removeMeta, repeatableRead, rollbackAsync, salvageTx, serializable, setRollbackOnly, size, startTime, startTimeNanos, state, state, storeEnabled, storeWriteThrough, subjectId, system, systemInvalidate, taskNameHash, threadId, timedOut, timeout, timeout, topologyVersion, topologyVersion, topologyVersionSnapshot, transactionNodes, txCounters, user, writeVersion, writeVersion, xid, xidVersion
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx
localFinish
-
-
-
-
Field Detail
-
COMMIT_ERR_UPD
protected static final AtomicReferenceFieldUpdater<IgniteTxLocalAdapter,Throwable> COMMIT_ERR_UPD
Commit error updater.
-
DONE_FLAG_UPD
protected static final AtomicIntegerFieldUpdater<IgniteTxLocalAdapter> DONE_FLAG_UPD
Done flag updater.
-
minVer
protected GridCacheVersion minVer
Minimal version encountered (either explicit lock or XID of this transaction).
-
implicitRes
protected GridCacheReturn implicitRes
Implicit transaction result.
-
txState
@GridToStringInclude protected final IgniteTxLocalState txState
-
-
Constructor Detail
-
IgniteTxLocalAdapter
protected IgniteTxLocalAdapter(GridCacheSharedContext cctx, GridCacheVersion xidVer, boolean implicit, boolean implicitSingle, 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-Trueif transaction was implicitly started by the system,falseif it was started explicitly by user.implicitSingle-Trueif transaction is implicit with only one key.sys- System flag.plc- IO policy.concurrency- Concurrency.isolation- Isolation.timeout- Timeout.txSize- Expected transaction size.
-
-
Method Detail
-
syncMode
public final CacheWriteSynchronizationMode syncMode()
- Returns:
- Transaction write synchronization mode.
-
syncMode
public void syncMode(CacheWriteSynchronizationMode syncMode)
- Parameters:
syncMode- Write synchronization mode.
-
txState
public IgniteTxLocalState txState()
- Specified by:
txStatein interfaceIgniteInternalTx- Returns:
- Transaction state.
-
initResult
protected void initResult()
Creates result instance.
-
eventNodeId
public UUID eventNodeId()
- Specified by:
eventNodeIdin interfaceIgniteInternalTx- Returns:
- Event node ID.
-
originatingNodeId
public 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.- Specified by:
originatingNodeIdin interfaceIgniteInternalTx- Returns:
- Originating node ID.
-
empty
public boolean empty()
- Specified by:
emptyin interfaceIgniteInternalTx- Returns:
Trueif transaction is empty.
-
masterNodeIds
public Collection<UUID> masterNodeIds()
- Specified by:
masterNodeIdsin interfaceIgniteInternalTx- Returns:
- Master node IDs.
-
commitError
public Throwable commitError()
- Specified by:
commitErrorin interfaceIgniteTxLocalEx- Returns:
- Commit error.
-
commitError
public void commitError(Throwable e)
- Specified by:
commitErrorin interfaceIgniteInternalTx- Parameters:
e- Commit error.
-
onOwnerChanged
public 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.- Specified by:
onOwnerChangedin interfaceIgniteInternalTx- Parameters:
entry- Cache entry.owner- Lock candidate that won ownership of the lock.- Returns:
Trueif transaction cared about notification.
-
activeCachesDeploymentEnabled
public boolean activeCachesDeploymentEnabled()
- Specified by:
activeCachesDeploymentEnabledin interfaceIgniteInternalTx- Returns:
trueorfalseif the deployment is enabled or disabled for all active caches involved in this transaction.
-
activeCachesDeploymentEnabled
public void activeCachesDeploymentEnabled(boolean depEnabled)
- Specified by:
activeCachesDeploymentEnabledin interfaceIgniteInternalTx- Parameters:
depEnabled- Flag indicating whether deployment is enabled for caches from this transaction or not.
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin classIgniteTxAdapter- Returns:
Trueif transaction has at least one key enlisted.
-
hasWriteKey
public boolean hasWriteKey(IgniteTxKey key)
- Specified by:
hasWriteKeyin interfaceIgniteInternalTx- Parameters:
key- Key to check.- Returns:
Trueif key is present.
-
readSet
public Set<IgniteTxKey> readSet()
- Specified by:
readSetin interfaceIgniteInternalTx- Returns:
- Transaction read set.
-
writeSet
public Set<IgniteTxKey> writeSet()
- Specified by:
writeSetin interfaceIgniteInternalTx- Returns:
- Transaction write set.
-
readMap
public Map<IgniteTxKey,IgniteTxEntry> readMap()
- Specified by:
readMapin interfaceIgniteInternalTx- Returns:
- Transaction read map.
-
writeMap
public Map<IgniteTxKey,IgniteTxEntry> writeMap()
- Specified by:
writeMapin interfaceIgniteInternalTx- Returns:
- Transaction write map.
-
allEntries
public Collection<IgniteTxEntry> allEntries()
- Specified by:
allEntriesin interfaceIgniteInternalTx- Returns:
- All transaction entries.
-
readEntries
public Collection<IgniteTxEntry> readEntries()
- Specified by:
readEntriesin interfaceIgniteInternalTx- Returns:
- Read entries.
-
writeEntries
public Collection<IgniteTxEntry> writeEntries()
- Specified by:
writeEntriesin interfaceIgniteInternalTx- Returns:
- Write entries.
-
entry
@Nullable public @Nullable IgniteTxEntry entry(IgniteTxKey key)
- Specified by:
entryin interfaceIgniteInternalTx- Parameters:
key- Key for the entry.- Returns:
- Entry for the key (either from write set or read set).
-
seal
public void seal()
Seals transaction for updates.- Specified by:
sealin interfaceIgniteInternalTx
-
implicitSingleResult
public void implicitSingleResult(GridCacheReturn ret)
- Parameters:
ret- Result.
-
hasInterceptor
public boolean hasInterceptor()
- Returns:
Trueif transaction participates in a cache that has an interceptor configured.
-
commitAfterLock
protected boolean commitAfterLock()
- Returns:
Trueif should be committed after lock is acquired.
-
peek
@Nullable public @Nullable GridTuple<CacheObject> peek(GridCacheContext cacheCtx, boolean failFast, KeyCacheObject key)
- Specified by:
peekin interfaceIgniteInternalTx- Parameters:
cacheCtx- Cache context.failFast- Fail-fast flag.key- Key to look up.- Returns:
- Current value for the key within transaction.
-
minVersion
public GridCacheVersion minVersion()
Gets minimum version present in transaction.- Specified by:
minVersionin interfaceIgniteTxLocalEx- Returns:
- Minimum versions.
-
userPrepare
public void userPrepare(@Nullable @Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException- Parameters:
entries- Entries to lock ornullif use defaultIgniteInternalTx.optimisticLockEntries().- Throws:
IgniteCheckedException- If prepare step failed.
-
calculatePartitionUpdateCounters
public void calculatePartitionUpdateCounters() throws IgniteTxRollbackCheckedExceptionCalculates partition update counters for current transaction. Each partition will be supplied with pair (init, delta) values, where init - initial update counter, and delta - updates count made by current transaction for a given partition.- Throws:
IgniteTxRollbackCheckedException
-
entryEx
protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key, AffinityTopologyVersion topVer)
Gets cache entry for given key and topology version.- Parameters:
cacheCtx- Cache context.key- Key.topVer- Topology version.- Returns:
- Cache entry.
-
userCommit
public void userCommit() throws IgniteCheckedException- Specified by:
userCommitin interfaceIgniteTxLocalEx- Throws:
IgniteCheckedException- If commit failed.
-
tmFinish
public void tmFinish(boolean commit, boolean nodeStop, boolean clearThreadMap) throws IgniteCheckedExceptionCommits transaction to transaction manager. Used for one-phase commit transactions only.- Parameters:
commit- Iftruecommits transaction, otherwise rollbacks.clearThreadMap- IftrueremovesGridNearTxLocalfrom thread map.nodeStop- Iftruetx is cancelled on node stop.- Throws:
IgniteCheckedException- If failed.
-
completedVersions
public void completedVersions(GridCacheVersion completedBase, Collection<GridCacheVersion> committedVers, Collection<GridCacheVersion> rolledbackVers)
- Specified by:
completedVersionsin interfaceIgniteInternalTx- Overrides:
completedVersionsin classIgniteTxAdapter- Parameters:
completedBase- Base for committed versions.committedVers- Committed transactions relative to base.rolledbackVers- Rolled back transactions relative to base.
-
completedBase
public GridCacheVersion completedBase()
- Returns:
- Completed base for ordering.
-
committedVersions
public Collection<GridCacheVersion> committedVersions()
- Returns:
- Committed versions.
-
rolledbackVersions
public Collection<GridCacheVersion> rolledbackVersions()
- Returns:
- Rolledback versions.
-
userRollback
public void userRollback(boolean clearThreadMap) throws IgniteCheckedException- Specified by:
userRollbackin interfaceIgniteTxLocalEx- Parameters:
clearThreadMap- IftrueremovesGridNearTxLocalfrom thread map.- Throws:
IgniteCheckedException- If rollback failed.
-
accessPolicy
protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext ctx, IgniteTxKey key, @Nullable @Nullable javax.cache.expiry.ExpiryPolicy expiryPlc)
- Parameters:
ctx- Cache context.key- Key.expiryPlc- Expiry policy.- Returns:
- Expiry policy wrapper for entries accessed locally in optimistic transaction.
-
accessPolicy
protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys)
- Parameters:
cacheCtx- Cache context.keys- Keys.- Returns:
- Expiry policy.
-
postLockWrite
protected final void postLockWrite(GridCacheContext cacheCtx, Iterable<KeyCacheObject> keys, GridCacheReturn ret, boolean rmv, boolean retval, boolean read, long accessTtl, CacheEntryPredicate[] filter, boolean computeInvoke) throws IgniteCheckedException
Post lock processing for put or remove.- Parameters:
cacheCtx- Context.keys- Keys.ret- Return value.rmv-Trueif remove.retval- Flag to return value or not.read-Trueif read.accessTtl- TTL for read operation.filter- Filter to check entries.computeInvoke- Iftruecomputes return value for invoke operation.- Throws:
IgniteCheckedException- If error.
-
addInvokeResult
protected final void addInvokeResult(IgniteTxEntry txEntry, CacheObject cacheVal, GridCacheReturn ret, GridCacheVersion ver)
- Parameters:
txEntry- Entry.cacheVal- Value.ret- Return value to update.ver- Entry version.
-
init
public boolean init()
Initializes read map.- Returns:
Trueif transaction was successfully started.
-
addActiveCache
public final void addActiveCache(GridCacheContext<?,?> cacheCtx, boolean recovery) throws IgniteCheckedException
Adds cache to the list of active caches in transaction.- Specified by:
addActiveCachein classIgniteTxAdapter- 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).
-
checkValid
protected void checkValid() throws IgniteCheckedExceptionChecks transaction expiration.- Throws:
IgniteCheckedException- If transaction check failed.
-
checkValid
protected void checkValid(boolean checkTimeout) throws IgniteCheckedExceptionChecks transaction expiration.- Parameters:
checkTimeout- Whether timeout should be checked.- Throws:
IgniteCheckedException- If transaction check failed.
-
alternateVersions
public Collection<GridCacheVersion> alternateVersions()
- Specified by:
alternateVersionsin interfaceIgniteInternalTx- Returns:
- Alternate transaction versions.
-
addEntry
public final IgniteTxEntry addEntry(GridCacheOperation op, @Nullable @Nullable CacheObject val, @Nullable @Nullable javax.cache.processor.EntryProcessor entryProc, Object[] invokeArgs, GridCacheEntryEx entry, @Nullable @Nullable javax.cache.expiry.ExpiryPolicy expiryPlc, CacheEntryPredicate[] filter, boolean filtersSet, long drTtl, long drExpireTime, @Nullable @Nullable GridCacheVersion drVer, boolean skipStore, boolean keepBinary, boolean addReader)
- Parameters:
op- Cache operation.val- Value.expiryPlc- Explicitly specified expiry policy.invokeArgs- Optional arguments for EntryProcessor.entryProc- Entry processor.entry- Cache entry.filter- Filter.filtersSet-Trueif filter should be marked as set.drTtl- DR TTL (if any).drExpireTime- DR expire time (if any).drVer- DR version.skipStore- Skip store flag.- Returns:
- Transaction entry.
-
updateExplicitVersion
protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry) throws GridCacheEntryRemovedException
Updates explicit version for tx entry based on current entry lock owner.- Parameters:
txEntry- Tx entry to update.entry- Entry.- Throws:
GridCacheEntryRemovedException- If entry was concurrently removed.
-
toString
public String toString()
- Overrides:
toStringin classIgniteTxAdapter
-
entryTtl
public long entryTtl(IgniteTxKey key)
- Parameters:
key- Key.- Returns:
- Tx entry time to live.
-
entryExpireTime
public long entryExpireTime(IgniteTxKey key)
- Parameters:
key- Key.- Returns:
- Tx entry expire time.
-
-