sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.57k stars 1.14k forks source link

JRaft usage problems #471

Closed guotaisu closed 4 years ago

guotaisu commented 4 years ago

Your question

本人现就生产代码引入JRaft存在以下问题,望官方协助答疑解惑: 1.状态机、Raft节点、Metric是否都需要根据自己都业务需求进行重写,对这里对“状态机”是什么、怎么用 文档看起来说得不够清楚 2.单组和多组(Multi-Raft-Group)怎么配置、怎么部署和启动 3.RheaKV使用原生接口直接存储即可吗?因为上述2中集群启动后,啥也不用管了,日志一致性、Raft通信底层都实现了

Your scenes

项目需求: 1.使用JRaft支持选举功能 2.使用JRaft支持配置单组和多组(Multi-Raft-Group) 3.使用JRaft-RheaKV支持数据持久和数据快照配置功能

目的: 1.抽象接口,提供其它开发人员开箱即用的能力 2.支持集群单组或多组配置、支持数据持久化配置(Memory、RocksDB)、支持快照配置(是否开启、周期等)

Your advice

官网文档在功能模块原理方面描述的比较清楚,但是作为刚刚接触和使用JRaft的人来说,我觉得应该先懂得如何在自己的项目中使用起来,文档应该重这个角度首先写好入门使用,使用过程中再就具体模块和原理参照文档进行分析。

Environment

sofastack-bot[bot] commented 4 years ago

Hi @guotaisu, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Your question I have the following problems with the introduction of production code to JRaft, I hope the official help answer the questions: 1. Whether the state machine, Raft node, and Metric need to be rewritten according to their business needs. "What is it, how to use the documentation seems to be not clear enough. 2. How to configure, deploy and start single-group and multi-group (Multi-Raft-Group) 3. Can RheaKV use the native interface for direct storage? Because the cluster in the above 2 is started, no matter what, the log consistency and the bottom layer of Raft communication have realized ### Your scenes Project requirements: 1. Use JRaft to support the election function 2. Use JRaft to support the configuration of single and multiple groups (Multi-Raft-Group) 3. Use JRaft-RheaKV to support data persistence and data snapshot configuration functions Purpose: 1. Abstract interface, provide other developers with out-of-the-box capabilities 2. Support cluster single or multiple group configuration, support Data persistence configuration (Memory, RocksDB), support snapshot configuration (whether open, cycle, etc.) ### Your advice The official website document describes the principle of the functional module more clearly, but as someone who has just contacted and used JRaft, I I think I should first understand how to use it in my own project. The document should focus on this angle. First, write the entry and use it, and then use the document to analyze the specific modules and principles. ### Environment-SOFAJRaft version: 1.3.1-JVM version (eg java -version): 1.8-OS version (eg uname -a): mac last version-Maven version: 3.5.9-IDE version: 2020.2

SteNicholas commented 4 years ago

@guotaisu You could refer to articles of SOFAJRaft in sofastack.tech. This would give you some examples to follow.

fengjiachun commented 4 years ago

1.状态机、Raft节点、Metric是否都需要根据自己都业务需求进行重写,对这里对“状态机”是什么、怎么用 文档看起来说得不够清楚

如果你只是用 jraft-core, 那么你需要实现自己的 stateMachine,可参考代码里所有 StateMachineAdapter 的子类,包括 RheaKVKVStoreStateMachine 均可作为参考,其他不用考虑

单组和多组(Multi-Raft-Group)怎么配置、怎么部署和启动

如果你基于 jraft-core 实现 multi group 的话,需要你自己实现分片策略,不是简单配置就搞的定,可参考 jraft-test 模块的配置和代码(该模块用于 jraft 的 jepsen 验证,是一个 multi group 实现),基于 rheakv 的话天然就是 multi group,配置可参考 jraft-example 中的 com.alipay.sofa.jraft.benchmark 部分的配置

3.RheaKV使用原生接口直接存储即可吗?因为上述2中集群启动后,啥也不用管了,日志一致性、Raft通信底层都实现了

是的

1.使用JRaft支持选举功能

可参考 example com.alipay.sofa.jraft.example.election

2.使用JRaft支持配置单组和多组(Multi-Raft-Group)

上面回答了不再重复

3.使用JRaft-RheaKV支持数据持久和数据快照配置功能

支持,精装修拎包住

fengjiachun commented 4 years ago

没其他问题先关闭了