Class ZooKeeperUpdatingListenerBuilder
java.lang.Object
com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListenerBuilder
public final class ZooKeeperUpdatingListenerBuilder extends Object
Builds a new
ZooKeeperUpdatingListener
, which registers the server to a ZooKeeper cluster.
Examples
ZooKeeperUpdatingListener listener =
ZooKeeperUpdatingListener.builder("myZooKeeperHost:2181", "/myProductionEndpoints")
.sessionTimeoutMillis(10000)
.nodeValueCodec(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")
.nodeValueCodec(NodeValueCodec.DEFAULT)
.build();
ServerBuilder sb = Server.builder();
sb.addListener(listener);
-
Constructor Summary
Constructors Constructor Description ZooKeeperUpdatingListenerBuilder(String connectionStr, String zNodePath)
Deprecated.ZooKeeperUpdatingListenerBuilder(org.apache.curator.framework.CuratorFramework client, String zNodePath)
Deprecated. -
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
connectTimeout(Duration connectTimeout)
Sets the connect timeout.ZooKeeperUpdatingListenerBuilder
connectTimeoutMillis(long connectTimeoutMillis)
Sets the connect timeout (in ms).ZooKeeperUpdatingListenerBuilder
endpoint(com.linecorp.armeria.client.Endpoint endpoint)
Sets theEndpoint
to register.ZooKeeperUpdatingListenerBuilder
nodeValueCodec(NodeValueCodec nodeValueCodec)
Sets theNodeValueCodec
to encode or decode ZooKeeper data.ZooKeeperUpdatingListenerBuilder
sessionTimeout(Duration sessionTimeout)
Sets the session timeout.ZooKeeperUpdatingListenerBuilder
sessionTimeoutMillis(long sessionTimeoutMillis)
Sets the session timeout (in ms).
-
Constructor Details
-
ZooKeeperUpdatingListenerBuilder
@Deprecated public ZooKeeperUpdatingListenerBuilder(org.apache.curator.framework.CuratorFramework client, String zNodePath)Deprecated.Creates aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a zNode path.- Parameters:
client
- the curator framework instancezNodePath
- the ZooKeeper node to register
-
ZooKeeperUpdatingListenerBuilder
Deprecated.Creates aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a zNode path.- Parameters:
connectionStr
- the ZooKeeper connection stringzNodePath
- the ZooKeeper node to register
-
-
Method Details
-
connectTimeout
Sets the connect timeout.- Parameters:
connectTimeout
- the connect timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListener.builder(CuratorFramework, String)
-
connectTimeoutMillis
Sets the connect timeout (in ms). (default: 1000)- Parameters:
connectTimeoutMillis
- the connect timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListener.builder(CuratorFramework, String)
-
sessionTimeout
Sets the session timeout.- Parameters:
sessionTimeout
- the session timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListener.builder(CuratorFramework, String)
-
sessionTimeoutMillis
Sets the session timeout (in ms). (default: 10000)- Parameters:
sessionTimeoutMillis
- the session timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListener.builder(CuratorFramework, String)
-
endpoint
Sets theEndpoint
to register. If not set, the current host name is used automatically.- Parameters:
endpoint
- theEndpoint
to register
-
nodeValueCodec
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.
-