Class GroupMember

java.lang.Object
org.apache.curator.framework.recipes.nodes.GroupMember
All Implemented Interfaces:
Closeable, AutoCloseable

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

    • GroupMember

      public GroupMember(CuratorFramework client, String membershipPath, 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(CuratorFramework client, String membershipPath, 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 Details

    • 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 AutoCloseable
      Specified by:
      close in interface Closeable
    • getCurrentMembers

      public Map<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 String idFromPath(String path)
      Given a full ZNode path, return the member ID
      Parameters:
      path - full ZNode path
      Returns:
      id