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
(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
.Returns the latest value notified before.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
(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, removeEndpoint, select, select, selectionStrategy, selectionTimeoutMillis, selectNow, setEndpoints, toString, toStringHelper, 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(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(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
-
latestValue
Description copied from class:AbstractListenable
Returns the latest value notified before.null
if the value has not been initialized yet or the implementation of this class cannot cache it.- Overrides:
latestValue
in classAbstractListenable<List<Endpoint>>
-