Package org.infinispan.container.entries
Class ReadCommittedEntry<K,V>
java.lang.Object
org.infinispan.container.entries.ReadCommittedEntry<K,V>
- All Implemented Interfaces:
Cloneable,Map.Entry<K,,V> CacheEntry<K,,V> MetadataAware,MVCCEntry<K,V>
- Direct Known Subclasses:
RepeatableReadEntry
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 -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()commit(int segment, InternalDataContainer<K, V> container) voidcommit(DataContainer<K, V> container) Commits changeslongfinal KgetKey()Retrieves the key to this entrylongfinal longfinal longGet metadata of this cache entry.final Metadatafinal Vfinal VgetValue()Retrieves the value of this entryfinal booleanbooleanfinal booleanbooleanbooleanReturns whether this entry was marked as being expired or notbooleanisLoaded()final booleanisNull()Tests whether the entry represents a null value, typically used for repeatable read.booleanbooleanvoidReset the current value of the entry to the value before the command was executed the first time.final voidsetChanged(boolean changed) voidMark this context-entry as already committed to theDataContainer.final voidsetCreated(boolean created) voidsetCreated(long created) voidsetEvicted(boolean evicted) voidsetExpired(boolean expired) Marks this entry as being expired.protected final voidUtility method that sets the value of the given flag to true.voidsetInternalMetadata(PrivateMetadata metadata) voidsetLastUsed(long lastUsed) voidsetLoaded(boolean loaded) voidsetMetadata(Metadata metadata) Set the metadata in the cache entry.final voidsetRemoved(boolean removed) voidsetSkipLookup(boolean skipLookup) voidSets the value of the entry, returning the previous valuebooleantoString()final voidUpdate the previous value of the entry - set it to current value.
-
Field Details
-
key
-
value
-
created
protected long created -
lastUsed
protected long lastUsed -
flags
protected short flags -
metadata
-
internalMetadata
-
oldValue
-
oldMetadata
-
-
Constructor Details
-
ReadCommittedEntry
-
-
Method Details
-
setFlag
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<K,V> - Returns:
- retrieves the lifespan of this entry. -1 means an unlimited lifespan.
-
getMaxIdle
public final long getMaxIdle()- Specified by:
getMaxIdlein interfaceCacheEntry<K,V> - Returns:
- the maximum allowed time for which this entry can be idle, after which it is considered expired.
-
getKey
Description copied from interface:CacheEntryRetrieves the key to this entry -
getValue
Description copied from interface:CacheEntryRetrieves the value of this entry -
isNull
public final boolean isNull()Description copied from interface:CacheEntryTests whether the entry represents a null value, typically used for repeatable read.- Specified by:
isNullin interfaceCacheEntry<K,V> - Returns:
- true if this represents a null, false otherwise.
-
commit
Description copied from interface:CacheEntryCommits changes- Specified by:
commitin interfaceCacheEntry<K,V> - Parameters:
container- data container to commit to
-
commit
-
isChanged
public final boolean isChanged()- Specified by:
isChangedin interfaceCacheEntry<K,V> - 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<K,V> - Specified by:
setChangedin interfaceMVCCEntry<K,V>
-
setSkipLookup
public void setSkipLookup(boolean skipLookup) Description copied from interface:CacheEntry- Specified by:
setSkipLookupin interfaceCacheEntry<K,V>
-
skipLookup
public boolean skipLookup()- Specified by:
skipLookupin interfaceCacheEntry<K,V> - Returns:
trueif the value must not be fetch from an external source
-
getCreated
public long getCreated()- Specified by:
getCreatedin interfaceCacheEntry<K,V> - Returns:
- timestamp when the entry was created
-
getLastUsed
public long getLastUsed()- Specified by:
getLastUsedin interfaceCacheEntry<K,V> - Returns:
- timestamp when the entry was last used
-
setValue
Description copied from interface:CacheEntrySets the value of the entry, returning the previous value -
getMetadata
Description copied from interface:MetadataAwareGet metadata of this cache entry.- Specified by:
getMetadatain interfaceMetadataAware- Returns:
- a Metadata instance
-
setMetadata
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<K,V> - Returns:
- true if this entry has been newly created, false otherwise.
-
setCreated
public final void setCreated(boolean created) - Specified by:
setCreatedin interfaceCacheEntry<K,V>
-
isRemoved
public boolean isRemoved()- Specified by:
isRemovedin interfaceCacheEntry<K,V> - Returns:
- true if this entry has been removed since being read from the container, false otherwise.
-
isEvicted
public boolean isEvicted()- Specified by:
isEvictedin interfaceCacheEntry<K,V> - 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<K,V>
-
isCommitted
public boolean isCommitted()- Specified by:
isCommittedin interfaceMVCCEntry<K,V> - Returns:
- True if this context entry has been committed to the
DataContainer
-
isLoaded
public boolean isLoaded() -
setLoaded
public void setLoaded(boolean loaded) -
resetCurrentValue
public void resetCurrentValue()Description copied from interface:MVCCEntryReset the current value of the entry to the value before the command was executed the first time. This is invoked before the command is retried.- Specified by:
resetCurrentValuein interfaceMVCCEntry<K,V>
-
updatePreviousValue
public final 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 successfully finished (there won't be any more retries) or when the value was updated from external source.- Specified by:
updatePreviousValuein interfaceMVCCEntry<K,V>
-
getOldValue
- Specified by:
getOldValuein interfaceMVCCEntry<K,V> - Returns:
- The previous value.
-
getOldMetadata
- Specified by:
getOldMetadatain interfaceMVCCEntry<K,V> - Returns:
- The previous metadata.
-
setRemoved
public final void setRemoved(boolean removed) - Specified by:
setRemovedin interfaceCacheEntry<K,V>
-
setEvicted
public void setEvicted(boolean evicted) - Specified by:
setEvictedin interfaceCacheEntry<K,V>
-
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<K,V> - Parameters:
expired- whether or not this entry should be expired
-
clone
-
setCreated
public void setCreated(long created) - Specified by:
setCreatedin interfaceCacheEntry<K,V>
-
setLastUsed
public void setLastUsed(long lastUsed) - Specified by:
setLastUsedin interfaceCacheEntry<K,V>
-
getInternalMetadata
- Specified by:
getInternalMetadatain interfaceCacheEntry<K,V>
-
setInternalMetadata
- Specified by:
setInternalMetadatain interfaceCacheEntry<K,V>
-
toString
-