Class ZooKeeperUpdatingListener
java.lang.Object
com.linecorp.armeria.server.ServerListenerAdapter
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListener
- All Implemented Interfaces:
ServerListener
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 TypeMethodDescriptionbuilder(String zkConnectionStr, String znodePath, ZooKeeperRegistrationSpec spec)
Returns aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a znode path.builder(CuratorFramework client, String znodePath, ZooKeeperRegistrationSpec spec)
Returns aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a znode path.static ZooKeeperUpdatingListener
of(String zkConnectionStr, String znodePath, ZooKeeperRegistrationSpec spec)
Creates a ZooKeeper server listener, which registers theServer
into ZooKeeper.static ZooKeeperUpdatingListener
of(CuratorFramework client, String znodePath, ZooKeeperRegistrationSpec spec)
Creates a ZooKeeper server listener, which registers theServer
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
-
of
public static ZooKeeperUpdatingListener of(String zkConnectionStr, String znodePath, ZooKeeperRegistrationSpec spec)Creates a ZooKeeper server listener, which registers theServer
into ZooKeeper.If you need a fully customized
ZooKeeperUpdatingListener
instance, usebuilder(String, String, ZooKeeperRegistrationSpec)
instead.- Parameters:
zkConnectionStr
- the ZooKeeper connection stringznodePath
- the ZooKeeper node to registerspec
- theZooKeeperRegistrationSpec
to encode and register theServer
-
of
public static ZooKeeperUpdatingListener of(CuratorFramework client, String znodePath, ZooKeeperRegistrationSpec spec)Creates a ZooKeeper server listener, which registers theServer
into ZooKeeper.If you need a fully customized
ZooKeeperUpdatingListener
instance, usebuilder(CuratorFramework, String, ZooKeeperRegistrationSpec)
instead.- Parameters:
client
- the curator framework instanceznodePath
- the ZooKeeper node to registerspec
- theZooKeeperRegistrationSpec
to encode and register theServer
-
builder
public static ZooKeeperUpdatingListenerBuilder builder(CuratorFramework client, String znodePath, ZooKeeperRegistrationSpec spec)Returns aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a znode path.- Parameters:
client
- the curator framework instanceznodePath
- the ZooKeeper node to registerspec
- theZooKeeperRegistrationSpec
to encode and register theServer
-
builder
public static ZooKeeperUpdatingListenerBuilder builder(String zkConnectionStr, String znodePath, ZooKeeperRegistrationSpec spec)Returns aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a znode path.- Parameters:
zkConnectionStr
- the ZooKeeper connection stringznodePath
- the ZooKeeper node to registerspec
- theZooKeeperRegistrationSpec
to encode and register theServer
-
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
-