weights.push_back(monmap.get_weight(rank_name));
}
std::random_device rd;
- weighted_shuffle(begin(ranks), end(ranks), begin(weights), end(weights),
- std::mt19937{rd()});
+ if (std::accumulate(begin(weights), end(weights), 0u) == 0) {
+ std::shuffle(begin(ranks), end(ranks), std::mt19937{rd()});
+ } else {
+ weighted_shuffle(begin(ranks), end(ranks), begin(weights), end(weights),
+ std::mt19937{rd()});
+ }
}
ldout(cct, 10) << __func__ << " ranks=" << ranks << dendl;
unsigned n = cct->_conf->mon_client_hunt_parallel;
name = prefix;
name += n;
if (addrs[i].v.size() == 1) {
- _add_ambiguous_addr(name, addrs[i].front(), 0, DEFAULT_WEIGHT, for_mkfs);
+ _add_ambiguous_addr(name, addrs[i].front(), 0, 0, for_mkfs);
} else {
// they specified an addrvec, so let's assume they also specified
// the addr *type* and *port*. (we could possibly improve this?)
string name = prefix;
name += n;
if (addrs[i].v.size() == 1) {
- _add_ambiguous_addr(name, addrs[i].front(), 0, DEFAULT_WEIGHT, false);
+ _add_ambiguous_addr(name, addrs[i].front(), 0, 0, false);
} else {
add(name, addrs[i], 0);
}
class Formatter;
}
-constexpr uint16_t DEFAULT_WEIGHT = 10;
-
struct mon_info_t {
/**
* monitor name
* the priority of the mon, the lower value the more preferred
*/
uint16_t priority{0};
- uint16_t weight{DEFAULT_WEIGHT};
+ uint16_t weight{0};
// <REMOVE ME>
mon_info_t(const string& n, const entity_addr_t& p_addr, uint16_t p)
* @param addr Monitor's public address
*/
void add(const string &name, const entity_addrvec_t &addrv,
- int priority=0, int weight=DEFAULT_WEIGHT) {
+ uint16_t priority=0, uint16_t weight=0) {
add(mon_info_t(name, addrv, priority, weight));
}