{"id":30623432,"url":"https://github.com/houbb/raft","last_synced_at":"2025-10-08T15:11:29.859Z","repository":{"id":300788274,"uuid":"957045951","full_name":"houbb/raft","owner":"houbb","description":"the raft for java.(分布式一致性协议 raft java 版本实现，分布式的基石)","archived":false,"fork":false,"pushed_at":"2025-07-08T16:45:22.000Z","size":264,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-30T16:30:52.571Z","etag":null,"topics":["consensus-algorithm","dubbo","mq","raft","raft-consensus-algorithm","rpc"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houbb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_LOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-29T12:27:14.000Z","updated_at":"2025-07-08T16:44:29.000Z","dependencies_parsed_at":"2025-06-23T16:44:40.390Z","dependency_job_id":"66f97d38-bc2a-4d4d-9a9f-08df377afb2a","html_url":"https://github.com/houbb/raft","commit_stats":null,"previous_names":["houbb/raft"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/houbb/raft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houbb","download_url":"https://codeload.github.com/houbb/raft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fraft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278964560,"owners_count":26076694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consensus-algorithm","dubbo","mq","raft","raft-consensus-algorithm","rpc"],"created_at":"2025-08-30T16:19:49.960Z","updated_at":"2025-10-08T15:11:29.816Z","avatar_url":"https://github.com/houbb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# raft\n\n[raft](https://github.com/houbb/raft) raft 算法的基本 java 实现。\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.houbb/raft/badge.svg)](http://mvnrepository.com/artifact/com.github.houbb/raft)\n[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/houbb/raft)\n[![](https://img.shields.io/badge/license-Apache2-FF0080.svg)](https://github.com/houbb/raft/blob/master/LICENSE.txt)\n\n如果有一些疑难杂症，可以加入：[技术交流群](https://mp.weixin.qq.com/s/rkSvXxiiLGjl3S-ZOZCr0Q)\n\n## 创作目的\n\n大家好，我是老马。\n\n主要是为了学习一下 raft，天天听别人吹牛听烦了。\n\n用了很久也不懂，就学习一下。\n\n## 特性\n\n- leader 选举\n- 日志复制\n- 成员变更\n- 日志压缩\n\n\n## 变更日志\n\n[CHANGE_LOG.md](https://github.com/houbb/raft/blob/master/CHANGE_LOG.md)\n\n# 入门\n\n## quick start\n\n🔥🔥🔥🔥🔥 注意：该项目仅支持 oracle jdk8 启动。\n\n🔴🔴🔴🔴🔴 注意：idea 需要安装 lombok 插件。\n\n#### 验证 \"leader 选举\"\n\n1. 启动RaftBootstrapTest1、RaftBootstrapTest2、RaftBootstrapTest3、RaftBootstrapTest4、RaftBootstrapTest5\n2. 依次启动 5 个 RaftNodeBootStrap 节点, 端口分别是 8775，8776， 8777, 8778, 8779.\n3. 观察控制台, 约 6 秒后, 会发生选举事件,此时,会产生一个 leader. 而  leader 会立刻发送心跳维持自己的地位.\n4. 如果leader 的端口是  8775, 使用 idea 关闭 8775 端口，模拟节点挂掉, 大约 15 秒后, 会重新开始选举, 并且会在剩余的 4 个节点中,产生一个新的 leader.  并开始发送心跳日志。\n\n#### 验证\"日志复制\"\n\n##### 正常状态下\n\n1. 启动RaftBootstrapTest1、RaftBootstrapTest2、RaftBootstrapTest3、RaftBootstrapTest4、RaftBootstrapTest5\n2. 依次启动 5 个 RaftNodeBootStrap 节点, 端口分别是 8775，8776， 8777, 8778, 8779.\n3. 使用客户端写入 kv 数据.\n4. 杀掉所有节点, 使用 junit test 读取每个 rocksDB 的值, 验证每个节点的数据是否一致.\n\n##### 非正常状态下\n\n1. 启动RaftBootstrapTest1、RaftBootstrapTest2、RaftBootstrapTest3、RaftBootstrapTest4、RaftBootstrapTest5\n2. 依次启动 5 个 RaftNodeBootStrap 节点, 端口分别是 8775，8776， 8777, 8778, 8779.\n3. 使用客户端写入 kv 数据.\n4. 杀掉 leader （假设是 8775）.\n5. 再次写入数据.\n6. 重启 8775.\n7. 关闭所有节点, 读取 RocksDB 验证数据一致性.\n\n# 拓展阅读\n\n[raft-07-java 如何编写一个 Raft 分布式 KV 存储 lu-raft-kv](https://houbb.github.io/2022/07/09/sofastack-sofajraft-07-raft-impl-in-java-lu)\n\n# 后期 ROAD-MAP\n\n- [ ] 成员变更 add/remove\n\n- [ ] 日志压缩\n\n- [ ] 输出的信息优化\n\n- [ ] 企业级 raft + 实际使用\n\n# 技术鸣谢\n\n主要参考项目 https://github.com/stateIs0/lu-raft-kv\n\n目前用于学习，后续希望可以拓展简化自己使用","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoubb%2Fraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fraft/lists"}