@NotThreadSafe public final class PrimarySelectorClient extends AbstractPrimarySelector implements Closeable, org.apache.curator.framework.recipes.leader.LeaderSelectorListener
Modifier and Type | Class and Description |
---|---|
protected static class |
PrimarySelectorClient.ZookeeperConnectionErrorPolicy
Defines supported connection error policies for leader election.
|
PrimarySelector.Factory, PrimarySelector.State
Constructor and Description |
---|
PrimarySelectorClient(String zookeeperAddress,
String electionPath,
String leaderPath)
Constructs a new
PrimarySelectorClient . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getName() |
List<String> |
getParticipants() |
void |
start(InetSocketAddress address)
Starts the leader selection.
|
void |
stateChanged(org.apache.curator.framework.CuratorFramework client,
org.apache.curator.framework.state.ConnectionState newState) |
void |
stop()
Stops the primary selector.
|
void |
takeLeadership(org.apache.curator.framework.CuratorFramework client) |
getState, onStateChange, setState, waitForState
public PrimarySelectorClient(String zookeeperAddress, String electionPath, String leaderPath)
PrimarySelectorClient
.zookeeperAddress
- the address to ZookeeperelectionPath
- the election pathleaderPath
- the path of the leaderpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void stop() throws IOException
PrimarySelector
stop
in interface PrimarySelector
IOException
public String getName()
public void start(InetSocketAddress address) throws IOException
start
in interface PrimarySelector
address
- the address of the local masterIOException
public void stateChanged(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.state.ConnectionState newState)
stateChanged
in interface org.apache.curator.framework.state.ConnectionStateListener
Copyright © 2023. All Rights Reserved.