org.infinispan.container.entries
Class ReadCommittedEntry

java.lang.Object
  extended by org.infinispan.container.entries.ReadCommittedEntry
All Implemented Interfaces:
Map.Entry<Object,Object>, CacheEntry, MVCCEntry, StateChangingEntry, Versioned
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  Object oldValue
           
protected  Object value
           
 
Constructor Summary
protected ReadCommittedEntry()
           
  ReadCommittedEntry(Object key, Object value, EntryVersion version, long lifespan)
           
 
Method Summary
 void commit(DataContainer container, EntryVersion newVersion)
          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()
           
 byte getStateFlags()
           
 Object getValue()
          Retrieves the value of this entry
 EntryVersion getVersion()
           
 boolean isChanged()
           
 boolean isCreated()
           
 boolean isEvicted()
           
protected  boolean isFlagSet(ReadCommittedEntry.Flags flag)
          Tests whether a flag is set.
 boolean isLockPlaceholder()
           
 boolean isNull()
          Tests whether the entry represents a null value, typically used for repeatable read.
 boolean isRemoved()
           
 boolean isValid()
           
 void rollback()
          Rolls back changes
protected  void setChanged()
           
 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 setLifespan(long lifespan)
          Sets the lifespan of the entry.
 void setLockPlaceholder(boolean placeholder)
          Marks an entry as a lock placeholder
 void setMaxIdle(long maxIdle)
          Sets the maximum idle time of the entry.
 void setRemoved(boolean removed)
           
 void setValid(boolean valid)
           
 Object setValue(Object value)
          Sets the value of the entry, returning the previous value
 void setVersion(EntryVersion version)
          Sets the version on this entry.
 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
Constructor Detail

ReadCommittedEntry

protected ReadCommittedEntry()

ReadCommittedEntry

public ReadCommittedEntry(Object key,
                          Object value,
                          EntryVersion version,
                          long lifespan)
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.

setMaxIdle

public final void setMaxIdle(long maxIdle)
Description copied from interface: CacheEntry
Sets the maximum idle time of the entry.

Specified by:
setMaxIdle in interface CacheEntry
Parameters:
maxIdle - maxIdle to set

setLifespan

public final void setLifespan(long lifespan)
Description copied from interface: CacheEntry
Sets the lifespan of the entry.

Specified by:
setLifespan in interface CacheEntry
Parameters:
lifespan - lifespan to set

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.

setLockPlaceholder

public void setLockPlaceholder(boolean placeholder)
Description copied from interface: MVCCEntry
Marks an entry as a lock placeholder

Specified by:
setLockPlaceholder in interface MVCCEntry
Parameters:
placeholder - if true, the entry is marked as a lock placeholder. If false, the entry is un-marked as a placeholder.

commit

public final void commit(DataContainer container,
                         EntryVersion newVersion)
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

protected final void setChanged()

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

isLockPlaceholder

public boolean isLockPlaceholder()
Specified by:
isLockPlaceholder in interface CacheEntry
Returns:
true if this entry is a placeholder for the sake of acquiring a lock; and false if it is a real entry.

getVersion

public EntryVersion getVersion()
Specified by:
getVersion in interface Versioned
Returns:
the version of the entry. May be null if versioning is not supported, and must never be null if versioning is supported.

setVersion

public void setVersion(EntryVersion version)
Description copied from interface: Versioned
Sets the version on this entry.

Specified by:
setVersion in interface Versioned
Parameters:
version - version to set

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

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 © 2012 JBoss, a division of Red Hat. All Rights Reserved.