diff options
author | Joao Eduardo Luis <joao.luis@inktank.com> | 2013-04-30 16:28:42 +0100 |
---|---|---|
committer | Joao Eduardo Luis <joao.luis@inktank.com> | 2013-04-30 16:28:42 +0100 |
commit | dee0a872f6d8cdf280cd48847484227a6a59c5ad (patch) | |
tree | c37fd84d6611299676e0067373f5fbf14e1c4331 | |
parent | 2691a7cf8da677cb75a6b40b58404219c2003208 (diff) | |
download | ceph-dee0a872f6d8cdf280cd48847484227a6a59c5ad.tar.gz |
mon: Monitor: use rank instead of name when randomly picking monitors
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r-- | src/common/config_opts.h | 6 | ||||
-rw-r--r-- | src/mon/Monitor.cc | 34 | ||||
-rw-r--r-- | src/mon/Monitor.h | 2 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 22d3d334f36..8cd9eefcd8d 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -174,9 +174,9 @@ OPTION(mon_sync_timeout, OPT_DOUBLE, 30.0) OPTION(mon_sync_max_retries, OPT_INT, 5) OPTION(mon_sync_max_payload_size, OPT_U32, 1048576) // max size for a sync chunk payload (say, 1MB) OPTION(mon_sync_debug, OPT_BOOL, false) // enable sync-specific debug -OPTION(mon_sync_debug_leader, OPT_STR, "") // monitor to be used as the sync leader -OPTION(mon_sync_debug_provider, OPT_STR, "") // monitor to be used as the sync provider -OPTION(mon_sync_debug_provider_fallback, OPT_STR, "") // monitor to be used as fallback if sync provider fails +OPTION(mon_sync_debug_leader, OPT_INT, -1) // monitor to be used as the sync leader +OPTION(mon_sync_debug_provider, OPT_INT, -1) // monitor to be used as the sync provider +OPTION(mon_sync_debug_provider_fallback, OPT_INT, -1) // monitor to be used as fallback if sync provider fails OPTION(mon_sync_leader_kill_at, OPT_INT, 0) // kill the sync leader at a specifc point in the work flow OPTION(mon_sync_provider_kill_at, OPT_INT, 0) // kill the sync provider at a specific point in the work flow OPTION(mon_sync_requester_kill_at, OPT_INT, 0) // kill the sync requester at a specific point in the work flow diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 022f94f42b1..ea1f07a1231 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1041,17 +1041,17 @@ void Monitor::handle_sync_finish(MMonSync *m) // synchronization provider -string Monitor::_pick_random_mon(int other) +int Monitor::_pick_random_mon(int other) { assert(monmap->size() > 0); if (monmap->size() == 1) - return monmap->get_name(0); + return 0; int max = monmap->size(); int n = sync_rng() % max; if (other >= 0 && n >= other) n++; - return monmap->get_name(n); + return n; } int Monitor::_pick_random_quorum_mon(int other) @@ -1089,31 +1089,31 @@ void Monitor::sync_timeout(entity_inst_t &entity) } unsigned int i = 0; - string entity_name = monmap->get_name(entity.addr); + int entity_rank = monmap->get_rank(entity.addr); -dout(0) << __func__ << " entity " << entity << " name " << entity_name << dendl; -dout(0) << __func__ << " our name " << name << dendl; +dout(0) << __func__ << " entity " << entity << " rank " << entity_rank << dendl; +dout(0) << __func__ << " our-rank " << rank << dendl; - string debug_mon = g_conf->mon_sync_debug_provider; - string debug_fallback = g_conf->mon_sync_debug_provider_fallback; + int debug_mon = g_conf->mon_sync_debug_provider; + int debug_fallback = g_conf->mon_sync_debug_provider_fallback; while ((i++) < 2*monmap->size()) { // we are trying to pick a random monitor, but we cannot do this forever. // in case something goes awfully wrong, just stop doing it after a // couple of attempts and try again later. - string new_mon = _pick_random_mon(); + int new_mon = _pick_random_mon(rank); - if (!debug_fallback.empty()) { - if (entity_name != debug_fallback) + if (debug_fallback >= 0) { + if (entity_rank != debug_fallback) new_mon = debug_fallback; - else if (!debug_mon.empty() && (entity_name != debug_mon)) + else if (debug_mon >= 0 && (entity_rank != debug_mon)) new_mon = debug_mon; } -dout(0) << __func__ << " randomly picking mon name " << new_mon << dendl; +dout(0) << __func__ << " randomly picking mon rank " << new_mon << dendl; - if ((new_mon != name) && (new_mon != entity_name)) { + if ((new_mon != rank) && (new_mon != entity_rank)) { sync_provider->entity = monmap->get_inst(new_mon); -dout(0) << __func__ << " randomly choosing " << sync_provider->entity << " name " << new_mon << dendl; +dout(0) << __func__ << " randomly choosing " << sync_provider->entity << " rank " << new_mon << dendl; sync_state = SYNC_STATE_START; sync_start_chunks(sync_provider); return; @@ -1402,13 +1402,13 @@ void Monitor::sync_start(entity_inst_t &other) entity_inst_t leader = other; entity_inst_t provider = other; - if (!g_conf->mon_sync_debug_leader.empty()) { + if (g_conf->mon_sync_debug_leader >= 0) { leader = monmap->get_inst(g_conf->mon_sync_debug_leader); dout(10) << __func__ << " assuming " << leader << " as the leader for debug" << dendl; } - if (!g_conf->mon_sync_debug_provider.empty()) { + if (g_conf->mon_sync_debug_provider >= 0) { provider = monmap->get_inst(g_conf->mon_sync_debug_provider); dout(10) << __func__ << " assuming " << provider << " as the provider for debug" << dendl; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 03eb593185e..f7efb14846a 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -719,7 +719,7 @@ private: * @param other Any monitor other than the one with rank @p other * @returns The picked monitor's name. */ - string _pick_random_mon(int other = -1); + int _pick_random_mon(int other = -1); int _pick_random_quorum_mon(int other = -1); /** * Deal with the consequences of @p entity's sync timing out. |