Coder Social home page Coder Social logo

Comments (4)

pifuant avatar pifuant commented on August 22, 2024 1

一个entry log会被提交给状态机的前提是已经被group接受了, 所以只需要leader sm apply即可。

from sofa-jraft.

fengjiachun avatar fengjiachun commented on August 22, 2024

你好,感谢关注

这段代码看起来像是只要Leader执行成功了,就会向Client发送“执行成功”的response。

StateMachine#onApply() 是在 raft log 被复制到多数派以后才会调用
所以向客户端发送 “执行成功” 的 response 是在 日志已形成多数派并且在 leader 上执行执行成功 这个时间节点

但实际情况不应该是Task在RaftGroup中成功后(不仅仅是在leader执行成功)才去向client返回response;

这个不太准确,见上面回复

而且这个回调理论上不应该是RAFT框架来调用的吗?为什么需要用户在这个地方来调用?

CounterStateMachine 是业务的状态机,在 jraft 中需要你自己来处理 client 响应

from sofa-jraft.

xingtanzjr avatar xingtanzjr commented on August 22, 2024

谢谢解答

from sofa-jraft.

killme2008 avatar killme2008 commented on August 22, 2024

补充下,还有个一个额外的接口 TaskClosure,可以用于在日志提交到组内多数派之后,应用到状态机之前回调

public interface TaskClosure extends Closure {

    /**
     * Called when task is committed to majority peers of the RAFT group but before it is applied to state machine.
     * 
     * <strong>Note: user implementation should not block this method and throw any exceptions.</strong>
     */
    void onCommitted();
}

from sofa-jraft.

Related Issues (20)

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.