Skip to content

Commit

Permalink
add snapshot overrides for repl listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravi Nagarjun Akella authored and Ravi Nagarjun Akella committed Aug 12, 2024
1 parent fa72a4d commit ac0f7ab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 28 additions & 2 deletions src/lib/homestore_backend/replication_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion src/lib/homestore_backend/replication_state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit ac0f7ab

Please sign in to comment.