Unverified Commit 2279a960 authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Add raft_get_last_applied_term() (#131)

Add raft_get_last_applied_term()
parent 21844ec6
...@@ -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);
......
...@@ -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;
......
...@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment