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
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, long lifespan)
           
 
Method Summary
 void commit(DataContainer container)
          Commits changes
 void copyForUpdate(DataContainer container, boolean writeSkewCheck)
          Makes internal copies of the entry for updates
 Object getKey()
          Retrieves the key to this entry
 long getLifespan()
           
 long getMaxIdle()
           
 Object getValue()
          Retrieves the value of this entry
 boolean isChanged()
           
 boolean isCreated()
           
protected  boolean isFlagSet(ReadCommittedEntry.Flags flag)
          Tests whether a flag is set.
 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)
           
protected  void setFlag(ReadCommittedEntry.Flags flag)
          Unility method that sets the value of the given flag to true.
 void setLifespan(long lifespan)
          Sets the lifespan of the entry.
 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, returing the previous value
 String toString()
           
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,
                          long lifespan)
Method Detail

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)
Unility 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, returing 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)
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

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.

setRemoved

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

toString

public String toString()
Overrides:
toString in class Object

Google Analytics

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