SlideShare a Scribd company logo
1 of 26
1
Atomix
BUILDING FAULT-TOLERANT DISTRIBUTED SYSTEMS
STEPAN RAKITIN
MAY 27, 2017
2
About me
• Software Engineer @ EPAM
• HPC Engineer and Researcher @ ITMO University
3
Atomix
• Distributed data-structure/coordination toolkit written in Java
• Provides a collection of asynchronous APIs for state sharing and solving a variety of
common distributed systems problems
• Reactive thus asynchronous and event-driven
• Provides strong consistency using its own Raft consensus algorithm implementation
4
What I will cover
• Raft algorithm
• Consensus
• State machines
• Log replication
• Atomix APIs
• Distributed data-structures API
• Coordination and messaging API
• Copycat
• Raft implementation
• State machine API
5
Consensus
• Agreement on shared state
• Autonomous recovery from server failures
– Minority of servers fail: no problem
– Majority fail: lose availability, retain consistency
Servers
6
What is the purpose of consensus?
• Key to building consistent storage systems
• Top-level system configuration
– Which server is the master?
– What shards exist in my storage system?
– Which servers store shard X?
• Sometimes used to replicate entire storage state
7
Raft
x3 y2 x1 z6
Log
Consensus
Module
State
Machine
Log
Consensus
Module
State
Machine
Log
Consensus
Module
State
Machine
Servers
Clients
x 1
y 2
z 6
x3 y2 x1 z6
x 1
y 2
z 6
x3 y2 x1 z6
x 1
y 2
z 6
z6
8
Raft terms
1. Leader election
– Select one of the servers to act as leader
– Detect crashes, choose new leader
– Only elect leaders with all committed entries in their logs
2. Log replication (normal operation)
– Leader takes commands from clients, appends them to its log
– Leader replicates its log to other servers (overwriting inconsistencies)
Term 1 Term 2 Term 3 Term 4 Term 5
time
Elections Normal OperationSplit Vote
9
Distributed data-structures
• Drop-in replacements for Java Collections
• Similar to Hazelcast distributed collections
• Strong consistency over availability
• Asynchronous with CompletableFuture
10
Distributed data-structures
• Single value access
• Sets
• Queues
• Maps and multimaps
11
Bootstrap
AtomixReplica replica = AtomixReplica.builder(new Address("localhost", 8700))
.withStorage(storage)
.withTransport(transport)
.build();
CompletableFuture<Atomix> future = replica.bootstrap();
// or
CompletableFuture<Atomix> future = replica.join(new Address(“172.16.42.10", 8700));
Atomix atomix = future.join();
12
Distributed data-structures
DistributedValue<String> value = atomix.getValue("value").join();
value.set("Hello world!").join();
value.get().thenAccept(result -> {
System.out.println("The value is " + result);
});
DistributedMap<String, String> map = atomix.getMap("map").join();
map.put("bar", "Hello world!").thenRun(() -> {
String value = map.get("bar").join();
});
DistributedQueue<Integer> queue = atomix.getQueue("queue").join();
CompletableFuture.allOf(queue.offer(1), queue.offer(2)).join();
queue.poll().thenAccept(value -> { System.out.println("retrieved " + value); });
13
Coordination and messaging API
• Locks
• Group membership management and leader election listening
• Direct messaging within groups
• Publish-subscribe
• Request-reply
14
Distributed locks
DistributedLock lock = atomix.getLock("foo").join();
lock.lock().thenRun(() -> {
System.out.println("Acquired a lock”);
lock.unlock().join();
});
15
Group membership management
DistributedGroup group = atomix.getGroup("group").join();
LocalMember member = group.join().join();
group.onJoin(member -> {
System.out.println(member + " joined the group");
});
group.members().forEach(member -> {
// ...
});
group.election().onElection(term -> {
System.out.println(term.leader() + " elected leader for term " + term.term());
});
16
Publish-subscribe
DistributedGroup group = atomix.getGroup("group").join();
MessageProducer.Options options = new MessageProducer.Options()
.withExecution(Execution.ASYNC)
.withDelivery(Delivery.BROADCAST);
MessageProducer<String> producer = group.messaging().producer("events", options);
producer.send("change").thenRun(() -> {...});
DistributedGroup group = atomix.getGroup("group").join();
LocalMember localMember = group.join().join();
MessageConsumer<String> consumer = localMember.messaging().consumer("events");
consumer.onMessage(message -> {
if (message.body().equals("change")) {
message.ack();
}
});
17
Request-reply
DistributedGroup group = atomix.getGroup("group").join();
Member member = group.member("foo");
MessageProducer.Options options = new MessageProducer.Options()
.withExecution(Execution.REQUEST_REPLY);
MessageProducer<String> producer = member.messaging().producer("hello");
producer.send("Hello world!").thenAccept(reply -> { System.out.println(reply); });
DistributedGroup group = atomix.getGroup("group").join();
LocalMember localMember = group.join().join();
MessageConsumer<String> consumer = localMember.messaging().consumer("hello");
consumer.onMessage(message -> {
if (message.body().equals("Hello world!")) {
messages.reply("Hello world back!");
}
});
18
What can I do with that?
• Use as the replacement for Zookeeper or etcd with High Level API
• Reliable messaging
• Simply make your Java collections distributed
• Resilient distributed caches
• Create any kind of distributed resource with fault-tolerance and strong consistency
through custom Atomix resource implementation
19
Copycat
• Raft implementation itself (best one in Java)
• State managing framework
• State machine API
• Command pattern
20
Command pattern
public class PutCommand extends Command<String> {
String key
String value
}
public class GetQuery extends Query<String> {
String key
}
21
State machine API
public class MapStateMachine extends StateMachine {
private Map<String, String> map = HashMap<>();
public String put(Commit<PutCommand> commit) {
try {
map.put(commit.operation().key(), commit.operation().value());
} finally {
commit.close();
}
}
public String get(Commit<GetQuery> commit) {
try {
return map.get(commit.operation().key());
} finally {
commit.close();
}
}
}
22
Copycat Server API
Address address = new Address(“localhost", 5000);
Collection<Address> cluster = Arrays.asList(
new Address("192.168.0.1", 8700),
new Address("192.168.0.2", 8700),
new Address("192.168.0.3", 8700)
);
CopycatServer server = CopycatServer.builder(address)
.withStateMachine(MyStateMachine::new)
.build();
server.bootstrap(cluster).join();
23
Copycat Client API
CopycatClient client = CopycatClient.builder()
.withTransport(new NettyTransport())
.withServerSelectionStrategy(ServerSelectionStrategies.FOLLOWERS)
.withConnectionStrategy(ConnectionStrategies.EXPONENTIAL_BACKOFF)
.build();
Collection<Address> cluster = Arrays.asList(
new Address("192.168.0.1", 8700),
new Address("192.168.0.2", 8700),
new Address("192.168.0.3", 8700)
);
client.connect(cluster).join();
client.submit(new PutCommand("foo", "Hello world!")).thenRun(() -> {
String value = client.submit(new GetQuery("foo")).join();
});
24
Why would I need that?
• If Atomix is too high level for you or so much for your task
• If you have some rather sophisticated resource you want to make consistent
• If you just want to practice or implement your ideas
25
In the end
• Atomix provides you with very simple distributed programming interface which allows
you to solve common distributed system problems
• Raft consensus algorithm gives you strong consistency (but over availability)
• Copycat provides you with low level state machine API which could become the
barebone for your distributed resource
26
atomix.io/docs
Docs

More Related Content

What's hot

Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19confluent
 
High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!Jonathan Katz
 
Scaling drupal on amazon web services dr
Scaling drupal on amazon web services drScaling drupal on amazon web services dr
Scaling drupal on amazon web services drTristan Roddis
 
State of HBase: Meet the Release Managers
State of HBase: Meet the Release ManagersState of HBase: Meet the Release Managers
State of HBase: Meet the Release ManagersHBaseCon
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the DataHao Chen
 
VMworld 2013: Architecting VMware Horizon Workspace for Scale and Performance
VMworld 2013: Architecting VMware Horizon Workspace for Scale and PerformanceVMworld 2013: Architecting VMware Horizon Workspace for Scale and Performance
VMworld 2013: Architecting VMware Horizon Workspace for Scale and PerformanceVMworld
 
Scylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for KubernetesScylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for KubernetesScyllaDB
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystemconfluent
 
Spark day 2017 - Spark on Kubernetes
Spark day 2017 - Spark on KubernetesSpark day 2017 - Spark on Kubernetes
Spark day 2017 - Spark on KubernetesYousun Jeong
 
OSMC 2019 | Directing the Director by Martin Schurz
OSMC 2019 | Directing the Director by Martin SchurzOSMC 2019 | Directing the Director by Martin Schurz
OSMC 2019 | Directing the Director by Martin SchurzNETWAYS
 
State of openstack industry: Why we are doing this
State of openstack industry: Why we are doing thisState of openstack industry: Why we are doing this
State of openstack industry: Why we are doing thisDmitriy Novakovskiy
 
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015Belmiro Moreira
 
Kubernetes Operators And The Redis Enterprise Journey: Michal Rabinowitch
Kubernetes Operators And The Redis Enterprise Journey: Michal RabinowitchKubernetes Operators And The Redis Enterprise Journey: Michal Rabinowitch
Kubernetes Operators And The Redis Enterprise Journey: Michal RabinowitchRedis Labs
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageWebinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageMayaData Inc
 
Think Distributed: The Hazelcast Way
Think Distributed: The Hazelcast WayThink Distributed: The Hazelcast Way
Think Distributed: The Hazelcast WayRahul Gupta
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"Gal Marder
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera ClusterAbdul Manaf
 
Apache Kafka
Apache KafkaApache Kafka
Apache KafkaJoe Stein
 

What's hot (20)

Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19
 
High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!
 
Scaling drupal on amazon web services dr
Scaling drupal on amazon web services drScaling drupal on amazon web services dr
Scaling drupal on amazon web services dr
 
State of HBase: Meet the Release Managers
State of HBase: Meet the Release ManagersState of HBase: Meet the Release Managers
State of HBase: Meet the Release Managers
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 
VMworld 2013: Architecting VMware Horizon Workspace for Scale and Performance
VMworld 2013: Architecting VMware Horizon Workspace for Scale and PerformanceVMworld 2013: Architecting VMware Horizon Workspace for Scale and Performance
VMworld 2013: Architecting VMware Horizon Workspace for Scale and Performance
 
Scylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for KubernetesScylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystem
 
Spark day 2017 - Spark on Kubernetes
Spark day 2017 - Spark on KubernetesSpark day 2017 - Spark on Kubernetes
Spark day 2017 - Spark on Kubernetes
 
OSMC 2019 | Directing the Director by Martin Schurz
OSMC 2019 | Directing the Director by Martin SchurzOSMC 2019 | Directing the Director by Martin Schurz
OSMC 2019 | Directing the Director by Martin Schurz
 
KubeCon_NA_2021
KubeCon_NA_2021KubeCon_NA_2021
KubeCon_NA_2021
 
State of openstack industry: Why we are doing this
State of openstack industry: Why we are doing thisState of openstack industry: Why we are doing this
State of openstack industry: Why we are doing this
 
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015
Tips Tricks and Tactics with Cells and Scaling OpenStack - May, 2015
 
Kubernetes Operators And The Redis Enterprise Journey: Michal Rabinowitch
Kubernetes Operators And The Redis Enterprise Journey: Michal RabinowitchKubernetes Operators And The Redis Enterprise Journey: Michal Rabinowitch
Kubernetes Operators And The Redis Enterprise Journey: Michal Rabinowitch
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageWebinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
 
Curator intro
Curator introCurator intro
Curator intro
 
Think Distributed: The Hazelcast Way
Think Distributed: The Hazelcast WayThink Distributed: The Hazelcast Way
Think Distributed: The Hazelcast Way
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera Cluster
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 

Similar to Building Fault-Tolerant Distributed Systems with Atomix and Copycat

Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...Christian Tzolov
 
An Engineer's Intro to Oracle Coherence
An Engineer's Intro to Oracle CoherenceAn Engineer's Intro to Oracle Coherence
An Engineer's Intro to Oracle CoherenceOracle
 
SCWCD : Thread safe servlets : CHAP : 8
SCWCD : Thread safe servlets : CHAP : 8SCWCD : Thread safe servlets : CHAP : 8
SCWCD : Thread safe servlets : CHAP : 8Ben Abdallah Helmi
 
BigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache ApexBigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache ApexThomas Weise
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13Dave Gardner
 
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & PackerLAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & PackerJan-Christoph Küster
 
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Apex
 
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014NoSQLmatters
 
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...Amazon Web Services
 
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3JavaEE Trainers
 
Planning to Fail #phpuk13
Planning to Fail #phpuk13Planning to Fail #phpuk13
Planning to Fail #phpuk13Dave Gardner
 
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating SystemOSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating SystemNETWAYS
 
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...Raffi Khatchadourian
 
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술John Kim
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your TeamGR8Conf
 
Cassandra
CassandraCassandra
Cassandraexsuns
 
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A Service
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A ServiceScala, Apache Spark, The PlayFramework and Docker in IBM Platform As A Service
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A ServiceRomeo Kienzler
 
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...Howard Greenberg
 

Similar to Building Fault-Tolerant Distributed Systems with Atomix and Copycat (20)

Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
JCache Using JCache
JCache Using JCacheJCache Using JCache
JCache Using JCache
 
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
 
An Engineer's Intro to Oracle Coherence
An Engineer's Intro to Oracle CoherenceAn Engineer's Intro to Oracle Coherence
An Engineer's Intro to Oracle Coherence
 
SCWCD : Thread safe servlets : CHAP : 8
SCWCD : Thread safe servlets : CHAP : 8SCWCD : Thread safe servlets : CHAP : 8
SCWCD : Thread safe servlets : CHAP : 8
 
BigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache ApexBigDataSpain 2016: Stream Processing Applications with Apache Apex
BigDataSpain 2016: Stream Processing Applications with Apache Apex
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13
 
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & PackerLAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
 
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
 
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
 
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
 
Introduction tomcat7 servlet3
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
 
Planning to Fail #phpuk13
Planning to Fail #phpuk13Planning to Fail #phpuk13
Planning to Fail #phpuk13
 
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating SystemOSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
 
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
 
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 
Cassandra
CassandraCassandra
Cassandra
 
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A Service
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A ServiceScala, Apache Spark, The PlayFramework and Docker in IBM Platform As A Service
Scala, Apache Spark, The PlayFramework and Docker in IBM Platform As A Service
 
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
 

More from epamspb

Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveepamspb
 
Mobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedMobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedepamspb
 
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...epamspb
 
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...epamspb
 
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...epamspb
 
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"epamspb
 
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"epamspb
 
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...epamspb
 
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"epamspb
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"epamspb
 
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...epamspb
 
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...epamspb
 
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...epamspb
 

More from epamspb (13)

Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
Mobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedMobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting married
 
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
 
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
 
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
 
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
 
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
 
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
 
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
 
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
 
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
 
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
 

Recently uploaded

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 

Recently uploaded (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 

Building Fault-Tolerant Distributed Systems with Atomix and Copycat

  • 1. 1 Atomix BUILDING FAULT-TOLERANT DISTRIBUTED SYSTEMS STEPAN RAKITIN MAY 27, 2017
  • 2. 2 About me • Software Engineer @ EPAM • HPC Engineer and Researcher @ ITMO University
  • 3. 3 Atomix • Distributed data-structure/coordination toolkit written in Java • Provides a collection of asynchronous APIs for state sharing and solving a variety of common distributed systems problems • Reactive thus asynchronous and event-driven • Provides strong consistency using its own Raft consensus algorithm implementation
  • 4. 4 What I will cover • Raft algorithm • Consensus • State machines • Log replication • Atomix APIs • Distributed data-structures API • Coordination and messaging API • Copycat • Raft implementation • State machine API
  • 5. 5 Consensus • Agreement on shared state • Autonomous recovery from server failures – Minority of servers fail: no problem – Majority fail: lose availability, retain consistency Servers
  • 6. 6 What is the purpose of consensus? • Key to building consistent storage systems • Top-level system configuration – Which server is the master? – What shards exist in my storage system? – Which servers store shard X? • Sometimes used to replicate entire storage state
  • 7. 7 Raft x3 y2 x1 z6 Log Consensus Module State Machine Log Consensus Module State Machine Log Consensus Module State Machine Servers Clients x 1 y 2 z 6 x3 y2 x1 z6 x 1 y 2 z 6 x3 y2 x1 z6 x 1 y 2 z 6 z6
  • 8. 8 Raft terms 1. Leader election – Select one of the servers to act as leader – Detect crashes, choose new leader – Only elect leaders with all committed entries in their logs 2. Log replication (normal operation) – Leader takes commands from clients, appends them to its log – Leader replicates its log to other servers (overwriting inconsistencies) Term 1 Term 2 Term 3 Term 4 Term 5 time Elections Normal OperationSplit Vote
  • 9. 9 Distributed data-structures • Drop-in replacements for Java Collections • Similar to Hazelcast distributed collections • Strong consistency over availability • Asynchronous with CompletableFuture
  • 10. 10 Distributed data-structures • Single value access • Sets • Queues • Maps and multimaps
  • 11. 11 Bootstrap AtomixReplica replica = AtomixReplica.builder(new Address("localhost", 8700)) .withStorage(storage) .withTransport(transport) .build(); CompletableFuture<Atomix> future = replica.bootstrap(); // or CompletableFuture<Atomix> future = replica.join(new Address(“172.16.42.10", 8700)); Atomix atomix = future.join();
  • 12. 12 Distributed data-structures DistributedValue<String> value = atomix.getValue("value").join(); value.set("Hello world!").join(); value.get().thenAccept(result -> { System.out.println("The value is " + result); }); DistributedMap<String, String> map = atomix.getMap("map").join(); map.put("bar", "Hello world!").thenRun(() -> { String value = map.get("bar").join(); }); DistributedQueue<Integer> queue = atomix.getQueue("queue").join(); CompletableFuture.allOf(queue.offer(1), queue.offer(2)).join(); queue.poll().thenAccept(value -> { System.out.println("retrieved " + value); });
  • 13. 13 Coordination and messaging API • Locks • Group membership management and leader election listening • Direct messaging within groups • Publish-subscribe • Request-reply
  • 14. 14 Distributed locks DistributedLock lock = atomix.getLock("foo").join(); lock.lock().thenRun(() -> { System.out.println("Acquired a lock”); lock.unlock().join(); });
  • 15. 15 Group membership management DistributedGroup group = atomix.getGroup("group").join(); LocalMember member = group.join().join(); group.onJoin(member -> { System.out.println(member + " joined the group"); }); group.members().forEach(member -> { // ... }); group.election().onElection(term -> { System.out.println(term.leader() + " elected leader for term " + term.term()); });
  • 16. 16 Publish-subscribe DistributedGroup group = atomix.getGroup("group").join(); MessageProducer.Options options = new MessageProducer.Options() .withExecution(Execution.ASYNC) .withDelivery(Delivery.BROADCAST); MessageProducer<String> producer = group.messaging().producer("events", options); producer.send("change").thenRun(() -> {...}); DistributedGroup group = atomix.getGroup("group").join(); LocalMember localMember = group.join().join(); MessageConsumer<String> consumer = localMember.messaging().consumer("events"); consumer.onMessage(message -> { if (message.body().equals("change")) { message.ack(); } });
  • 17. 17 Request-reply DistributedGroup group = atomix.getGroup("group").join(); Member member = group.member("foo"); MessageProducer.Options options = new MessageProducer.Options() .withExecution(Execution.REQUEST_REPLY); MessageProducer<String> producer = member.messaging().producer("hello"); producer.send("Hello world!").thenAccept(reply -> { System.out.println(reply); }); DistributedGroup group = atomix.getGroup("group").join(); LocalMember localMember = group.join().join(); MessageConsumer<String> consumer = localMember.messaging().consumer("hello"); consumer.onMessage(message -> { if (message.body().equals("Hello world!")) { messages.reply("Hello world back!"); } });
  • 18. 18 What can I do with that? • Use as the replacement for Zookeeper or etcd with High Level API • Reliable messaging • Simply make your Java collections distributed • Resilient distributed caches • Create any kind of distributed resource with fault-tolerance and strong consistency through custom Atomix resource implementation
  • 19. 19 Copycat • Raft implementation itself (best one in Java) • State managing framework • State machine API • Command pattern
  • 20. 20 Command pattern public class PutCommand extends Command<String> { String key String value } public class GetQuery extends Query<String> { String key }
  • 21. 21 State machine API public class MapStateMachine extends StateMachine { private Map<String, String> map = HashMap<>(); public String put(Commit<PutCommand> commit) { try { map.put(commit.operation().key(), commit.operation().value()); } finally { commit.close(); } } public String get(Commit<GetQuery> commit) { try { return map.get(commit.operation().key()); } finally { commit.close(); } } }
  • 22. 22 Copycat Server API Address address = new Address(“localhost", 5000); Collection<Address> cluster = Arrays.asList( new Address("192.168.0.1", 8700), new Address("192.168.0.2", 8700), new Address("192.168.0.3", 8700) ); CopycatServer server = CopycatServer.builder(address) .withStateMachine(MyStateMachine::new) .build(); server.bootstrap(cluster).join();
  • 23. 23 Copycat Client API CopycatClient client = CopycatClient.builder() .withTransport(new NettyTransport()) .withServerSelectionStrategy(ServerSelectionStrategies.FOLLOWERS) .withConnectionStrategy(ConnectionStrategies.EXPONENTIAL_BACKOFF) .build(); Collection<Address> cluster = Arrays.asList( new Address("192.168.0.1", 8700), new Address("192.168.0.2", 8700), new Address("192.168.0.3", 8700) ); client.connect(cluster).join(); client.submit(new PutCommand("foo", "Hello world!")).thenRun(() -> { String value = client.submit(new GetQuery("foo")).join(); });
  • 24. 24 Why would I need that? • If Atomix is too high level for you or so much for your task • If you have some rather sophisticated resource you want to make consistent • If you just want to practice or implement your ideas
  • 25. 25 In the end • Atomix provides you with very simple distributed programming interface which allows you to solve common distributed system problems • Raft consensus algorithm gives you strong consistency (but over availability) • Copycat provides you with low level state machine API which could become the barebone for your distributed resource