Interface Group<T extends NodeState>
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
MultiGroup<T>
- All Known Implementing Classes:
DelegateZooKeeperGroup,DelegateZooKeeperMultiGroup,ZooKeeperGroup,ZooKeeperMultiGroup
public interface Group<T extends NodeState> extends Closeable
-
-
Method Summary
All Methods Instance Methods Abstract 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.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.
-
-
-
Method Detail
-
isConnected
boolean isConnected()
Are we connected with the cluster?
-
start
void start()
Start this member
-
close
void close() throws IOExceptionA 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- Throws:
IOException
-
add
void add(GroupListener<T> listener)
Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.
-
remove
void remove(GroupListener<T> listener)
Removes a previously added listener.
-
update
void update(T state)
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.- Parameters:
state- the new state of this group member
-
isMaster
boolean isMaster()
Check if we are the master.
-
master
T master()
Retrieve the master node.
-
-