]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/msgr/perf_msgr_client.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / test / msgr / perf_msgr_client.cc
index 992217e341daf13c36de185ca3673569d544d5db..f9f3b617ea385f4a27e4c0f960e401200d4b44f5 100644 (file)
@@ -28,6 +28,7 @@ using namespace std;
 #include "global/global_init.h"
 #include "msg/Messenger.h"
 #include "messages/MOSDOp.h"
+#include "auth/DummyAuth.h"
 
 #include <atomic>
 
@@ -75,23 +76,23 @@ class MessengerClient {
     ClientDispatcher dispatcher;
 
    public:
-    Mutex lock;
-    Cond cond;
+    ceph::mutex lock = ceph::make_mutex("MessengerBenchmark::ClientThread::lock");
+    ceph::condition_variable cond;
     uint64_t inflight;
 
     ClientThread(Messenger *m, int c, ConnectionRef con, int len, int ops, int think_time_us):
         msgr(m), concurrent(c), conn(con), oid("object-name"), oloc(1, 1), msg_len(len), ops(ops),
-        dispatcher(think_time_us, this), lock("MessengerBenchmark::ClientThread::lock"), inflight(0) {
+        dispatcher(think_time_us, this), inflight(0) {
       m->add_dispatcher_head(&dispatcher);
       bufferptr ptr(msg_len);
       memset(ptr.c_str(), 0, msg_len);
       data.append(ptr);
     }
     void *entry() override {
-      lock.Lock();
+      std::unique_lock locker{lock};
       for (int i = 0; i < ops; ++i) {
         if (inflight > uint64_t(concurrent)) {
-          cond.Wait(lock);
+         cond.wait(locker);
         }
        hobject_t hobj(oid, oloc.key, CEPH_NOSNAP, pgid.ps(), pgid.pool(),
                       oloc.nspace);
@@ -103,7 +104,7 @@ class MessengerClient {
         conn->send_message(m);
         //cerr << __func__ << " send m=" << m << std::endl;
       }
-      lock.Unlock();
+      locker.unlock();
       msgr->shutdown();
       return 0;
     }
@@ -114,10 +115,12 @@ class MessengerClient {
   int think_time_us;
   vector<Messenger*> msgrs;
   vector<ClientThread*> clients;
+  DummyAuthClientServer dummy_auth;
 
  public:
   MessengerClient(const string &t, const string &addr, int delay):
-      type(t), serveraddr(addr), think_time_us(delay) {
+      type(t), serveraddr(addr), think_time_us(delay),
+      dummy_auth(g_ceph_context) {
   }
   ~MessengerClient() {
     for (uint64_t i = 0; i < clients.size(); ++i)
@@ -131,9 +134,11 @@ class MessengerClient {
     entity_addr_t addr;
     addr.parse(serveraddr.c_str());
     addr.set_nonce(0);
+    dummy_auth.auth_registry.refresh_config();
     for (int i = 0; i < jobs; ++i) {
       Messenger *msgr = Messenger::create(g_ceph_context, type, entity_name_t::CLIENT(0), "client", getpid()+i, 0);
       msgr->set_default_policy(Messenger::Policy::lossless_client(0));
+      msgr->set_auth_client(&dummy_auth);
       msgr->start();
       entity_addrvec_t addrs(addr);
       ConnectionRef conn = msgr->connect_to_osd(addrs);
@@ -154,9 +159,9 @@ class MessengerClient {
 void MessengerClient::ClientDispatcher::ms_fast_dispatch(Message *m) {
   usleep(think_time);
   m->put();
-  Mutex::Locker l(thread->lock);
+  std::lock_guard l{thread->lock};
   thread->inflight--;
-  thread->cond.Signal();
+  thread->cond.notify_all();
 }