public class Atomix extends AtomixCluster implements PrimitivesService
The Atomix
class is the primary interface to all Atomix features. To construct an Atomix
instance,
either configure the instance with a configuration file or construct a new instance from an AtomixBuilder
.
Builders can be created via various builder()
methods:
Atomix atomix = Atomix.builder()
.withMemberId("member-1")
.withAddress("localhost:5000")
.build();
Once an Atomix
instance has been constructed, start the instance by calling start()
:
atomix.start().join();
The returned CompletableFuture
will be completed once the node has been bootstrapped and all services are
available.
The instance can be used to access services for managing the cluster or communicating with other nodes. Additionally, it provides various methods for creating and operating on distributed primitives. Generally, the primitive methods are separated into two types. Primitive getters return multiton instances of a primitive. Primitives created via getters must be pre-configured in the Atomix instance configuration. Alternatively, primitive builders can be used to create and configure primitives in code:
AtomicMap<String, String> map = atomix.mapBuilder("my-map")
.withProtocol(MultiRaftProtocol.builder("raft")
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.build())
.build();
Custom primitives can be constructed by providing a custom PrimitiveType
and using the primitiveBuilder(String, PrimitiveType)
method:
MyPrimitive myPrimitive = atomix.primitiveBuilder("my-primitive, MyPrimitiveType.instance())
.withProtocol(MultiRaftProtocol.builder("raft")
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.build())
.build();
Constructor and Description |
---|
Atomix(ClassLoader classLoader,
File... configFiles) |
Atomix(ClassLoader classLoader,
List<File> configFiles) |
Atomix(ClassLoader classLoader,
String... configFiles) |
Atomix(File... configFiles) |
Atomix(String... configFiles) |
Modifier and Type | Method and Description |
---|---|
static AtomixBuilder |
builder()
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(AtomixConfig config)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(AtomixConfig config,
AtomixRegistry registry)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(AtomixConfig config,
ClassLoader classLoader)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(AtomixRegistry registry)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(ClassLoader classLoader)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(String config)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(String configFile,
AtomixRegistry registry)
Returns a new Atomix builder.
|
static AtomixBuilder |
builder(String configFile,
ClassLoader classLoader)
Returns a new Atomix builder.
|
static AtomixConfig |
config()
Returns a new Atomix configuration.
|
static AtomixConfig |
config(AtomixRegistry registry)
Returns a new Atomix configuration.
|
static AtomixConfig |
config(AtomixRegistry registry,
List<File> files)
Returns a new Atomix configuration from the given file.
|
static AtomixConfig |
config(AtomixRegistry registry,
String... files)
Returns a new Atomix configuration from the given file.
|
static AtomixConfig |
config(ClassLoader classLoader)
Returns a new Atomix configuration.
|
static AtomixConfig |
config(ClassLoader classLoader,
List<File> files)
Returns a new Atomix configuration from the given file.
|
static AtomixConfig |
config(ClassLoader classLoader,
String... files)
Returns a new Atomix configuration from the given file.
|
static AtomixConfig |
config(File... configFiles)
Returns a new Atomix configuration.
|
static AtomixConfig |
config(List<File> files)
Returns a new Atomix configuration from the given file.
|
static AtomixConfig |
config(String... files)
Returns a new Atomix configuration from the given file.
|
AtomicCounter |
getAtomicCounter(String name)
Gets or creates a
AtomicCounter . |
<K> AtomicCounterMap<K> |
getAtomicCounterMap(String name)
Gets or creates a
AtomicCounterMap . |
<V> AtomicDocumentTree<V> |
getAtomicDocumentTree(String name)
Gets or creates a
AtomicDocumentTree . |
AtomicIdGenerator |
getAtomicIdGenerator(String name)
Gets or creates a
AtomicIdGenerator . |
AtomicLock |
getAtomicLock(String name)
Gets or creates a
AtomicLock . |
<K,V> AtomicMap<K,V> |
getAtomicMap(String name)
Gets or creates a
AtomicMap . |
<K,V> AtomicMultimap<K,V> |
getAtomicMultimap(String name)
Gets or creates a
AtomicMultimap . |
<K extends Comparable<K>,V> |
getAtomicNavigableMap(String name)
Gets or creates a
AtomicNavigableMap . |
AtomicSemaphore |
getAtomicSemaphore(String name)
Gets or creates a
AtomicSemaphore . |
<K extends Comparable<K>,V> |
getAtomicSortedMap(String name)
Gets or creates a
AtomicSortedMap . |
<V> AtomicValue<V> |
getAtomicValue(String name)
Gets or creates a
AtomicValue . |
ConfigService |
getConfigService()
Returns the primitive configuration service.
|
DistributedCounter |
getCounter(String name)
Gets or creates a
DistributedCounter . |
DistributedCyclicBarrier |
getCyclicBarrier(String name)
Gets or creates a
DistributedCyclicBarrier . |
ScheduledExecutorService |
getExecutorService()
Returns the core Atomix executor service.
|
<T> LeaderElection<T> |
getLeaderElection(String name)
Gets or creates a
LeaderElection . |
<T> LeaderElector<T> |
getLeaderElector(String name)
Gets or creates a
LeaderElector . |
<E> DistributedList<E> |
getList(String name)
Gets or creates a
DistributedList . |
DistributedLock |
getLock(String name)
Gets or creates a
DistributedLock . |
<K,V> DistributedMap<K,V> |
getMap(String name)
Gets or creates a
DistributedMap . |
<K,V> DistributedMultimap<K,V> |
getMultimap(String name)
Gets or creates a
DistributedMultimap . |
<E> DistributedMultiset<E> |
getMultiset(String name)
Gets or creates a
DistributedMultiset . |
<K extends Comparable<K>,V> |
getNavigableMap(String name)
Gets or creates a
DistributedNavigableMap . |
<E extends Comparable<E>> |
getNavigableSet(String name)
Gets or creates a
DistributedNavigableSet . |
PartitionService |
getPartitionService()
Returns the partition service.
|
<P extends SyncPrimitive> |
getPrimitiveAsync(String name,
PrimitiveType<?,?,P> primitiveType)
Gets or creates a distributed primitive asynchronously.
|
<C extends PrimitiveConfig<C>,P extends SyncPrimitive> |
getPrimitiveAsync(String name,
PrimitiveType<?,C,P> primitiveType,
C primitiveConfig)
Gets or creates a distributed primitive asynchronously.
|
Collection<PrimitiveInfo> |
getPrimitives()
Returns a collection of open primitives.
|
Collection<PrimitiveInfo> |
getPrimitives(PrimitiveType primitiveType)
Returns a collection of open primitives of the given type.
|
PrimitivesService |
getPrimitivesService()
Returns the primitives service.
|
PrimitiveType |
getPrimitiveType(String typeName)
Returns a primitive type by name.
|
<E> DistributedQueue<E> |
getQueue(String name)
Gets or creates a
DistributedQueue . |
AtomixRegistry |
getRegistry()
Returns the Atomix registry service.
|
DistributedSemaphore |
getSemaphore(String name)
Gets or creates a
DistributedSemaphore . |
SerializationService |
getSerializationService()
Returns the primitive serialization service.
|
<E> DistributedSet<E> |
getSet(String name)
Gets or creates a
DistributedSet . |
<K extends Comparable<K>,V> |
getSortedMap(String name)
Gets or creates a
DistributedSortedMap . |
<E extends Comparable<E>> |
getSortedSet(String name)
Gets or creates a
DistributedSortedSet . |
TransactionService |
getTransactionService()
Returns the transaction service.
|
<V> DistributedValue<V> |
getValue(String name)
Gets or creates a
DistributedValue . |
<E> WorkQueue<E> |
getWorkQueue(String name)
Gets or creates a
WorkQueue . |
<B extends PrimitiveBuilder<B,C,P>,C extends PrimitiveConfig<C>,P extends SyncPrimitive> |
primitiveBuilder(String name,
PrimitiveType<B,C,P> primitiveType)
Creates a new named primitive builder of the given
primitiveType . |
CompletableFuture<Void> |
start()
Starts the Atomix instance.
|
CompletableFuture<Void> |
stop()
Stops the managed object.
|
String |
toString() |
TransactionBuilder |
transactionBuilder(String name)
Creates a new transaction builder.
|
builder, getBroadcastService, getCommunicationService, getEventService, getMembershipService, getMessagingService, getUnicastService, isRunning
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
atomicCounterBuilder, atomicCounterMapBuilder, atomicDocumentTreeBuilder, atomicIdGeneratorBuilder, atomicLockBuilder, atomicMapBuilder, atomicMultimapBuilder, atomicNavigableMapBuilder, atomicSemaphoreBuilder, atomicSortedMapBuilder, atomicValueBuilder, counterBuilder, cyclicBarrierBuilder, leaderElectionBuilder, leaderElectorBuilder, listBuilder, lockBuilder, mapBuilder, multimapBuilder, multisetBuilder, navigableMapBuilder, navigableSetBuilder, queueBuilder, semaphoreBuilder, setBuilder, sortedMapBuilder, sortedSetBuilder, transactionBuilder, valueBuilder, workQueueBuilder
getPrimitive, getPrimitive
public Atomix(String... configFiles)
public Atomix(ClassLoader classLoader, String... configFiles)
public Atomix(File... configFiles)
public Atomix(ClassLoader classLoader, File... configFiles)
public Atomix(ClassLoader classLoader, List<File> configFiles)
public static AtomixConfig config()
The configuration will be loaded from atomix.conf
, atomix.json
, or atomix.properties
if
located on the classpath.
public static AtomixConfig config(ClassLoader classLoader)
The configuration will be loaded from atomix.conf
, atomix.json
, or atomix.properties
if
located on the classpath.
classLoader
- the class loaderpublic static AtomixConfig config(AtomixRegistry registry)
The configuration will be loaded from atomix.conf
, atomix.json
, or atomix.properties
if
located on the classpath.
registry
- the Atomix registrypublic static AtomixConfig config(String... files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
files
- the file from which to return a new Atomix configurationpublic static AtomixConfig config(ClassLoader classLoader, String... files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
classLoader
- the class loaderfiles
- the file from which to return a new Atomix configurationpublic static AtomixConfig config(AtomixRegistry registry, String... files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
registry
- the Atomix registryfiles
- the file from which to return a new Atomix configurationpublic static AtomixConfig config(File... configFiles)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
configFiles
- the Atomix configuration filespublic static AtomixConfig config(List<File> files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
files
- the file from which to return a new Atomix configurationpublic static AtomixConfig config(ClassLoader classLoader, List<File> files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
classLoader
- the class loaderfiles
- the file from which to return a new Atomix configurationpublic static AtomixConfig config(AtomixRegistry registry, List<File> files)
The configuration will be loaded from the given file and will fall back to atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
registry
- the Atomix registryfiles
- the file from which to return a new Atomix configurationpublic static AtomixBuilder builder()
The builder will be initialized with the configuration in atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
public static AtomixBuilder builder(ClassLoader classLoader)
The builder will be initialized with the configuration in atomix.conf
, atomix.json
, or atomix.properties
if located on the classpath.
classLoader
- the class loaderpublic static AtomixBuilder builder(AtomixRegistry registry)
The builder will be initialized with the configuration in the given file and will fall back to atomix.conf
,
atomix.json
, or atomix.properties
if located on the classpath.
registry
- the AtomixRegistrypublic static AtomixBuilder builder(String config)
The builder will be initialized with the configuration in the given file and will fall back to atomix.conf
,
atomix.json
, or atomix.properties
if located on the classpath.
config
- the Atomix configurationpublic static AtomixBuilder builder(String configFile, ClassLoader classLoader)
The builder will be initialized with the configuration in the given file and will fall back to atomix.conf
,
atomix.json
, or atomix.properties
if located on the classpath.
configFile
- the Atomix configuration fileclassLoader
- the class loaderpublic static AtomixBuilder builder(String configFile, AtomixRegistry registry)
The builder will be initialized with the configuration in the given file and will fall back to atomix.conf
,
atomix.json
, or atomix.properties
if located on the classpath.
configFile
- the Atomix configuration fileregistry
- the Atomix registrypublic static AtomixBuilder builder(AtomixConfig config)
The returned builder will be initialized with the provided configuration.
config
- the Atomix configurationpublic static AtomixBuilder builder(AtomixConfig config, ClassLoader classLoader)
The returned builder will be initialized with the provided configuration.
config
- the Atomix configurationclassLoader
- the class loader with which to load the Atomix registrypublic static AtomixBuilder builder(AtomixConfig config, AtomixRegistry registry)
The returned builder will be initialized with the provided configuration.
config
- the Atomix configurationregistry
- the Atomix registrypublic AtomixRegistry getRegistry()
The registry contains references to all registered Atomix extensions.
public ScheduledExecutorService getExecutorService()
public ConfigService getConfigService()
The primitive configuration service provides all pre-defined named primitive configurations.
public SerializationService getSerializationService()
public PartitionService getPartitionService()
The partition service is responsible for managing the lifecycle of primitive partitions and can provide information about active partition groups and partitions in the cluster.
public PrimitivesService getPrimitivesService()
The primitives service is responsible for managing the lifecycle of local primitive instances and can provide information about all primitives registered in the cluster.
public TransactionService getTransactionService()
The transaction service is responsible for managing the lifecycle of all transactions in the cluster and can provide information about currently active transactions.
public TransactionBuilder transactionBuilder(String name)
PrimitivesService
To get an asynchronous instance of the transaction, use the SyncPrimitive.async()
method:
AsyncTransaction transaction = atomix.transactionBuilder().build().async();
transactionBuilder
in interface PrimitivesService
name
- the transaction namepublic <B extends PrimitiveBuilder<B,C,P>,C extends PrimitiveConfig<C>,P extends SyncPrimitive> B primitiveBuilder(String name, PrimitiveType<B,C,P> primitiveType)
PrimitiveFactory
primitiveType
.
The primitive name must be provided when constructing the builder. The name is used to reference a distinct instance of the primitive within the cluster. Multiple instances of the primitive with the same name will share the same state. However, the instance of the primitive constructed by the returned builder will be distinct and will not share local memory (e.g. cache) with any other instance on this node.
To get an asynchronous instance of the primitive, use the SyncPrimitive.async()
method:
AsyncPrimitive async = atomix.primitiveBuilder("my-primitive", MyPrimitiveType.instance()).build().async();
primitiveBuilder
in interface PrimitiveFactory
B
- the primitive builder typeP
- the primitive typename
- the primitive nameprimitiveType
- the primitive typepublic <K,V> DistributedMap<K,V> getMap(String name)
PrimitivesService
DistributedMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncDistributedMap<String, String> map = atomix.getMap("my-map").async();
getMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K extends Comparable<K>,V> DistributedSortedMap<K,V> getSortedMap(String name)
PrimitivesService
DistributedSortedMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncDistributedSortedMap<String, String> map = atomix.getSortedMap("my-map").async();
getSortedMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K extends Comparable<K>,V> DistributedNavigableMap<K,V> getNavigableMap(String name)
PrimitivesService
DistributedNavigableMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncDistributedNavigableMap<String, String> map = atomix.getNavigableMap("my-map").async();
getNavigableMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K,V> DistributedMultimap<K,V> getMultimap(String name)
PrimitivesService
DistributedMultimap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the multimap, use the SyncPrimitive.async()
method:
AsyncDistributedMultimap<String, String> multimap = atomix.getMultimap("my-multimap").async();
getMultimap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K,V> AtomicMap<K,V> getAtomicMap(String name)
PrimitivesService
AtomicMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncAtomicMap<String, String> map = atomix.getAtomicMap("my-map").async();
getAtomicMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <V> AtomicDocumentTree<V> getAtomicDocumentTree(String name)
PrimitivesService
AtomicDocumentTree
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the tree, use the SyncPrimitive.async()
method:
AsyncAtomicDocumentTree<String> map = atomix.getDocumentTree("my-tree").async();
getAtomicDocumentTree
in interface PrimitivesService
V
- value typename
- the primitive namepublic <K extends Comparable<K>,V> AtomicSortedMap<K,V> getAtomicSortedMap(String name)
PrimitivesService
AtomicSortedMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncAtomicSortedMap<String, String> map = atomix.getAtomicSortedMap("my-map").async();
getAtomicSortedMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K extends Comparable<K>,V> AtomicNavigableMap<K,V> getAtomicNavigableMap(String name)
PrimitivesService
AtomicNavigableMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncAtomicNavigableMap<String, String> map = atomix.getAtomicNavigableMap("my-map").async();
getAtomicNavigableMap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K,V> AtomicMultimap<K,V> getAtomicMultimap(String name)
PrimitivesService
AtomicMultimap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the multimap, use the SyncPrimitive.async()
method:
AsyncAtomicMultimap<String, String> multimap = atomix.getAtomicMultimap("my-multimap").async();
getAtomicMultimap
in interface PrimitivesService
K
- key typeV
- value typename
- the primitive namepublic <K> AtomicCounterMap<K> getAtomicCounterMap(String name)
PrimitivesService
AtomicCounterMap
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the map, use the SyncPrimitive.async()
method:
AsyncAtomicCounterMap<String> map = atomix.getAtomicCounterMap("my-counter-map").async();
getAtomicCounterMap
in interface PrimitivesService
K
- key typename
- the primitive namepublic <E> DistributedSet<E> getSet(String name)
PrimitivesService
DistributedSet
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the set, use the SyncPrimitive.async()
method:
AsyncDistributedSet<String> set = atomix.getSet("my-set").async();
getSet
in interface PrimitivesService
E
- set element typename
- the primitive namepublic <E extends Comparable<E>> DistributedSortedSet<E> getSortedSet(String name)
PrimitivesService
DistributedSortedSet
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the set, use the SyncPrimitive.async()
method:
AsyncDistributedSortedSet<String> set = atomix.getSortedSet("my-set").async();
getSortedSet
in interface PrimitivesService
E
- set element typename
- the primitive namepublic <E extends Comparable<E>> DistributedNavigableSet<E> getNavigableSet(String name)
PrimitivesService
DistributedNavigableSet
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the set, use the SyncPrimitive.async()
method:
AsyncDistributedNavigableSet<String> set = atomix.getNavigableSet("my-set").async();
getNavigableSet
in interface PrimitivesService
E
- set element typename
- the primitive namepublic <E> DistributedQueue<E> getQueue(String name)
PrimitivesService
DistributedQueue
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the queue, use the SyncPrimitive.async()
method:
AsyncDistributedQueue<String> queue = atomix.getQueue("my-queue").async();
getQueue
in interface PrimitivesService
E
- queue element typename
- the primitive namepublic <E> DistributedList<E> getList(String name)
PrimitivesService
DistributedList
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the list, use the SyncPrimitive.async()
method:
AsyncDistributedList<String> list = atomix.getList("my-list").async();
getList
in interface PrimitivesService
E
- list element typename
- the primitive namepublic <E> DistributedMultiset<E> getMultiset(String name)
PrimitivesService
DistributedMultiset
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the multiset, use the SyncPrimitive.async()
method:
AsyncDistributedMultiset<String> multiset = atomix.getMultiset("my-multiset").async();
getMultiset
in interface PrimitivesService
E
- multiset element typename
- the primitive namepublic DistributedCounter getCounter(String name)
PrimitivesService
DistributedCounter
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the counter, use the SyncPrimitive.async()
method:
AsyncDistributedCounter counter = atomix.getCounter("my-counter").async();
getCounter
in interface PrimitivesService
name
- the primitive namepublic AtomicCounter getAtomicCounter(String name)
PrimitivesService
AtomicCounter
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the counter, use the SyncPrimitive.async()
method:
AsyncAtomicCounter counter = atomix.getAtomicCounter("my-counter").async();
getAtomicCounter
in interface PrimitivesService
name
- the primitive namepublic AtomicIdGenerator getAtomicIdGenerator(String name)
PrimitivesService
AtomicIdGenerator
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the ID generator, use the SyncPrimitive.async()
method:
AsyncAtomicIdGenerator idGenerator = atomix.getAtomicIdGenerator("my-id-generator").async();
getAtomicIdGenerator
in interface PrimitivesService
name
- the primitive namepublic <V> DistributedValue<V> getValue(String name)
PrimitivesService
DistributedValue
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the value, use the SyncPrimitive.async()
method:
AsyncDistributedValue<String> value = atomix.getValue("my-value").async();
getValue
in interface PrimitivesService
V
- value typename
- the primitive namepublic <V> AtomicValue<V> getAtomicValue(String name)
PrimitivesService
AtomicValue
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the value, use the SyncPrimitive.async()
method:
AsyncAtomicValue<String> value = atomix.getAtomicValue("my-value").async();
getAtomicValue
in interface PrimitivesService
V
- atomic value typename
- the primitive namepublic <T> LeaderElection<T> getLeaderElection(String name)
PrimitivesService
LeaderElection
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the election, use the SyncPrimitive.async()
method:
AsyncLeaderElection<String> election = atomix.getLeaderElection("my-election").async();
getLeaderElection
in interface PrimitivesService
name
- the primitive namepublic <T> LeaderElector<T> getLeaderElector(String name)
PrimitivesService
LeaderElector
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the elector, use the SyncPrimitive.async()
method:
AsyncLeaderElector<String> elector = atomix.getLeaderElector("my-elector").async();
getLeaderElector
in interface PrimitivesService
name
- the primitive namepublic DistributedLock getLock(String name)
PrimitivesService
DistributedLock
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the lock, use the SyncPrimitive.async()
method:
AsyncDistributedLock lock = atomix.getLock("my-lock").async();
getLock
in interface PrimitivesService
name
- the primitive namepublic AtomicLock getAtomicLock(String name)
PrimitivesService
AtomicLock
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the lock, use the SyncPrimitive.async()
method:
AsyncAtomicLock lock = atomix.getAtomicLock("my-lock").async();
getAtomicLock
in interface PrimitivesService
name
- the primitive namepublic DistributedCyclicBarrier getCyclicBarrier(String name)
PrimitivesService
DistributedCyclicBarrier
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the barrier, use the SyncPrimitive.async()
method:
AsyncDistributedCyclicBarrier barrier = atomix.getCyclicBarrier("my-barrier").async();
getCyclicBarrier
in interface PrimitivesService
name
- the primitive namepublic DistributedSemaphore getSemaphore(String name)
PrimitivesService
DistributedSemaphore
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the semaphore, use the SyncPrimitive.async()
method:
AsyncDistributedSemaphore semaphore = atomix.getSemaphore("my-semaphore").async();
getSemaphore
in interface PrimitivesService
name
- the primitive namepublic AtomicSemaphore getAtomicSemaphore(String name)
PrimitivesService
AtomicSemaphore
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the semaphore, use the SyncPrimitive.async()
method:
AsyncAtomicSemaphore semaphore = atomix.getAtomicSemaphore("my-semaphore").async();
getAtomicSemaphore
in interface PrimitivesService
name
- the primitive namepublic <E> WorkQueue<E> getWorkQueue(String name)
PrimitivesService
WorkQueue
.
A new primitive will be created if no primitive instance with the given name
exists on this node, otherwise
the existing instance will be returned. The name is used to reference a distinct instance of the primitive within
the cluster. The returned primitive will share the same state with primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
To get an asynchronous instance of the work queue, use the SyncPrimitive.async()
method:
AsyncWorkQueue<String> workQueue = atomix.getWorkQueue("my-work-queue").async();
getWorkQueue
in interface PrimitivesService
E
- work queue element typename
- the primitive namepublic PrimitiveType getPrimitiveType(String typeName)
PrimitiveFactory
getPrimitiveType
in interface PrimitiveFactory
typeName
- the primitive type namepublic <P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync(String name, PrimitiveType<?,?,P> primitiveType)
PrimitiveFactory
A new primitive of the given primitiveType
will be created if no primitive instance with the given
name
exists on this node, otherwise the existing instance will be returned. The name is used to reference
a distinct instance of the primitive within the cluster. The returned primitive will share the same state with
primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
getPrimitiveAsync
in interface PrimitiveFactory
P
- the primitive typename
- the primitive nameprimitiveType
- the primitive typepublic <C extends PrimitiveConfig<C>,P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync(String name, PrimitiveType<?,C,P> primitiveType, C primitiveConfig)
PrimitiveFactory
A new primitive of the given primitiveType
will be created if no primitive instance with the given
name
exists on this node, otherwise the existing instance will be returned. The name is used to reference
a distinct instance of the primitive within the cluster. The returned primitive will share the same state with
primitives of the same name on other nodes.
When the instance is initially constructed, it will be configured with any pre-existing primitive configuration
defined in atomix.conf
.
getPrimitiveAsync
in interface PrimitiveFactory
C
- the primitive configuration typeP
- the primitive typename
- the primitive nameprimitiveType
- the primitive typeprimitiveConfig
- the primitive configurationpublic Collection<PrimitiveInfo> getPrimitives()
PrimitiveFactory
getPrimitives
in interface PrimitiveFactory
public Collection<PrimitiveInfo> getPrimitives(PrimitiveType primitiveType)
PrimitiveFactory
getPrimitives
in interface PrimitiveFactory
primitiveType
- the primitive typepublic CompletableFuture<Void> start()
The returned future will be completed once this instance completes startup. Note that in order to complete startup, all partitions must be able to form. For Raft partitions, that requires that a majority of the nodes in each partition be started concurrently.
start
in interface Managed<Void>
start
in class AtomixCluster
public CompletableFuture<Void> stop()
Managed
stop
in interface Managed<Void>
stop
in class AtomixCluster
public String toString()
toString
in class AtomixCluster
Copyright © 2013–2018. All rights reserved.