public abstract class GridCacheTxAdapter<K,V> extends GridMetadataAwareAdapter implements GridCacheTxEx<K,V>, Externalizable
GridCacheTxEx.FinalizationStatus| Modifier and Type | Field and Description |
|---|---|
protected GridCacheContext<K,V> |
cctx
Cache registry.
|
protected GridCacheTxConcurrency |
concurrency
Concurrency.
|
protected GridCacheVersion |
endVer
End version (a.k.a.
|
protected Object |
grpLockKey
Group lock key, if any.
|
protected boolean |
implicit
Implicit flag.
|
protected boolean |
implicitSingle
Implicit with one key flag.
|
protected boolean |
internal
Internal flag.
|
protected boolean |
invalidate
Invalidate flag.
|
protected AtomicBoolean |
isDone
Done marker.
|
protected GridCacheTxIsolation |
isolation
Isolation.
|
protected boolean |
loc
Local flag.
|
protected static GridLogger |
log
Logger.
|
protected UUID |
nodeId
Node ID.
|
protected boolean |
onePhaseCommit |
protected long |
startTime
Transaction start time.
|
protected GridCacheVersion |
startVer
Transaction counter value at the start of transaction.
|
protected boolean |
storeEnabled |
protected UUID |
subjId
Subject ID initiated this transaction.
|
protected boolean |
swapOrOffheapEnabled |
protected long |
threadId
Thread ID.
|
protected long |
timeout
Transaction timeout.
|
protected int |
txSize |
protected GridCacheVersion |
writeVer
Entries write version.
|
protected GridCacheVersion |
xidVer
Transaction ID.
|
| Modifier | Constructor and Description |
|---|---|
protected |
GridCacheTxAdapter()
Empty constructor required for
Externalizable. |
protected |
GridCacheTxAdapter(GridCacheContext<K,V> cctx,
GridCacheVersion xidVer,
boolean implicit,
boolean implicitSingle,
boolean loc,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
boolean invalidate,
boolean swapOrOffheapEnabled,
boolean storeEnabled,
int txSize,
Object grpLockKey,
UUID subjId) |
protected |
GridCacheTxAdapter(GridCacheContext<K,V> cctx,
UUID nodeId,
GridCacheVersion xidVer,
GridCacheVersion startVer,
long threadId,
GridCacheTxConcurrency concurrency,
GridCacheTxIsolation isolation,
long timeout,
boolean invalidate,
boolean swapOrOffheapEnabled,
boolean storeEnabled,
int txSize,
Object grpLockKey,
UUID subjId) |
| Modifier and Type | Method and Description |
|---|---|
void |
addInvalidPartition(int part) |
protected GridTuple3<GridCacheOperation,V,byte[]> |
applyTransformClosures(GridCacheTxEntry<K,V> txEntry,
boolean metrics) |
protected void |
awaitCompletion()
Awaits transaction completion.
|
protected void |
awaitSignal()
Waits for signal.
|
protected boolean |
awaitSignal(long ms)
Waits for signal.
|
protected boolean |
checkInternal(K key) |
void |
close()
Ends the transaction.
|
boolean |
colocated() |
GridCacheVersion |
commitVersion() |
boolean |
commitVersion(GridCacheVersion commitVer) |
void |
completedVersions(GridCacheVersion base,
Collection<GridCacheVersion> committed,
Collection<GridCacheVersion> txs) |
GridCacheTxConcurrency |
concurrency()
Cache transaction concurrency mode.
|
boolean |
dht() |
boolean |
done() |
protected GridBiTuple<GridCacheOperation,GridDrReceiverConflictContextImpl<K,V>> |
drResolveConflict(GridCacheOperation op,
K key,
V newVal,
byte[] newValBytes,
long newTtl,
long newDrExpireTime,
GridCacheVersion newVer,
GridCacheEntryEx<K,V> old)
Resolve DR conflict.
|
long |
endTime() |
GridCacheVersion |
endVersion() |
void |
endVersion(GridCacheVersion endVer) |
boolean |
enforceSerializable()
For Partitioned caches, this flag is
false for remote DHT and remote NEAR
transactions because serializability of transaction is enforced on primary node. |
boolean |
equals(Object o) |
protected boolean |
evictNearEntry(GridCacheTxEntry<K,V> e,
boolean primaryOnly) |
protected GridCacheTxEx.FinalizationStatus |
finalizationStatus() |
GridFuture<GridCacheTx> |
finishFuture() |
boolean |
groupLock() |
GridCacheTxEntry<K,V> |
groupLockEntry()
This method uses unchecked assignment to cast group lock key entry to transaction generic signature.
|
Object |
groupLockKey() |
int |
hashCode() |
boolean |
implicit()
Flag indicating whether transaction was started automatically by the
system or not.
|
boolean |
implicitSingle() |
void |
initCommitVersion() |
boolean |
internal() |
void |
invalidate(boolean invalidate) |
Set<Integer> |
invalidPartitions() |
boolean |
isInvalidate()
Get invalidation flag for this transaction.
|
protected boolean |
isNearLocallyMapped(GridCacheTxEntry<K,V> e,
boolean primaryOnly) |
GridCacheTxIsolation |
isolation()
Cache transaction isolation level.
|
boolean |
isRollbackOnly()
If transaction was marked as rollback-only.
|
abstract boolean |
isStarted() |
boolean |
isSystemInvalidate() |
boolean |
local() |
protected void |
lock()
Acquires lock.
|
protected long |
lockTimeout() |
protected GridLogger |
log() |
boolean |
markFinalizing(GridCacheTxEx.FinalizationStatus status) |
boolean |
markPreparing() |
boolean |
near() |
GridCacheVersion |
nearXidVersion() |
boolean |
needsCompletedVersions() |
UUID |
nodeId()
ID of the node on which this transaction started.
|
boolean |
onePhaseCommit() |
void |
onePhaseCommit(boolean onePhaseCommit) |
void |
onTimeout()
Timeout callback.
|
boolean |
optimistic() |
Collection<GridCacheTxEntry<K,V>> |
optimisticLockEntries()
Gets a list of entries that needs to be locked on the next step of prepare stage of
optimistic transaction.
|
UUID |
otherNodeId()
Gets ID of additional node involved.
|
GridCacheVersion |
ownedVersion(K key)
Gets owned version for near remote transaction.
|
boolean |
ownsLock(GridCacheEntryEx<K,V> entry) |
boolean |
ownsLockUnsafe(GridCacheEntryEx<K,V> entry) |
boolean |
pessimistic() |
boolean |
readCommitted() |
void |
readExternal(ObjectInput in) |
protected Object |
readResolve()
Reconstructs object on demarshalling.
|
Collection<GridCacheTxEntry<K,V>> |
recoveryWrites()
Gets pessimistic recovery writes, i.e.
|
void |
recoveryWrites(Collection<GridCacheTxEntry<K,V>> recoveryWrites) |
long |
remainingTime()
Gets remaining allowed transaction time.
|
boolean |
repeatableRead() |
boolean |
replicated() |
boolean |
serializable() |
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.
|
protected void |
signalAll()
Signals all waiters.
|
int |
size() |
long |
startTime()
Start time of this transaction.
|
GridCacheVersion |
startVersion() |
GridCacheTxState |
state()
Gets current transaction state value.
|
boolean |
state(GridCacheTxState state) |
UUID |
subjectId() |
boolean |
syncCommit() |
boolean |
syncRollback() |
void |
systemInvalidate(boolean sysInvalidate) |
long |
threadId()
ID of the thread in which this transaction started.
|
boolean |
timedOut() |
long |
timeout()
Gets timeout value in milliseconds for this transaction.
|
long |
timeout(long timeout)
Sets transaction timeout value.
|
GridUuid |
timeoutId() |
long |
topologyVersion() |
long |
topologyVersion(long topVer)
Attempts to set topology version and returns the current value.
|
String |
toString() |
Map<UUID,Collection<UUID>> |
transactionNodes() |
protected void |
unlock()
Releases lock.
|
protected boolean |
updateNearCache()
Checks whether near cache should be updated.
|
boolean |
user() |
void |
writeExternal(ObjectOutput out) |
GridCacheVersion |
writeVersion() |
void |
writeVersion(GridCacheVersion writeVer)
Sets write version.
|
GridUuid |
xid()
Gets unique identifier for this transaction.
|
GridCacheVersion |
xidVersion() |
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMetafinalize, getClass, notify, notifyAll, wait, wait, waitaddLocalCandidates, allEntries, alternateVersions, empty, entry, eventNodeId, hasReadKey, hasWriteKey, localCandidates, masterNodeIds, onOwnerChanged, originatingNodeId, peek, prepare, prepareAsync, readEntries, readMap, readSet, removed, rollbackAsync, seal, writeEntries, writeMap, writeSetcommit, commitAsync, rollbackaddMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMetaprotected static GridLogger log
@GridToStringInclude protected GridCacheVersion xidVer
@GridToStringInclude protected GridCacheVersion writeVer
@GridToStringInclude protected boolean implicit
@GridToStringInclude protected boolean implicitSingle
@GridToStringInclude protected boolean loc
@GridToStringInclude protected long threadId
@GridToStringInclude protected long startTime
@GridToStringInclude protected UUID nodeId
@GridToStringInclude protected GridCacheVersion startVer
@GridToStringExclude protected GridCacheContext<K,V> cctx
@GridToStringInclude protected GridCacheVersion endVer
@GridToStringInclude protected GridCacheTxIsolation isolation
@GridToStringInclude protected GridCacheTxConcurrency concurrency
@GridToStringInclude protected long timeout
protected volatile boolean invalidate
protected boolean swapOrOffheapEnabled
protected boolean storeEnabled
protected boolean internal
protected boolean onePhaseCommit
protected final AtomicBoolean isDone
protected int txSize
protected Object grpLockKey
protected UUID subjId
protected GridCacheTxAdapter()
Externalizable.protected GridCacheTxAdapter(GridCacheContext<K,V> cctx, GridCacheVersion xidVer, boolean implicit, boolean implicitSingle, boolean loc, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, boolean invalidate, boolean swapOrOffheapEnabled, boolean storeEnabled, int txSize, @Nullable Object grpLockKey, @Nullable UUID subjId)
cctx - Cache registry.xidVer - Transaction ID.implicit - Implicit flag.implicitSingle - Implicit with one key flag.loc - Local flag.concurrency - Concurrency.isolation - Isolation.timeout - Timeout.invalidate - Invalidation policy.swapOrOffheapEnabled - Whether to use swap storage.storeEnabled - Whether to use read/write through.txSize - Transaction size.grpLockKey - Group lock key if this is group-lock transaction.protected GridCacheTxAdapter(GridCacheContext<K,V> cctx, UUID nodeId, GridCacheVersion xidVer, GridCacheVersion startVer, long threadId, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, boolean invalidate, boolean swapOrOffheapEnabled, boolean storeEnabled, int txSize, @Nullable Object grpLockKey, @Nullable UUID subjId)
cctx - Cache registry.nodeId - Node ID.xidVer - Transaction ID.startVer - Start version mark.threadId - Thread ID.concurrency - Concurrency.isolation - Isolation.timeout - Timeout.invalidate - Invalidation policy.swapOrOffheapEnabled - Swap enabled flag.storeEnabled - Store enabled (read/write through) flag.txSize - Transaction size.grpLockKey - Group lock key if this is group-lock transaction.protected final void lock()
protected final void unlock()
protected final void signalAll()
protected final void awaitSignal()
throws InterruptedException
InterruptedException - If interrupted.protected final boolean awaitSignal(long ms)
throws InterruptedException
ms - Time to wait.True if signal occurred.InterruptedException - If interrupted.protected boolean updateNearCache()
public Collection<GridCacheTxEntry<K,V>> optimisticLockEntries()
optimisticLockEntries in interface GridCacheTxEx<K,V>public void recoveryWrites(Collection<GridCacheTxEntry<K,V>> recoveryWrites)
recoveryWrites - Recover write entries.public Collection<GridCacheTxEntry<K,V>> recoveryWrites()
GridCacheTxExrecoveryWrites in interface GridCacheTxEx<K,V>public GridCacheTxEntry<K,V> groupLockEntry()
public UUID otherNodeId()
otherNodeId in interface GridCacheTxEx<K,V>public UUID subjectId()
subjectId in interface GridCacheTxEx<K,V>public long topologyVersion()
topologyVersion in interface GridCacheTxEx<K,V>public long topologyVersion(long topVer)
topologyVersion in interface GridCacheTxEx<K,V>topVer - Topology version.public boolean markPreparing()
markPreparing in interface GridCacheTxEx<K,V>True if preparing flag was set with this call.public boolean markFinalizing(GridCacheTxEx.FinalizationStatus status)
markFinalizing in interface GridCacheTxEx<K,V>status - Finalization status to set.True if marked.protected GridCacheTxEx.FinalizationStatus finalizationStatus()
public abstract boolean isStarted()
True if transaction has at least one key enlisted.public boolean groupLock()
groupLock in interface GridCacheTxEx<K,V>True if transaction group-locked.public Object groupLockKey()
groupLockKey in interface GridCacheTxEx<K,V>GridCacheTxEx.groupLock() is true.public int size()
size in interface GridCacheTxEx<K,V>protected GridLogger log()
public boolean near()
near in interface GridCacheTxEx<K,V>True if near transaction.public boolean implicit()
put(..) or remove(..) operation is invoked
outside of transaction.implicit in interface GridCacheTxTrue if transaction was started implicitly.public boolean implicitSingle()
implicitSingle in interface GridCacheTxEx<K,V>public boolean local()
local in interface GridCacheTxEx<K,V>True if transaction is local, false if it's remote.public final boolean user()
user in interface GridCacheTxEx<K,V>True if transaction is user transaction, which means:
public boolean dht()
dht in interface GridCacheTxEx<K,V>True if DHT transaction.public boolean colocated()
colocated in interface GridCacheTxEx<K,V>True if dht colocated transaction.public boolean replicated()
replicated in interface GridCacheTxEx<K,V>True if transaction is replicated.public boolean enforceSerializable()
false for remote DHT and remote NEAR
transactions because serializability of transaction is enforced on primary node. All
other transaction types must enforce it.enforceSerializable in interface GridCacheTxEx<K,V>public boolean syncCommit()
syncCommit in interface GridCacheTxEx<K,V>True if transaction is configured with synchronous commit flag.public boolean syncRollback()
syncRollback in interface GridCacheTxEx<K,V>True if transaction is configured with synchronous rollback flag.public GridUuid xid()
xid in interface GridCacheTxpublic Set<Integer> invalidPartitions()
invalidPartitions in interface GridCacheTxEx<K,V>public void addInvalidPartition(int part)
addInvalidPartition in interface GridCacheTxEx<K,V>part - Invalid partition.public GridCacheVersion ownedVersion(K key)
ownedVersion in interface GridCacheTxEx<K,V>key - Key to get version for.public long startTime()
startTime in interface GridCacheTxpublic long remainingTime()
remainingTime in interface GridCacheTxEx<K,V>protected long lockTimeout()
public GridCacheVersion xidVersion()
xidVersion in interface GridCacheTxEx<K,V>public long threadId()
threadId in interface GridCacheTxpublic UUID nodeId()
nodeId in interface GridCacheTxpublic GridCacheTxIsolation isolation()
isolation in interface GridCacheTxpublic GridCacheTxConcurrency concurrency()
concurrency in interface GridCacheTxpublic long timeout()
GridCacheTxTimeoutException will be thrown.timeout in interface GridCacheTxpublic long timeout(long timeout)
timeout in interface GridCacheTxtimeout - Transaction timeout value.public boolean ownsLock(GridCacheEntryEx<K,V> entry) throws GridCacheEntryRemovedException
ownsLock in interface GridCacheTxEx<K,V>entry - Entry to check.True if lock is owned.GridCacheEntryRemovedException - If entry has been removed.public boolean ownsLockUnsafe(GridCacheEntryEx<K,V> entry)
ownsLockUnsafe in interface GridCacheTxEx<K,V>entry - Entry to check.True if lock is owned.public GridCacheTxState state()
state in interface GridCacheTxpublic boolean setRollbackOnly()
setRollbackOnly in interface GridCacheTxTrue if rollback-only flag was set as a result of this operation,
false if it was already set prior to this call or could not be set
because transaction is already finishing up committing or rolling back.public boolean isRollbackOnly()
GridCacheTxisRollbackOnly in interface GridCacheTxTrue if rollback only flag is set.public boolean done()
done in interface GridCacheTxEx<K,V>True if transaction had completed successfully or unsuccessfully.public GridCacheVersion commitVersion()
commitVersion in interface GridCacheTxEx<K,V>public boolean commitVersion(GridCacheVersion commitVer)
commitVersion in interface GridCacheTxEx<K,V>commitVer - Commit version.True if set to not null value.public void initCommitVersion()
public void close()
throws GridException
GridCacheTxclose in interface AutoCloseableclose in interface GridCacheTxGridException - If transaction could not be gracefully ended.public boolean needsCompletedVersions()
needsCompletedVersions in interface GridCacheTxEx<K,V>True if transaction needs completed versions for processing.public void completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> txs)
completedVersions in interface GridCacheTxEx<K,V>base - Base for committed versions.committed - Committed transactions relative to base.txs - Rolled back transactions relative to base.protected void awaitCompletion()
throws GridException
GridException - If waiting failed.public boolean internal()
internal in interface GridCacheTxEx<K,V>True if transaction has at least one internal entry.protected boolean checkInternal(K key)
key - Key.True if key is internal.public void onePhaseCommit(boolean onePhaseCommit)
onePhaseCommit - True if transaction commit should be performed in short-path way.public boolean onePhaseCommit()
onePhaseCommit in interface GridCacheTxEx<K,V>public boolean optimistic()
optimistic in interface GridCacheTxEx<K,V>True for OPTIMISTIC transactions.public boolean pessimistic()
pessimistic in interface GridCacheTxEx<K,V>True for PESSIMISTIC transactions.public boolean serializable()
serializable in interface GridCacheTxEx<K,V>True if serializable.public boolean repeatableRead()
repeatableRead in interface GridCacheTxEx<K,V>True if repeatable-read.public boolean readCommitted()
readCommitted in interface GridCacheTxEx<K,V>True if read-committed.public boolean state(GridCacheTxState state)
state in interface GridCacheTxEx<K,V>state - Transaction state.True if transition was valid, false otherwise.public GridFuture<GridCacheTx> finishFuture()
finishFuture in interface GridCacheTxEx<K,V>public GridCacheVersion startVersion()
startVersion in interface GridCacheTxEx<K,V>public GridCacheVersion endVersion()
endVersion in interface GridCacheTxEx<K,V>public void endVersion(GridCacheVersion endVer)
endVersion in interface GridCacheTxEx<K,V>endVer - End version (a.k.a. 'tnc' or 'transaction number counter')
assigned to this transaction at the end of write phase.public GridCacheVersion writeVersion()
writeVersion in interface GridCacheTxEx<K,V>GridCacheTxEx.xidVersion().public void writeVersion(GridCacheVersion writeVer)
writeVersion in interface GridCacheTxEx<K,V>writeVer - Write version.public GridUuid timeoutId()
timeoutId in interface GridTimeoutObjectpublic long endTime()
endTime in interface GridTimeoutObjectpublic void onTimeout()
onTimeout in interface GridTimeoutObjectpublic boolean timedOut()
timedOut in interface GridCacheTxEx<K,V>True if transaction timed out.public void invalidate(boolean invalidate)
invalidate in interface GridCacheTxEx<K,V>invalidate - Invalidate flag.public boolean isInvalidate()
true, then
remote values will be invalidated (set to null) 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.
isInvalidate in interface GridCacheTxpublic boolean isSystemInvalidate()
isSystemInvalidate in interface GridCacheTxEx<K,V>public void systemInvalidate(boolean sysInvalidate)
systemInvalidate in interface GridCacheTxEx<K,V>sysInvalidate - System invalidate flag.@Nullable public Map<UUID,Collection<UUID>> transactionNodes()
transactionNodes in interface GridCacheTxEx<K,V>@Nullable public GridCacheVersion nearXidVersion()
nearXidVersion in interface GridCacheTxEx<K,V>protected GridTuple3<GridCacheOperation,V,byte[]> applyTransformClosures(GridCacheTxEntry<K,V> txEntry, boolean metrics) throws GridCacheEntryRemovedException, GridException
txEntry - Entry to process.metrics - True if metrics should be updated.GridException - If failed to get previous value for transform.GridCacheEntryRemovedException - If entry was concurrently deleted.protected GridBiTuple<GridCacheOperation,GridDrReceiverConflictContextImpl<K,V>> drResolveConflict(GridCacheOperation op, K key, V newVal, byte[] newValBytes, long newTtl, long newDrExpireTime, GridCacheVersion newVer, GridCacheEntryEx<K,V> old) throws GridException, GridCacheEntryRemovedException
op - Initially proposed operation.key - Key.newVal - New value.newValBytes - New value bytes.newTtl - New TTL.newDrExpireTime - New explicit DR expire time.newVer - New version.old - Old entry.GridException - In case of eny exception.GridCacheEntryRemovedException - If entry got removed.protected boolean isNearLocallyMapped(GridCacheTxEntry<K,V> e, boolean primaryOnly)
e - Transaction entry.primaryOnly - Flag to include backups into check or not.True if entry is locally mapped as a primary or back up node.protected boolean evictNearEntry(GridCacheTxEntry<K,V> e, boolean primaryOnly) throws GridException
e - Entry to evict if it qualifies for eviction.primaryOnly - Flag to try to evict only on primary node.True if attempt was made to evict the entry.GridException - If failed.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionprotected Object readResolve() throws ObjectStreamException
ObjectStreamException - Thrown in case of demarshalling error.Copyright © 2014. All rights reserved.