Class DynamicEndpointGroup
java.lang.Object
com.linecorp.armeria.common.util.AbstractListenable<List<Endpoint>>
com.linecorp.armeria.client.endpoint.DynamicEndpointGroup
- All Implemented Interfaces:
EndpointGroup
,EndpointSelector
,AsyncCloseable
,Listenable<List<Endpoint>>
,ListenableAsyncCloseable
,AutoCloseable
- Direct Known Subclasses:
DnsAddressEndpointGroup
,DnsServiceEndpointGroup
,DnsTextEndpointGroup
,EurekaEndpointGroup
,HealthCheckedEndpointGroup
,PropertiesEndpointGroup
,ZooKeeperEndpointGroup
public class DynamicEndpointGroup extends AbstractListenable<List<Endpoint>> implements EndpointGroup, ListenableAsyncCloseable
A dynamic
EndpointGroup
. The list of Endpoint
s can be updated dynamically.-
Constructor Summary
Constructors Constructor Description DynamicEndpointGroup()
Creates a new emptyDynamicEndpointGroup
that usesEndpointSelectionStrategy.weightedRoundRobin()
as itsEndpointSelectionStrategy
.DynamicEndpointGroup(EndpointSelectionStrategy selectionStrategy)
Creates a new emptyDynamicEndpointGroup
that uses the specifiedEndpointSelectionStrategy
. -
Method Summary
Modifier and Type Method 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 thisEndpointGroup
and complete the specifiedCompletableFuture
.List<Endpoint>
endpoints()
Returns the endpoints held by thisEndpointGroup
.boolean
isClosed()
Returns whetherAsyncCloseable.close()
orAsyncCloseable.closeAsync()
operation has been completed.boolean
isClosing()
Returns whetherAsyncCloseable.close()
orAsyncCloseable.closeAsync()
has been called.protected void
removeEndpoint(Endpoint e)
Endpoint
select(ClientRequestContext ctx)
Selects anEndpoint
from thisEndpointGroup
.EndpointSelectionStrategy
selectionStrategy()
Returns theEndpointSelectionStrategy
of thisEndpointGroup
.protected void
setEndpoints(Iterable<Endpoint> endpoints)
CompletableFuture<?>
whenClosed()
Returns theCompletableFuture
which is completed after theAsyncCloseable.close()
orAsyncCloseable.closeAsync()
operation is completed.CompletableFuture<List<Endpoint>>
whenReady()
Returns theCompletableFuture
which is completed when the initialEndpoint
s are ready.Methods inherited from class com.linecorp.armeria.common.util.AbstractListenable
addListener, notifyListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.endpoint.EndpointGroup
addListener, orElse, removeListener
-
Constructor Details
-
DynamicEndpointGroup
public DynamicEndpointGroup()Creates a new emptyDynamicEndpointGroup
that usesEndpointSelectionStrategy.weightedRoundRobin()
as itsEndpointSelectionStrategy
. -
DynamicEndpointGroup
Creates a new emptyDynamicEndpointGroup
that uses the specifiedEndpointSelectionStrategy
.
-
-
Method Details
-
endpoints
Description copied from interface:EndpointGroup
Returns the endpoints held by thisEndpointGroup
.- Specified by:
endpoints
in interfaceEndpointGroup
-
selectionStrategy
Description copied from interface:EndpointGroup
Returns theEndpointSelectionStrategy
of thisEndpointGroup
.- Specified by:
selectionStrategy
in interfaceEndpointGroup
-
select
Description copied from interface:EndpointGroup
Selects anEndpoint
from thisEndpointGroup
.- Specified by:
select
in interfaceEndpointGroup
- Specified by:
select
in interfaceEndpointSelector
- Returns:
- the
Endpoint
selected by theEndpointSelectionStrategy
, which was specified when constructing thisEndpointGroup
.
-
whenReady
Returns theCompletableFuture
which is completed when the initialEndpoint
s are ready.- Specified by:
whenReady
in interfaceEndpointGroup
-
addEndpoint
-
removeEndpoint
-
setEndpoints
-
isClosing
public final boolean isClosing()Description copied from interface:ListenableAsyncCloseable
Returns whetherAsyncCloseable.close()
orAsyncCloseable.closeAsync()
has been called.- Specified by:
isClosing
in interfaceListenableAsyncCloseable
- See Also:
ListenableAsyncCloseable.isClosed()
-
isClosed
public final boolean isClosed()Description copied from interface:ListenableAsyncCloseable
Returns whetherAsyncCloseable.close()
orAsyncCloseable.closeAsync()
operation has been completed.- Specified by:
isClosed
in interfaceListenableAsyncCloseable
- See Also:
ListenableAsyncCloseable.isClosing()
-
whenClosed
Description copied from interface:ListenableAsyncCloseable
Returns theCompletableFuture
which is completed after theAsyncCloseable.close()
orAsyncCloseable.closeAsync()
operation is completed.- Specified by:
whenClosed
in interfaceListenableAsyncCloseable
-
closeAsync
Description copied from interface:AsyncCloseable
Releases any underlying resources held by this object asynchronously.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Returns:
- the
CompletableFuture
which is completed after the resources are released
-
doCloseAsync
Override this method to release the resources held by thisEndpointGroup
and complete the specifiedCompletableFuture
. -
close
public final void close()Description copied from interface:AsyncCloseable
Releases any underlying resources held by this object synchronously.- Specified by:
close
in interfaceAsyncCloseable
- Specified by:
close
in interfaceAutoCloseable
-