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 void
add(GroupListener<T> listener)
Registers a listener which will be called when the cluster membership changes or the group is connected or disconnected.void
close()
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 void
doStart()
protected void
doStop()
Group<T>
getGroup()
T
getLastState()
Gets the last state.boolean
isConnected()
Are we connected with the cluster?boolean
isMaster()
Check if we are the master.T
master()
Retrieve the master node.Map<String,T>
members()
Get the list of members connected to this group.void
remove(GroupListener<T> listener)
Removes a previously added listener.List<T>
slaves()
Retrieve the list of slaves.void
start()
Start this membervoid
update(T state)
Update the state of this group member.void
useCurator(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:Group
Registers 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:Group
Removes a previously added listener.
-
isConnected
public boolean isConnected()
Description copied from interface:Group
Are we connected with the cluster?- Specified by:
isConnected
in interfaceGroup<T extends NodeState>
-
start
public void start()
Description copied from interface:Group
Start this member
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceGroup<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.
-
members
public Map<String,T> members()
Description copied from interface:Group
Get the list of members connected to this group.
-
isMaster
public boolean isMaster()
Description copied from interface:Group
Check if we are the master.
-
slaves
public List<T> slaves()
Description copied from interface:Group
Retrieve the list of slaves.
-
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 alistener
but wants to retrieve the last state to be up to date when the client is added.- Specified by:
getLastState
in interfaceGroup<T extends NodeState>
- Returns:
- the state, or null if no last state yet.
-
-