Class ZooKeeperUpdatingListener

java.lang.Object
com.linecorp.armeria.server.ServerListenerAdapter
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListener
All Implemented Interfaces:
com.linecorp.armeria.server.ServerListener

public final class ZooKeeperUpdatingListener
extends com.linecorp.armeria.server.ServerListenerAdapter
A ServerListener which registers the current Server to ZooKeeper as an ephemeral node. When server stops, or a network partition occurs, the underlying ZooKeeper session will be closed, and the node will be automatically removed. As a result, the clients that use a ZooKeeperEndpointGroup will be notified, and they will update their endpoint list automatically so that they do not attempt to connect to the unreachable servers.
  • Constructor Details

    • ZooKeeperUpdatingListener

      @Deprecated public ZooKeeperUpdatingListener​(String zkConnectionStr, String zNodePath, int sessionTimeout, @Nullable com.linecorp.armeria.client.Endpoint endpoint)
      A ZooKeeper server listener, which registers server into ZooKeeper.
      Parameters:
      zkConnectionStr - ZooKeeper connection string
      zNodePath - ZooKeeper node path(under which this server will be registered)
      sessionTimeout - session timeout
      endpoint - the endpoint of the server being registered
    • ZooKeeperUpdatingListener

      @Deprecated public ZooKeeperUpdatingListener​(String zkConnectionStr, String zNodePath, int sessionTimeout)
      A ZooKeeper server listener, which registers server into ZooKeeper.
      Parameters:
      zkConnectionStr - ZooKeeper connection string
      zNodePath - ZooKeeper node path(under which this server will be registered)
      sessionTimeout - session timeout
  • Method Details

    • builder

      public static ZooKeeperUpdatingListenerBuilder builder​(org.apache.curator.framework.CuratorFramework client, String zNodePath)
      Returns a ZooKeeperUpdatingListenerBuilder with a CuratorFramework instance and a zNode path.
      Parameters:
      client - the curator framework instance
      zNodePath - the ZooKeeper node to register
    • builder

      public static ZooKeeperUpdatingListenerBuilder builder​(String connectionStr, String zNodePath)
      Returns a ZooKeeperUpdatingListenerBuilder with a ZooKeeper connection string and a zNode path.
      Parameters:
      connectionStr - the ZooKeeper connection string
      zNodePath - the ZooKeeper node to register
    • of

      public static ZooKeeperUpdatingListener of​(String zkConnectionStr, String zNodePath)
      Creates a ZooKeeper server listener, which registers server into ZooKeeper.

      If you need a fully customized ZooKeeperUpdatingListener instance, use builder(String, String) instead.

      Parameters:
      zkConnectionStr - ZooKeeper connection string
      zNodePath - ZooKeeper node path(under which this server will be registered)
    • serverStarted

      public void serverStarted​(com.linecorp.armeria.server.Server server) throws Exception
      Specified by:
      serverStarted in interface com.linecorp.armeria.server.ServerListener
      Overrides:
      serverStarted in class com.linecorp.armeria.server.ServerListenerAdapter
      Throws:
      Exception
    • serverStopping

      public void serverStopping​(com.linecorp.armeria.server.Server server)
      Specified by:
      serverStopping in interface com.linecorp.armeria.server.ServerListener
      Overrides:
      serverStopping in class com.linecorp.armeria.server.ServerListenerAdapter