Package leader
Class ExampleClient
java.lang.Object
org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter
leader.ExampleClient
- All Implemented Interfaces:
Closeable,AutoCloseable,LeaderSelectorListener,ConnectionStateListener
An example leader selector client. Note that
LeaderSelectorListenerAdapter which
has the recommended handling for connection state issues-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidstart()voidtakeLeadership(CuratorFramework client) Called when your instance has been granted leadership.Methods inherited from class org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter
stateChangedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.curator.framework.state.ConnectionStateListener
doNotProxy
-
Constructor Details
-
ExampleClient
-
-
Method Details
-
start
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
takeLeadership
Description copied from interface:LeaderSelectorListenerCalled when your instance has been granted leadership. This method should not return until you wish to release leadership.It is guaranteed that there is no concurrent executions of this method.
It is guaranteed that this method will be interrupted if
ConnectionStateListener.stateChanged(CuratorFramework, ConnectionState)throwsCancelLeadershipException. After interrupted, this method should exit(either return or throw) promptly, otherwise it will block following elections.- Specified by:
takeLeadershipin interfaceLeaderSelectorListener- Parameters:
client- the client- Throws:
Exception- any errors
-