class CrushTester {
CrushWrapper& crush;
- ostream& err;
+ std::ostream& err;
- map<int, int> device_weight;
+ std::map<int, int> device_weight;
int min_rule, max_rule;
int ruleset;
int min_x, max_x;
bool output_data_file;
bool output_csv;
- string output_data_file_name;
+ std::string output_data_file_name;
/*
* mark a ratio of devices down, can be used to simulate placement distributions
* under degrated cluster conditions
*/
- void adjust_weights(vector<__u32>& weight);
+ void adjust_weights(std::vector<__u32>& weight);
/*
* Get the maximum number of devices that could be selected to satisfy ruleno.
*
* which can help make post-processing easier
*/
- map<int,int> get_collapsed_mapping();
+ std::map<int,int> get_collapsed_mapping();
/*
* Essentially a re-implementation of CRUSH. Given a vector of devices
* check that the vector represents a valid placement for a given ruleno.
*/
- bool check_valid_placement(int ruleno, vector<int> in, const vector<__u32>& weight);
+ bool check_valid_placement(int ruleno, std::vector<int> in, const std::vector<__u32>& weight);
/*
* Generate a random selection of devices which satisfies ruleno. Essentially a
* monte-carlo simulator for CRUSH placements which can be used to compare the
* statistical distribution of the CRUSH algorithm to a random number generator
*/
- int random_placement(int ruleno, vector<int>& out, int maxout, vector<__u32>& weight);
+ int random_placement(int ruleno, std::vector<int>& out, int maxout, std::vector<__u32>& weight);
// scaffolding to store data for off-line processing
struct tester_data_set {
- vector <string> device_utilization;
- vector <string> device_utilization_all;
- vector <string> placement_information;
- vector <string> batch_device_utilization_all;
- vector <string> batch_device_expected_utilization_all;
- map<int, float> proportional_weights;
- map<int, float> proportional_weights_all;
- map<int, float> absolute_weights;
+ std::vector<std::string> device_utilization;
+ std::vector<std::string> device_utilization_all;
+ std::vector<std::string> placement_information;
+ std::vector<std::string> batch_device_utilization_all;
+ std::vector<std::string> batch_device_expected_utilization_all;
+ std::map<int, float> proportional_weights;
+ std::map<int, float> proportional_weights_all;
+ std::map<int, float> absolute_weights;
} ;
- void write_to_csv(ofstream& csv_file, vector<string>& payload)
+ void write_to_csv(std::ofstream& csv_file, std::vector<std::string>& payload)
{
if (csv_file.good())
- for (vector<string>::iterator it = payload.begin(); it != payload.end(); ++it)
+ for (std::vector<std::string>::iterator it = payload.begin(); it != payload.end(); ++it)
csv_file << (*it);
}
- void write_to_csv(ofstream& csv_file, map<int, float>& payload)
+ void write_to_csv(std::ofstream& csv_file, std::map<int, float>& payload)
{
if (csv_file.good())
- for (map<int, float>::iterator it = payload.begin(); it != payload.end(); ++it)
+ for (std::map<int, float>::iterator it = payload.begin(); it != payload.end(); ++it)
csv_file << (*it).first << ',' << (*it).second << std::endl;
}
- void write_data_set_to_csv(string user_tag, tester_data_set& tester_data)
+ void write_data_set_to_csv(std::string user_tag, tester_data_set& tester_data)
{
- ofstream device_utilization_file ((user_tag + (string)"-device_utilization.csv").c_str());
- ofstream device_utilization_all_file ((user_tag + (string)"-device_utilization_all.csv").c_str());
- ofstream placement_information_file ((user_tag + (string)"-placement_information.csv").c_str());
- ofstream proportional_weights_file ((user_tag + (string)"-proportional_weights.csv").c_str());
- ofstream proportional_weights_all_file ((user_tag + (string)"-proportional_weights_all.csv").c_str());
- ofstream absolute_weights_file ((user_tag + (string)"-absolute_weights.csv").c_str());
+ std::ofstream device_utilization_file((user_tag + (std::string)"-device_utilization.csv").c_str());
+ std::ofstream device_utilization_all_file((user_tag + (std::string)"-device_utilization_all.csv").c_str());
+ std::ofstream placement_information_file((user_tag + (std::string)"-placement_information.csv").c_str());
+ std::ofstream proportional_weights_file((user_tag + (std::string)"-proportional_weights.csv").c_str());
+ std::ofstream proportional_weights_all_file((user_tag + (std::string)"-proportional_weights_all.csv").c_str());
+ std::ofstream absolute_weights_file((user_tag + (std::string)"-absolute_weights.csv").c_str());
// write the headers
device_utilization_file << "Device ID, Number of Objects Stored, Number of Objects Expected" << std::endl;
absolute_weights_file.close();
if (num_batches > 1) {
- ofstream batch_device_utilization_all_file ((user_tag + (string)"-batch_device_utilization_all.csv").c_str());
- ofstream batch_device_expected_utilization_all_file ((user_tag + (string)"-batch_device_expected_utilization_all.csv").c_str());
+ std::ofstream batch_device_utilization_all_file ((user_tag + (std::string)"-batch_device_utilization_all.csv").c_str());
+ std::ofstream batch_device_expected_utilization_all_file ((user_tag + (std::string)"-batch_device_expected_utilization_all.csv").c_str());
batch_device_utilization_all_file << "Batch Round";
for (unsigned i = 0; i < tester_data.device_utilization.size(); i++) {
}
}
- void write_integer_indexed_vector_data_string(vector<string> &dst, int index, vector<int> vector_data);
- void write_integer_indexed_vector_data_string(vector<string> &dst, int index, vector<float> vector_data);
- void write_integer_indexed_scalar_data_string(vector<string> &dst, int index, int scalar_data);
- void write_integer_indexed_scalar_data_string(vector<string> &dst, int index, float scalar_data);
+ void write_integer_indexed_vector_data_string(std::vector<std::string> &dst, int index, std::vector<int> vector_data);
+ void write_integer_indexed_vector_data_string(std::vector<std::string> &dst, int index, std::vector<float> vector_data);
+ void write_integer_indexed_scalar_data_string(std::vector<std::string> &dst, int index, int scalar_data);
+ void write_integer_indexed_scalar_data_string(std::vector<std::string> &dst, int index, float scalar_data);
public:
- CrushTester(CrushWrapper& c, ostream& eo)
+ CrushTester(CrushWrapper& c, std::ostream& eo)
: crush(c), err(eo),
min_rule(-1), max_rule(-1),
ruleset(-1),
{ }
- void set_output_data_file_name(string name) {
+ void set_output_data_file_name(std::string name) {
output_data_file_name = name;
}
- string get_output_data_file_name() const {
+ std::string get_output_data_file_name() const {
return output_data_file_name;
}
}
namespace CrushTreeDumper {
- typedef mempool::osdmap::map<int64_t,string> name_map_t;
+typedef mempool::osdmap::map<int64_t,std::string> name_map_t;
}
WRITE_RAW_ENCODER(crush_rule_mask) // it's all u8's
-inline void encode(const crush_rule_step &s, bufferlist &bl)
+inline void encode(const crush_rule_step &s, ceph::buffer::list &bl)
{
using ceph::encode;
encode(s.op, bl);
encode(s.arg1, bl);
encode(s.arg2, bl);
}
-inline void decode(crush_rule_step &s, bufferlist::const_iterator &p)
+inline void decode(crush_rule_step &s, ceph::buffer::list::const_iterator &p)
{
using ceph::decode;
decode(s.op, p);
DEFAULT_CHOOSE_ARGS = -1
};
- std::map<int32_t, string> type_map; /* bucket/device type names */
- std::map<int32_t, string> name_map; /* bucket/device names */
- std::map<int32_t, string> rule_name_map;
+ std::map<int32_t, std::string> type_map; /* bucket/device type names */
+ std::map<int32_t, std::string> name_map; /* bucket/device names */
+ std::map<int32_t, std::string> rule_name_map;
std::map<int32_t, int32_t> class_map; /* item id -> class id */
- std::map<int32_t, string> class_name; /* class id -> class name */
- std::map<string, int32_t> class_rname; /* class name -> class id */
- std::map<int32_t, map<int32_t, int32_t> > class_bucket; /* bucket[id][class] == id */
+ std::map<int32_t, std::string> class_name; /* class id -> class name */
+ std::map<std::string, int32_t> class_rname; /* class name -> class id */
+ std::map<int32_t, std::map<int32_t, int32_t> > class_bucket; /* bucket[id][class] == id */
std::map<int64_t, crush_choose_arg_map> choose_args;
private:
/* reverse maps */
mutable bool have_rmaps = false;
- mutable std::map<string, int> type_rmap, name_rmap, rule_name_rmap;
+ mutable std::map<std::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(rule_name_map, rule_name_rmap);
have_rmaps = true;
}
- void build_rmap(const map<int, string> &f, std::map<string, int> &r) const {
+ void build_rmap(const std::map<int, std::string> &f, std::map<std::string, int> &r) const {
r.clear();
- for (std::map<int, string>::const_iterator p = f.begin(); p != f.end(); ++p)
+ for (auto p = f.begin(); p != f.end(); ++p)
r[p->second] = p->first;
}
bool is_v3_rule(unsigned ruleid) const;
bool is_v5_rule(unsigned ruleid) const;
- string get_min_required_version() const {
+ std::string get_min_required_version() const {
if (has_v5_rules() || has_nondefault_tunables5())
return "jewel";
else if (has_v4_buckets())
return 0;
return type_map.rbegin()->first;
}
- int get_type_id(const string& name) const {
+ int get_type_id(const std::string& name) const {
build_rmaps();
if (type_rmap.count(name))
return type_rmap[name];
return -1;
}
const char *get_type_name(int t) const {
- std::map<int,string>::const_iterator p = type_map.find(t);
+ auto p = type_map.find(t);
if (p != type_map.end())
return p->second.c_str();
return 0;
}
- void set_type_name(int i, const string& name) {
+ void set_type_name(int i, const std::string& name) {
type_map[i] = name;
if (have_rmaps)
type_rmap[name] = i;
}
// item/bucket names
- bool name_exists(const string& name) const {
+ bool name_exists(const std::string& name) const {
build_rmaps();
return name_rmap.count(name);
}
bool item_exists(int i) const {
return name_map.count(i);
}
- int get_item_id(const string& name) const {
+ int get_item_id(const std::string& name) const {
build_rmaps();
if (name_rmap.count(name))
return name_rmap[name];
return 0; /* hrm */
}
const char *get_item_name(int t) const {
- std::map<int,string>::const_iterator p = name_map.find(t);
+ std::map<int,std::string>::const_iterator p = name_map.find(t);
if (p != name_map.end())
return p->second.c_str();
return 0;
}
- int set_item_name(int i, const string& name) {
+ int set_item_name(int i, const std::string& name) {
if (!is_valid_crush_name(name))
return -EINVAL;
name_map[i] = name;
return 0;
}
void swap_names(int a, int b) {
- string an = name_map[a];
- string bn = name_map[b];
+ std::string an = name_map[a];
+ std::string bn = name_map[b];
name_map[a] = bn;
name_map[b] = an;
if (have_rmaps) {
}
int split_id_class(int i, int *idout, int *classout) const;
- bool class_exists(const string& name) const {
+ bool class_exists(const std::string& name) const {
return class_rname.count(name);
}
const char *get_class_name(int i) const {
return p->second.c_str();
return 0;
}
- int get_class_id(const string& name) const {
+ int get_class_id(const std::string& name) const {
auto p = class_rname.find(name);
if (p != class_rname.end())
return p->second;
else
return -EINVAL;
}
- int remove_class_name(const string& name) {
+ int remove_class_name(const std::string& name) {
auto p = class_rname.find(name);
if (p == class_rname.end())
return -ENOENT;
int32_t _alloc_class_id() const;
- int get_or_create_class_id(const string& name) {
+ int get_or_create_class_id(const std::string& name) {
int c = get_class_id(name);
if (c < 0) {
int i = _alloc_class_id();
return 0;
return get_class_name(p->second);
}
- int set_item_class(int i, const string& name) {
+ int set_item_class(int i, const std::string& name) {
if (!is_valid_crush_name(name))
return -EINVAL;
class_map[i] = get_or_create_class_id(name);
class_map[i] = c;
return c;
}
- void get_devices_by_class(const string &name, set<int> *devices) const {
+ void get_devices_by_class(const std::string &name,
+ std::set<int> *devices) const {
ceph_assert(devices);
devices->clear();
if (!class_exists(name)) {
}
class_map.erase(it);
}
- int can_rename_item(const string& srcname,
- const string& dstname,
- ostream *ss) const;
- int rename_item(const string& srcname,
- const string& dstname,
- ostream *ss);
- int can_rename_bucket(const string& srcname,
- const string& dstname,
- ostream *ss) const;
- int rename_bucket(const string& srcname,
- const string& dstname,
- ostream *ss);
+ int can_rename_item(const std::string& srcname,
+ const std::string& dstname,
+ std::ostream *ss) const;
+ int rename_item(const std::string& srcname,
+ const std::string& dstname,
+ std::ostream *ss);
+ int can_rename_bucket(const std::string& srcname,
+ const std::string& dstname,
+ std::ostream *ss) const;
+ int rename_bucket(const std::string& srcname,
+ const std::string& dstname,
+ std::ostream *ss);
// rule names
- int rename_rule(const string& srcname,
- const string& dstname,
- ostream *ss);
- bool rule_exists(string name) const {
+ int rename_rule(const std::string& srcname,
+ const std::string& dstname,
+ std::ostream *ss);
+ bool rule_exists(std::string name) const {
build_rmaps();
return rule_name_rmap.count(name);
}
- int get_rule_id(string name) const {
+ int get_rule_id(std::string name) const {
build_rmaps();
if (rule_name_rmap.count(name))
return rule_name_rmap[name];
return -ENOENT;
}
const char *get_rule_name(int t) const {
- std::map<int,string>::const_iterator p = rule_name_map.find(t);
+ auto p = rule_name_map.find(t);
if (p != rule_name_map.end())
return p->second.c_str();
return 0;
}
- void set_rule_name(int i, const string& name) {
+ void set_rule_name(int i, const std::string& name) {
rule_name_map[i] = name;
if (have_rmaps)
rule_name_rmap[name] = i;
*
* Note that these may not be parentless roots.
*/
- void find_takes(set<int> *roots) const;
- void find_takes_by_rule(int rule, set<int> *roots) const;
+ void find_takes(std::set<int> *roots) const;
+ void find_takes_by_rule(int rule, std::set<int> *roots) const;
/**
* find tree roots
*
* These are parentless nodes in the map.
*/
- void find_roots(set<int> *roots) const;
+ void find_roots(std::set<int> *roots) const;
/**
* find tree roots that contain shadow (device class) items only
*/
- void find_shadow_roots(set<int> *roots) const {
- set<int> all;
+ void find_shadow_roots(std::set<int> *roots) const {
+ std::set<int> all;
find_roots(&all);
for (auto& p: all) {
if (is_shadow_item(p)) {
* These are parentless nodes in the map that are not shadow
* items for device classes.
*/
- void find_nonshadow_roots(set<int> *roots) const {
- set<int> all;
+ void find_nonshadow_roots(std::set<int> *roots) const {
+ std::set<int> all;
find_roots(&all);
for (auto& p: all) {
if (!is_shadow_item(p)) {
* @param weight optional pointer to weight of item at that location
* @return true if item is at specified location
*/
- bool check_item_loc(CephContext *cct, int item, const map<string,string>& loc, int *iweight);
- bool check_item_loc(CephContext *cct, int item, const map<string,string>& loc, float *weight) {
+ bool check_item_loc(CephContext *cct, int item,
+ const std::map<std::string,std::string>& loc,
+ int *iweight);
+ bool check_item_loc(CephContext *cct, int item,
+ const std::map<std::string,std::string>& loc,
+ float *weight) {
int iweight;
bool ret = check_item_loc(cct, item, loc, &iweight);
if (weight)
*
* FIXME: ambiguous for items that occur multiple times in the map
*/
- pair<string,string> get_immediate_parent(int id, int *ret = NULL) const;
+ std::pair<std::string,std::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) const;
+ std::map<std::string, std::string> get_full_location(int id) const;
/**
* return location map for a item, by name
*/
int get_full_location(
- const string& name,
- std::map<string,string> *ploc);
+ const std::string& name,
+ std::map<std::string,std::string> *ploc);
/*
* 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) const;
+ int get_full_location_ordered(
+ int id,
+ std::vector<std::pair<std::string, std::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) const;
+ std::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 anomalous CRUSH maps
*/
- map<int, string> get_parent_hierarchy(int id) const;
+ std::map<int, std::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) const;
+ int get_children(int id, std::list<int> *children) const;
/**
* enumerate all children of given node
*
* @param id parent bucket or device id
* @return number of items, or error
*/
- int get_all_children(int id, set<int> *children) const;
+ int get_all_children(int id, std::set<int> *children) const;
void get_children_of_type(int id,
int type,
- vector<int> *children,
+ std::vector<int> *children,
bool exclude_shadow = true) const;
/**
* enumerate all subtrees by type
*/
- void get_subtree_of_type(int type, vector<int> *subtrees);
+ void get_subtree_of_type(int type, std::vector<int> *subtrees);
/**
int verify_upmap(CephContext *cct,
int rule_id,
int pool_size,
- const vector<int>& up);
+ const std::vector<int>& up);
/**
* 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) const;
+ int get_leaves(const std::string &name, std::set<int> *leaves) const;
private:
- int _get_leaves(int id, list<int> *leaves) const; // worker
+ int _get_leaves(int id, std::list<int> *leaves) const; // worker
public:
/**
* @param init_weight_sets initialize weight-set weights to weight (vs 0)
* @return 0 for success, negative on error
*/
- int insert_item(CephContext *cct, int id, float weight, string name,
- const map<string,string>& loc,
+ int insert_item(CephContext *cct, int id, float weight, std::string name,
+ const std::map<std::string,std::string>& loc,
bool init_weight_sets=true);
/**
* @param loc location (map of type to bucket names)
* @return 0 for success, negative on error
*/
- int move_bucket(CephContext *cct, int id, const map<string,string>& loc);
+ int move_bucket(CephContext *cct, int id, const std::map<std::string,std::string>& loc);
/**
* swap bucket contents of two buckets without touching bucket ids
* @param loc location (map of type to bucket names)
* @return 0 for success, negative on error
*/
- int link_bucket(CephContext *cct, int id, const map<string,string>& loc);
+ int link_bucket(CephContext *cct, int id,
+ const std::map<std::string,std::string>& loc);
/**
* add or update an item's position in the map
* @param loc location (map of type to bucket names)
* @return 0 for no change, 1 for successful change, negative on error
*/
- int update_item(CephContext *cct, int id, float weight, string name, const map<string,string>& loc);
+ int update_item(CephContext *cct, int id, float weight, std::string name,
+ const std::map<std::string, std::string>& loc);
/**
* create or move an item, but do not adjust its weight if it already exists
* @param init_weight_sets initialize weight-set values to weight (vs 0)
* @return 0 for no change, 1 for successful change, negative on error
*/
- int create_or_move_item(CephContext *cct, int item, float weight, string name,
- const map<string,string>& loc,
+ int create_or_move_item(CephContext *cct, int item, float weight,
+ std::string name,
+ const std::map<std::string,std::string>& loc,
bool init_weight_sets=true);
/**
* @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;
+ const std::multimap<std::string,std::string>& loc) const;
/**
* parse a set of key/value pairs out of a string vector
* @param args list of strings (each key= or key=value)
* @param ploc pointer to a resulting location map or multimap
*/
- static int parse_loc_map(const std::vector<string>& args,
- std::map<string,string> *ploc);
- static int parse_loc_multimap(const std::vector<string>& args,
- std::multimap<string,string> *ploc);
+ static int parse_loc_map(const std::vector<std::string>& args,
+ std::map<std::string,std::string> *ploc);
+ static int parse_loc_multimap(const std::vector<std::string>& args,
+ std::multimap<std::string,std::string> *ploc);
/**
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);
- float get_item_weightf_in_loc(int id, const map<string,string> &loc) {
+ int get_item_weight_in_loc(int id,
+ const std::map<std::string, std::string> &loc);
+ float get_item_weightf_in_loc(int id,
+ const std::map<std::string, std::string> &loc) {
return (float)get_item_weight_in_loc(id, loc) / (float)0x10000;
}
int bucket_id,
bool update_weight_sets);
int adjust_item_weight_in_loc(CephContext *cct, int id, int weight,
- const map<string,string>& loc,
+ const std::map<std::string,std::string>& loc,
bool update_weight_sets=true);
int adjust_item_weightf_in_loc(CephContext *cct, int id, float weight,
- const map<string,string>& loc,
+ const std::map<std::string,std::string>& loc,
bool update_weight_sets=true) {
int r = validate_weightf(weight);
if (r < 0) {
void reweight(CephContext *cct);
void reweight_bucket(crush_bucket *b,
crush_choose_arg_map& arg_map,
- vector<uint32_t> *weightv);
+ std::vector<uint32_t> *weightv);
int adjust_subtree_weight(CephContext *cct, int id, int weight,
bool update_weight_sets=true);
}
private:
- float _get_take_weight_osd_map(int root, map<int,float> *pmap) const;
- void _normalize_weight_map(float sum, const map<int,float>& m,
- map<int,float> *pmap) const;
+ float _get_take_weight_osd_map(int root, std::map<int,float> *pmap) const;
+ void _normalize_weight_map(float sum, const std::map<int,float>& m,
+ std::map<int,float> *pmap) const;
public:
/**
* @param pmap [out] map of osd to weight
* @return 0 for success, or negative error code
*/
- int get_rule_weight_osd_map(unsigned ruleno, map<int,float> *pmap) const;
+ int get_rule_weight_osd_map(unsigned ruleno, std::map<int,float> *pmap) const;
/**
* calculate a map of osds to weights for a given starting root
* @param pmap [out] map of osd to weight
* @return 0 for success, or negative error code
*/
- int get_take_weight_osd_map(int root, map<int,float> *pmap) const;
+ int get_take_weight_osd_map(int root, std::map<int,float> *pmap) const;
/* modifiers */
}
int add_simple_rule(
- string name, string root_name, string failure_domain_type,
- string device_class,
- string mode, int rule_type, ostream *err = 0);
+ std::string name, std::string root_name, std::string failure_domain_type,
+ std::string device_class, std::string mode, int rule_type,
+ std::ostream *err = 0);
/**
* @param rno rule[set] id to use, -1 to pick the lowest available
*/
int add_simple_rule_at(
- string name, string root_name,
- string failure_domain_type, string device_class, string mode,
- int rule_type, int rno, ostream *err = 0);
+ std::string name, std::string root_name,
+ std::string failure_domain_type, std::string device_class, std::string mode,
+ int rule_type, int rno, std::ostream *err = 0);
int remove_rule(int ruleno);
}
int bucket_set_alg(int id, int alg);
- int update_device_class(int id, const string& class_name, const string& name, ostream *ss);
- int remove_device_class(CephContext *cct, int id, ostream *ss);
+ int update_device_class(int id, const std::string& class_name,
+ const std::string& name, std::ostream *ss);
+ int remove_device_class(CephContext *cct, int id, std::ostream *ss);
int device_class_clone(
int original, int device_class,
- const std::map<int32_t, map<int32_t, int32_t>>& old_class_bucket,
+ const std::map<int32_t, std::map<int32_t, int32_t>>& old_class_bucket,
const std::set<int32_t>& used_ids,
int *clone,
- map<int,map<int,vector<int>>> *cmap_item_weight);
- bool class_is_in_use(int class_id, ostream *ss = nullptr);
- int rename_class(const string& srcname, const string& dstname);
+ std::map<int, std::map<int,std::vector<int>>> *cmap_item_weight);
+ bool class_is_in_use(int class_id, std::ostream *ss = nullptr);
+ int rename_class(const std::string& srcname, const std::string& dstname);
int populate_classes(
- const std::map<int32_t, map<int32_t, int32_t>>& old_class_bucket);
- int get_rules_by_class(const string &class_name, set<int> *rules);
- int get_rules_by_osd(int osd, set<int> *rules);
+ const std::map<int32_t, std::map<int32_t, int32_t>>& old_class_bucket);
+ int get_rules_by_class(const std::string &class_name, std::set<int> *rules);
+ int get_rules_by_osd(int osd, std::set<int> *rules);
bool _class_is_dead(int class_id);
void cleanup_dead_classes();
int rebuild_roots_with_classes(CephContext *cct);
int reclassify(
CephContext *cct,
- ostream& out,
- const map<string,string>& classify_root,
- const map<string,pair<string,string>>& classify_bucket
+ std::ostream& out,
+ const std::map<std::string,std::string>& classify_root,
+ const std::map<std::string,std::pair<std::string,std::string>>& classify_bucket
);
- int set_subtree_class(const string& name, const string& class_name);
+ int set_subtree_class(const std::string& name, const std::string& class_name);
void start_choose_profile() {
free(crush->choose_tries);
crush_choose_arg_map cmap,
int bucketid,
int id,
- const vector<int>& weight,
- ostream *ss);
+ const std::vector<int>& weight,
+ std::ostream *ss);
int choose_args_adjust_item_weight(
CephContext *cct,
crush_choose_arg_map cmap,
- int id, const vector<int>& weight,
- ostream *ss);
+ int id, const std::vector<int>& weight,
+ std::ostream *ss);
int choose_args_adjust_item_weightf(
CephContext *cct,
crush_choose_arg_map cmap,
- int id, const vector<double>& weightf,
- ostream *ss) {
- vector<int> weight(weightf.size());
+ int id, const std::vector<double>& weightf,
+ std::ostream *ss) {
+ std::vector<int> weight(weightf.size());
for (unsigned i = 0; i < weightf.size(); ++i) {
weight[i] = (int)(weightf[i] * (double)0x10000);
}
}
template<typename WeightVector>
- void do_rule(int rule, int x, vector<int>& out, int maxout,
+ void do_rule(int rule, int x, std::vector<int>& out, int maxout,
const WeightVector& weight,
uint64_t choose_args_index) const {
int rawout[maxout];
int _choose_type_stack(
CephContext *cct,
- const vector<pair<int,int>>& stack,
- const set<int>& overfull,
- const vector<int>& underfull,
- const vector<int>& orig,
- vector<int>::const_iterator& i,
- set<int>& used,
- vector<int> *pw,
+ const std::vector<std::pair<int,int>>& stack,
+ const std::set<int>& overfull,
+ const std::vector<int>& underfull,
+ const std::vector<int>& orig,
+ std::vector<int>::const_iterator& i,
+ std::set<int>& used,
+ std::vector<int> *pw,
int root_bucket) const;
int try_remap_rule(
CephContext *cct,
int rule,
int maxout,
- const set<int>& overfull,
- const vector<int>& underfull,
- const vector<int>& orig,
- vector<int> *out) const;
+ const std::set<int>& overfull,
+ const std::vector<int>& underfull,
+ const std::vector<int>& orig,
+ std::vector<int> *out) const;
- bool check_crush_rule(int ruleset, int type, int size, ostream& ss) {
+ bool check_crush_rule(int ruleset, int type, int size, std::ostream& ss) {
ceph_assert(crush);
__u32 i;
return false;
}
- void encode(bufferlist &bl, uint64_t features) const;
- void decode(bufferlist::const_iterator &blp);
- void decode_crush_bucket(crush_bucket** bptr, bufferlist::const_iterator &blp);
- void dump(Formatter *f) const;
- void dump_rules(Formatter *f) const;
- void dump_rule(int ruleset, Formatter *f) const;
- void dump_tunables(Formatter *f) const;
- void dump_choose_args(Formatter *f) const;
- void list_rules(Formatter *f) const;
- void list_rules(ostream *ss) const;
- void dump_tree(ostream *out,
- Formatter *f,
+ void encode(ceph::buffer::list &bl, uint64_t features) const;
+ void decode(ceph::buffer::list::const_iterator &blp);
+ void decode_crush_bucket(crush_bucket** bptr,
+ ceph::buffer::list::const_iterator &blp);
+ void dump(ceph::Formatter *f) const;
+ void dump_rules(ceph::Formatter *f) const;
+ void dump_rule(int ruleset, ceph::Formatter *f) const;
+ void dump_tunables(ceph::Formatter *f) const;
+ void dump_choose_args(ceph::Formatter *f) const;
+ void list_rules(ceph::Formatter *f) const;
+ void list_rules(std::ostream *ss) const;
+ void dump_tree(std::ostream *out,
+ ceph::Formatter *f,
const CrushTreeDumper::name_map_t& ws,
bool show_shadow = false) const;
- void dump_tree(ostream *out, Formatter *f) {
+ void dump_tree(std::ostream *out, ceph::Formatter *f) {
dump_tree(out, f, CrushTreeDumper::name_map_t());
}
- void dump_tree(Formatter *f,
+ void dump_tree(ceph::Formatter *f,
const CrushTreeDumper::name_map_t& ws) const;
- static void generate_test_instances(list<CrushWrapper*>& o);
+ static void generate_test_instances(std::list<CrushWrapper*>& o);
int get_osd_pool_default_crush_replicated_ruleset(CephContext *cct);
- static bool is_valid_crush_name(const string& s);
+ static bool is_valid_crush_name(const std::string& s);
static bool is_valid_crush_loc(CephContext *cct,
- const map<string,string>& loc);
+ const std::map<std::string,std::string>& loc);
};
WRITE_CLASS_ENCODER_FEATURES(CrushWrapper)
#endif
using namespace boost::spirit;
-struct crush_grammar : public grammar<crush_grammar>
+struct crush_grammar : public boost::spirit::grammar<crush_grammar>
{
enum {
_int = 1,
template <typename ScannerT>
struct definition
{
- rule<ScannerT, parser_context<>, parser_tag<_int> > integer;
- rule<ScannerT, parser_context<>, parser_tag<_posint> > posint;
- rule<ScannerT, parser_context<>, parser_tag<_negint> > negint;
- rule<ScannerT, parser_context<>, parser_tag<_name> > name;
-
- rule<ScannerT, parser_context<>, parser_tag<_tunable> > tunable;
-
- rule<ScannerT, parser_context<>, parser_tag<_device> > device;
-
- rule<ScannerT, parser_context<>, parser_tag<_bucket_type> > bucket_type;
-
- rule<ScannerT, parser_context<>, parser_tag<_bucket_id> > bucket_id;
- rule<ScannerT, parser_context<>, parser_tag<_bucket_alg> > bucket_alg;
- rule<ScannerT, parser_context<>, parser_tag<_bucket_hash> > bucket_hash;
- rule<ScannerT, parser_context<>, parser_tag<_bucket_item> > bucket_item;
- rule<ScannerT, parser_context<>, parser_tag<_bucket> > bucket;
-
- rule<ScannerT, parser_context<>, parser_tag<_step_take> > step_take;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_choose_tries> > step_set_choose_tries;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_choose_local_tries> > step_set_choose_local_tries;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_choose_local_fallback_tries> > step_set_choose_local_fallback_tries;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_tries> > step_set_chooseleaf_tries;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_vary_r> > step_set_chooseleaf_vary_r;
- rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_stable> > step_set_chooseleaf_stable;
- rule<ScannerT, parser_context<>, parser_tag<_step_choose> > step_choose;
- rule<ScannerT, parser_context<>, parser_tag<_step_chooseleaf> > step_chooseleaf;
- rule<ScannerT, parser_context<>, parser_tag<_step_emit> > step_emit;
- rule<ScannerT, parser_context<>, parser_tag<_step> > step;
- rule<ScannerT, parser_context<>, parser_tag<_crushrule> > crushrule;
- rule<ScannerT, parser_context<>, parser_tag<_weight_set_weights> > weight_set_weights;
- rule<ScannerT, parser_context<>, parser_tag<_weight_set> > weight_set;
- rule<ScannerT, parser_context<>, parser_tag<_choose_arg_ids> > choose_arg_ids;
- rule<ScannerT, parser_context<>, parser_tag<_choose_arg> > choose_arg;
- rule<ScannerT, parser_context<>, parser_tag<_choose_args> > choose_args;
-
- rule<ScannerT, parser_context<>, parser_tag<_crushmap> > crushmap;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>,boost::spirit::parser_tag<_int> > integer;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_posint> > posint;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_negint> > negint;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_name> > name;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_tunable> > tunable;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_device> > device;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket_type> > bucket_type;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket_id> > bucket_id;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket_alg> > bucket_alg;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket_hash> > bucket_hash;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket_item> > bucket_item;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_bucket> > bucket;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_take> > step_take;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_choose_tries> > step_set_choose_tries;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_choose_local_tries> > step_set_choose_local_tries;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_choose_local_fallback_tries> > step_set_choose_local_fallback_tries;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_chooseleaf_tries> > step_set_chooseleaf_tries;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_chooseleaf_vary_r> > step_set_chooseleaf_vary_r;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_set_chooseleaf_stable> > step_set_chooseleaf_stable;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_choose> > step_choose;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_chooseleaf> > step_chooseleaf;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step_emit> > step_emit;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_step> > step;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_crushrule> > crushrule;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_weight_set_weights> > weight_set_weights;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_weight_set> > weight_set;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_choose_arg_ids> > choose_arg_ids;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_choose_arg> > choose_arg;
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_choose_args> > choose_args;
+
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>, boost::spirit::parser_tag<_crushmap> > crushmap;
definition(crush_grammar const& /*self*/)
{
+ using boost::spirit::leaf_node_d;
+ using boost::spirit::lexeme_d;
+ using boost::spirit::str_p;
+ using boost::spirit::ch_p;
+ using boost::spirit::digit_p;
+ using boost::spirit::alnum_p;
+ using boost::spirit::real_p;
+
// base types
integer = leaf_node_d[ lexeme_d[
(!ch_p('-') >> +digit_p)
crushmap = *(tunable | device | bucket_type) >> *(bucket | crushrule) >> *choose_args;
}
- rule<ScannerT, parser_context<>, parser_tag<_crushmap> > const&
+ boost::spirit::rule<ScannerT, boost::spirit::parser_context<>,
+ boost::spirit::parser_tag<_crushmap> > const&
start() const { return crushmap; }
};
};