Reservation() {}
Reservation(T i, unsigned pr, Context *g, Context *p = 0)
: item(i), prio(pr), grant(g), preempt(p) {}
- void dump(Formatter *f) const {
+ void dump(ceph::Formatter *f) const {
f->dump_stream("item") << item;
f->dump_unsigned("prio", prio);
f->dump_bool("can_preempt", !!preempt);
}
- friend ostream& operator<<(ostream& out, const Reservation& r) {
+ friend std::ostream& operator<<(std::ostream& out, const Reservation& r) {
return out << r.item << "(prio " << r.prio << " grant " << r.grant
<< " preempt " << r.preempt << ")";
}
};
- map<unsigned, list<Reservation>> queues;
- map<T, pair<unsigned, typename list<Reservation>::iterator>> queue_pointers;
- map<T,Reservation> in_progress;
- set<pair<unsigned,T>> preempt_by_prio; ///< in_progress that can be preempted
+ std::map<unsigned, std::list<Reservation>> queues;
+ std::map<T, std::pair<unsigned, typename std::list<Reservation>::iterator>> queue_pointers;
+ std::map<T,Reservation> in_progress;
+ std::set<std::pair<unsigned,T>> preempt_by_prio; ///< in_progress that can be preempted
void preempt_one() {
ceph_assert(!preempt_by_prio.empty());
void do_queues() {
rdout(20) << __func__ << ":\n";
- JSONFormatter jf(true);
+ ceph::JSONFormatter jf(true);
jf.open_object_section("queue");
_dump(&jf);
jf.close_section();
p.grant = nullptr;
in_progress[p.item] = p;
if (p.preempt) {
- preempt_by_prio.insert(make_pair(p.prio, p.item));
+ preempt_by_prio.insert(std::make_pair(p.prio, p.item));
}
}
}
!in_progress.count(item));
r.prio = newprio;
queues[newprio].push_back(r);
- queue_pointers.insert(make_pair(item,
- make_pair(newprio,--(queues[newprio]).end())));
+ queue_pointers.insert(std::make_pair(item,
+ std::make_pair(newprio,--(queues[newprio]).end())));
} else {
auto p = in_progress.find(item);
if (p != in_progress.end()) {
<< " lowered priority let do_queues() preempt it" << dendl;
}
}
- preempt_by_prio.erase(make_pair(p->second.prio, p->second.item));
+ preempt_by_prio.erase(std::make_pair(p->second.prio, p->second.item));
p->second.prio = newprio;
- preempt_by_prio.insert(make_pair(p->second.prio, p->second.item));
+ preempt_by_prio.insert(std::make_pair(p->second.prio, p->second.item));
} else {
p->second.prio = newprio;
}
return;
}
- void dump(Formatter *f) {
+ void dump(ceph::Formatter *f) {
std::lock_guard l(lock);
_dump(f);
}
- void _dump(Formatter *f) {
+ void _dump(ceph::Formatter *f) {
f->dump_unsigned("max_allowed", max_allowed);
f->dump_unsigned("min_priority", min_priority);
f->open_array_section("queues");
ceph_assert(!queue_pointers.count(item) &&
!in_progress.count(item));
queues[prio].push_back(r);
- queue_pointers.insert(make_pair(item,
- make_pair(prio,--(queues[prio]).end())));
+ queue_pointers.insert(std::make_pair(item,
+ std::make_pair(prio,--(queues[prio]).end())));
do_queues();
}
rdout(10) << __func__ << " cancel " << p->second
<< " (was in progress)" << dendl;
if (p->second.preempt) {
- preempt_by_prio.erase(make_pair(p->second.prio, p->second.item));
+ preempt_by_prio.erase(std::make_pair(p->second.prio, p->second.item));
delete p->second.preempt;
}
in_progress.erase(p);
template<typename K, typename V>
class Transaction {
public:
- /// Set keys according to map
+ /// Std::set keys according to map
virtual void set_keys(
- const std::map<K, V> &keys ///< [in] keys/values to set
+ const std::map<K, V> &keys ///< [in] keys/values to std::set
) = 0;
/// Remove keys
/// Returns next key
virtual int get_next(
const K &key, ///< [in] key after which to get next
- pair<K, V> *next ///< [out] first key after key
+ std::pair<K, V> *next ///< [out] first key after key
) = 0; ///< @return 0 on success, -ENOENT if there is no next
virtual ~StoreDriver() {}
SharedPtrRegistry<K, boost::optional<V> > in_progress;
typedef typename SharedPtrRegistry<K, boost::optional<V> >::VPtr VPtr;
- typedef ContainerContext<set<VPtr> > TransHolder;
+ typedef ContainerContext<std::set<VPtr> > TransHolder;
public:
MapCacher(StoreDriver<K, V> *driver) : driver(driver) {}
- /// Fetch first key/value pair after specified key
+ /// Fetch first key/value std::pair after specified key
int get_next(
K key, ///< [in] key after which to get next
- pair<K, V> *next ///< [out] next key
+ std::pair<K, V> *next ///< [out] next key
) {
while (true) {
- pair<K, boost::optional<V> > cached;
- pair<K, V> store;
+ std::pair<K, boost::optional<V> > cached;
+ std::pair<K, V> store;
bool got_cached = in_progress.get_next(key, &cached);
bool got_store = false;
/// Adds operation setting keys to Transaction
void set_keys(
- const map<K, V> &keys, ///< [in] keys/values to set
+ const std::map<K, V> &keys, ///< [in] keys/values to std::set
Transaction<K, V> *t ///< [out] transaction to use
) {
std::set<VPtr> vptrs;
- for (typename map<K, V>::const_iterator i = keys.begin();
- i != keys.end();
- ++i) {
+ for (auto i = keys.begin(); i != keys.end(); ++i) {
VPtr ip = in_progress.lookup_or_create(i->first, i->second);
*ip = i->second;
vptrs.insert(ip);
/// Adds operation removing keys to Transaction
void remove_keys(
- const set<K> &keys, ///< [in]
+ const std::set<K> &keys, ///< [in]
Transaction<K, V> *t ///< [out] transaction to use
) {
std::set<VPtr> vptrs;
- for (typename set<K>::const_iterator i = keys.begin();
- i != keys.end();
- ++i) {
+ for (auto i = keys.begin(); i != keys.end(); ++i) {
boost::optional<V> empty;
VPtr ip = in_progress.lookup_or_create(*i, empty);
*ip = empty;
/// Gets keys, uses cached values for unstable keys
int get_keys(
- const set<K> &keys_to_get, ///< [in] set of keys to fetch
- map<K, V> *got ///< [out] keys gotten
+ const std::set<K> &keys_to_get, ///< [in] std::set of keys to fetch
+ std::map<K, V> *got ///< [out] keys gotten
) {
- set<K> to_get;
- map<K, V> _got;
- for (typename set<K>::const_iterator i = keys_to_get.begin();
+ std::set<K> to_get;
+ std::map<K, V> _got;
+ for (auto i = keys_to_get.begin();
i != keys_to_get.end();
++i) {
VPtr val = in_progress.lookup(*i);
int r = driver->get_keys(to_get, &_got);
if (r < 0)
return r;
- for (typename map<K, V>::iterator i = _got.begin();
- i != _got.end();
- ++i) {
+ for (auto i = _got.begin(); i != _got.end(); ++i) {
got->insert(*i);
}
return 0;
id(std::move(id)) {
}
- void encode(bufferlist& bl) const {
+ void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
encode(tenant, bl);
encode(id, bl);
ENCODE_FINISH(bl);
}
- void decode(bufferlist::const_iterator& bl) {
+ void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START(1, bl);
decode(tenant, bl);
decode(id, bl);
return id.empty();
}
- string to_str() const {
- string s;
+ std::string to_str() const {
+ std::string s;
to_str(s);
return s;
}
}
}
- rgw_user& operator=(const string& str) {
+ rgw_user& operator=(const std::string& str) {
from_str(str);
return *this;
}
return id.compare(u.id);
}
- int compare(const string& str) const {
+ int compare(const std::string& str) const {
rgw_user u(str);
return compare(u);
}
}
return (id < rhs.id);
}
- void dump(Formatter *f) const;
- static void generate_test_instances(list<rgw_user*>& o);
+ void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<rgw_user*>& o);
};
WRITE_CLASS_ENCODER(rgw_user)
rgw_pool() = default;
rgw_pool(const rgw_pool& _p) : name(_p.name), ns(_p.ns) {}
rgw_pool(rgw_pool&&) = default;
- rgw_pool(const string& _s) {
+ rgw_pool(const std::string& _s) {
from_str(_s);
}
- rgw_pool(const string& _name, const string& _ns) : name(_name), ns(_ns) {}
+ rgw_pool(const std::string& _name, const std::string& _ns) : name(_name), ns(_ns) {}
- string to_str() const;
- void from_str(const string& s);
+ std::string to_str() const;
+ void from_str(const std::string& s);
- void init(const string& _s) {
+ void init(const std::string& _s) {
from_str(_s);
}
return ns.compare(p.ns);
}
- void encode(bufferlist& bl) const {
+ void encode(ceph::buffer::list& bl) const {
ENCODE_START(10, 10, bl);
encode(name, bl);
encode(ns, bl);
ENCODE_FINISH(bl);
}
- void decode_from_bucket(bufferlist::const_iterator& bl);
+ void decode_from_bucket(ceph::buffer::list::const_iterator& bl);
- void decode(bufferlist::const_iterator& bl) {
+ void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl);
decode(name, bl);
};
WRITE_CLASS_ENCODER(rgw_pool)
-inline ostream& operator<<(ostream& out, const rgw_pool& p) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_pool& p) {
out << p.to_str();
return out;
}
return index_pool.compare(t.index_pool);
};
- void dump(Formatter *f) const;
+ void dump(ceph::Formatter *f) const;
void decode_json(JSONObj *obj);
};
void convert(cls_user_bucket *b) const;
- void encode(bufferlist& bl) const {
+ void encode(ceph::buffer::list& bl) const {
ENCODE_START(10, 10, bl);
encode(name, bl);
encode(marker, bl);
}
ENCODE_FINISH(bl);
}
- void decode(bufferlist::const_iterator& bl) {
+ void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl);
decode(name, bl);
if (struct_v < 10) {
DECODE_FINISH(bl);
}
- void update_bucket_id(const string& new_bucket_id) {
+ void update_bucket_id(const std::string& new_bucket_id) {
bucket_id = new_bucket_id;
}
return explicit_placement.get_data_extra_pool();
}
- void dump(Formatter *f) const;
+ void dump(ceph::Formatter *f) const;
void decode_json(JSONObj *obj);
- static void generate_test_instances(list<rgw_bucket*>& o);
+ static void generate_test_instances(std::list<rgw_bucket*>& o);
rgw_bucket& operator=(const rgw_bucket&) = default;
};
WRITE_CLASS_ENCODER(rgw_bucket)
-inline ostream& operator<<(ostream& out, const rgw_bucket &b) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_bucket &b) {
out << b.tenant << ":" << b.name << "[" << b.bucket_id << "])";
return out;
}
}
};
-inline ostream& operator<<(ostream& out, const rgw_bucket_shard& bs) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_bucket_shard& bs) {
if (bs.shard_id <= 0) {
return out << bs.bucket;
}
struct rgw_zone_id {
- string id;
+ std::string id;
rgw_zone_id() {}
- rgw_zone_id(const string& _id) : id(_id) {}
- rgw_zone_id(string&& _id) : id(std::move(_id)) {}
+ rgw_zone_id(const std::string& _id) : id(_id) {}
+ rgw_zone_id(std::string&& _id) : id(std::move(_id)) {}
- void encode(bufferlist& bl) const {
+ void encode(ceph::buffer::list& bl) const {
/* backward compatiblity, not using ENCODE_{START,END} macros */
ceph::encode(id, bl);
}
- void decode(bufferlist::const_iterator& bl) {
+ void decode(ceph::buffer::list::const_iterator& bl) {
/* backward compatiblity, not using DECODE_{START,END} macros */
ceph::decode(id, bl);
}
id.clear();
}
- bool operator==(const string& _id) const {
+ bool operator==(const std::string& _id) const {
return (id == _id);
}
bool operator==(const rgw_zone_id& zid) const {
};
WRITE_CLASS_ENCODER(rgw_zone_id)
-static inline ostream& operator<<(ostream& os, const rgw_zone_id& zid) {
+inline std::ostream& operator<<(std::ostream& os, const rgw_zone_id& zid) {
os << zid.id;
return os;
}
-void encode_json_impl(const char *name, const rgw_zone_id& zid, Formatter *f);
+void encode_json_impl(const char *name, const rgw_zone_id& zid, ceph::Formatter *f);
void decode_json_obj(rgw_zone_id& zid, JSONObj *obj);
enum types { User, Role, Tenant, Wildcard, OidcProvider };
types t;
rgw_user u;
- string idp_url;
+ std::string idp_url;
explicit Principal(types t)
: t(t) {}
Principal(types t, std::string&& n, std::string i)
: t(t), u(std::move(n), std::move(i)) {}
- Principal(string&& idp_url)
+ Principal(std::string&& idp_url)
: t(OidcProvider), idp_url(std::move(idp_url)) {}
public:
return Principal(Tenant, std::move(t), {});
}
- static Principal oidc_provider(string&& idp_url) {
+ static Principal oidc_provider(std::string&& idp_url) {
return Principal(std::move(idp_url));
}
return u.id;
}
- const string& get_idp_url() const {
+ const std::string& get_idp_url() const {
return idp_url;
}
class JSONObj;
void decode_json_obj(rgw_user& val, JSONObj *obj);
-void encode_json(const char *name, const rgw_user& val, Formatter *f);
-void encode_xml(const char *name, const rgw_user& val, Formatter *f);
+void encode_json(const char *name, const rgw_user& val, ceph::Formatter *f);
+void encode_xml(const char *name, const rgw_user& val, ceph::Formatter *f);
-inline ostream& operator<<(ostream& out, const rgw_user &u) {
- string s;
+inline std::ostream& operator<<(std::ostream& out, const rgw_user &u) {
+ std::string s;
u.to_str(s);
return out << s;
}