Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Willemt Raft
Commits
387fb3e3
Commit
387fb3e3
authored
Dec 02, 2015
by
Willem Thiart
Browse files
Add node_has_sufficient_logs callback
parent
1410fc5e
Changes
2
Show whitespace changes
Inline
Side-by-side
include/raft.h
View file @
387fb3e3
...
...
@@ -168,6 +168,19 @@ typedef int (
msg_appendentries_t
*
msg
);
/** Callback for detecting when non-voting nodes have obtained enough logs.
* @param[in] raft The Raft server making this callback
* @param[in] user_data User data that is passed from Raft server
* @param[in] node The node
* @return 0 on success */
typedef
void
(
*
func_node_has_sufficient_logs_f
)
(
raft_server_t
*
raft
,
void
*
user_data
,
raft_node_t
*
node
);
#ifndef HAVE_FUNC_LOG
#define HAVE_FUNC_LOG
/** Callback for providing debug logging information.
...
...
@@ -293,6 +306,9 @@ typedef struct
* time to free the memory. */
func_logentry_event_f
log_pop
;
/** Callback for detecting when a non-voting node has sufficient logs. */
func_node_has_sufficient_logs_f
node_has_sufficient_logs
;
/** Callback for catching debugging log messages
* This callback is optional */
func_log_f
log
;
...
...
src/raft_server.c
View file @
387fb3e3
...
...
@@ -221,6 +221,11 @@ int raft_recv_appendentries_response(raft_server_t* me_,
raft_node_set_next_idx
(
node
,
r
->
current_idx
+
1
);
raft_node_set_match_idx
(
node
,
r
->
current_idx
);
if
(
!
raft_node_is_voting
(
node
)
&&
raft_get_current_term
(
me_
)
<=
r
->
current_idx
+
1
&&
me
->
cb
.
node_has_sufficient_logs
)
me
->
cb
.
node_has_sufficient_logs
(
me_
,
me
->
udata
,
node
);
/* Update commit idx */
int
votes
=
1
;
/* include me */
int
point
=
r
->
current_idx
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment