Class ZooKeeperUpdatingListenerBuilder
java.lang.Object
com.linecorp.armeria.common.zookeeper.AbstractCuratorFrameworkBuilder
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListenerBuilder
public final class ZooKeeperUpdatingListenerBuilder extends AbstractCuratorFrameworkBuilder
Builds a new
ZooKeeperUpdatingListener
, which registers the server to a ZooKeeper cluster.
Examples
ZooKeeperUpdatingListener listener =
ZooKeeperUpdatingListener.builder("myZooKeeperHost:2181", "/myProductionEndpoints")
.sessionTimeoutMillis(10000)
.codec(NodeValueCodec.ofDefault())
.build();
ServerBuilder sb = Server.builder();
sb.addListener(listener);
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
.
ZooKeeperUpdatingListener listener =
ZooKeeperUpdatingListener.builder(curatorFramework, "/myProductionEndpoints")
.codec(NodeValueCodec.ofDefault())
.build();
ServerBuilder sb = Server.builder();
sb.addListener(listener);
-
Method Summary
Modifier and Type Method Description ZooKeeperUpdatingListener
build()
Returns a newly-createdZooKeeperUpdatingListener
instance that registers the server to ZooKeeper when the server starts.ZooKeeperUpdatingListenerBuilder
codec(NodeValueCodec nodeValueCodec)
Sets theNodeValueCodec
to encode or decode ZooKeeper data.ZooKeeperUpdatingListenerBuilder
connectTimeout(Duration connectTimeout)
Sets the specified connect timeout.ZooKeeperUpdatingListenerBuilder
connectTimeoutMillis(long connectTimeoutMillis)
Sets the specified connect timeout in milliseconds.ZooKeeperUpdatingListenerBuilder
customizer(Consumer<? super org.apache.curator.framework.CuratorFrameworkFactory.Builder> customizer)
Specifies theConsumer
that customizes theCuratorFramework
.ZooKeeperUpdatingListenerBuilder
endpoint(Endpoint endpoint)
Sets theEndpoint
to register.ZooKeeperUpdatingListenerBuilder
nodeValueCodec(NodeValueCodec nodeValueCodec)
Deprecated.ZooKeeperUpdatingListenerBuilder
sessionTimeout(Duration sessionTimeout)
Sets the session timeout.ZooKeeperUpdatingListenerBuilder
sessionTimeoutMillis(long sessionTimeoutMillis)
Sets the session timeout in milliseconds.Methods inherited from class com.linecorp.armeria.common.zookeeper.AbstractCuratorFrameworkBuilder
buildCuratorFramework, isUserSpecifiedCuratorFramework
-
Method Details
-
endpoint
Sets theEndpoint
to register. If not set, the current host name is used automatically.- Parameters:
endpoint
- theEndpoint
to register
-
codec
Sets theNodeValueCodec
to encode or decode ZooKeeper data.- Parameters:
nodeValueCodec
- theNodeValueCodec
instance to use
-
nodeValueCodec
Deprecated.Sets theNodeValueCodec
to encode or decode ZooKeeper data.- Parameters:
nodeValueCodec
- theNodeValueCodec
instance to use
-
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 org.apache.curator.framework.CuratorFrameworkFactory.Builder> customizer)Description copied from class:AbstractCuratorFrameworkBuilder
Specifies theConsumer
that customizes theCuratorFramework
.- Overrides:
customizer
in classAbstractCuratorFrameworkBuilder
-