Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive changes for HttpManager #205

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.0.12"
version = "2.0.13"

homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
Expand Down
3 changes: 0 additions & 3 deletions src/lib/homestore_backend/hs_homeobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ void HSHomeObject::init_homestore() {
ioenvironment.with_iomgr(iomgr::iomgr_params{.num_threads = app->threads(), .is_spdk = app->spdk_mode()})
.with_http_server();

// TODO: Fixme. This is a hack to restart http server. We should remove this once IOEnvironment has an api
// called stop_iomgr, stop_http_server. Until that this restart call allows us to cleanup previous instances
ioenvironment.restart_http_server();
http_mgr_ = std::make_unique< HttpManager >(*this);

/// TODO Where should this come from?
Expand Down
18 changes: 7 additions & 11 deletions src/lib/homestore_backend/hs_http_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ HttpManager::HttpManager(HSHomeObject& ho) : ho_(ho) {
using namespace Pistache::Rest;

LOGINFO("Setting up HomeObject HTTP routes");
struct http_route {
Pistache::Http::Method method;
std::string resource;
Pistache::Rest::Route::Handler handler;
iomgr::url_type type{iomgr::url_type::regular};
};

std::vector< http_route > routes = {
std::vector< iomgr::http_route > routes = {
{Pistache::Http::Method::Get, "/api/v1/getObjLife",
Pistache::Rest::Routes::bind(&HttpManager::get_obj_life, this)},
{Pistache::Http::Method::Get, "/api/v1/mallocStats",
Expand All @@ -46,11 +40,13 @@ HttpManager::HttpManager(HSHomeObject& ho) : ho_(ho) {
};

auto http_server = ioenvironment.get_http_server();
for (auto& route : routes) {
try {
http_server->setup_route(std::move(route.method), route.resource, std::move(route.handler), route.type);
} catch (std::runtime_error const& e) { LOGERROR("setup route {} failed, {}", route.resource, e.what()) }
if (!http_server) {
LOGERROR("http server not available");
return;
}
try {
http_server->setup_routes(routes);
} catch (std::runtime_error const& e) { LOGERROR("setup routes failed, {}", e.what()) }
}

void HttpManager::get_obj_life(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response) {
Expand Down
Loading