Interface ClientSession


  • public interface ClientSession
    Class ClientSession represents a client connection on the server. ClientSessions can be used from the cache server to perform interest registrations and unregistrations on behalf of clients. ClientSessions are only available on the cache server.

    The ClientSession is often used in conjunction with a callback EntryEvent as shown below.

     String durableClientId = ...; // Some part of the event's key or value would contain this id
     Cache cache = CacheFactory.getAnyInstance();
     CacheServer cacheServer = (CacheServer) cache.getCacheServers().iterator().next();
     ClientSession clientSession = cacheServer.getClientSession(durableClientId);
     clientSession.registerInterest(event.getRegion().getFullPath(), event.getKey(), InterestResultPolicy.KEYS_VALUES, true);
     
    Since:
    GemFire 6.0
    See Also:
    getClientSession, getClientSession
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean isPrimary()
      Returns whether this server is the primary for this client
      void registerInterest​(java.lang.String regionName, java.lang.Object keyOfInterest, InterestResultPolicy policy, boolean isDurable)
      Registers interest in a particular region and key
      void registerInterest​(java.lang.String regionName, java.lang.Object keyOfInterest, InterestResultPolicy policy, boolean isDurable, boolean receiveValues)
      Registers interest in a particular region and key
      void registerInterestRegex​(java.lang.String regionName, java.lang.String regex, boolean isDurable)
      Registers interest in a particular region and regular expression
      void registerInterestRegex​(java.lang.String regionName, java.lang.String regex, boolean isDurable, boolean receiveValues)
      Registers interest in a particular region and regular expression
      void unregisterInterest​(java.lang.String regionName, java.lang.Object keyOfInterest, boolean isDurable)
      Unregisters interest in a particular region and key
      void unregisterInterest​(java.lang.String regionName, java.lang.Object keyOfInterest, boolean isDurable, boolean receiveValues)
      Unregisters interest in a particular region and key
      void unregisterInterestRegex​(java.lang.String regionName, java.lang.String regex, boolean isDurable)
      Unregisters interest in a particular region and regular expression
      void unregisterInterestRegex​(java.lang.String regionName, java.lang.String regex, boolean isDurable, boolean receiveValues)
      Unregisters interest in a particular region and regular expression
    • Method Detail

      • registerInterest

        void registerInterest​(java.lang.String regionName,
                              java.lang.Object keyOfInterest,
                              InterestResultPolicy policy,
                              boolean isDurable)
        Registers interest in a particular region and key
        Parameters:
        regionName - The name of the region in which to register interest
        keyOfInterest - The key on which to register interest
        policy - The InterestResultPolicy. Note: For the special token 'ALL_KEYS' and lists of keys, values are not pushed to the client.
        isDurable - Whether the interest is durable
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
      • registerInterest

        void registerInterest​(java.lang.String regionName,
                              java.lang.Object keyOfInterest,
                              InterestResultPolicy policy,
                              boolean isDurable,
                              boolean receiveValues)
        Registers interest in a particular region and key
        Parameters:
        regionName - The name of the region in which to register interest
        keyOfInterest - The key to on which to register interest
        policy - The InterestResultPolicy. Note: For the special token 'ALL_KEYS' and lists of keys, values are not pushed to the client.
        isDurable - Whether the interest is durable
        receiveValues - Whether to receive create or update events as invalidates similar to notify-by-subscription false. The default is true.
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
        Since:
        GemFire 6.5
      • registerInterestRegex

        void registerInterestRegex​(java.lang.String regionName,
                                   java.lang.String regex,
                                   boolean isDurable)
        Registers interest in a particular region and regular expression
        Parameters:
        regionName - The name of the region in which to register interest
        regex - The regular expression on which to register interest
        isDurable - Whether the interest is durable
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
      • registerInterestRegex

        void registerInterestRegex​(java.lang.String regionName,
                                   java.lang.String regex,
                                   boolean isDurable,
                                   boolean receiveValues)
        Registers interest in a particular region and regular expression
        Parameters:
        regionName - The name of the region in which to register interest
        regex - The regular expression to on which to register interest
        isDurable - Whether the interest is durable
        receiveValues - Whether to receive create or update events as invalidates similar to notify-by-subscription false. The default is true.
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
        Since:
        GemFire 6.5
      • unregisterInterest

        void unregisterInterest​(java.lang.String regionName,
                                java.lang.Object keyOfInterest,
                                boolean isDurable)
        Unregisters interest in a particular region and key
        Parameters:
        regionName - The name of the region in which to unregister interest
        keyOfInterest - The key on which to unregister interest
        isDurable - Whether the interest is durable
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
      • unregisterInterest

        void unregisterInterest​(java.lang.String regionName,
                                java.lang.Object keyOfInterest,
                                boolean isDurable,
                                boolean receiveValues)
        Unregisters interest in a particular region and key
        Parameters:
        regionName - The name of the region in which to unregister interest
        keyOfInterest - The key on which to unregister interest
        isDurable - Whether the interest is durable
        receiveValues - Whether to receive create or update events as invalidates similar to notify-by-subscription false. The default is true.
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
        Since:
        GemFire 6.5
      • unregisterInterestRegex

        void unregisterInterestRegex​(java.lang.String regionName,
                                     java.lang.String regex,
                                     boolean isDurable)
        Unregisters interest in a particular region and regular expression
        Parameters:
        regionName - The name of the region in which to unregister interest
        regex - The regular expression on which to unregister interest
        isDurable - Whether the interest is durable
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
      • unregisterInterestRegex

        void unregisterInterestRegex​(java.lang.String regionName,
                                     java.lang.String regex,
                                     boolean isDurable,
                                     boolean receiveValues)
        Unregisters interest in a particular region and regular expression
        Parameters:
        regionName - The name of the region in which to unregister interest
        regex - The regular expression on which to unregister interest
        isDurable - Whether the interest is durable
        receiveValues - Whether to receive create or update events as invalidates similar to notify-by-subscription false. The default is true.
        Throws:
        java.lang.IllegalStateException - if this is not the primary server for the given client
        Since:
        GemFire 6.5
      • isPrimary

        boolean isPrimary()
        Returns whether this server is the primary for this client
        Returns:
        whether this server is the primary for this client