Package org.infinispan.container.entries
Class ReadCommittedEntry
- java.lang.Object
-
- org.infinispan.container.entries.ReadCommittedEntry
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.util.Map.Entry
,CacheEntry
,MetadataAware
,MVCCEntry
- Direct Known Subclasses:
RepeatableReadEntry
public class ReadCommittedEntry extends java.lang.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 class
ReadCommittedEntry.Flags
-
Constructor Summary
Constructors Constructor Description ReadCommittedEntry(java.lang.Object key, java.lang.Object value, Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadCommittedEntry
clone()
java.util.concurrent.CompletionStage<java.lang.Void>
commit(int segment, org.infinispan.container.impl.InternalDataContainer container)
void
commit(DataContainer container)
Commits changeslong
getCreated()
java.lang.Object
getKey()
Retrieves the key to this entrylong
getLastUsed()
long
getLifespan()
long
getMaxIdle()
Metadata
getMetadata()
Get metadata of this cache entry.java.lang.Object
getValue()
Retrieves the value of this entryboolean
isChanged()
boolean
isCommitted()
boolean
isCreated()
boolean
isEvicted()
boolean
isExpired()
Returns whether this entry was marked as being expired or notboolean
isLoaded()
boolean
isNull()
Tests whether the entry represents a null value, typically used for repeatable read.boolean
isRemoved()
void
resetCurrentValue()
Reset the current value of the entry to the value before the commmand was executed the first time.void
setChanged(boolean changed)
void
setCommitted()
Mark this context-entry as already committed to theDataContainer
.void
setCreated(boolean created)
void
setCreated(long created)
void
setEvicted(boolean evicted)
void
setExpired(boolean expired)
Marks this entry as being expired.protected void
setFlag(ReadCommittedEntry.Flags flag)
Utility method that sets the value of the given flag to true.void
setLastUsed(long lastUsed)
void
setLoaded(boolean loaded)
void
setMetadata(Metadata metadata)
Set the metadata in the cache entry.void
setRemoved(boolean removed)
void
setSkipLookup(boolean skipLookup)
java.lang.Object
setValue(java.lang.Object value)
Sets the value of the entry, returning the previous valueboolean
skipLookup()
java.lang.String
toString()
void
updatePreviousValue()
Update the previous value of the entry - set it to current value.
-
-
-
Field Detail
-
key
protected java.lang.Object key
-
value
protected java.lang.Object value
-
created
protected long created
-
lastUsed
protected long lastUsed
-
flags
protected short flags
-
metadata
protected Metadata metadata
-
-
Constructor Detail
-
ReadCommittedEntry
public ReadCommittedEntry(java.lang.Object key, java.lang.Object value, Metadata metadata)
-
-
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:
getLifespan
in interfaceCacheEntry
- Returns:
- retrieves the lifespan of this entry. -1 means an unlimited lifespan.
-
getMaxIdle
public final long getMaxIdle()
- Specified by:
getMaxIdle
in interfaceCacheEntry
- Returns:
- the maximum allowed time for which this entry can be idle, after which it is considered expired.
-
getKey
public final java.lang.Object getKey()
Description copied from interface:CacheEntry
Retrieves the key to this entry- Specified by:
getKey
in interfaceCacheEntry
- Specified by:
getKey
in interfacejava.util.Map.Entry
- Returns:
- a key
-
getValue
public final java.lang.Object getValue()
Description copied from interface:CacheEntry
Retrieves the value of this entry- Specified by:
getValue
in interfaceCacheEntry
- Specified by:
getValue
in interfacejava.util.Map.Entry
- Returns:
- the value of the entry
-
isNull
public 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
- Returns:
- true if this represents a null, false otherwise.
-
commit
public final void commit(DataContainer container)
Description copied from interface:CacheEntry
Commits changes- Specified by:
commit
in interfaceCacheEntry
- Parameters:
container
- data container to commit to
-
commit
public final java.util.concurrent.CompletionStage<java.lang.Void> commit(int segment, org.infinispan.container.impl.InternalDataContainer container)
-
isChanged
public final boolean isChanged()
- Specified by:
isChanged
in 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:
setChanged
in interfaceCacheEntry
- Specified by:
setChanged
in interfaceMVCCEntry
-
setSkipLookup
public void setSkipLookup(boolean skipLookup)
Description copied from interface:CacheEntry
- Specified by:
setSkipLookup
in interfaceCacheEntry
-
skipLookup
public boolean skipLookup()
- Specified by:
skipLookup
in interfaceCacheEntry
- Returns:
true
if the value must not be fetch from an external source
-
getCreated
public long getCreated()
- Specified by:
getCreated
in interfaceCacheEntry
- Returns:
- timestamp when the entry was created
-
getLastUsed
public long getLastUsed()
- Specified by:
getLastUsed
in interfaceCacheEntry
- Returns:
- timestamp when the entry was last used
-
setValue
public java.lang.Object setValue(java.lang.Object value)
Description copied from interface:CacheEntry
Sets the value of the entry, returning the previous value- Specified by:
setValue
in interfaceCacheEntry
- Specified by:
setValue
in interfacejava.util.Map.Entry
- Parameters:
value
- value to set- Returns:
- previous value
-
getMetadata
public Metadata getMetadata()
Description copied from interface:MetadataAware
Get metadata of this cache entry.- Specified by:
getMetadata
in interfaceMetadataAware
- Returns:
- a Metadata instance
-
setMetadata
public void setMetadata(Metadata metadata)
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
- Returns:
- true if this entry has been newly created, false otherwise.
-
setCreated
public final void setCreated(boolean created)
- Specified by:
setCreated
in interfaceCacheEntry
-
isRemoved
public boolean isRemoved()
- Specified by:
isRemoved
in interfaceCacheEntry
- 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
- 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
-
isCommitted
public boolean isCommitted()
- Specified by:
isCommitted
in interfaceMVCCEntry
- Returns:
- True if this context entry has been committed to the
DataContainer
-
isLoaded
public boolean isLoaded()
-
resetCurrentValue
public void resetCurrentValue()
Description copied from interface:MVCCEntry
Reset 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:
resetCurrentValue
in interfaceMVCCEntry
-
updatePreviousValue
public 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 successfuly finished (there won't be any more retries) or when the value was updated from external source.- Specified by:
updatePreviousValue
in interfaceMVCCEntry
-
setRemoved
public final void setRemoved(boolean removed)
- Specified by:
setRemoved
in interfaceCacheEntry
-
setEvicted
public void setEvicted(boolean evicted)
- Specified by:
setEvicted
in interfaceCacheEntry
-
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
- Parameters:
expired
- whether or not this entry should be expired
-
clone
public ReadCommittedEntry clone()
- Specified by:
clone
in interfaceCacheEntry
- Specified by:
clone
in interfaceMVCCEntry
- Overrides:
clone
in classjava.lang.Object
-
setCreated
public void setCreated(long created)
- Specified by:
setCreated
in interfaceCacheEntry
-
setLastUsed
public void setLastUsed(long lastUsed)
- Specified by:
setLastUsed
in interfaceCacheEntry
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-