Skip to content

Commit

Permalink
elector: hoist participating into ElectionLogic
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
  • Loading branch information
gregsfortytwo committed Aug 19, 2019
1 parent 0205695 commit b53b984
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/mon/Elector.cc
Expand Up @@ -114,7 +114,7 @@ void Elector::_bump_epoch()

void Elector::start()
{
if (!participating) {
if (!logic.participating) {
dout(0) << "not starting new election -- not participating" << dendl;
return;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ void Elector::dispatch(MonOpRequestRef op)

case MSG_MON_ELECTION:
{
if (!participating) {
if (!logic.participating) {
return;
}
if (op->get_req()->get_source().num() >= mon->monmap->size()) {
Expand Down Expand Up @@ -617,7 +617,5 @@ void Elector::dispatch(MonOpRequestRef op)

void Elector::start_participating()
{
if (!participating) {
participating = true;
}
logic.participating = true;
}
10 changes: 5 additions & 5 deletions src/mon/Elector.h
Expand Up @@ -31,11 +31,12 @@ class ElectionLogic {
public:
Elector *elector;
epoch_t epoch;
bool participating;
bool electing_me;
set<int> acked_me;
int leader_acked;

ElectionLogic(Elector *e) : elector(e), epoch(0),
ElectionLogic(Elector *e) : elector(e), epoch(0), participating(true),
electing_me(false), leader_acked(-1) {}
void init();
void bump_epoch(epoch_t e);
Expand Down Expand Up @@ -139,7 +140,7 @@ class Elector {
* have to call Elector::start_participating for us to resume
* participating in the quorum.
*/
bool participating;
// bool participating;

// electing me
/**
Expand Down Expand Up @@ -363,8 +364,7 @@ class Elector {
*/
explicit Elector(Monitor *m) : logic(this),
elector(this),
mon(m),
participating(true) {}
mon(m) {}

/**
* Initiate the Elector class.
Expand Down Expand Up @@ -426,7 +426,7 @@ class Elector {
*
* @post @p participating is false
*/
void stop_participating() { participating = false; }
void stop_participating() { logic.participating = false; }
/**
* Start participating in Elections.
*
Expand Down

0 comments on commit b53b984

Please sign in to comment.