#include <set>
#include <map>
#include <string>
-using namespace std;
#include "common/config.h"
struct mds_info_t {
uint64_t global_id;
- string name;
+ std::string name;
int32_t rank;
int32_t inc;
MDSMap::DaemonState state;
entity_addr_t addr;
utime_t laggy_since;
int32_t standby_for_rank;
- string standby_for_name;
- set<int32_t> export_targets;
+ std::string standby_for_name;
+ std::set<int32_t> export_targets;
mds_info_t() : global_id(0), rank(-1), inc(0), state(STATE_STANDBY), state_seq(0),
standby_for_rank(MDS_NO_STANDBY_PREF) { }
__u32 session_autoclose;
uint64_t max_file_size;
- set<int64_t> data_pools; // file data pools available to clients (via an ioctl). first is the default.
+ std::set<int64_t> data_pools; // file data pools available to clients (via an ioctl). first is the default.
int64_t cas_pool; // where CAS objects go
int64_t metadata_pool; // where fs metadata objects go
uint32_t max_mds; /* The maximum number of active MDSes. Also, the maximum rank. */
- set<int32_t> in; // currently defined cluster
- map<int32_t,int32_t> inc; // most recent incarnation.
- set<int32_t> failed, stopped; // which roles are failed or stopped
- map<int32_t,uint64_t> up; // who is in those roles
- map<uint64_t,mds_info_t> mds_info;
+ std::set<int32_t> in; // currently defined cluster
+ std::map<int32_t,int32_t> inc; // most recent incarnation.
+ std::set<int32_t> failed, stopped; // which roles are failed or stopped
+ std::map<int32_t,uint64_t> up; // who is in those roles
+ std::map<uint64_t,mds_info_t> mds_info;
bool ever_allowed_snaps; //< the cluster has ever allowed snap creation
bool explicitly_allowed_snaps; //< the user has explicitly enabled snap creation
int get_tableserver() const { return tableserver; }
int get_root() const { return root; }
- const set<int64_t> &get_data_pools() const { return data_pools; }
+ const std::set<int64_t> &get_data_pools() const { return data_pools; }
int64_t get_first_data_pool() const { return *data_pools.begin(); }
int64_t get_cas_pool() const { return cas_pool; }
int64_t get_metadata_pool() const { return metadata_pool; }
return data_pools.count(poolid);
}
- const map<uint64_t,mds_info_t>& get_mds_info() { return mds_info; }
+ const std::map<uint64_t,mds_info_t>& get_mds_info() { return mds_info; }
const mds_info_t& get_mds_info_gid(uint64_t gid) {
assert(mds_info.count(gid));
return mds_info[gid];
assert(up.count(m) && mds_info.count(up[m]));
return mds_info[up[m]];
}
- uint64_t find_mds_gid_by_name(const string& s) {
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ uint64_t find_mds_gid_by_name(const std::string& s) {
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p) {
if (p->second.name == s) {
}
unsigned get_num_mds(int state) const {
unsigned n = 0;
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state == state) ++n;
data_pools.insert(poolid);
}
int remove_data_pool(int64_t poolid) {
- set<int64_t>::iterator p = data_pools.find(poolid);
+ std::set<int64_t>::iterator p = data_pools.find(poolid);
if (p == data_pools.end())
return -ENOENT;
data_pools.erase(p);
}
// sets
- void get_mds_set(set<int>& s) {
+ void get_mds_set(std::set<int>& s) {
s = in;
}
- void get_up_mds_set(set<int>& s) {
- for (map<int32_t,uint64_t>::const_iterator p = up.begin();
+ void get_up_mds_set(std::set<int>& s) {
+ for (std::map<int32_t,uint64_t>::const_iterator p = up.begin();
p != up.end();
++p)
s.insert(p->first);
}
- void get_active_mds_set(set<int>& s) {
+ void get_active_mds_set(std::set<int>& s) {
get_mds_set(s, MDSMap::STATE_ACTIVE);
}
- void get_failed_mds_set(set<int>& s) {
+ void get_failed_mds_set(std::set<int>& s) {
s = failed;
}
int get_failed() {
if (!failed.empty()) return *failed.begin();
return -1;
}
- void get_stopped_mds_set(set<int>& s) {
+ void get_stopped_mds_set(std::set<int>& s) {
s = stopped;
}
- void get_recovery_mds_set(set<int>& s) {
+ void get_recovery_mds_set(std::set<int>& s) {
s = failed;
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state >= STATE_REPLAY && p->second.state <= STATE_STOPPING)
s.insert(p->second.rank);
}
- void get_clientreplay_or_active_or_stopping_mds_set(set<int>& s) {
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ void get_clientreplay_or_active_or_stopping_mds_set(std::set<int>& s) {
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state >= STATE_CLIENTREPLAY && p->second.state <= STATE_STOPPING)
s.insert(p->second.rank);
}
- void get_mds_set(set<int>& s, DaemonState state) {
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ void get_mds_set(std::set<int>& s, DaemonState state) {
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state == state)
int get_random_up_mds() {
if (up.empty())
return -1;
- map<int32_t,uint64_t>::iterator p = up.begin();
+ std::map<int32_t,uint64_t>::iterator p = up.begin();
for (int n = rand() % up.size(); n; n--)
++p;
return p->first;
}
- const mds_info_t* find_by_name(const string& name) const {
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ const mds_info_t* find_by_name(const std::string& name) const {
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p) {
if (p->second.name == name)
return NULL;
}
- uint64_t find_standby_for(int mds, string& name) {
- map<uint64_t, mds_info_t>::const_iterator generic_standby
+ uint64_t find_standby_for(int mds, std::string& name) {
+ std::map<uint64_t, mds_info_t>::const_iterator generic_standby
= mds_info.end();
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p) {
if ((p->second.state != MDSMap::STATE_STANDBY && p->second.state != MDSMap::STATE_STANDBY_REPLAY) ||
return generic_standby->first;
return 0;
}
- uint64_t find_unused_for(int mds, string& name) {
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ uint64_t find_unused_for(int mds, std::string& name) {
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p) {
if (p->second.state != MDSMap::STATE_STANDBY ||
}
return 0;
}
- uint64_t find_replacement_for(int mds, string& name) {
+ uint64_t find_replacement_for(int mds, std::string& name) {
uint64_t standby = find_standby_for(mds, name);
if (standby)
return standby;
return find_unused_for(mds, name);
}
- void get_health(list<pair<health_status_t,string> >& summary,
- list<pair<health_status_t,string> > *detail) const;
+ void get_health(list<pair<health_status_t,std::string> >& summary,
+ list<pair<health_status_t,std::string> > *detail) const;
// mds states
bool is_down(int m) const { return up.count(m) == 0; }
* Get MDS rank state if the rank is up, else STATE_NULL
*/
DaemonState get_state(int m) const {
- map<int32_t,uint64_t>::const_iterator u = up.find(m);
+ std::map<int32_t,uint64_t>::const_iterator u = up.find(m);
if (u == up.end())
return STATE_NULL;
return get_state_gid(u->second);
* Get MDS daemon status by GID
*/
DaemonState get_state_gid(uint64_t gid) const {
- map<uint64_t,mds_info_t>::const_iterator i = mds_info.find(gid);
+ std::map<uint64_t,mds_info_t>::const_iterator i = mds_info.find(gid);
if (i == mds_info.end())
return STATE_NULL;
return i->second.state;
bool is_laggy_gid(uint64_t gid) const {
if (!mds_info.count(gid))
return false;
- map<uint64_t,mds_info_t>::const_iterator p = mds_info.find(gid);
+ std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.find(gid);
return p->second.laggy();
}
bool is_degraded() const { // degraded = some recovery in process. fixes active membership and recovery_set.
if (!failed.empty())
return true;
- for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+ for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state >= STATE_REPLAY && p->second.state <= STATE_CLIENTREPLAY)
#include <ostream>
#include <set>
#include <map>
-using namespace std;
#include "common/config.h"
#include "common/Clock.h"
return memcmp(&l, &r, sizeof(l)) == 0;
}
-ostream& operator<<(ostream &out, const frag_info_t &f);
+std::ostream& operator<<(std::ostream &out, const frag_info_t &f);
struct nest_info_t : public scatter_info_t {
return memcmp(&l, &r, sizeof(l)) == 0;
}
-ostream& operator<<(ostream &out, const nest_info_t &n);
+std::ostream& operator<<(std::ostream &out, const nest_info_t &n);
struct vinodeno_t {
-inline ostream& operator<<(ostream &out, const vinodeno_t &vino) {
+inline std::ostream& operator<<(std::ostream &out, const vinodeno_t &vino) {
out << vino.ino;
if (vino.snapid == CEPH_NOSNAP)
out << ".head";
WRITE_CLASS_ENCODER(client_writeable_range_t)
-ostream& operator<<(ostream& out, const client_writeable_range_t& r);
+std::ostream& operator<<(std::ostream& out, const client_writeable_range_t& r);
inline bool operator==(const client_writeable_range_t& l,
const client_writeable_range_t& r) {
bufferlist inline_data;
version_t inline_version;
- map<client_t,client_writeable_range_t> client_ranges; // client(s) can write to these ranges
+ std::map<client_t,client_writeable_range_t> client_ranges; // client(s) can write to these ranges
// dirfrag, recursive accountin
frag_info_t dirstat; // protected by my filelock
uint64_t get_max_size() const {
uint64_t max = 0;
- for (map<client_t,client_writeable_range_t>::const_iterator p = client_ranges.begin();
+ for (std::map<client_t,client_writeable_range_t>::const_iterator p = client_ranges.begin();
p != client_ranges.end();
++p)
if (p->second.range.last > max)
if (new_max == 0) {
client_ranges.clear();
} else {
- for (map<client_t,client_writeable_range_t>::iterator p = client_ranges.begin();
+ for (std::map<client_t,client_writeable_range_t>::iterator p = client_ranges.begin();
p != client_ranges.end();
++p)
p->second.range.last = new_max;
}
void trim_client_ranges(snapid_t last) {
- map<client_t, client_writeable_range_t>::iterator p = client_ranges.begin();
+ std::map<client_t, client_writeable_range_t>::iterator p = client_ranges.begin();
while (p != client_ranges.end()) {
if (p->second.follows >= last)
client_ranges.erase(p++);
struct old_inode_t {
snapid_t first;
inode_t inode;
- map<string,bufferptr> xattrs;
+ std::map<string,bufferptr> xattrs;
void encode(bufferlist &bl) const;
void decode(bufferlist::iterator& bl);
};
WRITE_CLASS_ENCODER(old_rstat_t)
-inline ostream& operator<<(ostream& out, const old_rstat_t& o) {
+inline std::ostream& operator<<(std::ostream& out, const old_rstat_t& o) {
return out << "old_rstat(first " << o.first << " " << o.rstat << " " << o.accounted_rstat << ")";
}
struct session_info_t {
entity_inst_t inst;
- map<ceph_tid_t,inodeno_t> completed_requests;
+ std::map<ceph_tid_t,inodeno_t> completed_requests;
interval_set<inodeno_t> prealloc_inos; // preallocated, ready to use.
interval_set<inodeno_t> used_inos; // journaling use
}
};
-inline ostream& operator<<(ostream& out, const dentry_key_t &k)
+inline std::ostream& operator<<(std::ostream& out, const dentry_key_t &k)
{
return out << "(" << k.name << "," << k.snapid << ")";
}
return c < 0 || (c == 0 && l.snapid < r.snapid);
}
-inline ostream& operator<<(ostream& out, const string_snap_t &k)
+inline std::ostream& operator<<(std::ostream& out, const string_snap_t &k)
{
return out << "(" << k.name << "," << k.snapid << ")";
}
};
WRITE_CLASS_ENCODER(metareqid_t)
-inline ostream& operator<<(ostream& out, const metareqid_t& r) {
+inline std::ostream& operator<<(std::ostream& out, const metareqid_t& r) {
return out << r.name << ":" << r.tid;
}
WRITE_CLASS_ENCODER(dirfrag_t)
-inline ostream& operator<<(ostream& out, const dirfrag_t df) {
+inline std::ostream& operator<<(std::ostream& out, const dirfrag_t df) {
out << df.ino;
if (!df.frag.is_root()) out << "." << df.frag;
return out;
c.decode(t, p);
}
-inline ostream& operator<<(ostream& out, dirfrag_load_vec_t& dl)
+inline std::ostream& operator<<(std::ostream& out, dirfrag_load_vec_t& dl)
{
// ugliness!
utime_t now = ceph_clock_now(g_ceph_context);
c.decode(t, p);
}
-inline ostream& operator<<( ostream& out, mds_load_t& load )
+inline std::ostream& operator<<( std::ostream& out, mds_load_t& load )
{
return out << "mdsload<" << load.auth << "/" << load.all
<< ", req " << load.req_rate
MDSCacheObject *object;
mdsco_db_line_prefix(MDSCacheObject *o) : object(o) {}
};
-ostream& operator<<(ostream& out, mdsco_db_line_prefix o);
+std::ostream& operator<<(std::ostream& out, mdsco_db_line_prefix o);
// printer
-ostream& operator<<(ostream& out, MDSCacheObject &o);
+std::ostream& operator<<(std::ostream& out, MDSCacheObject &o);
class MDSCacheObjectInfo {
public:
virtual ~MDSCacheObject() {}
// printing
- virtual void print(ostream& out) = 0;
- virtual ostream& print_db_line_prefix(ostream& out) {
+ virtual void print(std::ostream& out) = 0;
+ virtual std::ostream& print_db_line_prefix(std::ostream& out) {
return out << "mdscacheobject(" << this << ") ";
}
protected:
__s32 ref; // reference count
#ifdef MDS_REF_SET
- map<int,int> ref_map;
+ std::map<int,int> ref_map;
#endif
public:
#ifdef MDS_REF_SET
int get_pin_totals() {
int total = 0;
- for(map<int,int>::iterator i = ref_map.begin(); i != ref_map.end(); ++i) {
+ for(std::map<int,int>::iterator i = ref_map.begin(); i != ref_map.end(); ++i) {
total += i->second;
}
return total;
#endif
}
- void print_pin_set(ostream& out) {
+ void print_pin_set(std::ostream& out) {
#ifdef MDS_REF_SET
- map<int, int>::iterator it = ref_map.begin();
+ std::map<int, int>::iterator it = ref_map.begin();
while (it != ref_map.end()) {
out << " " << pin_name(it->first) << "=" << it->second;
++it;
// replication (across mds cluster)
protected:
unsigned replica_nonce; // [replica] defined on replica
- map<int,unsigned> replica_map; // [auth] mds -> nonce
+ std::map<int,unsigned> replica_map; // [auth] mds -> nonce
public:
bool is_replicated() { return !replica_map.empty(); }
put(PIN_REPLICATED);
replica_map.clear();
}
- map<int,unsigned>::iterator replicas_begin() { return replica_map.begin(); }
- map<int,unsigned>::iterator replicas_end() { return replica_map.end(); }
- const map<int,unsigned>& get_replicas() { return replica_map; }
- void list_replicas(set<int>& ls) {
- for (map<int,unsigned>::const_iterator p = replica_map.begin();
+ std::map<int,unsigned>::iterator replicas_begin() { return replica_map.begin(); }
+ std::map<int,unsigned>::iterator replicas_end() { return replica_map.end(); }
+ const std::map<int,unsigned>& get_replicas() { return replica_map; }
+ void list_replicas(std::set<int>& ls) {
+ for (std::map<int,unsigned>::const_iterator p = replica_map.begin();
p != replica_map.end();
++p)
ls.insert(p->first);
};
-inline ostream& operator<<(ostream& out, MDSCacheObject &o) {
+inline std::ostream& operator<<(std::ostream& out, MDSCacheObject &o) {
o.print(out);
return out;
}
-inline ostream& operator<<(ostream& out, const MDSCacheObjectInfo &info) {
+inline std::ostream& operator<<(std::ostream& out, const MDSCacheObjectInfo &info) {
if (info.ino) return out << info.ino << "." << info.snapid;
if (info.dname.length()) return out << info.dirfrag << "/" << info.dname
<< " snap " << info.snapid;
return out << info.dirfrag;
}
-inline ostream& operator<<(ostream& out, mdsco_db_line_prefix o) {
+inline std::ostream& operator<<(std::ostream& out, mdsco_db_line_prefix o) {
o.object->print_db_line_prefix(out);
return out;
}