diff options
author | Greg Farnum <gfarnum@redhat.com> | 2019-11-22 03:53:07 +0100 |
---|---|---|
committer | Greg Farnum <gfarnum@redhat.com> | 2020-07-08 06:26:02 +0200 |
commit | d04f7e1e6d598d31afde0daa63c740dc311eecfc (patch) | |
tree | 622e2538e1888427f4969491ae235106bba98b93 /src/test/mon | |
parent | test: elector: remove init_pings; we handle this in ConnectionTracker better now (diff) | |
download | ceph-d04f7e1e6d598d31afde0daa63c740dc311eecfc.tar.xz ceph-d04f7e1e6d598d31afde0daa63c740dc311eecfc.zip |
mon: elector: simplify the report sharing interface
Just encode the ConnectionTracker and share that bufferlist around
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
Diffstat (limited to 'src/test/mon')
-rw-r--r-- | src/test/mon/test_election.cc | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/test/mon/test_election.cc b/src/test/mon/test_election.cc index ae4c53c5556..4660ee6223b 100644 --- a/src/test/mon/test_election.cc +++ b/src/test/mon/test_election.cc @@ -196,16 +196,15 @@ struct Owner : public ElectionOwner, RankProvider { parent->report_quorum(quorum); } } + void receive_scores(bufferlist bl) { + ConnectionTracker oct(bl); + peer_tracker.receive_peer_report(oct); + ldout(g_ceph_context, 10) << "received scores " << oct << dendl; + } void receive_ping(int from_rank, bufferlist bl) { - map<int,ConnectionReport> crs; - bufferlist::const_iterator bi = bl.begin(); - decode(crs, bi); ldout(g_ceph_context, 6) << "receive ping from " << from_rank << dendl; peer_tracker.report_live_connection(from_rank, parent->ping_interval); - for (auto& i : crs) { - peer_tracker.receive_peer_report(i.second); - } - + receive_scores(bl); } void receive_ping_timeout(int from_rank) { ldout(g_ceph_context, 6) << "timeout ping from " << from_rank << dendl; @@ -225,6 +224,9 @@ struct Owner : public ElectionOwner, RankProvider { << ", acked_me:" << logic.acked_me << dendl; reset_election(); } + void encode_scores(bufferlist& bl) { + encode(peer_tracker, bl); + } void send_pings() { if (!parent->ping_interval || parent->timesteps_run % parent->ping_interval != 0) { @@ -232,19 +234,7 @@ struct Owner : public ElectionOwner, RankProvider { } bufferlist bl; - map<int,ConnectionReport> crs; - peer_tracker.generate_report_of_peers(&crs[rank]); - for (int i = 0; i < parent->get_paxos_size(); ++i) { - if (i == rank) { - continue; - } - const ConnectionReport *view = peer_tracker.get_peer_view(i); - if (view != NULL) { - crs[i] = *view; - } - } - encode(crs, bl); - + encode_scores(bl); for (int i = 0; i < parent->get_paxos_size(); ++i) { if (i == rank) continue; |