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

public class ReadCommittedEntry<K,V> extends Object implements MVCCEntry<K,V>
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)
  • Field Details

    • key

      protected K key
    • value

      protected V value
    • created

      protected long created
    • lastUsed

      protected long lastUsed
    • flags

      protected short flags
    • metadata

      protected Metadata metadata
    • internalMetadata

      protected PrivateMetadata internalMetadata
    • oldValue

      protected V oldValue
    • oldMetadata

      protected Metadata oldMetadata
  • Constructor Details

    • ReadCommittedEntry

      public ReadCommittedEntry(K key, V value, Metadata metadata)
  • Method Details

    • 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 interface CacheEntry<K,V>
      Returns:
      retrieves the lifespan of this entry. -1 means an unlimited lifespan.
    • getMaxIdle

      public final long getMaxIdle()
      Specified by:
      getMaxIdle in interface CacheEntry<K,V>
      Returns:
      the maximum allowed time for which this entry can be idle, after which it is considered expired.
    • getKey

      public final K getKey()
      Description copied from interface: CacheEntry
      Retrieves the key to this entry
      Specified by:
      getKey in interface CacheEntry<K,V>
      Specified by:
      getKey in interface Map.Entry<K,V>
      Returns:
      a key
    • getValue

      public final V getValue()
      Description copied from interface: CacheEntry
      Retrieves the value of this entry
      Specified by:
      getValue in interface CacheEntry<K,V>
      Specified by:
      getValue in interface Map.Entry<K,V>
      Returns:
      the value of the 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 interface CacheEntry<K,V>
      Returns:
      true if this represents a null, false otherwise.
    • commit

      public void commit(DataContainer<K,V> container)
      Description copied from interface: CacheEntry
      Commits changes
      Specified by:
      commit in interface CacheEntry<K,V>
      Parameters:
      container - data container to commit to
    • commit

      public CompletionStage<Void> commit(int segment, InternalDataContainer<K,V> container)
    • isChanged

      public final boolean isChanged()
      Specified by:
      isChanged in interface CacheEntry<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 interface CacheEntry<K,V>
      Specified by:
      setChanged in interface MVCCEntry<K,V>
    • setSkipLookup

      public void setSkipLookup(boolean skipLookup)
      Description copied from interface: CacheEntry
      Specified by:
      setSkipLookup in interface CacheEntry<K,V>
    • skipLookup

      public boolean skipLookup()
      Specified by:
      skipLookup in interface CacheEntry<K,V>
      Returns:
      true if the value must not be fetch from an external source
    • getCreated

      public long getCreated()
      Specified by:
      getCreated in interface CacheEntry<K,V>
      Returns:
      timestamp when the entry was created
    • getLastUsed

      public long getLastUsed()
      Specified by:
      getLastUsed in interface CacheEntry<K,V>
      Returns:
      timestamp when the entry was last used
    • setValue

      public V setValue(V value)
      Description copied from interface: CacheEntry
      Sets the value of the entry, returning the previous value
      Specified by:
      setValue in interface CacheEntry<K,V>
      Specified by:
      setValue in interface Map.Entry<K,V>
      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 interface MetadataAware
      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 interface MetadataAware
      Parameters:
      metadata - to apply to the cache entry
    • isCreated

      public final boolean isCreated()
      Specified by:
      isCreated in interface CacheEntry<K,V>
      Returns:
      true if this entry has been newly created, false otherwise.
    • setCreated

      public final void setCreated(boolean created)
      Specified by:
      setCreated in interface CacheEntry<K,V>
    • isRemoved

      public boolean isRemoved()
      Specified by:
      isRemoved in interface CacheEntry<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 interface CacheEntry<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
      Specified by:
      isExpired in interface MVCCEntry<K,V>
      Returns:
      whether expired has been set
    • setCommitted

      public void setCommitted()
      Description copied from interface: MVCCEntry
      Mark this context-entry as already committed to the DataContainer.
      Specified by:
      setCommitted in interface MVCCEntry<K,V>
    • isCommitted

      public boolean isCommitted()
      Specified by:
      isCommitted in interface MVCCEntry<K,V>
      Returns:
      True if this context entry has been committed to the DataContainer
    • isLoaded

      public boolean isLoaded()
      Specified by:
      isLoaded in interface MVCCEntry<K,V>
      Returns:
      True if we've checked persistence for presence of this entry.
    • isSkipSharedStore

      public boolean isSkipSharedStore()
      Specified by:
      isSkipSharedStore in interface MVCCEntry<K,V>
      Returns:
      True if this entry should non be written to shared persistence
    • setLoaded

      public void setLoaded(boolean loaded)
      Specified by:
      setLoaded in interface MVCCEntry<K,V>
    • 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 interface MVCCEntry<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 interface MVCCEntry<K,V>
    • getOldValue

      public final V getOldValue()
      Specified by:
      getOldValue in interface MVCCEntry<K,V>
      Returns:
      The previous value.
    • getOldMetadata

      public final Metadata getOldMetadata()
      Specified by:
      getOldMetadata in interface MVCCEntry<K,V>
      Returns:
      The previous metadata.
    • setRemoved

      public final void setRemoved(boolean removed)
      Specified by:
      setRemoved in interface CacheEntry<K,V>
    • setEvicted

      public void setEvicted(boolean evicted)
      Specified by:
      setEvicted in interface CacheEntry<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 interface MVCCEntry<K,V>
      Parameters:
      expired - whether or not this entry should be expired
    • setSkipSharedStore

      public void setSkipSharedStore()
      Specified by:
      setSkipSharedStore in interface MVCCEntry<K,V>
    • clone

      public ReadCommittedEntry<K,V> clone()
      Specified by:
      clone in interface CacheEntry<K,V>
      Specified by:
      clone in interface MVCCEntry<K,V>
      Overrides:
      clone in class Object
    • setCreated

      public void setCreated(long created)
      Specified by:
      setCreated in interface CacheEntry<K,V>
    • setLastUsed

      public void setLastUsed(long lastUsed)
      Specified by:
      setLastUsed in interface CacheEntry<K,V>
    • getInternalMetadata

      public PrivateMetadata getInternalMetadata()
      Specified by:
      getInternalMetadata in interface CacheEntry<K,V>
    • setInternalMetadata

      public void setInternalMetadata(PrivateMetadata metadata)
      Specified by:
      setInternalMetadata in interface CacheEntry<K,V>
    • toString

      public String toString()
      Overrides:
      toString in class Object