}
int CrushWrapper::get_common_ancestor_distance(CephContext *cct, int id,
- const std::multimap<string,string>& loc)
+ const std::multimap<string,string>& loc) const
{
ldout(cct, 5) << __func__ << " " << id << " " << loc << dendl;
if (!item_exists(id))
return false;
}
-map<string, string> CrushWrapper::get_full_location(int id)
+map<string, string> CrushWrapper::get_full_location(int id) const
{
vector<pair<string, string> > full_location_ordered;
map<string,string> full_location;
return full_location;
}
-int CrushWrapper::get_full_location_ordered(int id, vector<pair<string, string> >& path)
+int CrushWrapper::get_full_location_ordered(int id, vector<pair<string, string> >& path) const
{
if (!item_exists(id))
return -ENOENT;
return 0;
}
-string CrushWrapper::get_full_location_ordered_string(int id)
+string CrushWrapper::get_full_location_ordered_string(int id) const
{
vector<pair<string, string> > full_location_ordered;
string full_location;
return full_location;
}
-map<int, string> CrushWrapper::get_parent_hierarchy(int id)
+map<int, string> CrushWrapper::get_parent_hierarchy(int id) const
{
map<int,string> parent_hierarchy;
pair<string, string> parent_coord = get_immediate_parent(id);
return parent_hierarchy;
}
-int CrushWrapper::get_children(int id, list<int> *children)
+int CrushWrapper::get_children(int id, list<int> *children) const
{
// leaf?
if (id >= 0) {
return 0;
}
- crush_bucket *b = get_bucket(id);
+ auto *b = get_bucket(id);
if (IS_ERR(b)) {
return -ENOENT;
}
return b->size;
}
-int CrushWrapper::_get_leaves(int id, list<int> *leaves)
+int CrushWrapper::_get_leaves(int id, list<int> *leaves) const
{
assert(leaves);
return 0;
}
- crush_bucket *b = get_bucket(id);
+ auto b = get_bucket(id);
if (IS_ERR(b)) {
return -ENOENT;
}
return 0; // all is well
}
-int CrushWrapper::get_leaves(const string &name, set<int> *leaves)
+int CrushWrapper::get_leaves(const string &name, set<int> *leaves) const
{
assert(leaves);
leaves->clear();
}
-pair<string,string> CrushWrapper::get_immediate_parent(int id, int *_ret)
+pair<string,string> CrushWrapper::get_immediate_parent(int id, int *_ret) const
{
for (int bidx = 0; bidx < crush->max_buckets; bidx++) {
continue;
for (unsigned i = 0; i < b->size; i++)
if (b->items[i] == id) {
- string parent_id = name_map[b->id];
- string parent_bucket_type = type_map[b->type];
+ string parent_id = name_map.at(b->id);
+ string parent_bucket_type = type_map.at(b->type);
if (_ret)
*_ret = 0;
return make_pair(parent_bucket_type, parent_id);
*
* FIXME: ambiguous for items that occur multiple times in the map
*/
- pair<string,string> get_immediate_parent(int id, int *ret = NULL);
+ pair<string,string> get_immediate_parent(int id, int *ret = NULL) const;
int get_immediate_parent_id(int id, int *parent) const;
* returns the location in the form of (type=foo) where type is a type of bucket
* specified in the CRUSH map and foo is a name specified in the CRUSH map
*/
- map<string, string> get_full_location(int id);
+ map<string, string> get_full_location(int id) const;
/*
* identical to get_full_location(int id) although it returns the type/name
*
* returns -ENOENT if id is not found.
*/
- int get_full_location_ordered(int id, vector<pair<string, string> >& path);
+ int get_full_location_ordered(int id, vector<pair<string, string> >& path) const;
/*
* identical to get_full_location_ordered(int id, vector<pair<string, string> >& path),
*
* returns the location in descending hierarchy as a string.
*/
- string get_full_location_ordered_string(int id);
+ string get_full_location_ordered_string(int id) const;
/**
* returns (type_id, type) of all parent buckets between id and
* default, can be used to check for anomolous CRUSH maps
*/
- map<int, string> get_parent_hierarchy(int id);
+ map<int, string> get_parent_hierarchy(int id) const;
/**
* enumerate immediate children of given node
* @param id parent bucket or device id
* @return number of items, or error
*/
- int get_children(int id, list<int> *children);
+ int get_children(int id, list<int> *children) const;
/**
* enumerate leaves(devices) of given node
* @param name parent bucket name
* @return 0 on success or a negative errno on error.
*/
- int get_leaves(const string &name, set<int> *leaves);
- int _get_leaves(int id, list<int> *leaves); // worker
+ int get_leaves(const string &name, set<int> *leaves) const;
+private:
+ int _get_leaves(int id, list<int> *leaves) const; // worker
+
+public:
/**
* insert an item into the map at a specific position
*
* @param loc a set of key=value pairs describing a location in the hierarchy
*/
int get_common_ancestor_distance(CephContext *cct, int id,
- const std::multimap<string,string>& loc);
+ const std::multimap<string,string>& loc) const;
/**
* parse a set of key/value pairs out of a string vector