Class IgniteTxEntry
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry
-
- All Implemented Interfaces:
Serializable,GridPeerDeployAware,Message
public class IgniteTxEntry extends Object implements GridPeerDeployAware, Message
Transaction entry. Note that it is essential that this class does not overrideObject.equals(Object)method, as transaction entries should use referential equality.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static GridCacheVersionGET_ENTRY_INVALID_VER_AFTER_GETstatic GridCacheVersionGET_ENTRY_INVALID_VER_UPDATEDstatic GridCacheVersionSER_READ_EMPTY_ENTRY_VERDummy version for non-existing entry read in SERIALIZABLE transaction.static GridCacheVersionSER_READ_NOT_EMPTY_VERDummy version for any existing entry read in SERIALIZABLE transaction.IgniteInternalTxtxOwning transaction.-
Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message
DIRECT_TYPE_SIZE
-
-
Constructor Summary
Constructors Constructor Description IgniteTxEntry()Required byExternalizableIgniteTxEntry(GridCacheContext<?,?> ctx, IgniteInternalTx tx, GridCacheOperation op, CacheObject val, long ttl, long conflictExpireTime, GridCacheEntryEx entry, @Nullable GridCacheVersion conflictVer, boolean skipStore, boolean keepBinary)This constructor is meant for remote transactions.IgniteTxEntry(GridCacheContext<?,?> ctx, IgniteInternalTx tx, GridCacheOperation op, CacheObject val, javax.cache.processor.EntryProcessor<Object,Object,Object> entryProcessor, Object[] invokeArgs, long ttl, GridCacheEntryEx entry, CacheEntryPredicate[] filters, GridCacheVersion conflictVer, boolean skipStore, boolean keepBinary, boolean addReader)This constructor is meant for local transactions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntryProcessor(javax.cache.processor.EntryProcessor<Object,Object,Object> entryProcessor, Object[] invokeArgs)booleanaddReader()voidaddReader(boolean addReader)CacheObjectapplyEntryProcessors(CacheObject cacheVal)GridCacheEntryExcached()voidcached(GridCacheEntryEx entry)intcacheId()ClassLoaderclassLoader()Gets class loader for the class.IgniteTxEntrycleanCopy(GridCacheContext<?,?> ctx)voidclearEntryReadVersion()Clears recorded read version, should be done before starting commit of not serializable/optimistic transaction.longconflictExpireTime()voidconflictExpireTime(long conflictExpireTime)@Nullable GridCacheVersionconflictVersion()voidconflictVersion(@Nullable GridCacheVersion conflictVer)GridCacheContext<?,?>context()voidcontext(GridCacheContext<?,?> ctx)GridAbsClosureXcqNotifyClosure()voidcqNotifyClosure(GridAbsClosureX clo)Class<?>deployClass()Gets top level user class being deployed.GridCacheVersiondhtVersion()voiddhtVersion(GridCacheVersion dhtVer)shortdirectType()Gets message type.T2<GridCacheOperation,CacheObject>entryProcessorCalculatedValue()voidentryProcessorCalculatedValue(T2<GridCacheOperation,CacheObject> entryProcessorCalcVal)Collection<T2<javax.cache.processor.EntryProcessor<Object,Object,Object>,Object[]>>entryProcessors()voidentryProcessors(@Nullable Collection<T2<javax.cache.processor.EntryProcessor<Object,Object,Object>,Object[]>> entryProcessorsCol)@Nullable GridCacheVersionentryReadVersion()Gets stored entry version.voidentryReadVersion(GridCacheVersion ver)@Nullable javax.cache.expiry.ExpiryPolicyexpiry()voidexpiry(@Nullable javax.cache.expiry.ExpiryPolicy expiryPlc)GridCacheVersionexplicitVersion()voidexplicitVersion(GridCacheVersion explicitVer)bytefieldsCount()Gets fields count.CacheEntryPredicate[]filters()voidfilters(CacheEntryPredicate[] filters)booleanfiltersPassed()voidfiltersPassed(boolean filtersPassed)booleanfiltersSet()voidfiltersSet(boolean filtersSet)booleanhasOldValue()booleanhasPreviousValue()booleanhasReadValue()booleanhasValue()booleanhasWriteValue()booleanisRead()booleankeepBinary()voidkeepBinary(boolean keepBinary)Sets keep binary flag value.KeyCacheObjectkey()booleanlocallyMapped()voidlocallyMapped(boolean locMapped)booleanlocked()voidmarkLocked()Marks tx entry as locked.voidmarkValid()Marks this entry as value-has-bean-read.voidmarshal(GridCacheSharedContext<?,?> ctx, boolean transferExpiry)UUIDnodeId()voidnodeId(UUID nodeId)booleannoop()voidnoop(boolean noop)@Nullable CacheObjectoldValue()voidoldValue(CacheObject oldVal)voidoldValueOnPrimary(boolean oldValOnPrimary)voidonAckReceived()Method called when ack message received.GridCacheOperationop()voidop(GridCacheOperation op)voidprepareUnmarshal(GridCacheSharedContext<?,?> ctx, AffinityTopologyVersion topVer, boolean near)Prepares this entry to unmarshall.@Nullable GridCacheOperationpreviousOperation()@Nullable CacheObjectpreviousValue()booleanreadFrom(ByteBuffer buf, MessageReader reader)Reads this message from provided byte buffer.voidreadValue(@Nullable CacheObject val)Sets read value if this tx entry does not have write value yet.voidsetAndMarkValid(CacheObject val)booleanskipStore()voidskipStore(boolean skipStore)Sets skip store flag value.StringtoString()longttl()voidttl(long ttl)IgniteTxKeytxKey()voidunmarshal(GridCacheSharedContext<?,?> ctx, boolean near, ClassLoader clsLdr)Unmarshalls entry.longupdateCounter()voidupdateCounter(long partCntr)Sets partition counter.@Nullable CacheObjectvalue()voidvalue(@Nullable CacheObject val, boolean writeVal, boolean readVal)booleanwriteTo(ByteBuffer buf, MessageWriter writer)Writes this message to provided byte buffer.
-
-
-
Field Detail
-
SER_READ_EMPTY_ENTRY_VER
public static final GridCacheVersion SER_READ_EMPTY_ENTRY_VER
Dummy version for non-existing entry read in SERIALIZABLE transaction.
-
SER_READ_NOT_EMPTY_VER
public static final GridCacheVersion SER_READ_NOT_EMPTY_VER
Dummy version for any existing entry read in SERIALIZABLE transaction.
-
GET_ENTRY_INVALID_VER_UPDATED
public static final GridCacheVersion GET_ENTRY_INVALID_VER_UPDATED
-
GET_ENTRY_INVALID_VER_AFTER_GET
public static final GridCacheVersion GET_ENTRY_INVALID_VER_AFTER_GET
-
tx
@GridToStringExclude public IgniteInternalTx tx
Owning transaction.
-
-
Constructor Detail
-
IgniteTxEntry
public IgniteTxEntry()
Required byExternalizable
-
IgniteTxEntry
public IgniteTxEntry(GridCacheContext<?,?> ctx, IgniteInternalTx tx, GridCacheOperation op, CacheObject val, long ttl, long conflictExpireTime, GridCacheEntryEx entry, @Nullable @Nullable GridCacheVersion conflictVer, boolean skipStore, boolean keepBinary)
This constructor is meant for remote transactions.- Parameters:
ctx- Cache registry.tx- Owning transaction.op- Operation.val- Value.ttl- Time to live.conflictExpireTime- DR expire time.entry- Cache entry.conflictVer- Data center replication version.skipStore- Skip store flag.
-
IgniteTxEntry
public IgniteTxEntry(GridCacheContext<?,?> ctx, IgniteInternalTx tx, GridCacheOperation op, CacheObject val, javax.cache.processor.EntryProcessor<Object,Object,Object> entryProcessor, Object[] invokeArgs, long ttl, GridCacheEntryEx entry, CacheEntryPredicate[] filters, GridCacheVersion conflictVer, boolean skipStore, boolean keepBinary, boolean addReader)
This constructor is meant for local transactions.- Parameters:
ctx- Cache registry.tx- Owning transaction.op- Operation.val- Value.entryProcessor- Entry processor.invokeArgs- Optional arguments for EntryProcessor.ttl- Time to live.entry- Cache entry.filters- Put filters.conflictVer- Data center replication version.skipStore- Skip store flag.addReader- Add reader flag.
-
-
Method Detail
-
context
public GridCacheContext<?,?> context()
- Returns:
- Cache context for this tx entry.
-
context
public void context(GridCacheContext<?,?> ctx)
- Parameters:
ctx- Cache context for this tx entry.
-
locallyMapped
public boolean locallyMapped()
- Returns:
- Flag indicating if this entry is affinity mapped to the same node.
-
locallyMapped
public void locallyMapped(boolean locMapped)
- Parameters:
locMapped- Flag indicating if this entry is affinity mapped to the same node.
-
cleanCopy
public IgniteTxEntry cleanCopy(GridCacheContext<?,?> ctx)
- Parameters:
ctx- Context.- Returns:
- Clean copy of this entry.
-
nodeId
public UUID nodeId()
- Returns:
- Node ID.
-
nodeId
public void nodeId(UUID nodeId)
- Parameters:
nodeId- Node ID.
-
dhtVersion
public GridCacheVersion dhtVersion()
- Returns:
- DHT version.
-
dhtVersion
public void dhtVersion(GridCacheVersion dhtVer)
- Parameters:
dhtVer- DHT version.
-
locked
public boolean locked()
- Returns:
Trueif tx entry was marked as locked.
-
markLocked
public void markLocked()
Marks tx entry as locked.
-
updateCounter
public void updateCounter(long partCntr)
Sets partition counter.- Parameters:
partCntr- Partition counter.
-
updateCounter
public long updateCounter()
- Returns:
- Partition index.
-
setAndMarkValid
public void setAndMarkValid(CacheObject val)
- Parameters:
val- Value to set.
-
markValid
public void markValid()
Marks this entry as value-has-bean-read. Effectively, makes values enlisted to transaction visible to further peek operations.
-
key
public KeyCacheObject key()
- Returns:
- Entry key.
-
cacheId
public int cacheId()
- Returns:
- Cache ID.
-
skipStore
public void skipStore(boolean skipStore)
Sets skip store flag value.- Parameters:
skipStore- Skip store flag.
-
skipStore
public boolean skipStore()
- Returns:
- Skip store flag.
-
oldValueOnPrimary
public void oldValueOnPrimary(boolean oldValOnPrimary)
- Parameters:
oldValOnPrimary-TrueIf old value for was non null on primary node.
-
keepBinary
public void keepBinary(boolean keepBinary)
Sets keep binary flag value.- Parameters:
keepBinary- Keep binary flag value.
-
keepBinary
public boolean keepBinary()
- Returns:
- Keep binary flag value.
-
addReader
public void addReader(boolean addReader)
- Parameters:
addReader- Add reader flag.
-
addReader
public boolean addReader()
- Returns:
- Add reader flag.
-
noop
public void noop(boolean noop)
- Parameters:
noop- Add no-op flag.
-
noop
public boolean noop()
- Returns:
trueif noop flag is set,falseotherwise.
-
txKey
public IgniteTxKey txKey()
- Returns:
- Tx key.
-
cached
public GridCacheEntryEx cached()
- Returns:
- Underlying cache entry.
-
cached
public void cached(GridCacheEntryEx entry)
- Parameters:
entry- Cache entry.
-
value
@Nullable public @Nullable CacheObject value()
- Returns:
- Entry value.
-
oldValue
@Nullable public @Nullable CacheObject oldValue()
- Returns:
- Old value.
-
oldValue
public void oldValue(CacheObject oldVal)
- Parameters:
oldVal- Old value.
-
hasOldValue
public boolean hasOldValue()
- Returns:
Trueif old value present.
-
hasValue
public boolean hasValue()
- Returns:
Trueif has value explicitly set.
-
hasWriteValue
public boolean hasWriteValue()
- Returns:
Trueif has write value set.
-
hasReadValue
public boolean hasReadValue()
- Returns:
Trueif has read value set.
-
previousValue
@Nullable public @Nullable CacheObject previousValue()
- Returns:
- Value visible for peek.
-
hasPreviousValue
public boolean hasPreviousValue()
- Returns:
Trueif has previous value explicitly set.
-
previousOperation
@Nullable public @Nullable GridCacheOperation previousOperation()
- Returns:
- Previous operation to revert entry in case of filter failure.
-
ttl
public long ttl()
- Returns:
- Time to live.
-
ttl
public void ttl(long ttl)
- Parameters:
ttl- Time to live.
-
conflictExpireTime
public long conflictExpireTime()
- Returns:
- Conflict expire time.
-
conflictExpireTime
public void conflictExpireTime(long conflictExpireTime)
- Parameters:
conflictExpireTime- Conflict expire time.
-
value
public void value(@Nullable @Nullable CacheObject val, boolean writeVal, boolean readVal)- Parameters:
val- Entry value.writeVal- Write value flag.readVal- Read value flag.
-
readValue
public void readValue(@Nullable @Nullable CacheObject val)Sets read value if this tx entry does not have write value yet.- Parameters:
val- Read value to set.
-
addEntryProcessor
public void addEntryProcessor(javax.cache.processor.EntryProcessor<Object,Object,Object> entryProcessor, Object[] invokeArgs)
- Parameters:
entryProcessor- Entry processor.invokeArgs- Optional arguments for EntryProcessor.
-
entryProcessors
public Collection<T2<javax.cache.processor.EntryProcessor<Object,Object,Object>,Object[]>> entryProcessors()
- Returns:
- Collection of entry processors.
-
applyEntryProcessors
public CacheObject applyEntryProcessors(CacheObject cacheVal)
- Parameters:
cacheVal- Value.- Returns:
- New value.
-
entryProcessors
public void entryProcessors(@Nullable @Nullable Collection<T2<javax.cache.processor.EntryProcessor<Object,Object,Object>,Object[]>> entryProcessorsCol)- Parameters:
entryProcessorsCol- Collection of entry processors.
-
op
public GridCacheOperation op()
- Returns:
- Cache operation.
-
op
public void op(GridCacheOperation op)
- Parameters:
op- Cache operation.
-
isRead
public boolean isRead()
- Returns:
Trueif read entry.
-
explicitVersion
public void explicitVersion(GridCacheVersion explicitVer)
- Parameters:
explicitVer- Explicit version.
-
explicitVersion
public GridCacheVersion explicitVersion()
- Returns:
- Explicit version.
-
conflictVersion
@Nullable public @Nullable GridCacheVersion conflictVersion()
- Returns:
- Conflict version.
-
conflictVersion
public void conflictVersion(@Nullable @Nullable GridCacheVersion conflictVer)- Parameters:
conflictVer- Conflict version.
-
filters
public CacheEntryPredicate[] filters()
- Returns:
- Put filters.
-
filters
public void filters(CacheEntryPredicate[] filters)
- Parameters:
filters- Put filters.
-
filtersPassed
public boolean filtersPassed()
- Returns:
Trueif filters passed for fast-commit transactions.
-
filtersPassed
public void filtersPassed(boolean filtersPassed)
- Parameters:
filtersPassed-Trueif filters passed for fast-commit transactions.
-
filtersSet
public boolean filtersSet()
- Returns:
Trueif filters are set.
-
filtersSet
public void filtersSet(boolean filtersSet)
- Parameters:
filtersSet-Trueif filters are set and should not be replaced.
-
marshal
public void marshal(GridCacheSharedContext<?,?> ctx, boolean transferExpiry) throws IgniteCheckedException
- Parameters:
ctx- Context.transferExpiry-Trueif expire policy should be marshalled.- Throws:
IgniteCheckedException- If failed.
-
prepareUnmarshal
public void prepareUnmarshal(GridCacheSharedContext<?,?> ctx, AffinityTopologyVersion topVer, boolean near) throws IgniteCheckedException
Prepares this entry to unmarshall. In particular, this method initialize a cache context.- Parameters:
ctx- Cache context.topVer- Topology version that is used to validate a cache context. If this parameter isnullthen validation will be skipped.near- Near flag.- Throws:
IgniteCheckedException- If un-marshalling failed.
-
unmarshal
public void unmarshal(GridCacheSharedContext<?,?> ctx, boolean near, ClassLoader clsLdr) throws IgniteCheckedException
Unmarshalls entry.- Parameters:
ctx- Cache context.near- Near flag.clsLdr- Class loader.- Throws:
IgniteCheckedException- If un-marshalling failed.
-
expiry
public void expiry(@Nullable @Nullable javax.cache.expiry.ExpiryPolicy expiryPlc)- Parameters:
expiryPlc- Expiry policy.
-
expiry
@Nullable public @Nullable javax.cache.expiry.ExpiryPolicy expiry()
- Returns:
- Expiry policy.
-
entryProcessorCalculatedValue
public T2<GridCacheOperation,CacheObject> entryProcessorCalculatedValue()
- Returns:
- Entry processor calculated value.
-
entryProcessorCalculatedValue
public void entryProcessorCalculatedValue(T2<GridCacheOperation,CacheObject> entryProcessorCalcVal)
- Parameters:
entryProcessorCalcVal- Entry processor calculated value.
-
entryReadVersion
@Nullable public @Nullable GridCacheVersion entryReadVersion()
Gets stored entry version. Version is stored for all entries in serializable transaction or when value is read usingIgniteCache.getEntry(Object)method.- Returns:
- Entry version.
-
entryReadVersion
public void entryReadVersion(GridCacheVersion ver)
- Parameters:
ver- Entry version.
-
clearEntryReadVersion
public void clearEntryReadVersion()
Clears recorded read version, should be done before starting commit of not serializable/optimistic transaction.
-
onAckReceived
public void onAckReceived()
Method called when ack message received.- Specified by:
onAckReceivedin interfaceMessage
-
writeTo
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
Writes this message to provided byte buffer.
-
readFrom
public boolean readFrom(ByteBuffer buf, MessageReader reader)
Reads this message from provided byte buffer.
-
directType
public short directType()
Gets message type.- Specified by:
directTypein interfaceMessage- Returns:
- Message type.
-
fieldsCount
public byte fieldsCount()
Gets fields count.- Specified by:
fieldsCountin interfaceMessage- Returns:
- Fields count.
-
deployClass
public Class<?> deployClass()
Gets top level user class being deployed.- Specified by:
deployClassin interfaceGridPeerDeployAware- Returns:
- Top level user deployed class.
-
cqNotifyClosure
public GridAbsClosureX cqNotifyClosure()
-
cqNotifyClosure
public void cqNotifyClosure(GridAbsClosureX clo)
- Parameters:
clo- Clo.
-
classLoader
public ClassLoader classLoader()
Gets class loader for the class. This class loader must be able to load the class returned fromGridPeerDeployAware.deployClass()as well as all of its dependencies.Note that in most cases the class loader returned from this method and the class loader for the class returned from
GridPeerDeployAware.deployClass()method will be the same. If they are not the same, it is required that the class loader returned from this method still has to be able to load the deploy class and all its dependencies.- Specified by:
classLoaderin interfaceGridPeerDeployAware- Returns:
- Class loader for the class.
-
-