com.cloudtran.coherence.llapi
Class CTNamedCache

java.lang.Object
  extended by com.cloudtran.coherence.llapi.CTNamedCache

public class CTNamedCache
extends Object

An instance of this class is returned from CTCacheFactory's getCache() methods. It should not be used outside an ongoing transaction (this is checked by CTCacheFactory.getCache()).

In the first and simplest implementation, a single client node talks to multiple cache nodes through multiple CTNamedCaches.

Changes are driven from the client, with instructions sent to the cache nodes using entryProcessors. The entry processors return a committed and dirty value, which is recorded in ctTransactionObject.cohortFlushInfoCoh.

When the transaction is committed, the committed and dirty values are sent to the transaction manager.

In addition to the operations on transactional cache, this class also provides static methods to do enhanced operations that use transactional entries - currently, snapshot isolation level operations. This class only implements the CloudTran-specific methods from NamedCache. if you want to call methods other than those supported by CloudTran, use the standard non-transactional NamedCache.


Field Summary
static int MVCC_READ_RETRY_COUNT
           
static int MVCC_READ_RETRY_DELAY
           
 
Constructor Summary
CTNamedCache(NamedCache namedCache, CTSpringTransactionObject transactionObject)
          This constructor restricts access to the CTCacheFactory class.
 
Method Summary
 void addIndex(ValueExtractor arg0, boolean arg1, Comparator arg2)
           
 void addMapListener(MapListener listener)
           
 void addMapListener(MapListener listener, Filter filter, boolean fLite)
           
 void addMapListener(MapListener listener, Object oKey, boolean fLite)
           
 Object aggregate(Collection arg0, EntryAggregator arg1)
           
 Object aggregate(Filter arg0, EntryAggregator arg1)
           
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 void destroy()
           
 Set entrySet()
           
 Set entrySet(Filter arg0)
           
 Set entrySet(Filter arg0, Comparator arg1)
           
 boolean equals(Object o)
           
static String expiryMillisToString(long expiryMillis)
           
 Object get(Object key)
           
 Map getAll(Collection keys)
          TBD: handle transactional entries on MVCC-noClientCache and PL.
 String getCacheName()
           
 CacheService getCacheService()
           
 NamedCache getNamedCache()
           
 int hashCode()
           
 void invalidate()
           
 Object invoke(Object key, EntryProcessor applicationEP)
          This is the invoke method for the low-level API.
 Map invokeAll(Collection keys, EntryProcessor applicationEP)
           
 Map invokeAll(Filter arg0, EntryProcessor arg1)
          This method is not implemented for CloudTran (yet).
static Object invokeAndCommit(NamedCache cache, Object key, EntryProcessor applicationEP, CTxDefinition ctxDefinition)
          This is a "one-shot" entry processor invocation.
 boolean isActive()
           
 boolean isEmpty()
           
 boolean isMvcc()
           
 Set keySet()
           
 Set keySet(Filter arg0)
           
 boolean lock(Object arg0)
          This method calls the underlying Coherence NamedCache lock() method.
 boolean lock(Object arg0, long arg1)
          This method calls the underlying Coherence NamedCache lock() method.
 Object put(Object key, Object value)
          Put an object into the cache, using a CloudTran transaction.
 Object put(Object key, Object value, long expiryMillis)
          Put an object into the cache, using a CloudTran transaction.
 void putAll(Map m)
           
 Object putInner(Object key, Object value, long expiryMillis)
           
 void release()
           
 Object remove(Object key)
           
 void removeIndex(ValueExtractor arg0)
           
 void removeMapListener(MapListener listener)
           
 void removeMapListener(MapListener listener, Filter filter)
           
 void removeMapListener(MapListener listener, Object oKey)
           
 int size()
           
 String toString()
           
 boolean unlock(Object arg0)
           
 Collection values()
           
static MapListener wrapMapListenerIfNecessary(NamedCache cache, MapListener arg0, int ADDorREMOVE)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MVCC_READ_RETRY_COUNT

public static final int MVCC_READ_RETRY_COUNT

MVCC_READ_RETRY_DELAY

public static final int MVCC_READ_RETRY_DELAY
Constructor Detail

CTNamedCache

public CTNamedCache(NamedCache namedCache,
                    CTSpringTransactionObject transactionObject)
This constructor restricts access to the CTCacheFactory class.

Parameters:
namedCache - a distributed cache. Other caches may work, but they are not guaranteed in this version.
transactionObject - The link back to the Spring transaction object; must not be null.
Method Detail

getNamedCache

public NamedCache getNamedCache()

isMvcc

