Skip to content

Commit

Permalink
feat(interactive): Track the start_time of hqps_service and return …
Browse files Browse the repository at this point in the history
…in `get_service_status` (#3838)

The start_time is returns in timestamp, and will be refreshed when
service got started.
  • Loading branch information
zhanglei1949 authored May 23, 2024
1 parent 324e7b2 commit f6a017b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flex/engines/http_server/actor/admin_actor.act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ seastar::future<admin_query_result> admin_actor::start_service(
"Fail to start compiler")));
}
LOG(INFO) << "Successfully started service with graph: " << graph_name;
hqps_service.reset_start_time();
return seastar::make_ready_future<admin_query_result>(
gs::Result<seastar::sstring>("Successfully start service"));
});
Expand Down Expand Up @@ -1083,6 +1084,7 @@ seastar::future<admin_query_result> admin_actor::service_status(
} else {
res["graph"] = {};
}
res["start_time"] = hqps_service.get_start_time();
} else {
LOG(INFO) << "Query service has not been inited!";
res["status"] = "Query service has not been inited!";
Expand Down
9 changes: 9 additions & 0 deletions flex/engines/http_server/service/hqps_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void HQPSService::init(const ServiceConfig& config) {
if (config.start_compiler) {
start_compiler_subprocess();
}
start_time_.store(gs::GetCurrentTimeStamp());
}

HQPSService::~HQPSService() {
Expand Down Expand Up @@ -131,6 +132,14 @@ uint16_t HQPSService::get_query_port() const {
return 0;
}

uint64_t HQPSService::get_start_time() const {
return start_time_.load(std::memory_order_relaxed);
}

void HQPSService::reset_start_time() {
start_time_.store(gs::GetCurrentTimeStamp());
}

std::shared_ptr<gs::IGraphMetaStore> HQPSService::get_metadata_store() const {
return metadata_store_;
}
Expand Down
5 changes: 5 additions & 0 deletions flex/engines/http_server/service/hqps_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class HQPSService {

uint16_t get_query_port() const;

uint64_t get_start_time() const;

void reset_start_time();

std::shared_ptr<gs::IGraphMetaStore> get_metadata_store() const;

gs::Result<seastar::sstring> service_status();
Expand Down Expand Up @@ -122,6 +126,7 @@ class HQPSService {
std::unique_ptr<hqps_http_handler> query_hdl_;
std::atomic<bool> running_{false};
std::atomic<bool> initialized_{false};
std::atomic<uint64_t> start_time_{0};
std::mutex mtx_;

ServiceConfig service_config_;
Expand Down
3 changes: 3 additions & 0 deletions flex/openapi/openapi_interactive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,9 @@ components:
gremlin_port:
type: integer
format: int32
start_time:
type: integer
format: int32
JobResponse:
type: object
x-body-name: job_response
Expand Down

0 comments on commit f6a017b

Please sign in to comment.