Package io.atomix.primitive.proxy
Interface ProxySession<S>
public interface ProxySession<S>
Proxy session.
-
Method Summary
Modifier and Type Method Description CompletableFuture<Void>accept(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.<R> CompletableFuture<R>apply(java.util.function.Function<S,R> operation)Submits an empty operation to the given partition.CompletableFuture<Void>close()Closes the proxy session.CompletableFuture<ProxySession<S>>connect()Connects the proxy session.io.atomix.utils.concurrent.ThreadContextcontext()Returns the session thread context.CompletableFuture<Void>delete()Closes the proxy session and deletes the service.PrimitiveStategetState()Returns the session state.Stringname()Returns the primitive name.PartitionIdpartitionId()Returns the proxy partition ID.voidregister(Object client)Registers a client listener.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.
-
partitionId
PartitionId partitionId()Returns the proxy partition ID.- Returns:
- the partition ID
-
context
io.atomix.utils.concurrent.ThreadContext context()Returns the session thread context.- Returns:
- the session thread context
-
getState
PrimitiveState getState()Returns the session state.- Returns:
- The session state.
-
register
Registers a client listener.- Parameters:
client- the client listener to register
-
accept
Submits an empty operation to the given partition.- 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
-
apply
Submits an empty operation to the given partition.- 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
-
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<ProxySession<S>> connect()Connects the proxy session.- Returns:
- a future to be completed once the proxy session has been connected
-
close
CompletableFuture<Void> close()Closes the proxy session.- Returns:
- a future to be completed once the proxy session has been closed
-
delete
CompletableFuture<Void> delete()Closes the proxy session and deletes the service.- Returns:
- a future to be completed once the service has been deleted
-