]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/Throttler.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RBD_MIRROR_THROTTLER_H
5 #define RBD_MIRROR_THROTTLER_H
14 #include "common/ceph_mutex.h"
15 #include "common/config_obs.h"
16 #include "include/common_fwd.h"
20 namespace ceph
{ class Formatter
; }
21 namespace librbd
{ class ImageCtx
; }
26 template <typename ImageCtxT
= librbd::ImageCtx
>
27 class Throttler
: public md_config_obs_t
{
29 static Throttler
*create(
31 const std::string
&config_key
) {
32 return new Throttler(cct
, config_key
);
38 Throttler(CephContext
*cct
,
39 const std::string
&config_key
);
40 ~Throttler() override
;
42 void set_max_concurrent_ops(uint32_t max
);
43 void start_op(const std::string
&ns
, const std::string
&id
,
45 bool cancel_op(const std::string
&ns
, const std::string
&id
);
46 void finish_op(const std::string
&ns
, const std::string
&id
);
47 void drain(const std::string
&ns
, int r
);
49 void print_status(ceph::Formatter
*f
);
52 typedef std::pair
<std::string
, std::string
> Id
;
55 const std::string m_config_key
;
56 mutable const char* m_config_keys
[2];
59 uint32_t m_max_concurrent_ops
;
60 std::list
<Id
> m_queue
;
61 std::map
<Id
, Context
*> m_queued_ops
;
62 std::set
<Id
> m_inflight_ops
;
64 const char **get_tracked_conf_keys() const override
;
65 void handle_conf_change(const ConfigProxy
& conf
,
66 const std::set
<std::string
> &changed
) override
;
72 extern template class rbd::mirror::Throttler
<librbd::ImageCtx
>;
74 #endif // RBD_MIRROR_THROTTLER_H