org.infinispan.container.entries
Class ReadCommittedEntry

java.lang.Object
  extended by org.infinispan.container.entries.ReadCommittedEntry
All Implemented Interfaces:
Map.Entry<Object,Object>, CacheEntry, MetadataAware, MVCCEntry, StateChangingEntry
Direct Known Subclasses:
RepeatableReadEntry

public class ReadCommittedEntry
extends 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
protected static class ReadCommittedEntry.Flags
           
 
Field Summary
protected  byte flags
           
protected  Object key
           
protected  Metadata metadata
           
protected  Object oldValue
           
protected  Object value
           
 
Constructor Summary
ReadCommittedEntry(Object key, Object value, Metadata metadata)
           
 
Method Summary
 void commit(DataContainer container, Metadata providedMetadata)
          Commits changes
 void copyForUpdate(DataContainer container, boolean writeSkewCheck)
          Makes internal copies of the entry for updates
 void copyStateFlagsFrom(StateChangingEntry other)
           
 Object getKey()
          Retrieves the key to this entry
 long getLifespan()
           
 long getMaxIdle()
           
 Metadata getMetadata()
          Get metadata of this cache entry.
 byte getStateFlags()
           
 Object getValue()
          Retrieves the value of this entry
 boolean isChanged()
           
 boolean isCreated()
           
 boolean isEvicted()
           
protected  boolean isFlagSet(ReadCommittedEntry.Flags flag)
          Tests whether a flag is set.
 boolean isLoaded()
           
 boolean isNull()
          Tests whether the entry represents a null value, typically used for repeatable read.
 boolean isRemoved()
           
 boolean isValid()
           
 void rollback()
          Rolls back changes
 void setChanged(boolean changed)
           
 void setCreated(boolean created)
           
 void setEvicted(boolean evicted)
           
protected  void setFlag(ReadCommittedEntry.Flags flag)
          Utility method that sets the value of the given flag to true.
 void setLoaded(boolean loaded)
           
 void setMetadata(Metadata metadata)
          Set the metadata in the cache entry.
 void setRemoved(boolean removed)
           
 void setValid(boolean valid)
           
 Object setValue(Object value)
          Sets the value of the entry, returning the previous value
 String toString()
           
 boolean undelete(boolean doUndelete)
          If the entry is marked as removed and doUndelete==true then the "valid" flag is set to true and "removed" flag is set to false.
protected  void unsetFlag(ReadCommittedEntry.Flags flag)
          Utility method that sets the value of the flag to false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map.Entry
equals, hashCode
 

Field Detail

key

protected Object key

value

protected Object value

oldValue

protected Object oldValue

flags

protected byte flags

metadata

protected Metadata metadata
Constructor Detail

ReadCommittedEntry

public ReadCommittedEntry(Object key,
                          Object value,
                          Metadata metadata)
Method Detail

getStateFlags

public byte getStateFlags()
Specified by:
getStateFlags in interface StateChangingEntry

copyStateFlagsFrom

public void copyStateFlagsFrom(StateChangingEntry other)
Specified by:
copyStateFlagsFrom in interface StateChangingEntry

isFlagSet

protected final boolean isFlagSet(ReadCommittedEntry.Flags flag)
Tests whether a flag is set.

Parameters:
flag - flag to test
Returns:
true if set, false otherwise.

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

unsetFlag

protected final void unsetFlag(ReadCommittedEntry.Flags flag)
Utility method that sets the value of the flag to false.

Parameters:
flag - flag to unset

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 Object getKey()
Description copied from interface: CacheEntry
Retrieves the key to this entry

Specified by:
getKey in interface Map.Entry<Object,Object>
Specified by:
getKey in interface CacheEntry
Returns:
a key

getValue

public final Object getValue()
Description copied from interface: CacheEntry
Retrieves the value of this entry

Specified by:
getValue in interface Map.Entry<Object,Object>
Specified by:
getValue in interface CacheEntry
Returns:
the value of the entry

setValue

public final Object setValue(Object value)
Description copied from interface: CacheEntry
Sets the value of the entry, returning the previous value

Specified by:
setValue in interface Map.Entry<Object,Object>
Specified by:
setValue in interface CacheEntry
Parameters:
value - value to set
Returns:
previous value

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.

copyForUpdate

public void copyForUpdate(DataContainer container,
                          boolean writeSkewCheck)
Description copied from interface: MVCCEntry
Makes internal copies of the entry for updates

Specified by:
copyForUpdate in interface MVCCEntry
Parameters:
container - data container
writeSkewCheck - if true, write skews are tested for and exceptions are thrown if detected. Only applicable to IsolationLevel.REPEATABLE_READ.

commit

public final void commit(DataContainer container,
                         Metadata providedMetadata)
Description copied from interface: CacheEntry
Commits changes

Specified by:
commit in interface CacheEntry
Parameters:
container - data container to commit to

rollback

public final void rollback()
Description copied from interface: CacheEntry
Rolls back changes

Specified by:
rollback in interface CacheEntry

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.

setChanged

public final void setChanged(boolean changed)
Specified by:
setChanged in interface CacheEntry
Specified by:
setChanged in interface MVCCEntry

isValid

public boolean isValid()
Specified by:
isValid in interface CacheEntry
Returns:
true if this entry is still valid, false otherwise.

setValid

public final void setValid(boolean valid)
Specified by:
setValid in interface CacheEntry

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
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.

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

isLoaded

public boolean isLoaded()
Specified by:
isLoaded in interface CacheEntry
Returns:
true if the entry was loaded from a cache store.

setLoaded

public void setLoaded(boolean loaded)
Specified by:
setLoaded in interface CacheEntry

toString

public String toString()
Overrides:
toString in class Object

undelete

public boolean undelete(boolean doUndelete)
Description copied from interface: CacheEntry
If the entry is marked as removed and doUndelete==true then the "valid" flag is set to true and "removed" flag is set to false.

Specified by:
undelete in interface CacheEntry

-->

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.