public class DynamicEndpointGroup extends AbstractListenable<List<Endpoint>> implements EndpointGroup, ListenableAsyncCloseable
EndpointGroup. The list of Endpoints can be updated dynamically.| Constructor and Description |
|---|
DynamicEndpointGroup()
Creates a new empty
DynamicEndpointGroup that uses
EndpointSelectionStrategy.weightedRoundRobin() as its EndpointSelectionStrategy. |
DynamicEndpointGroup(EndpointSelectionStrategy selectionStrategy)
Creates a new empty
DynamicEndpointGroup that uses the specified
EndpointSelectionStrategy. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEndpoint(Endpoint e)
|
void |
close()
Releases any underlying resources held by this object synchronously.
|
CompletableFuture<?> |
closeAsync()
Releases any underlying resources held by this object asynchronously.
|
protected void |
doCloseAsync(CompletableFuture<?> future)
Override this method to release the resources held by this
EndpointGroup and complete
the specified CompletableFuture. |
List<Endpoint> |
endpoints()
Returns the endpoints held by this
EndpointGroup. |
boolean |
isClosed()
Returns whether
AsyncCloseable.close() or AsyncCloseable.closeAsync() operation has been completed. |
boolean |
isClosing()
Returns whether
AsyncCloseable.close() or AsyncCloseable.closeAsync() has been called. |
protected void |
removeEndpoint(Endpoint e)
|
Endpoint |
select(ClientRequestContext ctx)
Selects an
Endpoint from this EndpointGroup. |
EndpointSelectionStrategy |
selectionStrategy()
Returns the
EndpointSelectionStrategy of this EndpointGroup. |
protected void |
setEndpoints(Iterable<Endpoint> endpoints)
|
CompletableFuture<?> |
whenClosed()
Returns the
CompletableFuture which is completed after the AsyncCloseable.close() or
AsyncCloseable.closeAsync() operation is completed. |
CompletableFuture<List<Endpoint>> |
whenReady()
Returns the
CompletableFuture which is completed when the initial Endpoints are ready. |
addListener, notifyListeners, removeListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, awaitInitialEndpoints, awaitInitialEndpoints, empty, initialEndpointsFuture, of, of, of, of, orElse, removeListenerpublic DynamicEndpointGroup()
DynamicEndpointGroup that uses
EndpointSelectionStrategy.weightedRoundRobin() as its EndpointSelectionStrategy.public DynamicEndpointGroup(EndpointSelectionStrategy selectionStrategy)
DynamicEndpointGroup that uses the specified
EndpointSelectionStrategy.public final List<Endpoint> endpoints()
EndpointGroupEndpointGroup.endpoints in interface EndpointGrouppublic final EndpointSelectionStrategy selectionStrategy()
EndpointGroupEndpointSelectionStrategy of this EndpointGroup.selectionStrategy in interface EndpointGrouppublic final Endpoint select(ClientRequestContext ctx)
EndpointGroupEndpoint from this EndpointGroup.select in interface EndpointGroupselect in interface EndpointSelectorEndpoint selected by the EndpointSelectionStrategy,
which was specified when constructing this EndpointGroup.public CompletableFuture<List<Endpoint>> whenReady()
CompletableFuture which is completed when the initial Endpoints are ready.whenReady in interface EndpointGroupprotected final void addEndpoint(Endpoint e)
protected final void removeEndpoint(Endpoint e)
public final boolean isClosing()
ListenableAsyncCloseableAsyncCloseable.close() or AsyncCloseable.closeAsync() has been called.isClosing in interface ListenableAsyncCloseableListenableAsyncCloseable.isClosed()public final boolean isClosed()
ListenableAsyncCloseableAsyncCloseable.close() or AsyncCloseable.closeAsync() operation has been completed.isClosed in interface ListenableAsyncCloseableListenableAsyncCloseable.isClosing()public final CompletableFuture<?> whenClosed()
ListenableAsyncCloseableCompletableFuture which is completed after the AsyncCloseable.close() or
AsyncCloseable.closeAsync() operation is completed.whenClosed in interface ListenableAsyncCloseablepublic final CompletableFuture<?> closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableFuture which is completed after the resources are releasedprotected void doCloseAsync(CompletableFuture<?> future)
EndpointGroup and complete
the specified CompletableFuture.public final void close()
AsyncCloseableclose in interface AsyncCloseableclose in interface AutoCloseableCopyright © 2020 LeanCloud. All rights reserved.