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
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
commit
(int segment, InternalDataContainer<K, V> container) void
commit
(DataContainer<K, V> container) Commits changeslong
final K
getKey()
Retrieves the key to this entrylong
final long
final long
Get metadata of this cache entry.final Metadata
final V
final V
getValue()
Retrieves the value of this entryfinal boolean
boolean
final boolean
boolean
boolean
Returns whether this entry was marked as being expired or notboolean
isLoaded()
final boolean
isNull()
Tests whether the entry represents a null value, typically used for repeatable read.boolean
boolean
void
Reset the current value of the entry to the value before the command was executed the first time.final void
setChanged
(boolean changed) void
Mark this context-entry as already committed to theDataContainer
.final void
setCreated
(boolean created) void
setCreated
(long created) void
setEvicted
(boolean evicted) void
setExpired
(boolean expired) Marks this entry as being expired.protected final void
Utility method that sets the value of the given flag to true.void
setInternalMetadata
(PrivateMetadata metadata) void
setLastUsed
(long lastUsed) void
setLoaded
(boolean loaded) void
setMetadata
(Metadata metadata) Set the metadata in the cache entry.final void
setRemoved
(boolean removed) void
setSkipLookup
(boolean skipLookup) void
Sets the value of the entry, returning the previous valueboolean
toString()
final void
Update 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:
getLifespan
in interfaceCacheEntry<K,
V> - Returns:
- retrieves the lifespan of this entry. -1 means an unlimited lifespan.
-
getMaxIdle
public final long getMaxIdle()- Specified by:
getMaxIdle
in 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:CacheEntry
Retrieves the key to this entry -
getValue
Description copied from interface:CacheEntry
Retrieves the value of this entry -
isNull
public final boolean isNull()Description copied from interface:CacheEntry
Tests whether the entry represents a null value, typically used for repeatable read.- Specified by:
isNull
in interfaceCacheEntry<K,
V> - Returns:
- true if this represents a null, false otherwise.
-
commit
Description copied from interface:CacheEntry
Commits changes- Specified by:
commit
in interfaceCacheEntry<K,
V> - Parameters:
container
- data container to commit to
-
commit
-
isChanged
public final boolean isChanged()- Specified by:
isChanged
in 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:
setChanged
in interfaceCacheEntry<K,
V> - Specified by:
setChanged
in interfaceMVCCEntry<K,
V>
-
setSkipLookup
public void setSkipLookup(boolean skipLookup) Description copied from interface:CacheEntry
- Specified by:
setSkipLookup
in interfaceCacheEntry<K,
V>
-
skipLookup
public boolean skipLookup()- Specified by:
skipLookup
in interfaceCacheEntry<K,
V> - Returns:
true
if the value must not be fetch from an external source
-
getCreated
public long getCreated()- Specified by:
getCreated
in interfaceCacheEntry<K,
V> - Returns:
- timestamp when the entry was created
-
getLastUsed
public long getLastUsed()- Specified by:
getLastUsed
in interfaceCacheEntry<K,
V> - Returns:
- timestamp when the entry was last used
-
setValue
Description copied from interface:CacheEntry
Sets the value of the entry, returning the previous value -
getMetadata
Description copied from interface:MetadataAware
Get metadata of this cache entry.- Specified by:
getMetadata
in interfaceMetadataAware
- Returns:
- a Metadata instance
-
setMetadata
Description copied from interface:MetadataAware
Set the metadata in the cache entry.- Specified by:
setMetadata
in interfaceMetadataAware
- Parameters:
metadata
- to apply to the cache entry
-
isCreated
public final boolean isCreated()- Specified by:
isCreated
in interfaceCacheEntry<K,
V> - Returns:
- true if this entry has been newly created, false otherwise.
-
setCreated
public final void setCreated(boolean created) - Specified by:
setCreated
in interfaceCacheEntry<K,
V>
-
isRemoved
public boolean isRemoved()- Specified by:
isRemoved
in 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:
isEvicted
in 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:MVCCEntry
Returns whether this entry was marked as being expired or not -
setCommitted
public void setCommitted()Description copied from interface:MVCCEntry
Mark this context-entry as already committed to theDataContainer
.- Specified by:
setCommitted
in interfaceMVCCEntry<K,
V>
-
isCommitted
public boolean isCommitted()- Specified by:
isCommitted
in 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:MVCCEntry
Reset 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:
resetCurrentValue
in interfaceMVCCEntry<K,
V>
-
updatePreviousValue
public final void updatePreviousValue()Description copied from interface:MVCCEntry
Update 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:
updatePreviousValue
in interfaceMVCCEntry<K,
V>
-
getOldValue
- Specified by:
getOldValue
in interfaceMVCCEntry<K,
V> - Returns:
- The previous value.
-
getOldMetadata
- Specified by:
getOldMetadata
in interfaceMVCCEntry<K,
V> - Returns:
- The previous metadata.
-
setRemoved
public final void setRemoved(boolean removed) - Specified by:
setRemoved
in interfaceCacheEntry<K,
V>
-
setEvicted
public void setEvicted(boolean evicted) - Specified by:
setEvicted
in interfaceCacheEntry<K,
V>
-
setExpired
public void setExpired(boolean expired) Description copied from interface:MVCCEntry
Marks this entry as being expired. This is a special form of removal.- Specified by:
setExpired
in interfaceMVCCEntry<K,
V> - Parameters:
expired
- whether or not this entry should be expired
-
clone
-
setCreated
public void setCreated(long created) - Specified by:
setCreated
in interfaceCacheEntry<K,
V>
-
setLastUsed
public void setLastUsed(long lastUsed) - Specified by:
setLastUsed
in interfaceCacheEntry<K,
V>
-
getInternalMetadata
- Specified by:
getInternalMetadata
in interfaceCacheEntry<K,
V>
-
setInternalMetadata
- Specified by:
setInternalMetadata
in interfaceCacheEntry<K,
V>
-
toString
-