Package io.atomix.primitive.session
Interface SessionClient
public interface SessionClient
Partition proxy.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSessionClient.BuilderPartition proxy builder. -
Method Summary
Modifier and Type Method Description voidaddEventListener(EventType eventType, java.util.function.Consumer<PrimitiveEvent> listener)Adds an event listener.voidaddStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)Registers a session state change listener.CompletableFuture<Void>close()Closes the proxy.CompletableFuture<SessionClient>connect()Connects the proxy.io.atomix.utils.concurrent.ThreadContextcontext()Returns the partition thread context.CompletableFuture<Void>delete()Closes the session and deletes the service.CompletableFuture<byte[]>execute(PrimitiveOperation operation)Executes an operation to the cluster.PrimitiveStategetState()Returns the session state.Stringname()Returns the primitive name.PartitionIdpartitionId()Returns the partition identifier.voidremoveEventListener(EventType eventType, java.util.function.Consumer<PrimitiveEvent> listener)Removes an event listener.voidremoveStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)Removes a state change listener.SessionIdsessionId()Returns the proxy session identifier.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.
-
getState
PrimitiveState getState()Returns the session state.- Returns:
- The session state.
-
sessionId
SessionId sessionId()Returns the proxy session identifier.- Returns:
- The proxy session identifier
-
partitionId
PartitionId partitionId()Returns the partition identifier.- Returns:
- the partition identifier.
-
context
io.atomix.utils.concurrent.ThreadContext context()Returns the partition thread context.- Returns:
- the partition thread context
-
execute
Executes an operation to the cluster.- Parameters:
operation- the operation to execute- Returns:
- a future to be completed with the operation result
- Throws:
NullPointerException- ifoperationis null
-
addEventListener
Adds an event listener.- Parameters:
eventType- the event type for which to add the listenerlistener- the event listener to add
-
removeEventListener
void removeEventListener(EventType eventType, java.util.function.Consumer<PrimitiveEvent> listener)Removes an event listener.- Parameters:
eventType- the event type for which to remove the listenerlistener- the event listener to remove
-
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<SessionClient> connect()Connects the proxy.- Returns:
- a future to be completed once the proxy has been connected
-
close
CompletableFuture<Void> close()Closes the proxy.- Returns:
- a future to be completed once the proxy has been closed
-
delete
CompletableFuture<Void> delete()Closes the session and deletes the service.- Returns:
- a future to be completed once the service has been deleted
-