org.codehaus.wadi.gridstate.impl
Class GCache

java.lang.Object
  extended byorg.codehaus.wadi.gridstate.impl.GCache
All Implemented Interfaces:
javax.cache.Cache, DispatcherConfig, Map, PartitionManagerConfig, StateManagerConfig

public class GCache
extends Object
implements javax.cache.Cache, DispatcherConfig, StateManagerConfig, PartitionManagerConfig

Geronimo is going to need a standard API for lookup of sessions across the Cluster. JCache is the obvious choice. This will allow the plugging of either e.g. GCache (WADI), Tangosol's Coherence or IPMs solution without changing of Geronimo code. In fact, this will allow WADI to sit on top of any of these three. GCache is a JCache compatible interface onto DIndex - WADI's own distributed index, which fulfills WADI's requirements for this lookup...

Author:
jules

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
protected  Dispatcher _dispatcher
           
protected  Log _log
           
protected  Map _map
           
protected  PartitionManager _partitionManager
           
protected  LockManager _pmSyncs
           
protected  LockManager _smSyncs
           
protected  StateManager _stateManager
           
protected  ThreadLocal _threadLocks
           
 
Constructor Summary
GCache(Dispatcher dispatcher, PartitionManager partitionManager, StateManager stateManager)
           
 
Method Summary
 void addListener(javax.cache.CacheListener listener)
           
protected  void addLock(Object key, Sync newSync)
           
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
           
 void evict()
           
 Object get(Object key)
           
 Map getAll(Collection keys)
           
 javax.cache.CacheEntry getCacheEntry(Object key)
           
 javax.cache.CacheStatistics getCacheStatistics()
           
 String getContextPath()
           
 Destination getLocalDestination()
           
 Map getMap()
           
 PartitionFacade getPartition(Object key)
           
 PartitionConfig getPartitionConfig()
           
 PartitionManager getPartitionManager()
           
 PartitionFacade[] getPartitions()
           
 LockManager getPMSyncs()
           
 LockManager getSMSyncs()
           
 StateManager getStateManager()
           
 void init()
           
 boolean isEmpty()
           
 Set keySet()
           
 void load(Object key)
           
 void loadAll(Collection keys)
           
 Object peek(Object key)
           
 Object put(Object key, Object value)
           
 Object put(Object key, Object value, boolean overwrite, boolean returnOldValue)
          Extension: Insert, globally, the key:value association only overwriting a previous value and returning it, if the relevant flags are passed in.
 void putAll(Map t)
           
 boolean putFirst(Object key, Object value)
          Extension: Insert, globally, the key:value association for the first time.
 void release()
           
 Object remove(Object key)
           
 Object remove(Object key, boolean returnOldValue)
          Remove the key's association globally, returning its current value if the flag is true.
 void removeListener(javax.cache.CacheListener listener)
           
 int size()
           
 void start()
           
 void stop()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

_log

protected final Log _log

_dispatcher

protected final Dispatcher _dispatcher

_partitionManager

protected final PartitionManager _partitionManager

_stateManager

protected final StateManager _stateManager

_map

protected final Map _map

_pmSyncs

protected final LockManager _pmSyncs

_smSyncs

protected final LockManager _smSyncs

_threadLocks

protected ThreadLocal _threadLocks
Constructor Detail

GCache

public GCache(Dispatcher dispatcher,
              PartitionManager partitionManager,
              StateManager stateManager)
       throws Exception
Method Detail

release

public void release()

addLock

protected void addLock(Object key,
                       Sync newSync)

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map

size

public int size()
Specified by:
size in interface Map

values

public Collection values()
Specified by:
values in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

getAll

public Map getAll(Collection keys)
           throws javax.cache.CacheException
Specified by:
getAll in interface javax.cache.Cache
Throws:
javax.cache.CacheException

load

public void load(Object key)
          throws javax.cache.CacheException
Specified by:
load in interface javax.cache.Cache
Throws:
javax.cache.CacheException

loadAll

public void loadAll(Collection keys)
             throws javax.cache.CacheException
Specified by:
loadAll in interface javax.cache.Cache
Throws:
javax.cache.CacheException

peek

public Object peek(Object key)
Specified by:
peek in interface javax.cache.Cache

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map

putFirst

public boolean putFirst(Object key,
                        Object value)
Extension: Insert, globally, the key:value association for the first time. This can be more efficient than a put(), as we can be sure that it will not have to return a value that is held remotely. Returns success if the insertion was able to occur (i.e. there was no value previously associated with this key).

Parameters:
key -
value -
Returns:

put

public Object put(Object key,
                  Object value,
                  boolean overwrite,
                  boolean returnOldValue)
Extension: Insert, globally, the key:value association only overwriting a previous value and returning it, if the relevant flags are passed in. If overwrite is true, returnOldValue will return any value previously associated with this key, else the insertion will occur and return Boolean.TRUE only if NO previous association exists otherwise Boolean.FALSE will be returned.

Parameters:
key -
value -
overwrite -
returnOldValue -
Returns:

getCacheEntry

public javax.cache.CacheEntry getCacheEntry(Object key)
Specified by:
getCacheEntry in interface javax.cache.Cache

getCacheStatistics

public javax.cache.CacheStatistics getCacheStatistics()
Specified by:
getCacheStatistics in interface javax.cache.Cache

remove

public Object remove(Object key)
Specified by:
remove in interface Map

remove

public Object remove(Object key,
                     boolean returnOldValue)
Remove the key's association globally, returning its current value if the flag is true. If the value is held remotely and not required, it will save bandwidth to pass in a value of false.

Parameters:
key -
returnOldValue -
Returns:

clear

public void clear()
Specified by:
clear in interface Map

evict

public void evict()
Specified by:
evict in interface javax.cache.Cache

addListener

public void addListener(javax.cache.CacheListener listener)
Specified by:
addListener in interface javax.cache.Cache

removeListener

public void removeListener(javax.cache.CacheListener listener)
Specified by:
removeListener in interface javax.cache.Cache

getPartitions

public PartitionFacade[] getPartitions()

getMap

public Map getMap()
Specified by:
getMap in interface StateManagerConfig

getPMSyncs

public LockManager getPMSyncs()
Specified by:
getPMSyncs in interface StateManagerConfig

getSMSyncs

public LockManager getSMSyncs()
Specified by:
getSMSyncs in interface StateManagerConfig

getPartitionConfig

public PartitionConfig getPartitionConfig()

getPartitionManager

public PartitionManager getPartitionManager()

getStateManager

public StateManager getStateManager()

start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Throws:
Exception

getPartition

public PartitionFacade getPartition(Object key)
Specified by:
getPartition in interface StateManagerConfig

getLocalDestination

public Destination getLocalDestination()
Specified by:
getLocalDestination in interface PartitionManagerConfig

init

public void init()
          throws Exception
Throws:
Exception

getContextPath

public String getContextPath()
Specified by:
getContextPath in interface DispatcherConfig


Copyright © 2004-2006 Core Developers Network Ltd.. All Rights Reserved.