private:
struct crush_map *crush;
/* reverse maps */
- bool have_rmaps;
- std::map<string, int> type_rmap, name_rmap, rule_name_rmap;
- void build_rmaps() {
+ mutable bool have_rmaps;
+ mutable std::map<string, int> type_rmap, name_rmap, rule_name_rmap;
+ void build_rmaps() const {
if (have_rmaps) return;
build_rmap(type_map, type_rmap);
build_rmap(name_map, name_rmap);
build_rmap(rule_name_map, rule_name_rmap);
have_rmaps = true;
}
- void build_rmap(const map<int, string> &f, std::map<string, int> &r) {
+ void build_rmap(const map<int, string> &f, std::map<string, int> &r) const {
r.clear();
for (std::map<int, string>::const_iterator p = f.begin(); p != f.end(); ++p)
r[p->second] = p->first;
int get_num_type_names() const {
return type_map.size();
}
- int get_type_id(const string& name) {
+ int get_type_id(const string& name) const {
build_rmaps();
if (type_rmap.count(name))
return type_rmap[name];
}
// item/bucket names
- bool name_exists(const string& name) {
+ bool name_exists(const string& name) const {
build_rmaps();
return name_rmap.count(name);
}
bool item_exists(int i) {
return name_map.count(i);
}
- int get_item_id(const string& name) {
+ int get_item_id(const string& name) const {
build_rmaps();
if (name_rmap.count(name))
return name_rmap[name];
}
// rule names
- bool rule_exists(string name) {
+ bool rule_exists(string name) const {
build_rmaps();
return rule_name_rmap.count(name);
}
- int get_rule_id(string name) {
+ int get_rule_id(string name) const {
build_rmaps();
if (rule_name_rmap.count(name))
return rule_name_rmap[name];
* @param id item id to check
* @return weight of item
*/
- int get_item_weight(int id);
- float get_item_weightf(int id) {
+ int get_item_weight(int id) const;
+ float get_item_weightf(int id) const {
return (float)get_item_weight(id) / (float)0x10000;
}
int get_item_weight_in_loc(int id, const map<string,string> &loc);
void reweight(CephContext *cct);
/// check if item id is present in the map hierarchy
- bool check_item_present(int id);
+ bool check_item_present(int id) const;
/*** devices ***/