public boolean isMvcc()
Returns:
true if MVCC; false if Pessimistic Locking.

addIndex

public void addIndex(ValueExtractor arg0,
                     boolean arg1,
                     Comparator arg2)

addMapListener

public void addMapListener(MapListener listener,
                           Filter filter,
                           boolean fLite)

addMapListener

public void addMapListener(MapListener listener,
                           Object oKey,
                           boolean fLite)

addMapListener

public void addMapListener(MapListener listener)

aggregate

public Object aggregate(Collection arg0,
                        EntryAggregator arg1)

aggregate

public Object aggregate(Filter arg0,
                        EntryAggregator arg1)

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

clear

public void clear()

destroy

public void destroy()

entrySet

public Set entrySet()

entrySet

public Set entrySet(Filter arg0,
                    Comparator arg1)

entrySet

public Set entrySet(Filter arg0)

get

public Object get(Object key)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getAll

public Map getAll(Collection keys)
TBD: handle transactional entries on MVCC-noClientCache and PL. MVCC useClientCache is handled correctly.


getCacheName

public String getCacheName()

getCacheService

public CacheService getCacheService()

invoke

public Object invoke(Object key,
                     EntryProcessor applicationEP)
This is the invoke method for the low-level API. It will take an EntryProcessor and wrap it in a CTEPWrapper_PL This CTEPWrapper_PL will be sent over the wire in place the application EntryProcessor


invokeAll

public Map invokeAll(Collection keys,
                     EntryProcessor applicationEP)

invokeAll

public Map invokeAll(Filter arg0,
                     EntryProcessor arg1)
This method is not implemented for CloudTran (yet).


invokeAndCommit

public static Object invokeAndCommit(NamedCache cache,
                                     Object key,
                                     EntryProcessor applicationEP,
                                     CTxDefinition ctxDefinition)
This is a "one-shot" entry processor invocation. It

This is a static method, because you do not need to start a transaction on the calling thread.

You can call this method on a thread with an existing transaction, but that transaction is not used by this method. CloudTran starts a new transaction on the target node.

To use this method, the target node must be storage enabled for the CloudTran manager caches.

The reason for using this method is that it is more efficient that starting the transaction and then doing the invoke() because it avoids the network calls to start and commit the transaction.

Parameters:
cache - must not be null. The cache must be enabled on the same nodes as the CloudTran manager cache. The manager cache is distributed (i.e. partitioned; it has "<distributed-scheme> in the cache-config.xml) so the cache you specify must also be distributed.
key - must not be null.
ctxDefinition - may be null, in which case the default attributes are used.
applicationEP - must not be null. This is the entryProcessor that will be executed on the target node.

isActive

public boolean isActive()

isEmpty

public boolean isEmpty()

keySet

public Set keySet()

keySet

public Set keySet(Filter arg0)

lock

public boolean lock(Object arg0,
                    long arg1)
This method calls the underlying Coherence NamedCache lock() method. This call pays no attention to CloudTran data locks in Pessimistic Locking mode; the two locking schemes are completely orthogonal - they do not interact at all.

See Also:
ConcurrentMap

lock

public boolean lock(Object arg0)
This method calls the underlying Coherence NamedCache lock() method. This call pays no attention to CloudTran data locks in Pessimistic Locking mode; the two locking schemes are completely orthogonal - they do not interact at all.

See Also:
ConcurrentMap

put

public Object put(Object key,
                  Object value,
                  long expiryMillis)
Put an object into the cache, using a CloudTran transaction. If another transaction has got this locked, we will return a TransactionExceptionLockConflict


putInner

public Object putInner(Object key,
                       Object value,
                       long expiryMillis)

put

public Object put(Object key,
                  Object value)
           throws RuntimeException
Put an object into the cache, using a CloudTran transaction. If another transaction has got this locked, we will return a TransactionExceptionLockConflict

Throws:
RuntimeException

putAll

public void putAll(Map m)

release

public void release()

remove

public Object remove(Object key)

removeIndex

public void removeIndex(ValueExtractor arg0)

removeMapListener

public void removeMapListener(MapListener listener,
                              Filter filter)

removeMapListener

public void removeMapListener(MapListener listener,
                              Object oKey)

removeMapListener

public void removeMapListener(MapListener listener)

size

public int size()

unlock

public boolean unlock(Object arg0)

values

public Collection values()

wrapMapListenerIfNecessary

public static MapListener wrapMapListenerIfNecessary(NamedCache cache,
                                                     MapListener arg0,
                                                     int ADDorREMOVE)

invalidate

public void invalidate()

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

expiryMillisToString

public static String expiryMillisToString(long expiryMillis)