vmware / haret
- понедельник, 22 мая 2017 г. в 03:12:03
Rust
A strongly consistent distributed coordination system, built using proven protocols & implemented in Rust.
haret provides a distributed service built on proven protocols that exposes strongly consistent coordination primitives via an easy to use API, in order to satisfy the essential dependencies of many distributed applications. You can read more about why we decided to build haret here.
This README contains quickstart instructions for both developers and users. More information about using haret can be found in the rough and incomplete User Guide.
Start Here if you are an enduser of haret and not interested in building the code.
Release binaries for Mac OSX
and Linux
can be downloaded
here.
Each release directory contains a config.toml
file for running a single node of haret. From the release directory
containing the config.toml
and binaries, run haret
in a terminal with the following command to
start a node:
RUST_LOG=haret=info,rabble=info ./haret
While a haret replication group (namespace) is intended to run in a cluster across multiple physical machines for fault tolerance, it is capable of running in a single process for testing purposes. Each replica in the group is represented by a lightweight actor that can receive and respond to messages, so we can just designate a group of actors on the same node to be the replication group.
Open another terminal that we can use to communicate with this node.
Connect to the admin server of node1
./haret-admin 127.0.0.1:5001
Check the cluster status to verify only a single node exists
haret-admin> cluster status
Create a namespaces on node1
haret-admin> vr create namespace test-ns r1::node1@127.0.0.1:5000,r2::node1@127.0.0.1:5000,r3::node1@127.0.0.1:5000
List namespaces
haret-admin> vr namespaces
Get the state of r1::dev1 - It will show the primary of the test-ns
namespace toward the top.
haret-admin> vr replica test-ns::r1::node1@127.0.0.1:2000`
Show Configuration
haret-admin> config
Now exit the admin CLI and connect to the API port on node1
using the CLI client
./haret-cli-client 127.0.0.1:5002
List namespaces
haret> list-namespaces
Enter the test-ns
namespace so you can issue operations against the namespace's tree. This entails
learning which replica is the primary for that namespace so it can be sent messages.
haret> enter test-ns
Now start issuing operations against the namespace. They can be discovered by typing help
at
the prompt. More examples are shown below.
If you'd like to build a multi-node cluster all on localhost, it's a simple matter of copying the
release directory n
times, where n
is the size of the cluster, and then editing each config file
to listen on different ports (This is exactly what make devrel
does if you have the build
dependencies). Each haret in each directory can then be started. From there the instructions
below detail joining nodes together to form a cluster.
Start here if you are looking to hack on haret.
cd haret && make launch
haret/dev/devN
rlwrap cargo run --bin haret-admin 127.0.0.1:2001
haret-admin> cluster status
haret-admin> cluster join dev2@127.0.0.1:3000
haret-admin> cluster join dev3@127.0.0.1:4000
haret-admin> vr create namespace test-ns r1::dev1@127.0.0.1:2000,r2::dev2@127.0.0.1:3000,r3::dev3@127.0.0.1:4000
haret-admin> vr namespaces
haret-admin> vr replica test-ns::r1::dev1@127.0.0.1:2000
config
rlwrap target/debug/haret-cli-client 127.0.0.1:2002
list-namespaces
test-ns
namespace so you can issue operations against the namespace's tree
enter test-ns
haret> create set /some/other/node
Ok
Epoch = 1, View = 6, Client Request Num = 3
haret> set insert /some/other/node hi
true
Version = 1 Epoch = 1, View = 6, Client Request Num = 4
haret> set contains /some/other/node hi
true
Version = 1 Epoch = 1, View = 6, Client Request Num = 5
haret> set contains /some/other/node h
false
Version = 1 Epoch = 1, View = 6, Client Request Num = 6
haret> create set /some/set
Ok
Epoch = 1, View = 6, Client Request Num = 7
haret> set insert /some/set blah
true
Version = 1 Epoch = 1, View = 6, Client Request Num = 8
haret> set intersection /some/set /some/other/node
Epoch = 1, View = 6, Client Request Num = 9
haret> set union /some/set /some/other/node
hi
blah
Epoch = 1, View = 6, Client Request Num = 10
haret>
haret-admin> vr replica test-ns::r1::dev1
make stop-dev2
enter test-ns
haret> set union /some/set /some/other/node
hi
blah
Epoch = 1, View = 7, Client Request Num = 11