Class 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.DistributedStateCache
    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.

    Version:
    $Revision$
    Author:
    Shreedhar Ganapathy Date: June 20, 2006
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addToCache​(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state)  
      void addToCache​(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state)  
      void addToLocalCache​(com.sun.enterprise.ee.cms.core.GMSCacheable cKey, java.lang.Object state)  
      void addToLocalCache​(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, byte[] state)  
      void addToLocalCache​(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key, java.io.Serializable state)  
      boolean contains​(java.lang.Object key)  
      boolean contains​(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.Object getFromCache​(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)  
      boolean isFirstSyncDone()  
      void removeAll()
      Empties the DistributedStateCache.
      void removeAllForMember​(java.lang.String memberToken)  
      void removeFromCache​(java.lang.String componentName, java.lang.String memberTokenId, java.io.Serializable key)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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:
        addToCache in interface com.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:
        addToLocalCache in interface com.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:
        toString in class java.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:
        removeFromCache in interface com.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:
        getFromCache in interface com.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:
        getAllCache in interface com.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:
        getFromCacheForPattern in interface com.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:
        getFromCache in interface com.sun.enterprise.ee.cms.core.DistributedStateCache
      • contains

        public boolean contains​(java.lang.Object key)
        Specified by:
        contains in interface com.sun.enterprise.ee.cms.core.DistributedStateCache
      • contains

        public boolean contains​(java.lang.String componentName,
                                java.lang.Object key)
        Specified by:
        contains in interface com.sun.enterprise.ee.cms.core.DistributedStateCache
      • isFirstSyncDone

        public boolean isFirstSyncDone()
        Specified by:
        isFirstSyncDone in interface com.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:
        removeAll in interface com.sun.enterprise.ee.cms.core.DistributedStateCache
      • removeAllForMember

        public void removeAllForMember​(java.lang.String memberToken)
        Specified by:
        removeAllForMember in interface com.sun.enterprise.ee.cms.core.DistributedStateCache