org.apache.zookeeper.client
Class StaticHostProvider

java.lang.Object
  extended by org.apache.zookeeper.client.StaticHostProvider
All Implemented Interfaces:
HostProvider

public final class StaticHostProvider
extends Object
implements HostProvider

Most simple HostProvider, resolves only on instantiation.


Constructor Summary
StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
          Constructs a SimpleHostSet.
 
Method Summary
 InetSocketAddress next(long spinDelay)
          The next host to try to connect to.
 void onConnected()
          Notify the HostProvider of a successful connection.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticHostProvider

public StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
                   throws UnknownHostException
Constructs a SimpleHostSet.

Parameters:
serverAddresses - possibly unresolved ZooKeeper server addresses
Throws:
UnknownHostException
IllegalArgumentException - if serverAddresses is empty or resolves to an empty list
Method Detail

size

public int size()
Specified by:
size in interface HostProvider

next

public InetSocketAddress next(long spinDelay)
Description copied from interface: HostProvider
The next host to try to connect to. For a spinDelay of 0 there should be no wait.

Specified by:
next in interface HostProvider
Parameters:
spinDelay - Milliseconds to wait if all hosts have been tried once.

onConnected

public void onConnected()
Description copied from interface: HostProvider
Notify the HostProvider of a successful connection. The HostProvider may use this notification to reset it's inner state.

Specified by:
onConnected in interface HostProvider


Copyright © 2011 The Apache Software Foundation