Class GroupMember

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class GroupMember
    extends java.lang.Object
    implements java.io.Closeable
    Group membership management. Adds this instance into a group and keeps a cache of members in the group
    • Constructor Summary

      Constructors 
      Constructor Description
      GroupMember​(org.apache.curator.framework.CuratorFramework client, java.lang.String membershipPath, java.lang.String thisId)  
      GroupMember​(org.apache.curator.framework.CuratorFramework client, java.lang.String membershipPath, java.lang.String thisId, byte[] payload)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Have thisId leave the group and stop caching membership
      java.util.Map<java.lang.String,​byte[]> getCurrentMembers()
      Return the current view of membership.
      java.lang.String idFromPath​(java.lang.String path)
      Given a full ZNode path, return the member ID
      protected PathChildrenCache newPathChildrenCache​(org.apache.curator.framework.CuratorFramework client, java.lang.String membershipPath)  
      protected PersistentEphemeralNode newPersistentEphemeralNode​(org.apache.curator.framework.CuratorFramework client, java.lang.String membershipPath, java.lang.String thisId, byte[] payload)  
      void setThisData​(byte[] data)
      Change the data stored in this instance's node
      void start()
      Start the group membership.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GroupMember

        public GroupMember​(org.apache.curator.framework.CuratorFramework client,
                           java.lang.String membershipPath,
                           java.lang.String thisId)
        Parameters:
        client - client
        membershipPath - the path to use for membership
        thisId - ID of this group member. MUST be unique for the group
      • GroupMember

        public GroupMember​(org.apache.curator.framework.CuratorFramework client,
                           java.lang.String membershipPath,
                           java.lang.String thisId,
                           byte[] payload)
        Parameters:
        client - client
        membershipPath - the path to use for membership
        thisId - ID of this group member. MUST be unique for the group
        payload - the payload to write in our member node
    • Method Detail

      • start

        public void start()
        Start the group membership. Register thisId as a member and begin caching all members
      • setThisData

        public void setThisData​(byte[] data)
        Change the data stored in this instance's node
        Parameters:
        data - new data (cannot be null)
      • close

        public void close()
        Have thisId leave the group and stop caching membership
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • getCurrentMembers

        public java.util.Map<java.lang.String,​byte[]> getCurrentMembers()
        Return the current view of membership. The keys are the IDs of the members. The values are each member's payload
        Returns:
        membership
      • idFromPath

        public java.lang.String idFromPath​(java.lang.String path)
        Given a full ZNode path, return the member ID
        Parameters:
        path - full ZNode path
        Returns:
        id
      • newPersistentEphemeralNode

        protected PersistentEphemeralNode newPersistentEphemeralNode​(org.apache.curator.framework.CuratorFramework client,
                                                                     java.lang.String membershipPath,
                                                                     java.lang.String thisId,
                                                                     byte[] payload)
      • newPathChildrenCache

        protected PathChildrenCache newPathChildrenCache​(org.apache.curator.framework.CuratorFramework client,
                                                         java.lang.String membershipPath)