Class ExhibitorEnsembleProvider
- java.lang.Object
-
- org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,EnsembleProvider
public class ExhibitorEnsembleProvider extends java.lang.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
Constructors Constructor Description ExhibitorEnsembleProvider(Exhibitors exhibitors, ExhibitorRestClient restClient, java.lang.String restUriPath, int pollingMs, RetryPolicy retryPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Curator will call this method whenCuratorZookeeperClient.close()is calledjava.lang.StringgetConnectionString()Return the current connection string to use.protected voidpoll()voidpollForInitialEnsemble()Can be called prior to starting the Curator instance to set the current connection stringvoidsetConnectionString(java.lang.String connectionString)A new connection string event was receivedvoidsetExhibitors(Exhibitors newExhibitors)Change the set of exhibitors to pollvoidstart()Curator will call this method whenCuratorZookeeperClient.start()is calledbooleanupdateServerListEnabled()Return true if this ensemble provider supportsZooKeeper.updateServerList(String)
-
-
-
Constructor Detail
-
ExhibitorEnsembleProvider
public ExhibitorEnsembleProvider(Exhibitors exhibitors, ExhibitorRestClient restClient, java.lang.String restUriPath, int pollingMs, RetryPolicy retryPolicy)
- Parameters:
exhibitors- the current set of exhibitor instances (can be changed later viasetExhibitors(Exhibitors))restClient- the rest client to use (useDefaultExhibitorRestClientfor most cases)restUriPath- the path of the REST call used to get the server set. Usually:/exhibitor/v1/cluster/listpollingMs- how ofter to poll the exhibitors for the listretryPolicy- 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 java.lang.ExceptionCan be called prior to starting the Curator instance to set the current connection string- Throws:
java.lang.Exception- errors
-
start
public void start() throws java.lang.ExceptionDescription copied from interface:EnsembleProviderCurator will call this method whenCuratorZookeeperClient.start()is called- Specified by:
startin interfaceEnsembleProvider- Throws:
java.lang.Exception- errors
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:EnsembleProviderCurator will call this method whenCuratorZookeeperClient.close()is called- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceEnsembleProvider- Throws:
java.io.IOException- errors
-
getConnectionString
public java.lang.String getConnectionString()
Description copied from interface:EnsembleProviderReturn the current connection string to use. Curator will call this each time it needs to create a ZooKeeper instance- Specified by:
getConnectionStringin interfaceEnsembleProvider- Returns:
- connection string (per
ZooKeeper(String, int, Watcher)etc.)
-
setConnectionString
public void setConnectionString(java.lang.String connectionString)
Description copied from interface:EnsembleProviderA new connection string event was received- Specified by:
setConnectionStringin interfaceEnsembleProvider- Parameters:
connectionString- the new connection string
-
updateServerListEnabled
public boolean updateServerListEnabled()
Description copied from interface:EnsembleProviderReturn true if this ensemble provider supportsZooKeeper.updateServerList(String)- Specified by:
updateServerListEnabledin interfaceEnsembleProvider- Returns:
- true/false
-
poll
protected void poll()
-
-