U - the type of address before resolution (unresolved address)R - the type of address after resolution (resolved address)Client - the type of client to connect to the partitionspublic final class DefaultPartitionedClientGroup<U,R,Client extends ListenableAsyncCloseable> extends java.lang.Object implements ClientGroup<PartitionAttributes,Client>
ClientGroup that can be used for partitioned client use-cases where PartitionAttributes are discovered through PartitionedServiceDiscovererEvents.| Modifier and Type | Class and Description |
|---|---|
static interface |
DefaultPartitionedClientGroup.PartitionedClientFactory<U,R,Client>
Factory for building partitioned clients.
|
| Constructor and Description |
|---|
DefaultPartitionedClientGroup(java.util.function.Function<PartitionAttributes,Client> closedPartitionClient,
java.util.function.Function<PartitionAttributes,Client> unknownPartitionClient,
DefaultPartitionedClientGroup.PartitionedClientFactory<U,R,Client> clientFactory,
PartitionMapFactory partitionMapFactory,
Publisher<? extends PartitionedServiceDiscovererEvent<R>> psdEvents,
int psdMaxQueueSize)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. |
Client |
get(PartitionAttributes partitionAttributes)
Return the
Client identified by the provided key or create a new one when none exists. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfrompublic DefaultPartitionedClientGroup(java.util.function.Function<PartitionAttributes,Client> closedPartitionClient, java.util.function.Function<PartitionAttributes,Client> unknownPartitionClient, DefaultPartitionedClientGroup.PartitionedClientFactory<U,R,Client> clientFactory, PartitionMapFactory partitionMapFactory, Publisher<? extends PartitionedServiceDiscovererEvent<R>> psdEvents, int psdMaxQueueSize)
closedPartitionClient - factory for clients that handle requests for a closed partitionunknownPartitionClient - factory for clients that handles requests for an unknown partitionclientFactory - used to create clients for newly discovered partitionspartitionMapFactory - factory to provide a PartitionMap implementation appropriate for the use-casepsdEvents - the stream of PartitionedServiceDiscovererEventspsdMaxQueueSize - max number of new partitions to queue uppublic Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync().
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync().
closeAsyncGracefully in interface AsyncCloseableCompletable that is notified once the close is complete.public Client get(PartitionAttributes partitionAttributes)
ClientGroupClient identified by the provided key or create a new one when none exists.get in interface ClientGroup<PartitionAttributes,Client extends ListenableAsyncCloseable>partitionAttributes - the key identifying the client to return or create, this key may contain attributes about the
requested client in order to create new instanceskey, either by looking up an existing or creating a new
instance if non-existent