Package io.atomix.primitive
Class AbstractAsyncPrimitive<A extends AsyncPrimitive,S>
java.lang.Object
io.atomix.primitive.AbstractAsyncPrimitive<A,S>
- All Implemented Interfaces:
AsyncPrimitive
,DistributedPrimitive
public abstract class AbstractAsyncPrimitive<A extends AsyncPrimitive,S> extends Object implements AsyncPrimitive
Abstract base class for primitives that interact with Raft replicated state machines via proxy.
-
Field Summary
Fields inherited from interface io.atomix.primitive.DistributedPrimitive
DEFAULT_OPERATION_TIMEOUT_MILLIS
-
Method Summary
Modifier and Type Method Description void
addStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)
Registers a listener to be called when the primitive's state changes.CompletableFuture<Void>
close()
Closes the primitive.CompletableFuture<A>
connect()
Connects the primitive.CompletableFuture<Void>
delete()
Purges state associated with this primitive.String
name()
Returns the name of this primitive.PrimitiveProtocol
protocol()
Returns the primitive protocol.void
removeStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)
Unregisters a previously registered listener to be called when the primitive's state changes.String
toString()
PrimitiveType
type()
Returns the type of primitive.
-
Method Details
-
name
Description copied from interface:DistributedPrimitive
Returns the name of this primitive.- Specified by:
name
in interfaceDistributedPrimitive
- Returns:
- name
-
type
Description copied from interface:DistributedPrimitive
Returns the type of primitive.- Specified by:
type
in interfaceDistributedPrimitive
- Returns:
- primitive type
-
protocol
Description copied from interface:DistributedPrimitive
Returns the primitive protocol.- Specified by:
protocol
in interfaceDistributedPrimitive
- Returns:
- the primitive protocol
-
addStateChangeListener
Description copied from interface:DistributedPrimitive
Registers a listener to be called when the primitive's state changes.- Specified by:
addStateChangeListener
in interfaceDistributedPrimitive
- Parameters:
listener
- The listener to be called when the state changes.
-
removeStateChangeListener
Description copied from interface:DistributedPrimitive
Unregisters a previously registered listener to be called when the primitive's state changes.- Specified by:
removeStateChangeListener
in interfaceDistributedPrimitive
- Parameters:
listener
- The listener to unregister
-
connect
Connects the primitive.- Returns:
- a future to be completed once the primitive has been connected
-
close
Description copied from interface:AsyncPrimitive
Closes the primitive.- Specified by:
close
in interfaceAsyncPrimitive
- Returns:
- a future to be completed once the primitive is closed
-
delete
Description copied from interface:AsyncPrimitive
Purges state associated with this primitive.Implementations can override and provide appropriate clean up logic for purging any state state associated with the primitive. Whether modifications made within the destroy method have local or global visibility is left unspecified.
- Specified by:
delete
in interfaceAsyncPrimitive
- Returns:
CompletableFuture
that is completed when the operation completes
-
toString
-