Skip to content

Commit

Permalink
SDSTOR-12187 : PartitionUtilization Endpoint
Browse files Browse the repository at this point in the history
Expose volume used size divided by AM total size
  • Loading branch information
shosseinimotlagh committed Jan 8, 2024
1 parent 6dc0544 commit 821f897
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "3.6.12"
version = "3.6.13"

homepage = "https://github.corp.ebay.com/SDS/homestore"
description = "HomeStore"
Expand Down
1 change: 1 addition & 0 deletions src/api/vol_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ class VolInterface {

virtual const char* get_name(const VolumePtr& vol) = 0;
virtual uint64_t get_size(const VolumePtr& vol) = 0;
virtual uint64_t get_used_size(const VolumePtr& vol) = 0;
virtual uint64_t get_page_size(const VolumePtr& vol) = 0;
virtual boost::uuids::uuid get_uuid(std::shared_ptr< Volume > vol) = 0;
virtual sisl::blob at_offset(const boost::intrusive_ptr< BlkBuffer >& buf, uint32_t offset) = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/homeblks/home_blks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,11 @@ bool HomeBlks::verify_index_bm() {
return true;
}

uint64_t HomeBlks::get_used_size(const VolumePtr& vol) {
/* Update per volume status */
return vol->get_used_size().used_total_size;
}

sisl::status_response HomeBlks::get_status(const sisl::status_request& request) {
sisl::status_response response;
/* Update per volume status */
Expand Down
1 change: 1 addition & 0 deletions src/homeblks/home_blks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class HomeBlks : public VolInterface, public HomeStore< BLKSTORE_BUFFER_TYPE > {
virtual const char* get_name(const VolumePtr& vol) override;
virtual uint64_t get_page_size(const VolumePtr& vol) override;
virtual uint64_t get_size(const VolumePtr& vol) override;
virtual uint64_t get_used_size(const VolumePtr& vol) override;
virtual boost::uuids::uuid get_uuid(VolumePtr vol) override;
virtual sisl::blob at_offset(const blk_buf_t& buf, uint32_t offset) override;

Expand Down
21 changes: 21 additions & 0 deletions src/homeblks/homeblks_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void HomeBlksHttpServer::setup_routes() {
iomgr::url_t::localhost);
http_server_ptr->setup_route(Http::Method::Get, "/api/v1/getStatus",
Routes::bind(&HomeBlksHttpServer::get_status, this));
http_server_ptr->setup_route(Http::Method::Get, "/api/v1/utilization/:volumeUUID",
Routes::bind(&HomeBlksHttpServer::get_utilization, this));
http_server_ptr->setup_route(Http::Method::Get, "/api/v1/verifyBitmap",
Routes::bind(&HomeBlksHttpServer::verify_bitmap, this), iomgr::url_t::localhost);
http_server_ptr->setup_route(Http::Method::Get, "/api/v1/dumpDiskMetaBlks",
Expand Down Expand Up @@ -151,7 +153,26 @@ void HomeBlksHttpServer::set_log_level(const Pistache::Rest::Request& request,

response.send(Pistache::Http::Code::Ok, resp);
}
void HomeBlksHttpServer::get_utilization(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response)
{
const std::string vol_uuid{request.param(":volumeUUID").as<std::string>()};
if (vol_uuid.length() == 0) {
response.send(Pistache::Http::Code::Bad_Request, "empty vol_uuid!");
return;
}

boost::uuids::string_generator gen;
boost::uuids::uuid uuid = gen(vol_uuid);
const auto vol = VolInterface::get_instance()->lookup_volume(uuid);
if (!vol) {
response.send(Pistache::Http::Code::Bad_Request, "vol not found!");
return;
}
const auto total_data_size = VolInterface::get_instance()->get_system_capacity().initial_total_data_meta_size;
const auto vol_used = VolInterface::get_instance()->get_used_size(vol);
auto resp = std::to_string(static_cast<double> (vol_used) / total_data_size);
response.send(Pistache::Http::Code::Ok, resp);
}
void HomeBlksHttpServer::get_log_level(const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
std::string logmodule;
Expand Down
1 change: 1 addition & 0 deletions src/homeblks/homeblks_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HomeBlksHttpServer {
void verify_metablk_store(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response);
void wakeup_init(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response);
void copy_vol(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response);
void get_utilization(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response);

#ifdef _PRERELEASE
void set_safe_mode(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response);
Expand Down

0 comments on commit 821f897

Please sign in to comment.