public interface EndpointGroup extends Listenable<List<Endpoint>>, EndpointSelector, AsyncCloseable
Endpoints.| Modifier and Type | Method and Description |
|---|---|
default void |
addListener(Consumer<? super List<Endpoint>> listener)
Adds a
Consumer that will be invoked when a Listenable changes its value. |
default List<Endpoint> |
awaitInitialEndpoints()
Deprecated.
Use
whenReady() and CompletableFuture.get(). |
default List<Endpoint> |
awaitInitialEndpoints(long timeout,
TimeUnit unit)
Deprecated.
|
static EndpointGroup |
empty()
Returns a singleton
EndpointGroup which does not contain any Endpoints. |
List<Endpoint> |
endpoints()
Returns the endpoints held by this
EndpointGroup. |
default CompletableFuture<List<Endpoint>> |
initialEndpointsFuture()
Deprecated.
Use
whenReady(). |
static EndpointGroup |
of(EndpointGroup... endpointGroups)
|
static EndpointGroup |
of(EndpointSelectionStrategy selectionStrategy,
EndpointGroup... endpointGroups)
|
static EndpointGroup |
of(EndpointSelectionStrategy selectionStrategy,
Iterable<? extends EndpointGroup> endpointGroups)
|
static EndpointGroup |
of(Iterable<? extends EndpointGroup> endpointGroups)
|
default EndpointGroup |
orElse(EndpointGroup nextEndpointGroup)
Creates a new
EndpointGroup that tries this EndpointGroup first and then the specified
EndpointGroup when this EndpointGroup does not have a requested resource. |
default void |
removeListener(Consumer<?> listener)
Remove a listener.
|
Endpoint |
select(ClientRequestContext ctx)
Selects an
Endpoint from this EndpointGroup. |
EndpointSelectionStrategy |
selectionStrategy()
Returns the
EndpointSelectionStrategy of this EndpointGroup. |
CompletableFuture<List<Endpoint>> |
whenReady()
Returns a
CompletableFuture which is completed when the initial Endpoints are ready. |
close, closeAsyncstatic EndpointGroup empty()
EndpointGroup which does not contain any Endpoints.static EndpointGroup of(EndpointGroup... endpointGroups)
EndpointGroup that combines all the Endpoints of endpointGroups.
endpointGroups can be instances of Endpoint as well, any EndpointGroups and
Endpoint will all be combined into a single EndpointGroup that contains the total set.
The EndpointGroup returned by this method will use
EndpointSelectionStrategy.weightedRoundRobin() for selecting an Endpoint.static EndpointGroup of(EndpointSelectionStrategy selectionStrategy, EndpointGroup... endpointGroups)
EndpointGroup that combines all the Endpoints of endpointGroups.
endpointGroups can be instances of Endpoint as well, any EndpointGroups and
Endpoint will all be combined into a single EndpointGroup that contains the total set.static EndpointGroup of(Iterable<? extends EndpointGroup> endpointGroups)
EndpointGroup that combines all the Endpoints of endpointGroups.
endpointGroups can be instances of Endpoint as well, any EndpointGroups and
Endpoint will all be combined into a single EndpointGroup that contains the total set.
The EndpointGroup returned by this method will use
EndpointSelectionStrategy.weightedRoundRobin() for selecting an Endpoint.static EndpointGroup of(EndpointSelectionStrategy selectionStrategy, Iterable<? extends EndpointGroup> endpointGroups)
EndpointGroup that combines all the Endpoints of endpointGroups.
endpointGroups can be instances of Endpoint as well, any EndpointGroups and
Endpoint will all be combined into a single EndpointGroup that contains the total set.List<Endpoint> endpoints()
EndpointGroup.EndpointSelectionStrategy selectionStrategy()
EndpointSelectionStrategy of this EndpointGroup.Endpoint select(ClientRequestContext ctx)
Endpoint from this EndpointGroup.select in interface EndpointSelectorEndpoint selected by the EndpointSelectionStrategy,
which was specified when constructing this EndpointGroup.CompletableFuture<List<Endpoint>> whenReady()
CompletableFuture which is completed when the initial Endpoints are ready.@Deprecated default CompletableFuture<List<Endpoint>> initialEndpointsFuture()
whenReady().CompletableFuture which is completed when the initial Endpoints are ready.@Deprecated default List<Endpoint> awaitInitialEndpoints() throws InterruptedException
whenReady() and CompletableFuture.get().Endpoints are ready.CancellationException - if AsyncCloseable.close() was called before the initial Endpoints are setInterruptedException@Deprecated default List<Endpoint> awaitInitialEndpoints(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
whenReady() and CompletableFuture.get(long, TimeUnit).Endpoints are ready, with timeout.CancellationException - if AsyncCloseable.close() was called before the initial Endpoints are setTimeoutException - if the initial Endpoints are not set until timeoutInterruptedExceptiondefault void addListener(Consumer<? super List<Endpoint>> listener)
ListenableConsumer that will be invoked when a Listenable changes its value.addListener in interface Listenable<List<Endpoint>>default void removeListener(Consumer<?> listener)
ListenableremoveListener in interface Listenable<List<Endpoint>>default EndpointGroup orElse(EndpointGroup nextEndpointGroup)
EndpointGroup that tries this EndpointGroup first and then the specified
EndpointGroup when this EndpointGroup does not have a requested resource.nextEndpointGroup - the EndpointGroup to try secondly.Copyright © 2020 LeanCloud. All rights reserved.