contrib/raftexample: Update README to reflect dynamic configuration changes (fixes #4018)

This commit is contained in:
Adam Wolfe Gordon 2016-02-08 13:00:54 -07:00
parent 4a527be302
commit ffd61c0faf

View File

@ -65,6 +65,36 @@ goreman run start raftexample2
curl -L http://127.0.0.1:22380/my-key
```
### Dynamic cluster reconfiguration
Nodes can be added to or removed from a running cluster using requests to the REST API.
For example, suppose we have a 3-node cluster that was started with the commands:
```sh
raftexample --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380
raftexample --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380
raftexample --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380
```
A fourth node with ID 4 can be added by issuing a POST:
```sh
curl -L http://127.0.0.1:12380/4 -XPOST -d http://127.0.0.1:42379
```
Then the new node can be started as the others were, using the --join option:
```sh
raftexample --id 4 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379,http://127.0.0.1:42379 --port 42380 --join
```
The new node should join the cluster and be able to service key/value requests.
We can remove a node using a DELETE request:
```sh
curl -L http://127.0.0.1:12380/3 -XDELETE
```
Node 3 should shut itself down once the cluster has processed this request.
## Design
The raftexample consists of three components: a raft-backed key-value store, a REST API server, and a raft consensus server based on etcd's raft implementation.
@ -87,4 +117,3 @@ For raftexample, this commit channel is consumed by the key-value store.
### TODO
- Snapshot support
- Dynamic reconfiguration