T - The partition type.public final class PowerSetPartitionMap<T extends AsyncCloseable> extends java.lang.Object implements PartitionMap<T>
PartitionMap that creates the full power set using the individual attributes in
PartitionAttributeses to create partitions for each add(PartitionAttributes).| Constructor and Description |
|---|
PowerSetPartitionMap(java.util.function.Function<PartitionAttributes,T> valueFactory,
java.util.function.IntFunction<PartitionAttributesBuilder> partitionAttributesBuilderFunc)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<T> |
add(PartitionAttributes partition)
Add a new
PartitionAttributes that is absolutely specified. |
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. |
T |
get(PartitionAttributes wildCardAttributes)
Get the partition value corresponding to the
PartitionAttributes parameter. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
java.util.List<T> |
remove(PartitionAttributes partition)
Remove a
PartitionAttributes that was previously added via PartitionMap.add(PartitionAttributes). |
public PowerSetPartitionMap(java.util.function.Function<PartitionAttributes,T> valueFactory, java.util.function.IntFunction<PartitionAttributesBuilder> partitionAttributesBuilderFunc)
valueFactory - Generates values for new partitions.partitionAttributesBuilderFunc - Generates new PartitionAttributes objects, this factory must be
consistent with the factory used to build the PartitionAttributes objects for
add(PartitionAttributes) and remove(PartitionAttributes) to ensure Object.hashCode() and
Object.equals(Object) are consistent.public T get(@Nullable PartitionAttributes wildCardAttributes)
PartitionMapPartitionAttributes parameter.
This may be called from any thread.
get in interface PartitionMap<T extends AsyncCloseable>wildCardAttributes - A PartitionAttributes which identifies the partition. Note that this may not be
fully specified, and this is where the "wild card" terminology comes from.PartitionAttributes parameter.public java.util.List<T> add(PartitionAttributes partition)
PartitionMapPartitionAttributes that is absolutely specified. This may create new partitions.
The terminology "absolutely"/"fully" here is meant to clarify that partition contains all the attributes
to uniquely identify a single host. This is typically called when notification is received from
ServiceDiscoverer and that address is translated to the corresponding PartitionAttributes.
This method is not guaranteed to provide any thread safety or visibility with respect to calls to this method or
PartitionMap.remove(PartitionAttributes). If these methods are called from multiple threads you may need to
provide external synchronization.
add in interface PartitionMap<T extends AsyncCloseable>partition - A fully specified PartitionAttributes.partition belongs to. These may (or may not) be new partitions.public java.util.List<T> remove(PartitionAttributes partition)
PartitionMapPartitionAttributes that was previously added via PartitionMap.add(PartitionAttributes).
New partitions typically are not created as a result of this method call.
This method is not guaranteed to provide any thread safety or visibility with respect to calls to this method or
PartitionMap.add(PartitionAttributes). If these methods are called from multiple threads you may need to
provide external synchronization.
remove in interface PartitionMap<T extends AsyncCloseable>partition - A fully specified PartitionAttributes.partition belongs to.public 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.