|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.enterprise.ee.cms.impl.jxta.DistributedStateCacheImpl
public class DistributedStateCacheImpl
Messaging 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.
Method Summary | |
---|---|
void |
addToCache(String componentName,
String memberTokenId,
Serializable key,
byte[] state)
|
void |
addToCache(String componentName,
String memberTokenId,
Serializable key,
Serializable state)
Caches a serializable object representing state to be cached. |
void |
addToLocalCache(GMSCacheable cKey,
Object state)
|
void |
addToLocalCache(String componentName,
String memberTokenId,
Serializable key,
byte[] state)
|
void |
addToLocalCache(String componentName,
String memberTokenId,
Serializable key,
Serializable state)
Locally caches a serializable object representing state to be cached. |
boolean |
contains(Object key)
returns true if the DSC contains an entry wherein the component key portion of the composite key in the DSC is the same as the key specified in the argument |
boolean |
contains(String componentName,
Object key)
returns true if the DSC contains an entry wherein the componentName and the componet key portion of the composite key in the DSC is the same as the parameters specified in the argument |
Map<GMSCacheable,Object> |
getAllCache()
returns the current cache state to caller. |
Map<GMSCacheable,Object> |
getFromCache(Object key)
returns a Map containing entries that are in the DSC where either the componentName or the memberToken or the key is the same as the key specified in the argument. |
Object |
getFromCache(String componentName,
String memberTokenId,
Serializable key)
retrieves the cache for the given composite key of component name, member token id and the key. |
Map<Serializable,Serializable> |
getFromCacheForPattern(String componentName,
String memberToken)
returns a Map containing key-value pairs matching entries that have keys with the given componentName and memberToken |
boolean |
isFirstSyncDone()
returns true if this cache has been sync'd with any other member For implementations that do not intend to have a synchronized cache on all members, this method can be a no-op |
void |
removeAll()
Empties the DistributedStateCache. |
void |
removeAllForMember(String memberToken)
Empties the DistributedStateCache entries pertaining to a particular member. |
void |
removeFromCache(String componentName,
String memberTokenId,
Serializable key)
removes an entry from the cache for the given composite key of the component name, member token id and the specific key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void addToCache(String componentName, String memberTokenId, Serializable key, Serializable state) throws GMSException
DistributedStateCache
addToCache
in interface DistributedStateCache
componentName
- - name of the GMS client component that is storing
this cachememberTokenId
- - member token Id of this memberkey
- - a serializable key that differentiates this cache from other
caches of the same component and member.state
- - a serializable object representing the cachable
state
GMSException
public void addToCache(String componentName, String memberTokenId, Serializable key, byte[] state) throws GMSException
GMSException
public void addToLocalCache(String componentName, String memberTokenId, Serializable key, Serializable state)
DistributedStateCache
addToLocalCache
in interface DistributedStateCache
componentName
- Name of GMS Client componentmemberTokenId
- Member's identitykey
- - an Objectstate
- - an Objectpublic void addToLocalCache(String componentName, String memberTokenId, Serializable key, byte[] state)
public void addToLocalCache(GMSCacheable cKey, Object state)
public void removeFromCache(String componentName, String memberTokenId, Serializable key) throws GMSException
DistributedStateCache
removeFromCache
in interface DistributedStateCache
componentName
- Name of GMS Client componentmemberTokenId
- Member's identitykey
- The component provided key
GMSException
public Object getFromCache(String componentName, String memberTokenId, Serializable key) throws GMSException
DistributedStateCache
getFromCache
in interface DistributedStateCache
componentName
- Name of GMS Client componentmemberTokenId
- Member's identitykey
- - a serializable key that differentiates this cache entry
from other cache entries.
GMSException
public Map<GMSCacheable,Object> getAllCache()
DistributedStateCache
getAllCache
in interface DistributedStateCache
public Map<Serializable,Serializable> getFromCacheForPattern(String componentName, String memberToken)
DistributedStateCache
getFromCacheForPattern
in interface DistributedStateCache
componentName
- Name of GMS Client componentmemberToken
- Member's identity
public Map<GMSCacheable,Object> getFromCache(Object key)
DistributedStateCache
getFromCache
in interface DistributedStateCache
key
- The key here is one of MemberToken, ComponentName, or the
component-provided key itself
public boolean contains(Object key)
DistributedStateCache
contains
in interface DistributedStateCache
key
- component-provided key
public boolean contains(String componentName, Object key)
DistributedStateCache
contains
in interface DistributedStateCache
componentName
- Name of componentkey
- component-provided key
public boolean isFirstSyncDone()
DistributedStateCache
isFirstSyncDone
in interface DistributedStateCache
public void removeAll()
removeAll
in interface DistributedStateCache
public void removeAllForMember(String memberToken)
DistributedStateCache
removeAllForMember
in interface DistributedStateCache
memberToken
- member's identity
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |