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
RedisLabs Raft
Commits
66a1f846
"tests/vscode:/vscode.git/clone" did not exist on "ae67539c8bb2f898e33633c571f89b168f0ddb73"
Commit
66a1f846
authored
May 19, 2016
by
Willem Thiart
Browse files
Add entry index to applylog callback
parent
2e2c15ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/raft.h
View file @
66a1f846
...
@@ -214,19 +214,6 @@ typedef void (
...
@@ -214,19 +214,6 @@ typedef void (
);
);
#endif
#endif
/** Callback for applying this log entry to the state machine.
* @param[in] raft The Raft server making this callback
* @param[in] user_data User data that is passed from Raft server
* @param[in] ety Log entry to be applied
* @return 0 on success */
typedef
int
(
*
func_applylog_f
)
(
raft_server_t
*
raft
,
void
*
user_data
,
raft_entry_t
*
ety
);
/** Callback for saving who we voted for to disk.
/** Callback for saving who we voted for to disk.
* For safety reasons this callback MUST flush the change to disk.
* For safety reasons this callback MUST flush the change to disk.
* @param[in] raft The Raft server making this callback
* @param[in] raft The Raft server making this callback
...
@@ -245,9 +232,10 @@ typedef int (
...
@@ -245,9 +232,10 @@ typedef int (
*
*
* This callback is used for:
* This callback is used for:
* <ul>
* <ul>
* <li>Adding entries to the log (ie. offer)
* <li>Adding entries to the log (ie. offer)</li>
* <li>Removing the first entry from the log (ie. polling)
* <li>Removing the first entry from the log (ie. polling)</li>
* <li>Removing the last entry from the log (ie. popping)
* <li>Removing the last entry from the log (ie. popping)</li>
* <li>Applying entries</li>
* </ul>
* </ul>
*
*
* For safety reasons this callback MUST flush the change to disk.
* For safety reasons this callback MUST flush the change to disk.
...
@@ -255,8 +243,9 @@ typedef int (
...
@@ -255,8 +243,9 @@ typedef int (
* @param[in] raft The Raft server making this callback
* @param[in] raft The Raft server making this callback
* @param[in] user_data User data that is passed from Raft server
* @param[in] user_data User data that is passed from Raft server
* @param[in] entry The entry that the event is happening to.
* @param[in] entry The entry that the event is happening to.
* The user is allowed to change the memory pointed to in the
* For offering, polling, and popping, the user is allowed to change the
* raft_entry_data_t struct. This MUST be done if the memory is temporary.
* memory pointed to in the raft_entry_data_t struct. This MUST be done if
* the memory is temporary.
* @param[in] entry_idx The entries index in the log
* @param[in] entry_idx The entries index in the log
* @return 0 on success */
* @return 0 on success */
typedef
int
(
typedef
int
(
...
@@ -279,7 +268,7 @@ typedef struct
...
@@ -279,7 +268,7 @@ typedef struct
/** Callback for finite state machine application
/** Callback for finite state machine application
* Return 0 on success.
* Return 0 on success.
* Return RAFT_ERR_SHUTDOWN if you want the server to shutdown. */
* Return RAFT_ERR_SHUTDOWN if you want the server to shutdown. */
func_
applylog
_f
applylog
;
func_
logentry_event
_f
applylog
;
/** Callback for persisting vote data
/** Callback for persisting vote data
* For safety reasons this callback MUST flush the change to disk. */
* For safety reasons this callback MUST flush the change to disk. */
...
...
src/raft_server.c
View file @
66a1f846
...
@@ -659,7 +659,7 @@ int raft_apply_entry(raft_server_t* me_)
...
@@ -659,7 +659,7 @@ int raft_apply_entry(raft_server_t* me_)
me
->
last_applied_idx
++
;
me
->
last_applied_idx
++
;
if
(
me
->
cb
.
applylog
)
if
(
me
->
cb
.
applylog
)
{
{
int
e
=
me
->
cb
.
applylog
(
me_
,
me
->
udata
,
ety
);
int
e
=
me
->
cb
.
applylog
(
me_
,
me
->
udata
,
ety
,
me
->
last_applied_idx
-
1
);
if
(
RAFT_ERR_SHUTDOWN
==
e
)
if
(
RAFT_ERR_SHUTDOWN
==
e
)
return
RAFT_ERR_SHUTDOWN
;
return
RAFT_ERR_SHUTDOWN
;
}
}
...
...
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