org.apache.curator.ensemble.exhibitor
Class ExhibitorEnsembleProvider

java.lang.Object
  extended by org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider
All Implemented Interfaces:
Closeable, EnsembleProvider

public class ExhibitorEnsembleProvider
extends Object
implements EnsembleProvider

Ensemble provider that polls a cluster of Exhibitor (https://github.com/Netflix/exhibitor) instances for the connection string. If the set of instances should change, new ZooKeeper connections will use the new connection string.


Constructor Summary
ExhibitorEnsembleProvider(Exhibitors exhibitors, ExhibitorRestClient restClient, String restUriPath, int pollingMs, RetryPolicy retryPolicy)
           
 
Method Summary
 void close()
          Curator will call this method when CuratorZookeeperClient.close() is called
 String getConnectionString()
          Return the current connection string to use.
protected  void poll()
           
 void pollForInitialEnsemble()
          Can be called prior to starting the Curator instance to set the current connection string
 void setExhibitors(Exhibitors newExhibitors)
          Change the set of exhibitors to poll
 void start()
          Curator will call this method when CuratorZookeeperClient.start() is called
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExhibitorEnsembleProvider

public ExhibitorEnsembleProvider(Exhibitors exhibitors,
                                 ExhibitorRestClient restClient,
                                 String restUriPath,
                                 int pollingMs,
                                 RetryPolicy retryPolicy)
Parameters:
exhibitors - the current set of exhibitor instances (can be changed later via setExhibitors(Exhibitors))
restClient - the rest client to use (use DefaultExhibitorRestClient for most cases)
restUriPath - the path of the REST call used to get the server set. Usually: /exhibitor/v1/cluster/list
pollingMs - how ofter to poll the exhibitors for the list
retryPolicy - retry policy to use when connecting to the exhibitors
Method Detail

setExhibitors

public void setExhibitors(Exhibitors newExhibitors)
Change the set of exhibitors to poll

Parameters:
newExhibitors - new set

pollForInitialEnsemble

public void pollForInitialEnsemble()
                            throws Exception
Can be called prior to starting the Curator instance to set the current connection string

Throws:
Exception - errors

start

public void start()
           throws Exception
Description copied from interface: EnsembleProvider
Curator will call this method when CuratorZookeeperClient.start() is called

Specified by:
start in interface EnsembleProvider
Throws:
Exception - errors

close

public void close()
           throws IOException
Description copied from interface: EnsembleProvider
Curator will call this method when CuratorZookeeperClient.close() is called

Specified by:
close in interface Closeable
Specified by:
close in interface EnsembleProvider
Throws:
IOException - errors

getConnectionString

public String getConnectionString()
Description copied from interface: EnsembleProvider
Return the current connection string to use. Curator will call this each time it needs to create a ZooKeeper instance

Specified by:
getConnectionString in interface EnsembleProvider
Returns:
connection string (per ZooKeeper.ZooKeeper(String, int, Watcher) etc.)

poll

protected void poll()


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.