public class ExampleClient extends LeaderSelectorListenerAdapter implements Closeable
LeaderSelectorListenerAdapter
which
has the recommended handling for connection state issuesConstructor and Description |
---|
ExampleClient(CuratorFramework client,
String path,
String name) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
start() |
void |
takeLeadership(CuratorFramework client)
Called when your instance has been granted leadership.
|
stateChanged
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doNotProxy
public ExampleClient(CuratorFramework client, String path, String name)
public void start() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void takeLeadership(CuratorFramework client) throws Exception
LeaderSelectorListener
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)
throws CancelLeadershipException
. After interrupted, this
method should exit(either return or throw) promptly, otherwise it
will block following elections.
takeLeadership
in interface LeaderSelectorListener
client
- the clientException
- any errorsCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.