From 46f32a281987de920855bdc518490018a4f46b16 Mon Sep 17 00:00:00 2001 From: yuwmao Date: Tue, 15 Oct 2024 02:59:20 -0700 Subject: [PATCH] Adaptive change for pg move API --- conanfile.py | 2 +- src/include/homeobject/homeobject.hpp | 5 +++-- src/include/homeobject/pg_manager.hpp | 4 +++- src/lib/homeobject_impl.hpp | 2 +- src/lib/pg_manager.cpp | 2 +- src/lib/tests/PGManagerTest.cpp | 12 ++++++------ 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/conanfile.py b/conanfile.py index d38974c4..b12eb6a9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomeObjectConan(ConanFile): name = "homeobject" - version = "2.1.3" + version = "2.1.4" homepage = "https://github.com/eBay/HomeObject" description = "Blob Store built on HomeReplication" diff --git a/src/include/homeobject/homeobject.hpp b/src/include/homeobject/homeobject.hpp index 1b49125c..2eef7d23 100644 --- a/src/include/homeobject/homeobject.hpp +++ b/src/include/homeobject/homeobject.hpp @@ -57,9 +57,10 @@ struct HomeObjectStats { uint64_t used_capacity_bytes{0}; uint32_t num_open_shards{0}; uint32_t avail_open_shards{0}; + uint32_t num_disks{0}; std::string to_string() const { - return fmt::format("total_capacity_bytes={}, used_capacity_bytes={}, num_open_shards={}, avail_open_shards={}", - total_capacity_bytes, used_capacity_bytes, num_open_shards, avail_open_shards); + return fmt::format("total_capacity_bytes={}, used_capacity_bytes={}, num_open_shards={}, avail_open_shards={}, num_disks={}", + total_capacity_bytes, used_capacity_bytes, num_open_shards, avail_open_shards, num_disks); } }; diff --git a/src/include/homeobject/pg_manager.hpp b/src/include/homeobject/pg_manager.hpp index e6ea6144..3013d35c 100644 --- a/src/include/homeobject/pg_manager.hpp +++ b/src/include/homeobject/pg_manager.hpp @@ -34,6 +34,7 @@ struct PGInfo { pg_id_t id; mutable MemberSet members; peer_id_t replica_set_uuid; + u_int64_t size; auto operator<=>(PGInfo const& rhs) const { return id <=> rhs.id; } auto operator==(PGInfo const& rhs) const { return id == rhs.id; } @@ -51,6 +52,7 @@ struct PGStats { uint64_t avail_bytes; // total number of bytes available on this PG; uint64_t num_active_objects; // total number of active objects on this PG; uint64_t num_tombstone_objects; // total number of tombstone objects on this PG; + uint64_t pg_state; // PG state; std::vector< std::tuple< peer_id_t, std::string, uint64_t /* last_commit_lsn */, uint64_t /* last_succ_resp_us_ */ > > members; @@ -76,7 +78,7 @@ struct PGStats { class PGManager : public Manager< PGError > { public: virtual NullAsyncResult create_pg(PGInfo&& pg_info) = 0; - virtual NullAsyncResult replace_member(pg_id_t id, peer_id_t const& old_member, PGMember const& new_member) = 0; + virtual NullAsyncResult replace_member(pg_id_t id, peer_id_t const& old_member, PGMember const& new_member, u_int32_t commit_quorum) = 0; /** * Retrieves the statistics for a specific PG (Placement Group) identified by its ID. diff --git a/src/lib/homeobject_impl.hpp b/src/lib/homeobject_impl.hpp index 731198e1..5722cc34 100644 --- a/src/lib/homeobject_impl.hpp +++ b/src/lib/homeobject_impl.hpp @@ -145,7 +145,7 @@ class HomeObjectImpl : public HomeObject, /// PgManager PGManager::NullAsyncResult create_pg(PGInfo&& pg_info) final; PGManager::NullAsyncResult replace_member(pg_id_t id, peer_id_t const& old_member, - PGMember const& new_member) final; + PGMember const& new_member, u_int32_t commit_quorum) final; // see api comments in base class; bool get_stats(pg_id_t id, PGStats& stats) const final; void get_pg_ids(std::vector< pg_id_t >& pg_ids) const final; diff --git a/src/lib/pg_manager.cpp b/src/lib/pg_manager.cpp index f38410f3..6d3f94f4 100644 --- a/src/lib/pg_manager.cpp +++ b/src/lib/pg_manager.cpp @@ -21,7 +21,7 @@ PGManager::NullAsyncResult HomeObjectImpl::create_pg(PGInfo&& pg_info) { } PGManager::NullAsyncResult HomeObjectImpl::replace_member(pg_id_t id, peer_id_t const& old_member, - PGMember const& new_member) { + PGMember const& new_member, u_int32_t commit_quorum) { LOGI("[pg={}] replace member [{}] with [{}]", id, to_string(old_member), to_string(new_member.id)); if (old_member == new_member.id) { LOGW("rejecting identical replacement SvcId [{}]!", to_string(old_member)); diff --git a/src/lib/tests/PGManagerTest.cpp b/src/lib/tests/PGManagerTest.cpp index 6afef298..c02eccdd 100644 --- a/src/lib/tests/PGManagerTest.cpp +++ b/src/lib/tests/PGManagerTest.cpp @@ -33,25 +33,25 @@ TEST_F(TestFixture, CreateDuplicatePg) { TEST_F(TestFixture, Migrate) { EXPECT_EQ(homeobj_->pg_manager() ->replace_member(UINT16_MAX, boost::uuids::random_generator()(), - PGMember{boost::uuids::random_generator()()}) + PGMember{boost::uuids::random_generator()()}, 0) .get() .error(), PGError::UNSUPPORTED_OP); EXPECT_EQ( homeobj_->pg_manager() - ->replace_member(_pg_id, boost::uuids::random_generator()(), PGMember{boost::uuids::random_generator()()}) + ->replace_member(_pg_id, boost::uuids::random_generator()(), PGMember{boost::uuids::random_generator()()}, 0) .get() .error(), PGError::UNSUPPORTED_OP); - EXPECT_EQ(homeobj_->pg_manager()->replace_member(_pg_id, _peer1, PGMember{_peer1}).get().error(), + EXPECT_EQ(homeobj_->pg_manager()->replace_member(_pg_id, _peer1, PGMember{_peer1}, 0).get().error(), PGError::INVALID_ARG); - EXPECT_EQ(homeobj_->pg_manager()->replace_member(_pg_id, _peer1, PGMember{_peer2}).get().error(), + EXPECT_EQ(homeobj_->pg_manager()->replace_member(_pg_id, _peer1, PGMember{_peer2}, 0).get().error(), PGError::INVALID_ARG); EXPECT_EQ(homeobj_->pg_manager() - ->replace_member(_pg_id, _peer1, PGMember{boost::uuids::random_generator()()}) + ->replace_member(_pg_id, _peer1, PGMember{boost::uuids::random_generator()()}, 0) .get() .error(), PGError::INVALID_ARG); EXPECT_FALSE( - homeobj_->pg_manager()->replace_member(_pg_id, _peer2, PGMember{boost::uuids::random_generator()()}).get()); + homeobj_->pg_manager()->replace_member(_pg_id, _peer2, PGMember{boost::uuids::random_generator()()}, 0).get()); }