The repository can be complied using mvn clean package -DskipTests
under the project root directory;
see also BUILDING.md.
All the scripts for running the examples are located in the ratis-examples/src/main/bin directory; see below for the usage.
FileStore is a high performance file service supporting read, write and delete operations. The FileStoreStateMachine is implemented using the asynchronous event-driven model. The source code is located in
To spawn a FileStore server, run
server.sh filestore server --id <SELF_ID> --storage <STORAGE_DIR> --peers <ID:IP_ADDRESS,...>
where
<SELF_ID>
, which must be in the peer list, is the ID of the instance being spawned,<STORAGE_DIR>
is a local directory for storing Raft log and other data, and<ID:IP_ADDRESS,...>
, which is a comma separated list of ID and IP address pairs, specifies the list of server peers.
Note that when multiple servers running at the same host, they must use different <STORAGE_DIR>
.
For example,
BIN=ratis-examples/src/main/bin
PEERS=n0:127.0.0.1:6000,n1:127.0.0.1:6001,n2:127.0.0.1:6002
ID=n0; ${BIN}/server.sh filestore server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
ID=n1; ${BIN}/server.sh filestore server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
ID=n2; ${BIN}/server.sh filestore server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
To spawn a FileStore load generation client, run
client.sh filestore loadgen --size <FILE_SIZE> --numFiles <NUM_FILES> --peers <ID:IP_ADDRESS,...>
where
<FILE_SIZE>
is the size of the files to be generated in bytes, and<NUM_FILES>
is the number of files to be generated.
Continue the server command example,
${BIN}/client.sh filestore loadgen --size 1048576 --numFiles 1000 --peers ${PEERS}
Arithmetic is an implementation of a replicated state machine. A variable map is stored in the ArithmeticStateMachine which supports assign and get operations. Clients may assign a variable to a value by specifying either the value or a formula to compute the value.
In TestArithemetic, it uses Arithmetic to solve Pythagorean equation and compute π using Gauss–Legendre algorithm.
The source code is located in
To spawn an Arithmetic server, run
server.sh arithmetic server --id <SELF_ID> --storage <STORAGE_DIR> --peers <ID:IP_ADDRESS,...>
where
<SELF_ID>
, which must be in the peer list, is the ID of the instance being spawned,<STORAGE_DIR>
is a local directory for storing Raft log and other data, and<ID:IP_ADDRESS,...>
, which is a comma separated list of ID and IP address pairs, specifies the list of server peers.
Note that when multiple servers running at the same host, they must use different <STORAGE_DIR>
.
For example,
BIN=ratis-examples/src/main/bin
PEERS=n0:127.0.0.1:6000,n1:127.0.0.1:6001,n2:127.0.0.1:6002
ID=n0; ${BIN}/server.sh arithmetic server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
ID=n1; ${BIN}/server.sh arithmetic server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
ID=n2; ${BIN}/server.sh arithmetic server --id ${ID} --storage /tmp/ratis/${ID} --peers ${PEERS}
To run an Arithmetic client command, run
client.sh arithmetic get --name <VAR> --peers <ID:IP_ADDRESS,...>
or
client.sh arithmetic assign --name <VAR> --value <VALUE> --peers <ID:IP_ADDRESS,...>
where
<VAR>
is the name of a variable, and<VALUE>
is the value (or a formula to compute the value) to be assigned.
Continue the server command example,
${BIN}/client.sh arithmetic assign --name a --value 3 --peers ${PEERS}
${BIN}/client.sh arithmetic assign --name b --value 4 --peers ${PEERS}
${BIN}/client.sh arithmetic assign --name c --value a+b --peers ${PEERS}
${BIN}/client.sh arithmetic get --name c --peers ${PEERS}
One can see the interactions of a three server Ratis cluster with a load-generator running against it
by using the run_all_tests.sh
script found in dev-support/vagrant/.
See the dev-support/vagrant/README.md for more on dependencies and what is setup.
This will allow one to try a fully setup three server Ratis cluster on a single VM image,
preventing resource contention with your development host and allowing failure injection too.