GithubHelp home page GithubHelp logo

Comments (2)

greensky00 avatar greensky00 commented on July 22, 2024

Hi @ZTJiu

In srv_config, there is a boolean flag indicating whether it is a learner:

/**
* `true` if this node is learner.
* Learner will not initiate or participate in leader election.
*/
bool learner_;

You can make the flag true, and use it for initializing s2

my_srv_config_ = cs_new<srv_config>( srv_id, endpoint );

then s2 will not be a leader at the beginning.

After that, you can use the same srv_config for adding s2 to the leader.

/**
* Add a new server to the current cluster.
* Only leader will accept this operation.
* Note that this is an asynchronous task so that needs more network
* communications. Returning this function does not guarantee
* adding the server.
*
* @param srv Configuration of server to add.
* @return `get_accepted()` will be true on success.
*/
ptr< cmd_result< ptr<buffer> > >
add_srv(const srv_config& srv);

Once adding a learner is successfully done, you can see a log like this:

2020-06-02T10:46:15.276_630-07:00 [8d67] [INFO] new configuration: log idx 4, prev log idx 3
peer 1, DC ID 1, tcp://127.0.0.1:11111, voting member, 50
peer 2, DC ID 1, tcp://127.0.0.1:11112, voting member, 50
peer 3, DC ID 1, tcp://127.0.0.1:11113, voting member, 50
peer 4, DC ID 1, tcp://127.0.0.1:11114, learner, 50
my id: 1, leader: 1, term: 1    [handle_commit.cxx:693, reconfigure()]

from nuraft.

ZTJiu avatar ZTJiu commented on July 22, 2024

Hi @greensky00
It works. Thanks a lot!

from nuraft.

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.