Skip to content

Commit

Permalink
Add num_disks into stat
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Dec 6, 2024
1 parent 24655f4 commit 31cf583
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
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.15"
version = "2.1.16"

homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
Expand Down
12 changes: 12 additions & 0 deletions src/lib/homestore_backend/heap_chunk_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ class HeapChunkSelector : public homestore::ChunkSelector {

uint32_t get_chunk_size() const;

/**
* @brief Returns the number of disks we seen
*
* Warning : calling this before HS fully start might getting wrong result.
*
* This function returns the number of disks the chunk selector seen.
* It should be the accurate source that how many disks in the system for data.
* If a disk is down in degraded mode, it wont be load and no chunk will be
* added into selector.
*/
uint32_t total_disks() const { return m_per_dev_heap.size(); }

private:
void add_chunk_internal(const chunk_num_t, bool add_to_heap = true);

Expand Down
1 change: 1 addition & 0 deletions src/lib/homestore_backend/hs_homeobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ HomeObjectStats HSHomeObject::_get_stats() const {

stats.num_open_shards = num_open_shards;
stats.avail_open_shards = chunk_selector()->total_chunks() - num_open_shards;
stats.num_disks = chunk_selector()->total_disks();
return stats;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ TEST_F(HeapChunkSelectorTest, test_for_each_chunk) {
ASSERT_EQ(size.load(), 18);
}

TEST_F(HeapChunkSelectorTest, test_total_disks) { ASSERT_EQ(HCS.total_disks(), 3); }

TEST_F(HeapChunkSelectorTest, test_identical_layout) {
const homestore::blk_count_t count = 1;
homestore::blk_alloc_hints hints;
Expand Down

0 comments on commit 31cf583

Please sign in to comment.