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 voidaddStateChangeListener(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.Stringname()Returns the name of this primitive.PrimitiveProtocolprotocol()Returns the primitive protocol.voidremoveStateChangeListener(java.util.function.Consumer<PrimitiveState> listener)Unregisters a previously registered listener to be called when the primitive's state changes.StringtoString()PrimitiveTypetype()Returns the type of primitive.
-
Method Details
-
name
Description copied from interface:DistributedPrimitiveReturns the name of this primitive.- Specified by:
namein interfaceDistributedPrimitive- Returns:
- name
-
type
Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
typein interfaceDistributedPrimitive- Returns:
- primitive type
-
protocol
Description copied from interface:DistributedPrimitiveReturns the primitive protocol.- Specified by:
protocolin interfaceDistributedPrimitive- Returns:
- the primitive protocol
-
addStateChangeListener
Description copied from interface:DistributedPrimitiveRegisters a listener to be called when the primitive's state changes.- Specified by:
addStateChangeListenerin interfaceDistributedPrimitive- Parameters:
listener- The listener to be called when the state changes.
-
removeStateChangeListener
Description copied from interface:DistributedPrimitiveUnregisters a previously registered listener to be called when the primitive's state changes.- Specified by:
removeStateChangeListenerin 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:AsyncPrimitiveCloses the primitive.- Specified by:
closein interfaceAsyncPrimitive- Returns:
- a future to be completed once the primitive is closed
-
delete
Description copied from interface:AsyncPrimitivePurges 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:
deletein interfaceAsyncPrimitive- Returns:
CompletableFuturethat is completed when the operation completes
-
toString
-