]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: remove `using namespace std` in headers 2342/head
authorJohn Spray <john.spray@redhat.com>
Thu, 28 Aug 2014 12:41:21 +0000 (13:41 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 28 Aug 2014 13:07:34 +0000 (14:07 +0100)
Avoid polluting global namespace: .cc files should
do the `using` if they want it.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/MDSMap.h
src/mds/mdstypes.h

index 77ffa04de63f758bfd4a61bfc993c7dd7d083b95..23620ea468fbf45292bc5bec936fc7865a855c9d 100644 (file)
@@ -25,7 +25,6 @@
 #include <set>
 #include <map>
 #include <string>
-using namespace std;
 
 #include "common/config.h"
 
@@ -125,7 +124,7 @@ public:
 
   struct mds_info_t {
     uint64_t global_id;
-    string name;
+    std::string name;
     int32_t rank;
     int32_t inc;
     MDSMap::DaemonState state;
@@ -133,8 +132,8 @@ public:
     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) { }
@@ -175,7 +174,7 @@ protected:
   __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
   
@@ -191,11 +190,11 @@ protected:
 
   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
@@ -264,7 +263,7 @@ public:
   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; }
@@ -272,7 +271,7 @@ public:
     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];
@@ -281,8 +280,8 @@ public:
     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) {
@@ -304,7 +303,7 @@ public:
   }
   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;
@@ -316,7 +315,7 @@ public:
     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);
@@ -324,45 +323,45 @@ public:
   }
 
   // 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)
@@ -372,14 +371,14 @@ public:
   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)
@@ -388,10 +387,10 @@ public:
     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) ||
@@ -407,8 +406,8 @@ public:
       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 ||
@@ -423,7 +422,7 @@ public:
     }
     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;
@@ -431,8 +430,8 @@ public:
       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; }
@@ -450,7 +449,7 @@ public:
    * 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);
@@ -460,7 +459,7 @@ public:
    * 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;
@@ -498,7 +497,7 @@ public:
   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();
   }
 
@@ -510,7 +509,7 @@ public:
   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)
index a56e952faf8fce8e1dcd98ae5983f1c268295eeb..4b69b9ac59fdbdfb3bc8658a2e15a8c138274daf 100644 (file)
@@ -9,7 +9,6 @@
 #include <ostream>
 #include <set>
 #include <map>
-using namespace std;
 
 #include "common/config.h"
 #include "common/Clock.h"
@@ -162,7 +161,7 @@ inline bool operator==(const frag_info_t &l, const frag_info_t &r) {
   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 {
@@ -214,7 +213,7 @@ inline bool operator==(const nest_info_t &l, const nest_info_t &r) {
   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 {
@@ -259,7 +258,7 @@ CEPH_HASH_NAMESPACE_END
 
 
 
-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";
@@ -296,7 +295,7 @@ inline void decode(client_writeable_range_t::byte_range_t& range, bufferlist::it
 
 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) {
@@ -339,7 +338,7 @@ struct inode_t {
   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
@@ -404,7 +403,7 @@ struct inode_t {
 
   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)
@@ -415,7 +414,7 @@ struct inode_t {
     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;
@@ -423,7 +422,7 @@ struct inode_t {
   }
 
   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++);
@@ -458,7 +457,7 @@ WRITE_CLASS_ENCODER(inode_t)
 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);
@@ -497,7 +496,7 @@ struct old_rstat_t {
 };
 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 << ")";
 }
 
@@ -508,7 +507,7 @@ inline ostream& operator<<(ostream& out, const old_rstat_t& o) {
 
 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
 
@@ -577,7 +576,7 @@ struct dentry_key_t {
   }
 };
 
-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 << ")";
 }
@@ -615,7 +614,7 @@ inline bool operator<(const string_snap_t& l, const string_snap_t& r) {
   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 << ")";
 }
@@ -658,7 +657,7 @@ struct metareqid_t {
 };
 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;
 }
 
@@ -788,7 +787,7 @@ struct dirfrag_t {
 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;
@@ -933,7 +932,7 @@ inline void decode(dirfrag_load_vec_t& c, const utime_t &t, bufferlist::iterator
   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);
@@ -985,7 +984,7 @@ inline void decode(mds_load_t &c, const utime_t &t, bufferlist::iterator &p) {
   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 
@@ -1074,10 +1073,10 @@ struct mdsco_db_line_prefix {
   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:
@@ -1157,8 +1156,8 @@ class MDSCacheObject {
   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 << ") "; 
   }
   
@@ -1191,7 +1190,7 @@ class MDSCacheObject {
 protected:
   __s32      ref;       // reference count
 #ifdef MDS_REF_SET
-  map<int,int> ref_map;
+  std::map<int,int> ref_map;
 #endif
 
  public:
@@ -1208,7 +1207,7 @@ protected:
 #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;
@@ -1265,9 +1264,9 @@ protected:
 #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;
@@ -1294,7 +1293,7 @@ protected:
   // 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(); }
@@ -1327,11 +1326,11 @@ protected:
       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);
@@ -1425,19 +1424,19 @@ protected:
 
 };
 
-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;
 }