From 7a0f91e12557beda27758336e41df382abfffebc Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 8 Mar 2018 16:49:07 -0500 Subject: [PATCH] rbd-mirror: moved pool watcher listener interface out of templated class Signed-off-by: Jason Dillaman --- src/test/rbd_mirror/test_PoolWatcher.cc | 3 ++- src/test/rbd_mirror/test_mock_PoolWatcher.cc | 2 +- src/tools/rbd_mirror/PoolReplayer.h | 3 ++- src/tools/rbd_mirror/PoolWatcher.cc | 2 +- src/tools/rbd_mirror/PoolWatcher.h | 14 +++------- src/tools/rbd_mirror/pool_watcher/Types.h | 27 ++++++++++++++++++++ 6 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/tools/rbd_mirror/pool_watcher/Types.h diff --git a/src/test/rbd_mirror/test_PoolWatcher.cc b/src/test/rbd_mirror/test_PoolWatcher.cc index 06dcd570b32f3..74383d96b43ca 100644 --- a/src/test/rbd_mirror/test_PoolWatcher.cc +++ b/src/test/rbd_mirror/test_PoolWatcher.cc @@ -20,6 +20,7 @@ #include "tools/rbd_mirror/PoolWatcher.h" #include "tools/rbd_mirror/Threads.h" #include "tools/rbd_mirror/types.h" +#include "tools/rbd_mirror/pool_watcher/Types.h" #include "test/librados/test.h" #include "gtest/gtest.h" #include @@ -67,7 +68,7 @@ public: TestFixture::TearDown(); } - struct PoolWatcherListener : public PoolWatcher<>::Listener { + struct PoolWatcherListener : public rbd::mirror::pool_watcher::Listener { TestPoolWatcher *test; Cond cond; ImageIds image_ids; diff --git a/src/test/rbd_mirror/test_mock_PoolWatcher.cc b/src/test/rbd_mirror/test_mock_PoolWatcher.cc index 3300c63ceb6a6..07f9a4d62f8a4 100644 --- a/src/test/rbd_mirror/test_mock_PoolWatcher.cc +++ b/src/test/rbd_mirror/test_mock_PoolWatcher.cc @@ -158,7 +158,7 @@ public: typedef librbd::MockMirroringWatcher MockMirroringWatcher; typedef librbd::MirroringWatcher MirroringWatcher; - struct MockListener : MockPoolWatcher::Listener { + struct MockListener : pool_watcher::Listener { TestMockPoolWatcher *test; MockListener(TestMockPoolWatcher *test) : test(test) { diff --git a/src/tools/rbd_mirror/PoolReplayer.h b/src/tools/rbd_mirror/PoolReplayer.h index f17bd9eb878cb..3bcb1ed5fe88a 100644 --- a/src/tools/rbd_mirror/PoolReplayer.h +++ b/src/tools/rbd_mirror/PoolReplayer.h @@ -15,6 +15,7 @@ #include "PoolWatcher.h" #include "ImageDeleter.h" #include "types.h" +#include "tools/rbd_mirror/pool_watcher/Types.h" #include "tools/rbd_mirror/service_daemon/Types.h" #include @@ -98,7 +99,7 @@ private: * @endverbatim */ - struct PoolWatcherListener : public PoolWatcher<>::Listener { + struct PoolWatcherListener : public pool_watcher::Listener { PoolReplayer *pool_replayer; bool local; diff --git a/src/tools/rbd_mirror/PoolWatcher.cc b/src/tools/rbd_mirror/PoolWatcher.cc index 8d60aa4f47a8c..9056a615ddd60 100644 --- a/src/tools/rbd_mirror/PoolWatcher.cc +++ b/src/tools/rbd_mirror/PoolWatcher.cc @@ -69,7 +69,7 @@ private: template PoolWatcher::PoolWatcher(Threads *threads, librados::IoCtx &remote_io_ctx, - Listener &listener) + pool_watcher::Listener &listener) : m_threads(threads), m_remote_io_ctx(remote_io_ctx), m_listener(listener), m_lock(librbd::util::unique_lock_name("rbd::mirror::PoolWatcher", this)) { m_mirroring_watcher = new MirroringWatcher(m_remote_io_ctx, diff --git a/src/tools/rbd_mirror/PoolWatcher.h b/src/tools/rbd_mirror/PoolWatcher.h index 9a02bad4bd83a..9949ecddec819 100644 --- a/src/tools/rbd_mirror/PoolWatcher.h +++ b/src/tools/rbd_mirror/PoolWatcher.h @@ -17,6 +17,7 @@ #include #include #include "include/assert.h" +#include "tools/rbd_mirror/pool_watcher/Types.h" namespace librbd { struct ImageCtx; } @@ -32,17 +33,8 @@ template struct Threads; template class PoolWatcher { public: - struct Listener { - virtual ~Listener() { - } - - virtual void handle_update(const std::string &mirror_uuid, - ImageIds &&added_image_ids, - ImageIds &&removed_image_ids) = 0; - }; - PoolWatcher(Threads *threads, librados::IoCtx &remote_io_ctx, - Listener &listener); + pool_watcher::Listener &listener); ~PoolWatcher(); PoolWatcher(const PoolWatcher&) = delete; PoolWatcher& operator=(const PoolWatcher&) = delete; @@ -106,7 +98,7 @@ private: Threads *m_threads; librados::IoCtx m_remote_io_ctx; - Listener &m_listener; + pool_watcher::Listener &m_listener; ImageIds m_refresh_image_ids; bufferlist m_out_bl; diff --git a/src/tools/rbd_mirror/pool_watcher/Types.h b/src/tools/rbd_mirror/pool_watcher/Types.h new file mode 100644 index 0000000000000..45fdd51b4d2aa --- /dev/null +++ b/src/tools/rbd_mirror/pool_watcher/Types.h @@ -0,0 +1,27 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_RBD_MIRROR_POOL_WATCHER_TYPES_H +#define CEPH_RBD_MIRROR_POOL_WATCHER_TYPES_H + +#include "tools/rbd_mirror/types.h" +#include + +namespace rbd { +namespace mirror { +namespace pool_watcher { + +struct Listener { + virtual ~Listener() { + } + + virtual void handle_update(const std::string &mirror_uuid, + ImageIds &&added_image_ids, + ImageIds &&removed_image_ids) = 0; +}; + +} // namespace pool_watcher +} // namespace mirror +} // namespace rbd + +#endif // CEPH_RBD_MIRROR_POOL_WATCHER_TYPES_H -- 2.39.5