Class 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 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 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 java.lang.Exception
        Can be called prior to starting the Curator instance to set the current connection string
        Throws:
        java.lang.Exception - errors
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: EnsembleProvider
        Curator will call this method when CuratorZookeeperClient.close() is called
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface EnsembleProvider
        Throws:
        java.io.IOException - errors
      • getConnectionString

        public java.lang.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(String, int, Watcher) etc.)
      • setConnectionString

        public void setConnectionString​(java.lang.String connectionString)
        Description copied from interface: EnsembleProvider
        A new connection string event was received
        Specified by:
        setConnectionString in interface EnsembleProvider
        Parameters:
        connectionString - the new connection string
      • updateServerListEnabled

        public boolean updateServerListEnabled()
        Description copied from interface: EnsembleProvider
        Return true if this ensemble provider supports ZooKeeper.updateServerList(String)
        Specified by:
        updateServerListEnabled in interface EnsembleProvider
        Returns:
        true/false
      • poll

        protected void poll()