]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: wire instance notifications through to pool replayer
authorJason Dillaman <dillaman@redhat.com>
Fri, 9 Mar 2018 02:55:48 +0000 (21:55 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 10 Apr 2018 20:32:13 +0000 (16:32 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/test_LeaderWatcher.cc
src/test/rbd_mirror/test_mock_LeaderWatcher.cc
src/tools/rbd_mirror/LeaderWatcher.h
src/tools/rbd_mirror/PoolReplayer.cc
src/tools/rbd_mirror/PoolReplayer.h
src/tools/rbd_mirror/leader_watcher/Types.h

index c578e4792659e56b6ec6f4e8ef8e2acf45886bc6..490c07ab4e5cc9c2bbe347c0f69588b479344e3c 100644 (file)
@@ -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;
index 78d879da73d0c40b266be6cd3e9b74a93de4df31..f4eae19b9e3898a674f4bc828b7b62c061269f87 100644 (file)
@@ -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;
index 35f958b7f9781a04c764ad0afd718cf16185c6af..b21a781697736bd2e6f85f0984751be0301af9b8 100644 (file)
@@ -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);
     }
   };
 
index 940726e2223baeb18e84f39c4f258669e19ba155..0eb67af9b2c135eca9ea66816c29684e5839382f 100644 (file)
@@ -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<I>::handle_remove_image(const std::string &mirror_uuid,
   // TODO
 }
 
+template <typename I>
+void PoolReplayer<I>::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 <typename I>
+void PoolReplayer<I>::handle_instances_removed(
+    const InstanceIds &instance_ids) {
+  dout(5) << "instance_ids=" << instance_ids << dendl;
+  // TODO
+}
+
 } // namespace mirror
 } // namespace rbd
 
index 12548eaaadadc661914dfffed240ce0d3b8d4cb1..e15d183725f11fa2c7038888e1f68fc7c4a3b542 100644 (file)
@@ -25,6 +25,7 @@
 #include <memory>
 #include <atomic>
 #include <string>
+#include <vector>
 
 class AdminSocketHook;
 
@@ -106,6 +107,8 @@ private:
    * @endverbatim
    */
 
+  typedef std::vector<std::string> 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<ImageCtxT> *m_threads;
   ServiceDaemon<ImageCtxT>* 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;
index 76980d588df4bdebf8bf5798e1f98044a74650f1..6d5e5b3613de38051bc3e26c79f4c1ad398b1dde 100644 (file)
@@ -8,6 +8,7 @@
 #include "include/buffer_fwd.h"
 #include "include/encoding.h"
 #include <string>
+#include <vector>
 #include <boost/variant.hpp>
 
 struct Context;
@@ -19,6 +20,8 @@ namespace mirror {
 namespace leader_watcher {
 
 struct Listener {
+  typedef std::vector<std::string> 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 {