Floyd 中文
Floyd is an C++ library based on Raft consensus protocol.
- Raft is a consensus algorithm which is easy to understand;
- Floyd is an library that could be easily embeded into users' application;
- Floyd support consistency between cluster nodes by APIs like Read/Write/Delete;
- Also we support direct access to data without consistency: DirtyRead/DirtyWrite;
- Also some query and debug managment APIs: GetLeader/GetServerStatus/set_log_level
- Floyd has provided high available store for Meta cluster of Zeppelin , which is a huge distributed key-value storage.
- The list will goes on.
When we want to coordinate services, ZooKeeper is always a good choice.
- But we have to maintain another service.
- We must use its' SDK at the same time.
In our opion, a single service is much more simple than two services. As a result, an embeded library could be a better choice.
- APIs and usage
type | API | Status |
---|---|---|
Consensus | Read | support |
Consensus | Write | support |
Consensus | Delete | support |
Consensus | Lock | working |
Consensus | UnLock | working |
Consensus | GetLease | working |
Local | DirtyRead | support |
Local | DirtyWrite | support |
Query | GetLeader | support |
Query | GetServerStatus | support |
Debug | set_log_level | support |
- Raft fetaures
Language | Leader election + Log Replication | Membership Changes | Log Compaction |
---|---|---|---|
C++ | Yes | No | No |
-
Dependencies
- gcc version 4.8+ to support C++11.
- protobuf-devel
- snappy-devel
- bzip2-devel
- zlib-devel
- bzip2
- submodules:
-
- Get source code and submodules recursively.
git clone --recursive https://github.com/Qihoo360/floyd.git
-
- Compile library
make
- Compile library
-
- Compile example
make test
- Compile example
-
- run example/server groups
cd exampler/server
./output/bin/floyd_node --servers 127.0.0.1:9100,127.0.0.1:9101,127.0.0.1:9102 --local_ip 127.0.0.1 --local_port 9100 --sdk_port 8900 --data_path ./node1/data --log_path ./node1/log
./output/bin/floyd_node --servers 127.0.0.1:9100,127.0.0.1:9101,127.0.0.1:9102 --local_ip 127.0.0.1 --local_port 9101 --sdk_port 8901 --data_path ./node2/data --log_path ./node2/log
./output/bin/floyd_node --servers 127.0.0.1:9100,127.0.0.1:9101,127.0.0.1:9102 --local_ip 127.0.0.1 --local_port 9102 --sdk_port 8902 --data_path ./node3/data --log_path ./node3/log
-
- run client
# ./floyd_client
Usage:
./client --server ip:port
--cmd [read | write | delete | status | debug_on | debug_off]
--begin id0 --end id1
# ./floyd_client --server 127.0.0.1:8901 --cmd status --begin 0 --end 1
- email: [email protected]
- QQ Group: 294254078
- WeChat public: 360基础架构组