]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/ImageSyncThrottler.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_IMAGE_SYNC_THROTTLER_H
5 #define RBD_MIRROR_IMAGE_SYNC_THROTTLER_H
14 #include "common/Mutex.h"
15 #include "common/config_obs.h"
20 namespace ceph
{ class Formatter
; }
21 namespace librbd
{ class ImageCtx
; }
26 template <typename ImageCtxT
= librbd::ImageCtx
>
27 class ImageSyncThrottler
: public md_config_obs_t
{
29 static ImageSyncThrottler
*create(CephContext
*cct
) {
30 return new ImageSyncThrottler(cct
);
36 ImageSyncThrottler(CephContext
*cct
);
37 ~ImageSyncThrottler() override
;
39 void set_max_concurrent_syncs(uint32_t max
);
40 void start_op(const std::string
&id
, Context
*on_start
);
41 bool cancel_op(const std::string
&id
);
42 void finish_op(const std::string
&id
);
45 void print_status(Formatter
*f
, std::stringstream
*ss
);
50 uint32_t m_max_concurrent_syncs
;
51 std::list
<std::string
> m_queue
;
52 std::map
<std::string
, Context
*> m_queued_ops
;
53 std::set
<std::string
> m_inflight_ops
;
55 const char **get_tracked_conf_keys() const override
;
56 void handle_conf_change(const ConfigProxy
& conf
,
57 const std::set
<std::string
> &changed
) override
;
63 extern template class rbd::mirror::ImageSyncThrottler
<librbd::ImageCtx
>;
65 #endif // RBD_MIRROR_IMAGE_SYNC_THROTTLER_H