#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"
#include "msg/Messenger.h"
+#include "common/Throttle.h"
#include "common/Timer.h"
#include "common/TracepointProvider.h"
#include "common/ceph_argparse.h"
#include <mutex>
#include "include/Context.h"
+#include "common/ThrottleInterface.h"
#include "common/Timer.h"
#include "common/convenience.h"
#include "common/perf_counters.h"
* 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;
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);
* @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
* @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
*/
--- /dev/null
+// -*- 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;
+};
#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"
#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"
// 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
}
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; }
#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"
#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"
#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"