Class ZooKeeperUpdatingListener
java.lang.Object
com.linecorp.armeria.server.ServerListenerAdapter
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListener
- All Implemented Interfaces:
ServerListener
public final class ZooKeeperUpdatingListener extends 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.-
Method Summary
Modifier and Type Method Description static ZooKeeperUpdatingListenerBuilder
builder(String zkConnectionStr, String zNodePath)
Returns aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a zNode path.static ZooKeeperUpdatingListenerBuilder
builder(org.apache.curator.framework.CuratorFramework client, String zNodePath)
Returns aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a zNode path.static ZooKeeperUpdatingListener
of(String zkConnectionStr, String zNodePath)
Creates a ZooKeeper server listener, which registers server into ZooKeeper.void
serverStarted(Server server)
Invoked when aServer
finished its startup procedure successfully and it started to serve incoming requests.void
serverStopping(Server server)
Invoked when aServer
begins its shutdown procedure.Methods inherited from class com.linecorp.armeria.server.ServerListenerAdapter
serverStarting, serverStopped
-
Method Details
-
builder
public static ZooKeeperUpdatingListenerBuilder builder(org.apache.curator.framework.CuratorFramework client, String zNodePath)Returns aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a zNode path.- Parameters:
client
- the curator framework instancezNodePath
- the ZooKeeper node to register
-
builder
Returns aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a zNode path.- Parameters:
zkConnectionStr
- the ZooKeeper connection stringzNodePath
- the ZooKeeper node to register
-
of
Creates a ZooKeeper server listener, which registers server into ZooKeeper.If you need a fully customized
ZooKeeperUpdatingListener
instance, usebuilder(String, String)
instead.- Parameters:
zkConnectionStr
- ZooKeeper connection stringzNodePath
- ZooKeeper node path(under which this server will be registered)
-
serverStarted
Description copied from interface:ServerListener
Invoked when aServer
finished its startup procedure successfully and it started to serve incoming requests.- Specified by:
serverStarted
in interfaceServerListener
- Overrides:
serverStarted
in classServerListenerAdapter
- Throws:
Exception
-
serverStopping
Description copied from interface:ServerListener
Invoked when aServer
begins its shutdown procedure.- Specified by:
serverStopping
in interfaceServerListener
- Overrides:
serverStopping
in classServerListenerAdapter
-