]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Throttle: extract ThrottleInterface
authorKefu Chai <kchai@redhat.com>
Sat, 26 May 2018 05:35:26 +0000 (13:35 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 13 Jun 2018 16:10:34 +0000 (00:10 +0800)
the Message classes are shared by OSD and other components of Ceph,
and the throttle in Policy class is different in seastar and
non-seastar world. we will have different implementations for the
seastar applications and non-seastar apps, to consolidate these
two implementations, we need to introduce a common interface for
them.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/ceph_mon.cc
src/ceph_osd.cc
src/common/Throttle.h
src/common/ThrottleInterface.h [new file with mode: 0644]
src/msg/DispatchQueue.h
src/msg/Message.h
src/os/bluestore/BlueStore.h
src/os/kstore/KStore.h
src/osdc/Objecter.h

index 297111831d0b3a872e50f384b47321311be37473..025d01858249ed69464d0c902dfffd05676e8f15 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "common/ceph_argparse.h"
 #include "common/pick_address.h"
+#include "common/Throttle.h"
 #include "common/Timer.h"
 #include "common/errno.h"
 #include "common/Preforker.h"
index 6487679eac2c410387f8a5c4bb116aee73423577..95d03ecd8d48d32e530ccefc9bc1231a19ea8200 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "msg/Messenger.h"
 
+#include "common/Throttle.h"
 #include "common/Timer.h"
 #include "common/TracepointProvider.h"
 #include "common/ceph_argparse.h"
index 0c03e60569a603319f5c54e5fd80abd4a1a84c6d..6558c401fd06312996723a52542a9b99e6282bbc 100644 (file)
@@ -13,6 +13,7 @@
 #include <mutex>
 
 #include "include/Context.h"
+#include "common/ThrottleInterface.h"
 #include "common/Timer.h"
 #include "common/convenience.h"
 #include "common/perf_counters.h"
@@ -25,7 +26,7 @@
  * excessive requests for more of them are delayed, until some slots are put
  * back, so @p get_current() drops below the limit after fulfills the requests.
  */
-class Throttle {
+class Throttle final : public ThrottleInterface {
   CephContext *cct;
   const std::string name;
   PerfCountersRef logger;
@@ -36,7 +37,7 @@ class Throttle {
 
 public:
   Throttle(CephContext *cct, const std::string& n, int64_t m = 0, bool _use_perf = true);
-  ~Throttle();
+  ~Throttle() override;
 
 private:
   void _reset_max(int64_t m);
@@ -87,7 +88,7 @@ public:
    * @param c number of slots to take
    * @returns the total number of taken slots
    */
-  int64_t take(int64_t c = 1);
+  int64_t take(int64_t c = 1) override;
 
   /**
    * get the specified amount of slots from the stock, but will wait if the
@@ -111,7 +112,7 @@ public:
    * @param c number of slots to return
    * @returns number of requests being hold after this
    */
-  int64_t put(int64_t c = 1);
+  int64_t put(int64_t c = 1) override;
    /**
    * reset the zero to the stock
    */
diff --git a/src/common/ThrottleInterface.h b/src/common/ThrottleInterface.h
new file mode 100644 (file)
index 0000000..49182a1
--- /dev/null
@@ -0,0 +1,23 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <cstdint>
+
+class ThrottleInterface {
+public:
+  virtual ~ThrottleInterface() {}
+  /**
+   * take the specified number of slots from the stock regardless the throttling
+   * @param c number of slots to take
+   * @returns the total number of taken slots
+   */
+  virtual int64_t take(int64_t c = 1) = 0;
+  /**
+   * put slots back to the stock
+   * @param c number of slots to return
+   * @returns number of requests being hold after this
+   */
+  virtual int64_t put(int64_t c = 1) = 0;
+};
index 55698819361da7489f5f1b1a2a5abe8a6b551a1c..e95712d5d79398af7cc2aa9a520881d67d3428d7 100644 (file)
@@ -20,6 +20,7 @@
 #include <boost/intrusive_ptr.hpp>
 #include "include/assert.h"
 #include "include/xlist.h"
+#include "common/Throttle.h"
 #include "common/Mutex.h"
 #include "common/Cond.h"
 #include "common/Thread.h"
index a3ea35364d32c9e5224e3edda74af693436f47d4..be3f599f18cbec1c46fe9df96a1e98feb1427801 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "include/types.h"
 #include "include/buffer.h"
-#include "common/Throttle.h"
+#include "common/ThrottleInterface.h"
 #include "common/zipkin_trace.h"
 #include "msg_types.h"
 
@@ -283,10 +283,10 @@ protected:
 
   // release our size in bytes back to this throttler when our payload
   // is adjusted or when we are destroyed.
-  Throttle *byte_throttler = nullptr;
+  ThrottleInterface *byte_throttler = nullptr;
 
   // release a count back to this throttler when we are destroyed
-  Throttle *msg_throttler = nullptr;
+  ThrottleInterface *msg_throttler = nullptr;
 
   // keep track of how big this message was when we reserved space in
   // the msgr dispatch_throttler, so that we can properly release it
@@ -333,10 +333,12 @@ public:
   }
   CompletionHook* get_completion_hook() { return completion_hook; }
   void set_completion_hook(CompletionHook *hook) { completion_hook = hook; }
-  void set_byte_throttler(Throttle *t) { byte_throttler = t; }
-  Throttle *get_byte_throttler() { return byte_throttler; }
-  void set_message_throttler(Throttle *t) { msg_throttler = t; }
-  Throttle *get_message_throttler() { return msg_throttler; }
+  void set_byte_throttler(ThrottleInterface *t) {
+    byte_throttler = t;
+  }
+  void set_message_throttler(ThrottleInterface *t) {
+    msg_throttler = t;
+  }
 
   void set_dispatch_throttle_size(uint64_t s) { dispatch_throttle_size = s; }
   uint64_t get_dispatch_throttle_size() const { return dispatch_throttle_size; }
index fdd7b8012a68420de3afd09b900a787b56b59cc5..b1ea9175f8cd932fdf89aef3aa641d1c5eb0b432 100644 (file)
@@ -35,6 +35,7 @@
 #include "include/mempool.h"
 #include "common/bloom_filter.hpp"
 #include "common/Finisher.h"
+#include "common/Throttle.h"
 #include "common/perf_counters.h"
 #include "common/PriorityCache.h"
 #include "compressor/Compressor.h"
index 4e1ca5cf7c33accfd29f670e0e49963ab8b8f1f4..3f8e959964f51fe7f17586c141eb0961cbfc57ba 100644 (file)
@@ -28,6 +28,7 @@
 #include "include/memory.h"
 #include "common/Finisher.h"
 #include "common/RWLock.h"
+#include "common/Throttle.h"
 #include "common/WorkQueue.h"
 #include "os/ObjectStore.h"
 #include "common/perf_counters.h"
index 5e9c1edf4e6b6644cdd622136331d2aa79912e82..14da2fe4ca18ed62e94bfdea196c9c9e39291458 100644 (file)
 #include "common/admin_socket.h"
 #include "common/ceph_time.h"
 #include "common/ceph_timer.h"
-#include "common/Finisher.h"
 #include "common/shunique_lock.h"
 #include "common/zipkin_trace.h"
+#include "common/Finisher.h"
+#include "common/Throttle.h"
 
 #include "messages/MOSDOp.h"
 #include "msg/Dispatcher.h"