Class DelegateZooKeeperGroup<T extends NodeState>

java.lang.Object
org.apache.camel.component.zookeepermaster.group.internal.DelegateZooKeeperGroup<T>
All Implemented Interfaces:
Closeable, AutoCloseable, Group<T>
Direct Known Subclasses:
DelegateZooKeeperMultiGroup

public class DelegateZooKeeperGroup<T extends NodeState> extends Object implements Group<T>
  • Constructor Details

    • DelegateZooKeeperGroup

      public DelegateZooKeeperGroup(String path, Class<T> clazz)
  • Method Details

    • useCurator

      public void useCurator(org.apache.curator.framework.CuratorFramework curator)
    • createGroup

      protected Group<T> createGroup(org.apache.curator.framework.CuratorFramework client, String path, Class<T> clazz)
    • add

      public void add(GroupListener<T> listener)
      Description copied from interface: Group
      Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.
      Specified by:
      add in interface Group<T extends NodeState>
    • remove

      public void remove(GroupListener<T> listener)
      Description copied from interface: Group
      Removes a previously added listener.
      Specified by:
      remove in interface Group<T extends NodeState>
    • isConnected

      public boolean isConnected()
      Description copied from interface: Group
      Are we connected with the cluster?
      Specified by:
      isConnected in interface Group<T extends NodeState>
    • start

      public void start()
      Description copied from interface: Group
      Start this member
      Specified by:
      start in interface Group<T extends NodeState>
    • doStart

      protected void doStart()
    • close

      public void close() throws IOException
      Description copied from interface: Group
      A member should be closed to release acquired resources used to monitor the group membership. When the member is closed, any memberships registered via this Group will be removed from the group.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Group<T extends NodeState>
      Throws:
      IOException
    • doStop

      protected void doStop()
    • update

      public void update(T state)
      Description copied from interface: Group
      Update the state of this group member. If the state is null, the member will leave the group. This method can be called even if the group is not started, in which case the state will be stored and updated when the group becomes started.
      Specified by:
      update in interface Group<T extends NodeState>
      Parameters:
      state - the new state of this group member
    • members

      public Map<String,T> members()
      Description copied from interface: Group
      Get the list of members connected to this group.
      Specified by:
      members in interface Group<T extends NodeState>
    • isMaster

      public boolean isMaster()
      Description copied from interface: Group
      Check if we are the master.
      Specified by:
      isMaster in interface Group<T extends NodeState>
    • master

      public T master()
      Description copied from interface: Group
      Retrieve the master node.
      Specified by:
      master in interface Group<T extends NodeState>
    • slaves

      public List<T> slaves()
      Description copied from interface: Group
      Retrieve the list of slaves.
      Specified by:
      slaves in interface Group<T extends NodeState>
    • getGroup

      public Group<T> getGroup()
    • getLastState

      public T getLastState()
      Description copied from interface: Group
      Gets the last state.

      This can be used by clients to access that last state, such as when the clients is being added as a listener but wants to retrieve the last state to be up to date when the client is added.

      Specified by:
      getLastState in interface Group<T extends NodeState>
      Returns:
      the state, or null if no last state yet.