diff --git a/conanfile.py b/conanfile.py index 1801c99..7fc78ce 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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" diff --git a/src/lib/homestore_backend/heap_chunk_selector.h b/src/lib/homestore_backend/heap_chunk_selector.h index cbcbbd2..c0a84b0 100644 --- a/src/lib/homestore_backend/heap_chunk_selector.h +++ b/src/lib/homestore_backend/heap_chunk_selector.h @@ -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); diff --git a/src/lib/homestore_backend/hs_homeobject.cpp b/src/lib/homestore_backend/hs_homeobject.cpp index 305f5d7..ffa76fe 100644 --- a/src/lib/homestore_backend/hs_homeobject.cpp +++ b/src/lib/homestore_backend/hs_homeobject.cpp @@ -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; } diff --git a/src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp b/src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp index 3a7a39d..0251e4f 100644 --- a/src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp +++ b/src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp @@ -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;