Interface ProxyClient<S>


public interface ProxyClient<S>
Primitive proxy.
  • Method Details

    • name

      String name()
      Returns the primitive name.
      Returns:
      the primitive name
    • 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

      ProxySession<S> getPartition​(PartitionId partitionId)
      Returns the proxy with the given identifier.
      Parameters:
      partitionId - the partition with the given identifier
      Returns:
      the partition proxy with the given identifier
    • getPartitionId

      PartitionId getPartitionId​(String key)
      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

      PartitionId getPartitionId​(Object key)
      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

      default ProxySession<S> getPartition​(String key)
      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

      default ProxySession<S> getPartition​(Object key)
      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

      default void register​(Object client)
      Registers a client proxy.
      Parameters:
      client - the client proxy to register
    • acceptAll

      default CompletableFuture<Void> acceptAll​(java.util.function.Consumer<S> operation)
      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 PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is 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 PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is 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 operation
      operation - the operation identifier
      Returns:
      A completable future to be completed with the operation result. The future is guaranteed to be completed after all PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is 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 operation
      operation - the operation identifier
      Returns:
      A completable future to be completed with the operation result. The future is guaranteed to be completed after all PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is null
    • acceptBy

      default CompletableFuture<Void> acceptBy​(String key, java.util.function.Consumer<S> operation)
      Submits an empty operation to the owning partition for the given key.
      Parameters:
      key - the key for which to submit the operation
      operation - the operation
      Returns:
      A completable future to be completed with the operation result. The future is guaranteed to be completed after all PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is null
    • applyBy

      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.
      Type Parameters:
      R - the operation result type
      Parameters:
      key - the key for which to submit the operation
      operation - the operation
      Returns:
      A completable future to be completed with the operation result. The future is guaranteed to be completed after all PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is null
    • applyBy

      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.
      Type Parameters:
      R - the operation result type
      Parameters:
      key - the key for which to submit the operation
      operation - the operation
      Returns:
      A completable future to be completed with the operation result. The future is guaranteed to be completed after all PrimitiveOperation submission futures that preceded it.
      Throws:
      NullPointerException - if operation is null
    • addStateChangeListener

      void addStateChangeListener​(java.util.function.Consumer<PrimitiveState> listener)
      Registers a session state change listener.
      Parameters:
      listener - The callback to call when the session state changes.
    • removeStateChangeListener

      void removeStateChangeListener​(java.util.function.Consumer<PrimitiveState> listener)
      Removes a state change listener.
      Parameters:
      listener - the state change listener to remove
    • connect

      Connects the proxy client.
      Returns:
      a future to be completed once the proxy client has been connected
    • close

      Closes the proxy client.
      Returns:
      a future to be completed once the proxy client has been closed
    • delete

      Deletes the proxy client.
      Returns:
      a future to be completed once the service has been deleted