@InterfaceAudience.Public public final class StaticHostProvider extends Object implements HostProvider
| Modifier and Type | Class and Description | 
|---|---|
static interface  | 
StaticHostProvider.Resolver  | 
| Constructor and Description | 
|---|
StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
Constructs a SimpleHostSet. 
 | 
StaticHostProvider(Collection<InetSocketAddress> serverAddresses,
                  long randomnessSeed)
Constructs a SimpleHostSet. 
 | 
StaticHostProvider(Collection<InetSocketAddress> serverAddresses,
                  StaticHostProvider.Resolver resolver)
Constructs a SimpleHostSet. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
InetSocketAddress | 
getServerAtCurrentIndex()  | 
InetSocketAddress | 
getServerAtIndex(int i)  | 
InetSocketAddress | 
next(long spinDelay)
The next host to try to connect to. 
 | 
void | 
onConnected()
Notify the HostProvider of a successful connection. 
 | 
int | 
size()  | 
boolean | 
updateServerList(Collection<InetSocketAddress> serverAddresses,
                InetSocketAddress currentHost)
Update the list of servers. 
 | 
public StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
serverAddresses - possibly unresolved ZooKeeper server addressesIllegalArgumentException - if serverAddresses is empty or resolves to an empty listpublic StaticHostProvider(Collection<InetSocketAddress> serverAddresses, StaticHostProvider.Resolver resolver)
serverAddresses - possibly unresolved ZooKeeper server addressesresolver - custom resolver implementationpublic StaticHostProvider(Collection<InetSocketAddress> serverAddresses, long randomnessSeed)
serverAddresses - possibly unresolved ZooKeeper server addressesrandomnessSeed - a seed used to initialize sourceOfRandomnesIllegalArgumentException - if serverAddresses is empty or resolves to an empty listpublic boolean updateServerList(Collection<InetSocketAddress> serverAddresses, InetSocketAddress currentHost)
updateServerList in interface HostProviderserverAddresses - new host listcurrentHost - the host to which this client is currently connectedpublic InetSocketAddress getServerAtIndex(int i)
public InetSocketAddress getServerAtCurrentIndex()
public int size()
size in interface HostProviderpublic InetSocketAddress next(long spinDelay)
HostProvidernext in interface HostProviderspinDelay - Milliseconds to wait if all hosts have been tried once.public void onConnected()
HostProvideronConnected in interface HostProviderCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.