MCPcopy Create free account
hub / github.com/baidu/braft / start

Method start

example/counter/server.cpp:75–99  ·  view source on GitHub ↗

Starts this node

Source from the content-addressed store, hash-verified

73
74 // Starts this node
75 int start() {
76 butil::EndPoint addr(butil::my_ip(), FLAGS_port);
77 braft::NodeOptions node_options;
78 if (node_options.initial_conf.parse_from(FLAGS_conf) != 0) {
79 LOG(ERROR) << "Fail to parse configuration `" << FLAGS_conf << '\'';
80 return -1;
81 }
82 node_options.election_timeout_ms = FLAGS_election_timeout_ms;
83 node_options.fsm = this;
84 node_options.node_owns_fsm = false;
85 node_options.snapshot_interval_s = FLAGS_snapshot_interval;
86 std::string prefix = "local://" + FLAGS_data_path;
87 node_options.log_uri = prefix + "/log";
88 node_options.raft_meta_uri = prefix + "/raft_meta";
89 node_options.snapshot_uri = prefix + "/snapshot";
90 node_options.disable_cli = FLAGS_disable_cli;
91 braft::Node* node = new braft::Node(FLAGS_group, braft::PeerId(addr));
92 if (node->init(node_options) != 0) {
93 LOG(ERROR) << "Fail to init raft node";
94 delete node;
95 return -1;
96 }
97 _node = node;
98 return 0;
99 }
100
101 // Impelements Service methods
102 void fetch_add(const FetchAddRequest* request,

Callers 1

mainFunction · 0.45

Calls 3

PeerIdClass · 0.85
parse_fromMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected