Ratis is a Raft protocol library in Java. It’s not a standalone server application like Zookeeper or Consul.
To demonstrate how to use Ratis from the code, Please look at the following examples.
Arithmetic example: This is a simple distributed calculator that replicates the values defined and allows user to perform arithmetic operations on these replicated values.
FileStore example: This is an example of using Ratis for reading and writing files.
The source code of the examples could be found in the ratis-examples sub-project.
To use in our project you can access the latest binaries from maven central:
<dependency>
<artifactId>ratis-server</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
You also need to include one of the transports:
<dependency>
<artifactId>ratis-grpc</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-netty</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-hadoop</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
Please note that Apache Hadoop dependencies are shaded, so it’s safe to use hadoop transport with different versions of Hadoop.