Class DistributedStateCacheImpl
- java.lang.Object
-
- com.sun.enterprise.ee.cms.impl.base.DistributedStateCacheImpl
-
- All Implemented Interfaces:
com.sun.enterprise.ee.cms.core.DistributedStateCache
public class DistributedStateCacheImpl extends java.lang.Object implements com.sun.enterprise.ee.cms.core.DistributedStateCacheMessaging based implementation of a shared distributed state cache(DSC). Every write entry made such as adding a new entry or removing an existing entry is disseminated to all group members through a message. Read-only operation i.e getFromCache() is a local call. During startup of a member, a singleton instance of this class is created. This instance is available to GMS client components in this member through GroupHandle.getDistributedStateCache() so that the client components can read or write to this cache.When an entry is added or removed, this implementation uses underlying GroupCommunicationProvider(GCP) to sends a message to the all members of the group. The recipients in turn call corresponding method for adding or removing the entry to/from their copy of the this DistributedStateCache implementation.
When new member joins the group, the join notification is received on every member. When this happens, and if this member is a leader of the group, then it uses the GCP's messaging api to sends a message to the new member to pass on the current state of this DSC. The remote member updates its DSC with this current state while returning its own state to this member through another message. This member updates its own DSC with this new entry resulting in all members getting this updated state. This brings the group-wide DSC into a synchronized state.
This initial sync-up is a heavy weight operation particularly during startup of the whole group concurrently as new members are joining the group rapidly. To prevent data loss during such times, each sync activity will require a blocking call to ensure that rapid group view changes during group startup will not result in data loss.
- Version:
- $Revision$
- Author:
- Shreedhar Ganapathy Date: June 20, 2006
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state)voidaddToCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state)voidaddToLocalCache(com.sun.enterprise.ee.cms.core.GMSCacheable cKey, java.lang.Object state)voidaddToLocalCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state)voidaddToLocalCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state)booleancontains(java.lang.Object key)booleancontains(java.lang.String componentName, java.lang.Object key)java.util.Map<com.sun.enterprise.ee.cms.core.GMSCacheable,java.lang.Object>getAllCache()java.util.Map<com.sun.enterprise.ee.cms.core.GMSCacheable,java.lang.Object>getFromCache(java.lang.Object key)java.lang.ObjectgetFromCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key)java.util.Map<java.io.Serializable,java.io.Serializable>getFromCacheForPattern(java.lang.String componentName, java.lang.String memberToken)booleanisFirstSyncDone()voidremoveAll()Empties the DistributedStateCache.voidremoveAllForMember(java.lang.String memberToken)voidremoveFromCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key)java.lang.StringtoString()
-
-
-
Method Detail
-
addToCache
public void addToCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state) throws com.sun.enterprise.ee.cms.core.GMSException- Specified by:
addToCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache- Throws:
com.sun.enterprise.ee.cms.core.GMSException
-
addToCache
public void addToCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state) throws com.sun.enterprise.ee.cms.core.GMSException- Throws:
com.sun.enterprise.ee.cms.core.GMSException
-
addToLocalCache
public void addToLocalCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state)- Specified by:
addToLocalCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
addToLocalCache
public void addToLocalCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state)
-
addToLocalCache
public void addToLocalCache(com.sun.enterprise.ee.cms.core.GMSCacheable cKey, java.lang.Object state)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
removeFromCache
public void removeFromCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key) throws com.sun.enterprise.ee.cms.core.GMSException- Specified by:
removeFromCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache- Throws:
com.sun.enterprise.ee.cms.core.GMSException
-
getFromCache
public java.lang.Object getFromCache(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key) throws com.sun.enterprise.ee.cms.core.GMSException- Specified by:
getFromCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache- Throws:
com.sun.enterprise.ee.cms.core.GMSException
-
getAllCache
public java.util.Map<com.sun.enterprise.ee.cms.core.GMSCacheable,java.lang.Object> getAllCache()
- Specified by:
getAllCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
getFromCacheForPattern
public java.util.Map<java.io.Serializable,java.io.Serializable> getFromCacheForPattern(java.lang.String componentName, java.lang.String memberToken)- Specified by:
getFromCacheForPatternin interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
getFromCache
public java.util.Map<com.sun.enterprise.ee.cms.core.GMSCacheable,java.lang.Object> getFromCache(java.lang.Object key)
- Specified by:
getFromCachein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
contains
public boolean contains(java.lang.Object key)
- Specified by:
containsin interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
contains
public boolean contains(java.lang.String componentName, java.lang.Object key)- Specified by:
containsin interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
isFirstSyncDone
public boolean isFirstSyncDone()
- Specified by:
isFirstSyncDonein interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
removeAll
public void removeAll()
Empties the DistributedStateCache. This is typically called in a group shutdown context so that the group's stale data is not retained for any later lives of the group.- Specified by:
removeAllin interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
removeAllForMember
public void removeAllForMember(java.lang.String memberToken)
- Specified by:
removeAllForMemberin interfacecom.sun.enterprise.ee.cms.core.DistributedStateCache
-
-