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

        public final long getMaxIdle()
        Specified by:
        getMaxIdle in interface CacheEntry
        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 interface CacheEntry
        Specified by:
        getKey in interface java.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 interface CacheEntry
        Specified by:
        getValue in interface java.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 interface CacheEntry
        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 interface CacheEntry
        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 interface CacheEntry
        Returns:
        true if this entry has changed since being read from the container, false otherwise.
      • skipLookup

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

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

        public long getLastUsed()
        Specified by:
        getLastUsed in interface CacheEntry
        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 interface CacheEntry
        Specified by:
        setValue in interface java.util.Map.Entry
        Parameters:
        value - value to set
        Returns:
        previous value
      • 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
        Returns:
        true if this entry has been newly created, false otherwise.
      • setCreated

        public final void setCreated​(boolean created)
        Specified by:
        setCreated in interface CacheEntry
      • isRemoved

        public boolean isRemoved()
        Specified by:
        isRemoved in interface CacheEntry
        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
        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
        Returns:
        whether expired has been set
      • isCommitted

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

        public boolean isLoaded()
        Specified by:
        isLoaded in interface MVCCEntry
        Returns:
        True if we've checked persistence for presence of this entry.
      • setLoaded

        public void setLoaded​(boolean loaded)
        Specified by:
        setLoaded in interface MVCCEntry
      • 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 interface MVCCEntry
      • 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 interface MVCCEntry
      • setRemoved

        public final void setRemoved​(boolean removed)
        Specified by:
        setRemoved in interface CacheEntry
      • setEvicted

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

        public void setCreated​(long created)
        Specified by:
        setCreated in interface CacheEntry
      • setLastUsed

        public void setLastUsed​(long lastUsed)
        Specified by:
        setLastUsed in interface CacheEntry
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object