monmap: calc_ranks() on rename()

This is simpler than ensuring we track all the right invariants.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-05-22 07:05:36 -07:00
parent d93410c799
commit d7a8084b4c

View File

@ -103,6 +103,14 @@ class MonMap {
calc_ranks();
}
void rename(string oldname, string newname) {
assert(contains(oldname));
assert(!contains(newname));
mon_addr[newname] = mon_addr[oldname];
mon_addr.erase(oldname);
calc_ranks();
}
bool contains(const string& name) {
return mon_addr.count(name);
}
@ -147,14 +155,6 @@ class MonMap {
return true;
}
void rename(string oldname, string newname) {
assert(contains(oldname));
assert(!contains(newname));
mon_addr[newname] = mon_addr[oldname];
mon_addr.erase(oldname);
addr_name[mon_addr[newname]] = newname;
}
const entity_addr_t& get_addr(const string& n) {
assert(mon_addr.count(n));
return mon_addr[n];