Class ZooKeeperEndpointGroup
java.lang.Object
com.linecorp.armeria.common.util.AbstractListenable<List<Endpoint>>
com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
com.linecorp.armeria.client.zookeeper.ZooKeeperEndpointGroup
- All Implemented Interfaces:
EndpointGroup
,EndpointSelector
,AsyncCloseable
,Listenable<List<Endpoint>>
,ListenableAsyncCloseable
,AutoCloseable
A ZooKeeper-based
EndpointGroup
implementation. This EndpointGroup
retrieves the list of
Endpoint
s from a ZooKeeper and updates it when the children of the znode changes.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(String zkConnectionStr, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroupBuilder
created with the specified ZooKeeper connection string and ZNode path.builder
(org.apache.curator.framework.CuratorFramework client, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroupBuilder
created with the specifiedCuratorFramework
and ZNode path.protected void
doCloseAsync
(CompletableFuture<?> future) Override this method to release the resources held by thisEndpointGroup
and complete the specifiedCompletableFuture
.static ZooKeeperEndpointGroup
of
(String zkConnectionStr, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroup
that retrieves theEndpoint
list from the ZNode at the specified connection string and path.static ZooKeeperEndpointGroup
of
(org.apache.curator.framework.CuratorFramework client, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroup
that retrieves theEndpoint
list from the ZNode at the specified path using the specifiedCuratorFramework
.Methods inherited from class com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
addEndpoint, allowsEmptyEndpoints, builder, close, closeAsync, endpoints, isClosed, isClosing, latestValue, removeEndpoint, select, select, selectionStrategy, selectionTimeoutMillis, selectNow, setEndpoints, toString, toString, whenClosed, whenReady
Methods inherited from class com.linecorp.armeria.common.util.AbstractListenable
addListener, addListener, notifyListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.endpoint.EndpointGroup
addListener, addListener, orElse, removeListener
-
Method Details
-
of
public static ZooKeeperEndpointGroup of(String zkConnectionStr, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroup
that retrieves theEndpoint
list from the ZNode at the specified connection string and path. A new ZooKeeper client will be created internally. The ZooKeeper client will be destroyed when the returnedZooKeeperEndpointGroup
is closed.- Parameters:
zkConnectionStr
- the ZooKeeper connection stringznodePath
- the ZooKeeper node to registerspec
- theZooKeeperDiscoverySpec
to find and decode the registered instances
-
of
public static ZooKeeperEndpointGroup of(org.apache.curator.framework.CuratorFramework client, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroup
that retrieves theEndpoint
list from the ZNode at the specified path using the specifiedCuratorFramework
. Note that the specifiedCuratorFramework
will not be destroyed when the returnedZooKeeperEndpointGroup
is closed.- Parameters:
client
- the curator framework instanceznodePath
- the ZooKeeper node to registerspec
- theZooKeeperDiscoverySpec
to find and decode the registered instances
-
builder
public static ZooKeeperEndpointGroupBuilder builder(String zkConnectionStr, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroupBuilder
created with the specified ZooKeeper connection string and ZNode path. TheZooKeeperEndpointGroup
built by the returned builder will create a new ZooKeeper client internally. The ZooKeeper client will be destroyed when theZooKeeperEndpointGroup
is closed.- Parameters:
zkConnectionStr
- the ZooKeeper connection stringznodePath
- the ZooKeeper node to registerspec
- theZooKeeperDiscoverySpec
to find and decode the registered instances
-
builder
public static ZooKeeperEndpointGroupBuilder builder(org.apache.curator.framework.CuratorFramework client, String znodePath, ZooKeeperDiscoverySpec spec) Returns a newZooKeeperEndpointGroupBuilder
created with the specifiedCuratorFramework
and ZNode path. Note that the specifiedCuratorFramework
will not be destroyed when theZooKeeperEndpointGroup
built by the returned builder is closed.- Parameters:
client
- the curator framework instanceznodePath
- the ZooKeeper node to registerspec
- theZooKeeperDiscoverySpec
to find and decode the registered instances
-
doCloseAsync
Description copied from class:DynamicEndpointGroup
Override this method to release the resources held by thisEndpointGroup
and complete the specifiedCompletableFuture
.- Overrides:
doCloseAsync
in classDynamicEndpointGroup
-