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 Summary
Constructors Constructor Description ZooKeeperUpdatingListener(String zkConnectionStr, String zNodePath, int sessionTimeout)
Deprecated.ZooKeeperUpdatingListener(String zkConnectionStr, String zNodePath, int sessionTimeout, com.linecorp.armeria.client.Endpoint endpoint)
Deprecated. -
Method Summary
Modifier and Type Method Description static ZooKeeperUpdatingListenerBuilder
builder(String connectionStr, 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(com.linecorp.armeria.server.Server server)
void
serverStopping(com.linecorp.armeria.server.Server server)
-
Constructor Details
-
ZooKeeperUpdatingListener
@Deprecated public ZooKeeperUpdatingListener(String zkConnectionStr, String zNodePath, int sessionTimeout, @Nullable com.linecorp.armeria.client.Endpoint endpoint)Deprecated.A ZooKeeper server listener, which registers server into ZooKeeper.- Parameters:
zkConnectionStr
- ZooKeeper connection stringzNodePath
- ZooKeeper node path(under which this server will be registered)sessionTimeout
- session timeoutendpoint
- the endpoint of the server being registered
-
ZooKeeperUpdatingListener
@Deprecated public ZooKeeperUpdatingListener(String zkConnectionStr, String zNodePath, int sessionTimeout)Deprecated.A ZooKeeper server listener, which registers server into ZooKeeper.- Parameters:
zkConnectionStr
- ZooKeeper connection stringzNodePath
- 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 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:
connectionStr
- 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
- Specified by:
serverStarted
in interfacecom.linecorp.armeria.server.ServerListener
- Overrides:
serverStarted
in classcom.linecorp.armeria.server.ServerListenerAdapter
- Throws:
Exception
-
serverStopping
public void serverStopping(com.linecorp.armeria.server.Server server)- Specified by:
serverStopping
in interfacecom.linecorp.armeria.server.ServerListener
- Overrides:
serverStopping
in classcom.linecorp.armeria.server.ServerListenerAdapter
-