Giter VIP home page Giter VIP logo

my-raft-rs-with-annotation's Introduction

关于HardState:

message HardState {
    uint64 term = 1;
    uint64 vote = 2;
    uint64 commit = 3;
}

HardState需要被持久化

  • term: 当前raft节点的任期
  • vote: 当前raft节点在本任期内投票给了谁(用于防止一个任期一个节点多次投票)
  • commit: 当前raft节点已经commit的最高的日志索引

raft论文中commitIndex和applyIndex都是不需要持久化的,原因是其假设的stateMachine是volatile的, 但实际工程化中会选择进行持久化来提高节点的启动速度。 那为什么这里只持久化了commitIndex,而没有持久化applyIndex呢? 是否是从上次snapshot后的raftlog开始replay到commitIndex?

关于ConfState:

message ConfState {
    repeated uint64 nodes = 1;
    repeated uint64 learners = 2;
}

ConfState也需要被初始化,节点重启需要获取这些信息

  • nodes: raft中的所有节点
  • learners: raft中的learner节点(可选)

关于MsgType的描述说明:

MsgHup : MsgBeat : MsgPropose = 2; MsgAppend = 3; MsgAppendResponse = 4; MsgRequestVote :candicate发起的投票请求 MsgRequestVoteResponse :投票请求响应结果 MsgSnapshot = 7; MsgHeartbeat :Leader给Follower发送的心跳请求 MsgHeartbeatResponse :心跳响应结果 MsgUnreachable = 10; MsgSnapStatus = 11; MsgCheckQuorum = 12; MsgTransferLeader = 13; MsgTimeoutNow = 14; MsgReadIndex : Follower向Leader发起的ReadIndex请求 MsgReadIndexResp :ReadIndex响应 MsgRequestPreVote :预投票请求 MsgRequestPreVoteResponse : 预投票响应

my-raft-rs-with-annotation's People

Contributors

guoxiangcn avatar

Forkers

zhangxuewen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.