From: Jason Dillaman Date: Fri, 9 Mar 2018 02:55:48 +0000 (-0500) Subject: rbd-mirror: wire instance notifications through to pool replayer X-Git-Tag: v13.1.0~312^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e01c6c4bcf639e806b9ee661ed7e862dfbe1e99d;p=ceph.git rbd-mirror: wire instance notifications through to pool replayer Signed-off-by: Jason Dillaman --- diff --git a/src/test/rbd_mirror/test_LeaderWatcher.cc b/src/test/rbd_mirror/test_LeaderWatcher.cc index c578e4792659..490c07ab4e5c 100644 --- a/src/test/rbd_mirror/test_LeaderWatcher.cc +++ b/src/test/rbd_mirror/test_LeaderWatcher.cc @@ -74,6 +74,11 @@ public: void update_leader_handler(const std::string &leader_instance_id) override { } + void handle_instances_added(const InstanceIds& instance_ids) override { + } + void handle_instances_removed(const InstanceIds& instance_ids) override { + } + private: mutable Mutex m_test_lock; int m_acquire_count = 0; diff --git a/src/test/rbd_mirror/test_mock_LeaderWatcher.cc b/src/test/rbd_mirror/test_mock_LeaderWatcher.cc index 78d879da73d0..f4eae19b9e38 100644 --- a/src/test/rbd_mirror/test_mock_LeaderWatcher.cc +++ b/src/test/rbd_mirror/test_mock_LeaderWatcher.cc @@ -272,6 +272,8 @@ struct MockListener : public leader_watcher::Listener { MOCK_METHOD1(pre_release_handler, void(Context *)); MOCK_METHOD1(update_leader_handler, void(const std::string &)); + MOCK_METHOD1(handle_instances_added, void(const InstanceIds&)); + MOCK_METHOD1(handle_instances_removed, void(const InstanceIds&)); }; MockListener *MockListener::s_instance = nullptr; diff --git a/src/tools/rbd_mirror/LeaderWatcher.h b/src/tools/rbd_mirror/LeaderWatcher.h index 35f958b7f978..b21a78169773 100644 --- a/src/tools/rbd_mirror/LeaderWatcher.h +++ b/src/tools/rbd_mirror/LeaderWatcher.h @@ -107,11 +107,11 @@ private: } void handle_added(const InstanceIds& instance_ids) override { - // TODO + leader_watcher->m_listener->handle_instances_added(instance_ids); } void handle_removed(const InstanceIds& instance_ids) override { - // TODO + leader_watcher->m_listener->handle_instances_removed(instance_ids); } }; diff --git a/src/tools/rbd_mirror/PoolReplayer.cc b/src/tools/rbd_mirror/PoolReplayer.cc index 940726e2223b..0eb67af9b2c1 100644 --- a/src/tools/rbd_mirror/PoolReplayer.cc +++ b/src/tools/rbd_mirror/PoolReplayer.cc @@ -42,6 +42,8 @@ using librbd::util::create_async_context_callback; namespace rbd { namespace mirror { +using ::operator<<; + namespace { const std::string SERVICE_DAEMON_LEADER_KEY("leader"); @@ -1028,6 +1030,22 @@ void PoolReplayer::handle_remove_image(const std::string &mirror_uuid, // TODO } +template +void PoolReplayer::handle_instances_added(const InstanceIds &instance_ids) { + dout(5) << "instance_ids=" << instance_ids << dendl; + + // TODO only register ourselves for now + auto instance_id = m_instance_watcher->get_instance_id(); + m_image_map->update_instances_added({instance_id}); +} + +template +void PoolReplayer::handle_instances_removed( + const InstanceIds &instance_ids) { + dout(5) << "instance_ids=" << instance_ids << dendl; + // TODO +} + } // namespace mirror } // namespace rbd diff --git a/src/tools/rbd_mirror/PoolReplayer.h b/src/tools/rbd_mirror/PoolReplayer.h index 12548eaaadad..e15d183725f1 100644 --- a/src/tools/rbd_mirror/PoolReplayer.h +++ b/src/tools/rbd_mirror/PoolReplayer.h @@ -25,6 +25,7 @@ #include #include #include +#include class AdminSocketHook; @@ -106,6 +107,8 @@ private: * @endverbatim */ + typedef std::vector InstanceIds; + struct PoolWatcherListener : public pool_watcher::Listener { PoolReplayer *pool_replayer; bool local; @@ -202,6 +205,9 @@ private: const std::string &instance_id, Context* on_finish); + void handle_instances_added(const InstanceIds &instance_ids); + void handle_instances_removed(const InstanceIds &instance_ids); + Threads *m_threads; ServiceDaemon* m_service_daemon; int64_t m_local_pool_id = -1; @@ -269,6 +275,14 @@ private: m_pool_replayer->handle_update_leader(leader_instance_id); } + void handle_instances_added(const InstanceIds& instance_ids) override { + m_pool_replayer->handle_instances_added(instance_ids); + } + + void handle_instances_removed(const InstanceIds& instance_ids) override { + m_pool_replayer->handle_instances_removed(instance_ids); + } + private: PoolReplayer *m_pool_replayer; } m_leader_listener; diff --git a/src/tools/rbd_mirror/leader_watcher/Types.h b/src/tools/rbd_mirror/leader_watcher/Types.h index 76980d588df4..6d5e5b3613de 100644 --- a/src/tools/rbd_mirror/leader_watcher/Types.h +++ b/src/tools/rbd_mirror/leader_watcher/Types.h @@ -8,6 +8,7 @@ #include "include/buffer_fwd.h" #include "include/encoding.h" #include +#include #include struct Context; @@ -19,6 +20,8 @@ namespace mirror { namespace leader_watcher { struct Listener { + typedef std::vector InstanceIds; + virtual ~Listener() { } @@ -27,6 +30,9 @@ struct Listener { virtual void update_leader_handler( const std::string &leader_instance_id) = 0; + + virtual void handle_instances_added(const InstanceIds& instance_ids) = 0; + virtual void handle_instances_removed(const InstanceIds& instance_ids) = 0; }; enum NotifyOp {