Class ZooKeeperUpdatingListenerBuilder
- java.lang.Object
-
- com.linecorp.armeria.server.zookeeper.ZooKeeperUpdatingListenerBuilder
-
public final class ZooKeeperUpdatingListenerBuilder extends Object
Builds a newZooKeeperUpdatingListener
, which registers the server to a ZooKeeper cluster.Examples
ZooKeeperUpdatingListener listener = new ZooKeeperUpdatingListenerBuilder("myZooKeeperHost:2181", "/myProductionEndpoints") .sessionTimeoutMillis(10000) .nodeValueCodec(NodeValueCodec.DEFAULT) .build(); ServerBuilder sb = new ServerBuilder(); sb.addListener(listener);
You can also specify the
CuratorFramework
instance to use. In this case, invokingconnectTimeout(Duration)
,connectTimeoutMillis(long)
,sessionTimeout(Duration)
orsessionTimeoutMillis(long)
will raise anIllegalStateException
.ZooKeeperUpdatingListener listener = new ZooKeeperUpdatingListenerBuilder(curatorFramework, "/myProductionEndpoints") .nodeValueCodec(NodeValueCodec.DEFAULT) .build(); ServerBuilder sb = new ServerBuilder(); sb.addListener(listener);
-
-
Constructor Summary
Constructors Constructor Description ZooKeeperUpdatingListenerBuilder(String connectionStr, String zNodePath)
Creates aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a zNode path.ZooKeeperUpdatingListenerBuilder(org.apache.curator.framework.CuratorFramework client, String zNodePath)
Creates aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a zNode path.
-
Method Summary
All Methods Instance Methods Concrete Methods 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 Detail
-
ZooKeeperUpdatingListenerBuilder
public ZooKeeperUpdatingListenerBuilder(org.apache.curator.framework.CuratorFramework client, String zNodePath)
Creates aZooKeeperUpdatingListenerBuilder
with aCuratorFramework
instance and a zNode path.- Parameters:
client
- the curator framework instancezNodePath
- the ZooKeeper node to register
-
ZooKeeperUpdatingListenerBuilder
public ZooKeeperUpdatingListenerBuilder(String connectionStr, String zNodePath)
Creates aZooKeeperUpdatingListenerBuilder
with a ZooKeeper connection string and a zNode path.- Parameters:
connectionStr
- the ZooKeeper connection stringzNodePath
- the ZooKeeper node to register
-
-
Method Detail
-
connectTimeout
public ZooKeeperUpdatingListenerBuilder connectTimeout(Duration connectTimeout)
Sets the connect timeout.- Parameters:
connectTimeout
- the connect timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListenerBuilder(CuratorFramework, String)
-
connectTimeoutMillis
public ZooKeeperUpdatingListenerBuilder connectTimeoutMillis(long connectTimeoutMillis)
Sets the connect timeout (in ms). (default: 1000)- Parameters:
connectTimeoutMillis
- the connect timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListenerBuilder(CuratorFramework, String)
-
sessionTimeout
public ZooKeeperUpdatingListenerBuilder sessionTimeout(Duration sessionTimeout)
Sets the session timeout.- Parameters:
sessionTimeout
- the session timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListenerBuilder(CuratorFramework, String)
-
sessionTimeoutMillis
public ZooKeeperUpdatingListenerBuilder sessionTimeoutMillis(long sessionTimeoutMillis)
Sets the session timeout (in ms). (default: 10000)- Parameters:
sessionTimeoutMillis
- the session timeout- Throws:
IllegalStateException
- if this builder is constructed withZooKeeperUpdatingListenerBuilder(CuratorFramework, String)
-
endpoint
public ZooKeeperUpdatingListenerBuilder endpoint(com.linecorp.armeria.client.Endpoint endpoint)
Sets theEndpoint
to register. If not set, the current host name is used automatically.- Parameters:
endpoint
- theEndpoint
to register
-
nodeValueCodec
public ZooKeeperUpdatingListenerBuilder nodeValueCodec(NodeValueCodec nodeValueCodec)
Sets theNodeValueCodec
to encode or decode ZooKeeper data.- Parameters:
nodeValueCodec
- theNodeValueCodec
instance to use
-
build
public ZooKeeperUpdatingListener build()
Returns a newly-createdZooKeeperUpdatingListener
instance that registers the server to ZooKeeper when the server starts.
-
-