Package io.atomix.primitive.proxy
Interface ProxyClient<S>
public interface ProxyClient<S>
Primitive proxy.
-
Method Summary
Modifier and Type Method Description default CompletableFuture<Void>acceptAll(java.util.function.Consumer<S> operation)Submits an empty operation to all partitions.default CompletableFuture<Void>acceptBy(String key, java.util.function.Consumer<S> operation)Submits an empty operation to the owning partition for the given key.default CompletableFuture<Void>acceptOn(PartitionId partitionId, java.util.function.Consumer<S> operation)Submits an empty operation to the given partition.voidaddStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)Registers a session state change listener.default <R> CompletableFuture<java.util.stream.Stream<R>>applyAll(java.util.function.Function<S,R> operation)Submits an empty operation to all partitions.default <R> CompletableFuture<R>applyBy(Object key, java.util.function.Function<S,R> operation)Submits an empty operation to the owning partition for the given key.default <R> CompletableFuture<R>applyBy(String key, java.util.function.Function<S,R> operation)Submits an empty operation to the owning partition for the given key.default <R> CompletableFuture<R>applyOn(PartitionId partitionId, java.util.function.Function<S,R> operation)Submits an empty operation to the given partition.CompletableFuture<Void>close()Closes the proxy client.CompletableFuture<ProxyClient<S>>connect()Connects the proxy client.CompletableFuture<Void>delete()Deletes the proxy client.ProxySession<S>getPartition(PartitionId partitionId)Returns the proxy with the given identifier.default ProxySession<S>getPartition(Object key)Returns the partition proxy for the given key.default ProxySession<S>getPartition(String key)Returns the partition proxy for the given key.PartitionIdgetPartitionId(Object key)Returns the partition ID for the given key.PartitionIdgetPartitionId(String key)Returns the partition ID for the given key.Collection<PartitionId>getPartitionIds()Returns the collection of all partition IDs.Collection<ProxySession<S>>getPartitions()Returns the collection of all partition proxies.PrimitiveStategetState()Returns the session state.Stringname()Returns the primitive name.PrimitiveProtocolprotocol()Returns the client proxy protocol.default voidregister(Object client)Registers a client proxy.voidremoveStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)Removes a state change listener.PrimitiveTypetype()Returns the client proxy type.
-
Method Details
-
name
String name()Returns the primitive name.- Returns:
- the primitive name
-
type
PrimitiveType type()Returns the client proxy type.- Returns:
- The client proxy type.
-
protocol
PrimitiveProtocol protocol()Returns the client proxy protocol.- Returns:
- the client proxy protocol
-
getState
PrimitiveState getState()Returns the session state.- Returns:
- The session state.
-
getPartitions
Collection<ProxySession<S>> getPartitions()Returns the collection of all partition proxies.- Returns:
- the collection of all partition proxies
-
getPartitionIds
Collection<PartitionId> getPartitionIds()Returns the collection of all partition IDs.- Returns:
- the collection of all partition IDs
-
getPartition
Returns the proxy with the given identifier.- Parameters:
partitionId- the partition with the given identifier- Returns:
- the partition proxy with the given identifier
-
getPartitionId
Returns the partition ID for the given key.- Parameters:
key- the key for which to return the partition ID- Returns:
- the partition ID for the given key
-
getPartitionId
Returns the partition ID for the given key.- Parameters:
key- the key for which to return the partition ID- Returns:
- the partition ID for the given key
-
getPartition
Returns the partition proxy for the given key.- Parameters:
key- the key for which to return the partition proxy- Returns:
- the partition proxy for the given key
-
getPartition
Returns the partition proxy for the given key.- Parameters:
key- the key for which to return the partition proxy- Returns:
- the partition proxy for the given key
-
register
Registers a client proxy.- Parameters:
client- the client proxy to register
-
acceptAll
Submits an empty operation to all partitions.- Parameters:
operation- the operation identifier- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
applyAll
default <R> CompletableFuture<java.util.stream.Stream<R>> applyAll(java.util.function.Function<S,R> operation)Submits an empty operation to all partitions.- Type Parameters:
R- the operation result type- Parameters:
operation- the operation identifier- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
acceptOn
default CompletableFuture<Void> acceptOn(PartitionId partitionId, java.util.function.Consumer<S> operation)Submits an empty operation to the given partition.- Parameters:
partitionId- the partition in which to execute the operationoperation- the operation identifier- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
applyOn
default <R> CompletableFuture<R> applyOn(PartitionId partitionId, java.util.function.Function<S,R> operation)Submits an empty operation to the given partition.- Type Parameters:
R- the operation result type- Parameters:
partitionId- the partition in which to execute the operationoperation- the operation identifier- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
acceptBy
Submits an empty operation to the owning partition for the given key.- Parameters:
key- the key for which to submit the operationoperation- the operation- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
applyBy
Submits an empty operation to the owning partition for the given key.- Type Parameters:
R- the operation result type- Parameters:
key- the key for which to submit the operationoperation- the operation- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
applyBy
Submits an empty operation to the owning partition for the given key.- Type Parameters:
R- the operation result type- Parameters:
key- the key for which to submit the operationoperation- the operation- Returns:
- A completable future to be completed with the operation result. The future is guaranteed to be completed after all
PrimitiveOperationsubmission futures that preceded it. - Throws:
NullPointerException- ifoperationis null
-
addStateChangeListener
Registers a session state change listener.- Parameters:
listener- The callback to call when the session state changes.
-
removeStateChangeListener
Removes a state change listener.- Parameters:
listener- the state change listener to remove
-
connect
CompletableFuture<ProxyClient<S>> connect()Connects the proxy client.- Returns:
- a future to be completed once the proxy client has been connected
-
close
CompletableFuture<Void> close()Closes the proxy client.- Returns:
- a future to be completed once the proxy client has been closed
-
delete
CompletableFuture<Void> delete()Deletes the proxy client.- Returns:
- a future to be completed once the service has been deleted
-