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
2279a960
Unverified
Commit
2279a960
authored
Aug 29, 2022
by
Ozan Tezcan
Committed by
GitHub
Aug 29, 2022
Browse files
Add raft_get_last_applied_term() (#131)
Add raft_get_last_applied_term()
parent
21844ec6
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/raft.h
View file @
2279a960
...
@@ -1153,6 +1153,10 @@ raft_time_t raft_get_timeout_elapsed(raft_server_t *me);
...
@@ -1153,6 +1153,10 @@ raft_time_t raft_get_timeout_elapsed(raft_server_t *me);
* @return index of last applied entry */
* @return index of last applied entry */
raft_index_t
raft_get_last_applied_idx
(
raft_server_t
*
me
);
raft_index_t
raft_get_last_applied_idx
(
raft_server_t
*
me
);
/**
* @return index of last applied term */
raft_term_t
raft_get_last_applied_term
(
raft_server_t
*
me
);
/**
/**
* @return the node's next index */
* @return the node's next index */
raft_index_t
raft_node_get_next_idx
(
raft_node_t
*
node
);
raft_index_t
raft_node_get_next_idx
(
raft_node_t
*
node
);
...
...
src/raft_server_properties.c
View file @
2279a960
...
@@ -97,6 +97,11 @@ raft_index_t raft_get_last_applied_idx(raft_server_t *me)
...
@@ -97,6 +97,11 @@ raft_index_t raft_get_last_applied_idx(raft_server_t *me)
return
me
->
last_applied_idx
;
return
me
->
last_applied_idx
;
}
}
raft_term_t
raft_get_last_applied_term
(
raft_server_t
*
me
)
{
return
me
->
last_applied_term
;
}
raft_index_t
raft_get_commit_idx
(
raft_server_t
*
me
)
raft_index_t
raft_get_commit_idx
(
raft_server_t
*
me
)
{
{
return
me
->
commit_idx
;
return
me
->
commit_idx
;
...
...
tests/test_server.c
View file @
2279a960
...
@@ -4754,10 +4754,10 @@ void TestRaft_apply_entry_timeout(CuTest *tc)
...
@@ -4754,10 +4754,10 @@ void TestRaft_apply_entry_timeout(CuTest *tc)
void
*
r
=
raft_new
();
void
*
r
=
raft_new
();
raft_add_node
(
r
,
NULL
,
1
,
1
);
raft_add_node
(
r
,
NULL
,
1
,
1
);
raft_set_callbacks
(
r
,
&
funcs
,
&
ts
);
raft_set_callbacks
(
r
,
&
funcs
,
&
ts
);
raft_set_current_term
(
r
,
1
);
raft_set_current_term
(
r
,
3
);
raft_config
(
r
,
1
,
RAFT_CONFIG_REQUEST_TIMEOUT
,
100
);
raft_config
(
r
,
1
,
RAFT_CONFIG_REQUEST_TIMEOUT
,
100
);
__RAFT_APPEND_ENTRIES_SEQ_ID
(
r
,
21
,
0
,
1
,
""
);
__RAFT_APPEND_ENTRIES_SEQ_ID
(
r
,
21
,
0
,
3
,
""
);
raft_set_commit_idx
(
r
,
21
);
raft_set_commit_idx
(
r
,
21
);
/* Each execution iteration will apply 5 entries as we throttle when we
/* Each execution iteration will apply 5 entries as we throttle when we
...
@@ -4767,6 +4767,7 @@ void TestRaft_apply_entry_timeout(CuTest *tc)
...
@@ -4767,6 +4767,7 @@ void TestRaft_apply_entry_timeout(CuTest *tc)
raft_exec_operations
(
r
);
raft_exec_operations
(
r
);
CuAssertIntEquals
(
tc
,
1
,
raft_pending_operations
(
r
));
CuAssertIntEquals
(
tc
,
1
,
raft_pending_operations
(
r
));
CuAssertIntEquals
(
tc
,
5
,
raft_get_last_applied_idx
(
r
));
CuAssertIntEquals
(
tc
,
5
,
raft_get_last_applied_idx
(
r
));
CuAssertIntEquals
(
tc
,
3
,
raft_get_last_applied_term
(
r
));
raft_exec_operations
(
r
);
raft_exec_operations
(
r
);
CuAssertIntEquals
(
tc
,
1
,
raft_pending_operations
(
r
));
CuAssertIntEquals
(
tc
,
1
,
raft_pending_operations
(
r
));
...
...
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