Commit b20cb85c authored by Yossi Gottlieb's avatar Yossi Gottlieb
Browse files

Cleanup unused stuff.

parent c7d4e751
...@@ -81,13 +81,6 @@ typedef enum { ...@@ -81,13 +81,6 @@ typedef enum {
RAFT_LOGTYPE_NUM=100, RAFT_LOGTYPE_NUM=100,
} raft_logtype_e; } raft_logtype_e;
typedef struct
{
void *buf;
unsigned int len;
} raft_entry_data_t;
/** Entry that is stored in the server's entry log. */ /** Entry that is stored in the server's entry log. */
typedef struct raft_entry typedef struct raft_entry
{ {
...@@ -210,9 +203,6 @@ typedef struct ...@@ -210,9 +203,6 @@ typedef struct
/** If success, this is the highest log IDX we've received and appended to /** If success, this is the highest log IDX we've received and appended to
* our log; otherwise, this is the our currentIndex */ * our log; otherwise, this is the our currentIndex */
raft_index_t current_idx; raft_index_t current_idx;
/** The first idx that we received within the appendentries message */
raft_index_t first_idx;
} msg_appendentries_response_t; } msg_appendentries_response_t;
typedef void* raft_server_t; typedef void* raft_server_t;
...@@ -580,15 +570,6 @@ typedef struct raft_log_impl ...@@ -580,15 +570,6 @@ typedef struct raft_log_impl
raft_index_t (*count) (void *log); raft_index_t (*count) (void *log);
} raft_log_impl_t; } raft_log_impl_t;
typedef struct
{
/** User data pointer for addressing.
* Examples of what this could be:
* - void* pointing to implementor's networking data
* - a (IP,Port) tuple */
void* udata_address;
} raft_node_configuration_t;
/** Initialise a new Raft server, using the in-memory log implementation. /** Initialise a new Raft server, using the in-memory log implementation.
* *
* Request timeout defaults to 200 milliseconds * Request timeout defaults to 200 milliseconds
......
...@@ -285,11 +285,10 @@ int raft_recv_appendentries_response(raft_server_t* me_, ...@@ -285,11 +285,10 @@ int raft_recv_appendentries_response(raft_server_t* me_,
raft_server_private_t* me = (raft_server_private_t*)me_; raft_server_private_t* me = (raft_server_private_t*)me_;
__log(me_, node, __log(me_, node,
"received appendentries response %s ci:%d rci:%d 1stidx:%d", "received appendentries response %s ci:%d rci:%d",
r->success == 1 ? "SUCCESS" : "fail", r->success == 1 ? "SUCCESS" : "fail",
raft_get_current_idx(me_), raft_get_current_idx(me_),
r->current_idx, r->current_idx);
r->first_idx);
if (!node) if (!node)
return -1; return -1;
...@@ -542,7 +541,6 @@ out: ...@@ -542,7 +541,6 @@ out:
r->term = me->current_term; r->term = me->current_term;
if (0 == r->success) if (0 == r->success)
r->current_idx = raft_get_current_idx(me_); r->current_idx = raft_get_current_idx(me_);
r->first_idx = ae->prev_log_idx + 1;
return e; return e;
} }
......
...@@ -2639,7 +2639,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori ...@@ -2639,7 +2639,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
...@@ -2657,7 +2656,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori ...@@ -2657,7 +2656,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 2;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 1, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 1, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
...@@ -2704,7 +2702,6 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_for_nod ...@@ -2704,7 +2702,6 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_for_nod
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 1;
raft_node_set_voting(node, 0); raft_node_set_voting(node, 0);
raft_recv_appendentries_response(r, node, &aer); raft_recv_appendentries_response(r, node, &aer);
...@@ -2754,7 +2751,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_using_votin ...@@ -2754,7 +2751,6 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_using_votin
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 1, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 1, raft_get_commit_idx(r));
/* leader will now have majority followers who have appended this log */ /* leader will now have majority followers who have appended this log */
...@@ -2795,7 +2791,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma ...@@ -2795,7 +2791,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 1, raft_node_get_match_idx(raft_get_node(r, 2))); CuAssertIntEquals(tc, 1, raft_node_get_match_idx(raft_get_node(r, 2)));
...@@ -2803,7 +2798,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma ...@@ -2803,7 +2798,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 2;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 2, raft_node_get_match_idx(raft_get_node(r, 2))); CuAssertIntEquals(tc, 2, raft_node_get_match_idx(raft_get_node(r, 2)));
...@@ -2811,7 +2805,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma ...@@ -2811,7 +2805,6 @@ void TestRaft_leader_recv_appendentries_response_duplicate_does_not_decrement_ma
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 2, raft_node_get_match_idx(raft_get_node(r, 2))); CuAssertIntEquals(tc, 2, raft_node_get_match_idx(raft_get_node(r, 2)));
} }
...@@ -2857,7 +2850,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca ...@@ -2857,7 +2850,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
...@@ -2874,7 +2866,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca ...@@ -2874,7 +2866,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 2;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
...@@ -2890,7 +2881,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca ...@@ -2890,7 +2881,6 @@ void TestRaft_leader_recv_appendentries_response_do_not_increase_commit_idx_beca
aer.term = 2; aer.term = 2;
aer.success = 1; aer.success = 1;
aer.current_idx = 3; aer.current_idx = 3;
aer.first_idx = 3;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
...@@ -3058,7 +3048,6 @@ void TestRaft_leader_recv_appendentries_response_retry_only_if_leader(CuTest * t ...@@ -3058,7 +3048,6 @@ void TestRaft_leader_recv_appendentries_response_retry_only_if_leader(CuTest * t
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
CuAssertTrue(tc, RAFT_ERR_NOT_LEADER == raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer)); CuAssertTrue(tc, RAFT_ERR_NOT_LEADER == raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer));
CuAssertTrue(tc, NULL == sender_poll_msg_data(sender)); CuAssertTrue(tc, NULL == sender_poll_msg_data(sender));
} }
...@@ -3086,7 +3075,6 @@ void TestRaft_leader_recv_appendentries_response_without_node_fails(CuTest * tc) ...@@ -3086,7 +3075,6 @@ void TestRaft_leader_recv_appendentries_response_without_node_fails(CuTest * tc)
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 0; aer.current_idx = 0;
aer.first_idx = 0;
CuAssertIntEquals(tc, -1, raft_recv_appendentries_response(r, NULL, &aer)); CuAssertIntEquals(tc, -1, raft_recv_appendentries_response(r, NULL, &aer));
} }
...@@ -3298,7 +3286,6 @@ void TestRaft_leader_recv_appendentries_response_failure_does_not_set_node_nexti ...@@ -3298,7 +3286,6 @@ void TestRaft_leader_recv_appendentries_response_failure_does_not_set_node_nexti
aer.term = 1; aer.term = 1;
aer.success = 0; aer.success = 0;
aer.current_idx = 0; aer.current_idx = 0;
aer.first_idx = 0;
raft_node_t* p = raft_get_node(r, 2); raft_node_t* p = raft_get_node(r, 2);
raft_recv_appendentries_response(r, p, &aer); raft_recv_appendentries_response(r, p, &aer);
CuAssertTrue(tc, 1 == raft_node_get_next_idx(p)); CuAssertTrue(tc, 1 == raft_node_get_next_idx(p));
...@@ -3333,7 +3320,6 @@ void TestRaft_leader_recv_appendentries_response_increment_idx_of_node( ...@@ -3333,7 +3320,6 @@ void TestRaft_leader_recv_appendentries_response_increment_idx_of_node(
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 0; aer.current_idx = 0;
aer.first_idx = 0;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertIntEquals(tc, 1, raft_node_get_next_idx(p)); CuAssertIntEquals(tc, 1, raft_node_get_next_idx(p));
} }
...@@ -3365,7 +3351,6 @@ void TestRaft_leader_recv_appendentries_response_drop_message_if_term_is_old( ...@@ -3365,7 +3351,6 @@ void TestRaft_leader_recv_appendentries_response_drop_message_if_term_is_old(
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertTrue(tc, 1 == raft_node_get_next_idx(p)); CuAssertTrue(tc, 1 == raft_node_get_next_idx(p));
} }
...@@ -3396,7 +3381,6 @@ void TestRaft_leader_recv_appendentries_response_steps_down_if_term_is_newer( ...@@ -3396,7 +3381,6 @@ void TestRaft_leader_recv_appendentries_response_steps_down_if_term_is_newer(
aer.term = 3; aer.term = 3;
aer.success = 0; aer.success = 0;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 0;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
CuAssertTrue(tc, 1 == raft_is_follower(r)); CuAssertTrue(tc, 1 == raft_is_follower(r));
CuAssertTrue(tc, -1 == raft_get_current_leader(r)); CuAssertTrue(tc, -1 == raft_get_current_leader(r));
...@@ -3621,7 +3605,7 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_after_v ...@@ -3621,7 +3605,7 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_after_v
CuAssertIntEquals(tc, 0, raft_recv_entry(r, ety, &etyr)); CuAssertIntEquals(tc, 0, raft_recv_entry(r, ety, &etyr));
msg_appendentries_response_t aer = { msg_appendentries_response_t aer = {
.term = 1, .success = 1, .current_idx = 2, .first_idx = 0 .term = 1, .success = 1, .current_idx = 2
}; };
/* node 3 responds so it has sufficient logs and will be promoted */ /* node 3 responds so it has sufficient logs and will be promoted */
...@@ -3637,7 +3621,6 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_after_v ...@@ -3637,7 +3621,6 @@ void TestRaft_leader_recv_appendentries_response_set_has_sufficient_logs_after_v
CuAssertIntEquals(tc, 1, has_sufficient_logs_flag); CuAssertIntEquals(tc, 1, has_sufficient_logs_flag);
/* both nodes respond to the promotion */ /* both nodes respond to the promotion */
aer.first_idx = 2;
aer.current_idx = 3; aer.current_idx = 3;
raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 2), &aer);
raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer); raft_recv_appendentries_response(r, raft_get_node(r, 3), &aer);
......
...@@ -729,7 +729,6 @@ void TestRaft_leader_sends_snapshot_if_log_was_compacted(CuTest* tc) ...@@ -729,7 +729,6 @@ void TestRaft_leader_sends_snapshot_if_log_was_compacted(CuTest* tc)
aer.term = 1; aer.term = 1;
aer.success = 0; aer.success = 0;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 4;
raft_recv_appendentries_response(r, node, &aer); raft_recv_appendentries_response(r, node, &aer);
CuAssertIntEquals(tc, 1, send_snapshot_count); CuAssertIntEquals(tc, 1, send_snapshot_count);
......
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