Package org.infinispan.container.entries
Class ReadCommittedEntry
- java.lang.Object
-
- org.infinispan.container.entries.ReadCommittedEntry
-
- All Implemented Interfaces:
Cloneable,Map.Entry,CacheEntry,MetadataAware,MVCCEntry,StateChangingEntry
- Direct Known Subclasses:
RepeatableReadEntry
public class ReadCommittedEntry extends Object implements MVCCEntry
A wrapper around a cached entry that encapsulates read committed semantics when writes are initiated, committed or rolled back.- Since:
- 4.0
- Author:
- Manik Surtani (manik@jboss.org)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classReadCommittedEntry.Flags
-
Constructor Summary
Constructors Constructor Description ReadCommittedEntry(Object key, Object value, Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadCommittedEntryclone()voidcommit(int segment, org.infinispan.container.impl.InternalDataContainer container)voidcommit(DataContainer container)Commits changeslonggetCreated()ObjectgetKey()Retrieves the key to this entrylonggetLastUsed()longgetLifespan()longgetMaxIdle()MetadatagetMetadata()Get metadata of this cache entry.ObjectgetValue()Retrieves the value of this entrybooleanisChanged()booleanisCommitted()booleanisCreated()booleanisEvicted()booleanisExpired()Returns whether this entry was marked as being expired or notbooleanisLoaded()booleanisNull()Tests whether the entry represents a null value, typically used for repeatable read.booleanisRemoved()voidresetCurrentValue()Reset the current value of the entry to the value before the commmand was executed the first time.voidsetChanged(boolean changed)voidsetCommitted()Mark this context-entry as already committed to theDataContainer.voidsetCreated(boolean created)voidsetCreated(long created)voidsetEvicted(boolean evicted)voidsetExpired(boolean expired)Marks this entry as being expired.protected voidsetFlag(ReadCommittedEntry.Flags flag)Utility method that sets the value of the given flag to true.voidsetLastUsed(long lastUsed)voidsetLoaded(boolean loaded)voidsetMetadata(Metadata metadata)Set the metadata in the cache entry.voidsetRemoved(boolean removed)voidsetSkipLookup(boolean skipLookup)ObjectsetValue(Object value)Sets the value of the entry, returning the previous valuebooleanskipLookup()StringtoString()voidupdatePreviousValue()Update the previous value of the entry - set it to current value.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.container.entries.CacheEntry
commit, isValid, rollback, setValid, undelete
-
Methods inherited from interface org.infinispan.container.entries.MVCCEntry
copyForUpdate, copyForUpdate, isRead, setRead
-
Methods inherited from interface org.infinispan.container.entries.StateChangingEntry
copyStateFlagsFrom, getStateFlags
-
-
-
-
Method Detail
-
setFlag
protected final void setFlag(ReadCommittedEntry.Flags flag)
Utility method that sets the value of the given flag to true.- Parameters:
flag- flag to set
-
getLifespan
public final long getLifespan()
- Specified by:
getLifespanin interfaceCacheEntry- Returns:
- retrieves the lifespan of this entry. -1 means an unlimited lifespan.
-
getMaxIdle
public final long getMaxIdle()
- Specified by:
getMaxIdlein interfaceCacheEntry- Returns:
- the maximum allowed time for which this entry can be idle, after which it is considered expired.
-
getKey
public final Object getKey()
Description copied from interface:CacheEntryRetrieves the key to this entry- Specified by:
getKeyin interfaceCacheEntry- Specified by:
getKeyin interfaceMap.Entry- Returns:
- a key
-
getValue
public final Object getValue()
Description copied from interface:CacheEntryRetrieves the value of this entry- Specified by:
getValuein interfaceCacheEntry- Specified by:
getValuein interfaceMap.Entry- Returns:
- the value of the entry
-
isNull
public boolean isNull()
Description copied from interface:CacheEntryTests whether the entry represents a null value, typically used for repeatable read.- Specified by:
isNullin interfaceCacheEntry- Returns:
- true if this represents a null, false otherwise.
-
commit
public final void commit(DataContainer container)
Description copied from interface:CacheEntryCommits changes- Specified by:
commitin interfaceCacheEntry- Parameters:
container- data container to commit to
-
commit
public final void commit(int segment, org.infinispan.container.impl.InternalDataContainer container)
-
isChanged
public final boolean isChanged()
- Specified by:
isChangedin interfaceCacheEntry- Returns:
- true if this entry has changed since being read from the container, false otherwise.
-
setChanged
public final void setChanged(boolean changed)
- Specified by:
setChangedin interfaceCacheEntry- Specified by:
setChangedin interfaceMVCCEntry
-
setSkipLookup
public void setSkipLookup(boolean skipLookup)
Description copied from interface:CacheEntry- Specified by:
setSkipLookupin interfaceCacheEntry
-
skipLookup
public boolean skipLookup()
- Specified by:
skipLookupin interfaceCacheEntry- Returns:
trueif the value must not be fetch from an external source
-
getCreated
public long getCreated()
- Specified by:
getCreatedin interfaceCacheEntry- Returns:
- timestamp when the entry was created
-
getLastUsed
public long getLastUsed()
- Specified by:
getLastUsedin interfaceCacheEntry- Returns:
- timestamp when the entry was last used
-
setValue
public Object setValue(Object value)
Description copied from interface:CacheEntrySets the value of the entry, returning the previous value- Specified by:
setValuein interfaceCacheEntry- Specified by:
setValuein interfaceMap.Entry- Parameters:
value- value to set- Returns:
- previous value
-
getMetadata
public Metadata getMetadata()
Description copied from interface:MetadataAwareGet metadata of this cache entry.- Specified by:
getMetadatain interfaceMetadataAware- Returns:
- a Metadata instance
-
setMetadata
public void setMetadata(Metadata metadata)
Description copied from interface:MetadataAwareSet the metadata in the cache entry.- Specified by:
setMetadatain interfaceMetadataAware- Parameters:
metadata- to apply to the cache entry
-
isCreated
public final boolean isCreated()
- Specified by:
isCreatedin interfaceCacheEntry- Returns:
- true if this entry has been newly created, false otherwise.
-
setCreated
public final void setCreated(boolean created)
- Specified by:
setCreatedin interfaceCacheEntry
-
isRemoved
public boolean isRemoved()
- Specified by:
isRemovedin interfaceCacheEntry- Returns:
- true if this entry has been removed since being read from the container, false otherwise.
-
isEvicted
public boolean isEvicted()
- Specified by:
isEvictedin interfaceCacheEntry- Returns:
- true if this entry has been evicted since being read from the container, false otherwise.
-
isExpired
public boolean isExpired()
Description copied from interface:MVCCEntryReturns whether this entry was marked as being expired or not
-
setCommitted
public void setCommitted()
Description copied from interface:MVCCEntryMark this context-entry as already committed to theDataContainer.- Specified by:
setCommittedin interfaceMVCCEntry
-
isCommitted
public boolean isCommitted()
- Specified by:
isCommittedin interfaceMVCCEntry- Returns:
- True if this context entry has been committed to the
DataContainer
-
isLoaded
public boolean isLoaded()
- Specified by:
isLoadedin interfaceCacheEntry- Specified by:
isLoadedin interfaceMVCCEntry- Returns:
- True if we've checked persistence for presence of this entry.
-
setLoaded
public void setLoaded(boolean loaded)
- Specified by:
setLoadedin interfaceCacheEntry- Specified by:
setLoadedin interfaceMVCCEntry
-
resetCurrentValue
public void resetCurrentValue()
Description copied from interface:MVCCEntryReset the current value of the entry to the value before the commmand was executed the first time. This is invoked before the command is retried.- Specified by:
resetCurrentValuein interfaceMVCCEntry
-
updatePreviousValue
public void updatePreviousValue()
Description copied from interface:MVCCEntryUpdate the previous value of the entry - set it to current value. This is invoked when the command is successfuly finished (there won't be any more retries) or when the value was updated from external source.- Specified by:
updatePreviousValuein interfaceMVCCEntry
-
setRemoved
public final void setRemoved(boolean removed)
- Specified by:
setRemovedin interfaceCacheEntry
-
setEvicted
public void setEvicted(boolean evicted)
- Specified by:
setEvictedin interfaceCacheEntry
-
setExpired
public void setExpired(boolean expired)
Description copied from interface:MVCCEntryMarks this entry as being expired. This is a special form of removal.- Specified by:
setExpiredin interfaceMVCCEntry- Parameters:
expired- whether or not this entry should be expired
-
clone
public ReadCommittedEntry clone()
-
setCreated
public void setCreated(long created)
- Specified by:
setCreatedin interfaceCacheEntry
-
setLastUsed
public void setLastUsed(long lastUsed)
- Specified by:
setLastUsedin interfaceCacheEntry
-
-