]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: Update Session.h to work without using namespace
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 29 Mar 2019 00:39:51 +0000 (20:39 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Fri, 29 Mar 2019 14:30:35 +0000 (10:30 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/mon/Session.h

index 46846c5e1950ac2cc5bc418dbb436c303897b5f1..434395a7bf231fa23a01e6d13de94cf026cea1e8 100644 (file)
 #ifndef CEPH_MON_SESSION_H
 #define CEPH_MON_SESSION_H
 
-#include "global/global_context.h"
+#include <string>
+#include <string_view>
+
+#include "include/utime.h"
 #include "include/xlist.h"
+
+#include "global/global_context.h"
 #include "msg/msg_types.h"
 #include "mon/mon_types.h"
 
@@ -29,13 +34,13 @@ struct MonSession;
 
 struct Subscription {
   MonSession *session;
-  string type;
+  std::string type;
   xlist<Subscription*>::item type_item;
   version_t next;
   bool onetime;
   bool incremental_onetime;  // has CEPH_FEATURE_INCSUBOSDMAP
   
-  Subscription(MonSession *s, const string& t) : session(s), type(t), type_item(this),
+  Subscription(MonSession *s, const std::string& t) : session(s), type(t), type_item(this),
                                                 next(0), onetime(false), incremental_onetime(false) {}
 };
 
@@ -49,12 +54,12 @@ struct MonSession : public RefCountedObject {
   utime_t session_timeout;
   bool closed = false;
   xlist<MonSession*>::item item;
-  set<uint64_t> routed_request_tids;
+  std::set<uint64_t> routed_request_tids;
   MonCap caps;
 
   bool authenticated = false;  ///< true if auth handshake is complete
 
-  map<string, Subscription*> sub_map;
+  std::map<std::string, Subscription*> sub_map;
   epoch_t osd_epoch = 0;       ///< the osdmap epoch sent to the mon client
 
   AuthServiceHandler *auth_handler = nullptr;
@@ -63,8 +68,8 @@ struct MonSession : public RefCountedObject {
   ConnectionRef proxy_con;
   uint64_t proxy_tid = 0;
 
-  string remote_host;                ///< remote host name
-  map<std::string,std::string,std::less<>> last_config;    ///< most recently shared config
+  std::string remote_host;                ///< remote host name
+  std::map<std::string,std::string,std::less<>> last_config;    ///< most recently shared config
   bool any_config = false;
 
   MonSession(Connection *c)
@@ -91,8 +96,8 @@ struct MonSession : public RefCountedObject {
     delete auth_handler;
   }
 
-  bool is_capable(string service, int mask) {
-    map<string,string> args;
+  bool is_capable(std::string service, int mask) {
+    std::map<std::string,std::string> args;
     return caps.is_capable(
       g_ceph_context,
       CEPH_ENTITY_TYPE_MON,
@@ -110,8 +115,8 @@ struct MonSession : public RefCountedObject {
 
 struct MonSessionMap {
   xlist<MonSession*> sessions;
-  map<string, xlist<Subscription*>* > subs;
-  multimap<int, MonSession*> by_osd;
+  std::map<std::string, xlist<Subscription*>* > subs;
+  std::multimap<int, MonSession*> by_osd;
   FeatureMap feature_map; // type -> features -> count
 
   MonSessionMap() {}
@@ -129,14 +134,14 @@ struct MonSessionMap {
 
   void remove_session(MonSession *s) {
     ceph_assert(!s->closed);
-    for (map<string,Subscription*>::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p) {
+    for (std::map<std::string,Subscription*>::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p) {
       p->second->type_item.remove_myself();
       delete p->second;
     }
     s->sub_map.clear();
     s->item.remove_myself();
     if (s->name.is_osd()) {
-      for (multimap<int,MonSession*>::iterator p = by_osd.find(s->name.num());
+      for (auto p = by_osd.find(s->name.num());
           p->first == s->name.num();
           ++p)
        if (p->second == s) {
@@ -165,7 +170,7 @@ struct MonSessionMap {
     sessions.push_back(&s->item);
     s->get();
     if (s->name.is_osd()) {
-      by_osd.insert(pair<int,MonSession*>(s->name.num(), s));
+      by_osd.insert(std::pair<int,MonSession*>(s->name.num(), s));
     }
     if (s->con_features) {
       feature_map.add(s->con_type, s->con_features);
@@ -179,7 +184,7 @@ struct MonSessionMap {
     int n = by_osd.rbegin()->first + 1;
     int r = rand() % n;
 
-    multimap<int,MonSession*>::iterator p = by_osd.lower_bound(r);
+    auto p = by_osd.lower_bound(r);
     if (p == by_osd.end())
       --p;
 
@@ -189,7 +194,8 @@ struct MonSessionMap {
 
     MonSession *s = NULL;
 
-    multimap<int,MonSession*>::iterator b = p, f = p;
+    auto b = p;
+    auto f = p;
     bool backward = true, forward = true;
     while (backward || forward) {
       if (backward) {
@@ -217,7 +223,7 @@ struct MonSessionMap {
     return s;
   }
 
-  void add_update_sub(MonSession *s, const string& what, version_t start, bool onetime, bool incremental_onetime) {
+  void add_update_sub(MonSession *s, const std::string& what, version_t start, bool onetime, bool incremental_onetime) {
     Subscription *sub = 0;
     if (s->sub_map.count(what)) {
       sub = s->sub_map[what];
@@ -241,7 +247,7 @@ struct MonSessionMap {
   }
 };
 
-inline ostream& operator<<(ostream& out, const MonSession& s)
+inline std::ostream& operator<<(std::ostream& out, const MonSession& s)
 {
   out << "MonSession(" << s.name << " " << s.addrs
       << " is " << (s.closed ? "closed" : "open")