Class ZooKeeperUpdatingListenerBuilder
java.lang.Object
com.linecorp.armeria.common.zookeeper.AbstractCuratorFrameworkBuilder
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListenerBuilder
Builds a new
ZooKeeperUpdatingListener
, which registers the server to a ZooKeeper cluster.
ZooKeeperRegistrationSpec spec = ZooKeeperRegistrationSpec.curator("myServices");
ZooKeeperUpdatingListener listener =
ZooKeeperUpdatingListener.builder("myZooKeeperHost:2181", "/myProductionEndpoints", spec)
.sessionTimeoutMillis(10000)
.build();
ServerBuilder sb = Server.builder();
sb.serverListener(listener);
This registers the Server
using the format compatible with
Curator Service Discovery.
You can also specify the CuratorFramework
instance to use. In this case,
invoking connectTimeout(Duration)
, connectTimeoutMillis(long)
,
sessionTimeout(Duration)
or sessionTimeoutMillis(long)
will raise an
IllegalStateException
.
ZooKeeperRegistrationSpec spec = ...
ZooKeeperUpdatingListener listener =
ZooKeeperUpdatingListener.builder(curatorFramework, "/myProductionEndpoints", spec)
.build();
ServerBuilder sb = Server.builder();
sb.serverListener(listener);
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newly-createdZooKeeperUpdatingListener
instance that registers the server to ZooKeeper when the server starts.connectTimeout(Duration connectTimeout)
Sets the specified connect timeout.connectTimeoutMillis(long connectTimeoutMillis)
Sets the specified connect timeout in milliseconds.customizer(Consumer<? super CuratorFrameworkFactory.Builder> customizer)
Specifies theConsumer
that customizes theCuratorFramework
.sessionTimeout(Duration sessionTimeout)
Sets the session timeout.sessionTimeoutMillis(long sessionTimeoutMillis)
Sets the session timeout in milliseconds.Methods inherited from class com.linecorp.armeria.common.zookeeper.AbstractCuratorFrameworkBuilder
buildCuratorFramework, isUserSpecifiedCuratorFramework, znodePath
-
Method Details
-
build
Returns a newly-createdZooKeeperUpdatingListener
instance that registers the server to ZooKeeper when the server starts. -
connectTimeout
Description copied from class:AbstractCuratorFrameworkBuilder
Sets the specified connect timeout. 1000 ms is used by default.- Overrides:
connectTimeout
in classAbstractCuratorFrameworkBuilder
- Parameters:
connectTimeout
- the connect timeout
-
connectTimeoutMillis
Description copied from class:AbstractCuratorFrameworkBuilder
Sets the specified connect timeout in milliseconds. 1000 ms is used by default.- Overrides:
connectTimeoutMillis
in classAbstractCuratorFrameworkBuilder
- Parameters:
connectTimeoutMillis
- the connect timeout in milliseconds
-
sessionTimeout
Description copied from class:AbstractCuratorFrameworkBuilder
Sets the session timeout. 10000 ms is used by default.- Overrides:
sessionTimeout
in classAbstractCuratorFrameworkBuilder
- Parameters:
sessionTimeout
- the session timeout
-
sessionTimeoutMillis
Description copied from class:AbstractCuratorFrameworkBuilder
Sets the session timeout in milliseconds. 10000 ms is used by default.- Overrides:
sessionTimeoutMillis
in classAbstractCuratorFrameworkBuilder
- Parameters:
sessionTimeoutMillis
- the session timeout in milliseconds
-
customizer
public ZooKeeperUpdatingListenerBuilder customizer(Consumer<? super CuratorFrameworkFactory.Builder> customizer)Description copied from class:AbstractCuratorFrameworkBuilder
Specifies theConsumer
that customizes theCuratorFramework
.- Overrides:
customizer
in classAbstractCuratorFrameworkBuilder
-