From ac0f7abd465780ef057e5d47e83ef11d82dda8f7 Mon Sep 17 00:00:00 2001 From: Ravi Nagarjun Akella Date: Mon, 12 Aug 2024 16:46:44 -0700 Subject: [PATCH] add snapshot overrides for repl listener --- conanfile.py | 2 +- .../replication_state_machine.cpp | 30 +++++++++++++++++-- .../replication_state_machine.hpp | 10 ++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index 255ea92..b0b9b0f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomeObjectConan(ConanFile): name = "homeobject" - version = "2.0.9" + version = "2.0.10" homepage = "https://github.com/eBay/HomeObject" description = "Blob Store built on HomeReplication" diff --git a/src/lib/homestore_backend/replication_state_machine.cpp b/src/lib/homestore_backend/replication_state_machine.cpp index 8dd3567..fbe629e 100644 --- a/src/lib/homestore_backend/replication_state_machine.cpp +++ b/src/lib/homestore_backend/replication_state_machine.cpp @@ -153,10 +153,36 @@ void ReplicationStateMachine::on_destroy() { LOGI("replica destroyed"); } -homestore::AsyncReplResult<> ReplicationStateMachine::create_snapshot(homestore::repl_snapshot& s) { +homestore::AsyncReplResult<> +ReplicationStateMachine::create_snapshot(std::shared_ptr< homestore::snapshot_context > context) { // TODO::add create snapshot logic - LOGI("create snapshot, last_log_idx_: {} , last_log_term_: {}", s.last_log_idx_, s.last_log_term_); + auto ctx = dynamic_pointer_cast< homestore::nuraft_snapshot_context >(context); + auto s = ctx->nuraft_snapshot(); + LOGI("create snapshot, last_log_idx_: {} , last_log_term_: {}", s->get_last_log_idx(), s->get_last_log_term()); return folly::makeSemiFuture< homestore::ReplResult< folly::Unit > >(folly::Unit{}); } +bool ReplicationStateMachine::apply_snapshot(std::shared_ptr< homestore::snapshot_context > context) { + LOGE("apply_snapshot not implemented"); + return false; +} + +std::shared_ptr< homestore::snapshot_context > ReplicationStateMachine::last_snapshot() { + LOGE("last_snapshot not implemented"); + return nullptr; +} + +int ReplicationStateMachine::read_snapshot_data(std::shared_ptr< homestore::snapshot_context > context, + std::shared_ptr< homestore::snapshot_data > snp_data) { + LOGE("read_snapshot_data not implemented"); + return -1; +} + +void ReplicationStateMachine::write_snapshot_data(std::shared_ptr< homestore::snapshot_context > context, + std::shared_ptr< homestore::snapshot_data > snp_data) { + LOGE("write_snapshot_data not implemented"); +} + +void ReplicationStateMachine::free_user_snp_ctx(void*& user_snp_ctx) { LOGE("free_user_snp_ctx not implemented"); } + } // namespace homeobject diff --git a/src/lib/homestore_backend/replication_state_machine.hpp b/src/lib/homestore_backend/replication_state_machine.hpp index 53ea0a9..dad9ee7 100644 --- a/src/lib/homestore_backend/replication_state_machine.hpp +++ b/src/lib/homestore_backend/replication_state_machine.hpp @@ -171,8 +171,16 @@ class ReplicationStateMachine : public homestore::ReplDevListener { /// @brief Called when the replica is being destroyed by nuraft; void on_destroy() override; + /// Not Implemented /// @brief Called when the snapshot is being created by nuraft; - homestore::AsyncReplResult<> create_snapshot(homestore::repl_snapshot& s) override; + homestore::AsyncReplResult<> create_snapshot(std::shared_ptr< homestore::snapshot_context > context) override; + virtual bool apply_snapshot(std::shared_ptr< homestore::snapshot_context > context) override; + virtual std::shared_ptr< homestore::snapshot_context > last_snapshot() override; + virtual int read_snapshot_data(std::shared_ptr< homestore::snapshot_context > context, + std::shared_ptr< homestore::snapshot_data > snp_data) override; + virtual void write_snapshot_data(std::shared_ptr< homestore::snapshot_context > context, + std::shared_ptr< homestore::snapshot_data > snp_data) override; + virtual void free_user_snp_ctx(void*& user_snp_ctx) override; private: HSHomeObject* home_object_{nullptr};