Atomix is an event-driven framework for coordinating fault-tolerant distributed systems using a variety of proven distributed systems protocols. It provides the building blocks that solve many common distributed systems problems including cluster management, asynchronous messaging, group membership, leader election, distributed concurrency control, partitioning, and replication.

// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get or create an AtomicValue
AtomicValue<String> value = atomix.getAtomicValue("value");

// Set the value
value.set("Hello world!");

// Print the current value
System.out.println(value.get());
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get or create an AtomicCounter
AtomicCounter counter = atomix.getAtomicCounter("my-counter");

// Increment the counter
long value = counter.incrementAndGet();

// Reset the counter value
counter.set(0);
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Create a cached ConsistentMap
ConsistentMap<String, String> map = atomix.consistentMapBuilder("my-map")
  .withCacheEnabled()
  .withCacheSize(100)
  .build();

// Set a value in the map
map.put("foo", "Hello world!");

// Read a value from the map
Versioned<String> value = map.get("foo");

// Update the value using an optimistic lock
while (!map.put("foo", "Hello world again!", value.version())) {
  Thread.sleep(10);
}
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get or create a multimap
ConsistentMultimap<String, String> multimap = atomix.getConsistentMultimap("my-multimap");

// Add a value to a key
multimap.put("foo", "Hello world!");

// Get the values associated with a key
Versioned<Collection<String>> values = multimap.get("foo");
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Create a cached distributed set
DistributedSet<String> set = atomix.setBuilder("my-set")
  .withCacheEnabled()
  .withCacheSize(100)
  .build();

// Add a value to the set
set.add("foo");

// Check a value in the set
if (set.contains("foo")) {
  ...
}
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get or create a distributed lock
DistributedLock lock = atomix.getLock("my-lock");

// Acquire the lock
lock.lock();

// Perform some functions and then release the lock
try {
  ...
} finally {
  lock.unlock();
}

// Attempt to acquire the lock until a timeout
lock.lock(Duration.ofSeconds(5));
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get or create a leader election
LeaderElection<MemberId> election = atomix.getLeaderElection("my-election");

// Enter the election
Leadership<MemberId> leadership = election.run(atomix.membershipService().getLocalMember().id());

// Check if the current node is the leader
if (leadership.leader().equals(atomix.membershipService().getLocalMember().id())) {
  System.out.println("I am the leader!");
}

// Listen for changes in leadership
election.addListener(event -> {
  if (event.newLeadership().leader().equals(atomix.membershipService().getLocalMember().id())) {
    System.out.println("I am the leader!");
  }
});
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get a list of members in the cluster
Collection<Node> nodes = atomix.getMembershipService().getNodes();

// Listen for members joining/leaving the cluster
atomix.getMembershipService().addListener(event -> {
  switch (event.type()) {
    case MEMBER_ADDED:
      System.out.println(event.subject().id() + " joined the cluster");
      break;
    case MEMBER_REMOVED:
      System.out.println(event.subject().id() + " left the cluster");
      break;
  }
});
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get the cluster communication service
ClusterCommunicationService communicationService = atomix.getCommunicationService();

// Register a listener for the "test" subject
communicationService.subscribe("test", message -> {
  System.out.println("Received message " + message);
});

// Send a "test" message to all other nodes
communicationService.broadcast("test", "Hello world!");

// Send a "test" message to node "foo"
communicationService.unicast("test", "Hello world!", atomix.getMembershipService().getNode("foo").id());

// Send a "test" message to node "bar" and wait for a reply
communicationService.send("test", "Hello world!", atomix.getMembershipService().getNode("bar").id())
  .thenAccept(reply -> {
    System.out.println("bar said: " + reply);
  });
// Create an Atomix instance from a HOCON configuration file
Atomix atomix = new Atomix("atomix.conf");

// Start the instance
atomix.start().join();

// Get the cluster event service
ClusterEventService eventService = atomix.getEventService();

// Register a listener for the "test" subject
eventService.subscribe("test", message -> {
  System.out.println("Received message " + message);
});

// Send a "test" message to all other subscribers
eventService.broadcast("test", "Hello world!");

// Send a "test" message to one of the subscribers
eventService.unicast("test", "Hello world!");

// Send a "test" message to one of the subscribers and wait for a reply
eventService.send("test", "Hello world!")
  .thenAccept(reply -> {
    System.out.println("responder said: " + reply);
  });

Simple

Atomix provides a collection of dead simple, synchronous and asynchronous APIs for sharing mission critical state, communicating across nodes, and coordinating state changes in distributed systems.

Reliable

Atomix features reliable data consistency guarantees backed by a novel implementation of the Raft consensus protocol, allowing it to maintain its guarantees even when machine or network failures occur.

Resilient

Atomix clusters are resilient to failure, automatically redistributing state as nodes come and go.

Scalable

Atomix partitions data to provide the ability to scale data size and throughput without sacrificing consistency guarantees.

Ready to learn more?

Explore the Docs