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 Summary
Constructors Constructor Description DelegateZooKeeperGroup(String path, Class<T> clazz)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(GroupListener<T> listener)Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.voidclose()A member should be closed to release acquired resources used to monitor the group membership.protected Group<T>createGroup(org.apache.curator.framework.CuratorFramework client, String path, Class<T> clazz)protected voiddoStart()protected voiddoStop()Group<T>getGroup()TgetLastState()Gets the last state.booleanisConnected()Are we connected with the cluster?booleanisMaster()Check if we are the master.Tmaster()Retrieve the master node.Map<String,T>members()Get the list of members connected to this group.voidremove(GroupListener<T> listener)Removes a previously added listener.List<T>slaves()Retrieve the list of slaves.voidstart()Start this membervoidupdate(T state)Update the state of this group member.voiduseCurator(org.apache.curator.framework.CuratorFramework curator)
-
-
-
Method Detail
-
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:GroupRegisters a listener which will be called when the cluster membership changes or the group is connected or disconnected.
-
remove
public void remove(GroupListener<T> listener)
Description copied from interface:GroupRemoves a previously added listener.
-
isConnected
public boolean isConnected()
Description copied from interface:GroupAre we connected with the cluster?- Specified by:
isConnectedin interfaceGroup<T extends NodeState>
-
start
public void start()
Description copied from interface:GroupStart this member
-
doStart
protected void doStart()
-
close
public void close() throws IOExceptionDescription copied from interface:GroupA 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceGroup<T extends NodeState>- Throws:
IOException
-
doStop
protected void doStop()
-
update
public void update(T state)
Description copied from interface:GroupUpdate 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.
-
members
public Map<String,T> members()
Description copied from interface:GroupGet the list of members connected to this group.
-
isMaster
public boolean isMaster()
Description copied from interface:GroupCheck if we are the master.
-
slaves
public List<T> slaves()
Description copied from interface:GroupRetrieve the list of slaves.
-
getLastState
public T getLastState()
Description copied from interface:GroupGets the last state. This can be used by clients to access that last state, such as when the clients is being added as alistenerbut wants to retrieve the last state to be up to date when the client is added.- Specified by:
getLastStatein interfaceGroup<T extends NodeState>- Returns:
- the state, or null if no last state yet.
-
-