Skip to content

Commit

Permalink
Adaptive change for pg move API
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwmao committed Oct 22, 2024
1 parent d22f806 commit 46f32a2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 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.1.3"
version = "2.1.4"

homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
Expand Down
5 changes: 3 additions & 2 deletions src/include/homeobject/homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
4 changes: 3 additions & 1 deletion src/include/homeobject/pg_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/homeobject_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pg_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions src/lib/tests/PGManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 46f32a2

Please sign in to comment.