Skip to content

Commit

Permalink
Extended Controller's REST API to report database activities
Browse files Browse the repository at this point in the history
Incremented the version number of the REST API.
  • Loading branch information
iagaponenko committed Aug 8, 2023
1 parent 62a3a1a commit b6285f7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/admin/python/lsst/qserv/admin/replicationInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def __init__(
self.repl_ctrl = urlparse(repl_ctrl_uri)
self.auth_key = auth_key
self.admin_auth_key = admin_auth_key
self.repl_api_version = 23
self.repl_api_version = 24
_log.debug(f"ReplicationInterface %s", self.repl_ctrl)

def version(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/replica/HttpMetaModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using json = nlohmann::json;

namespace lsst::qserv::replica {

unsigned int const HttpMetaModule::version = 23;
unsigned int const HttpMetaModule::version = 24;

void HttpMetaModule::process(ServiceProvider::Ptr const& serviceProvider, string const& context,
qhttp::Request::Ptr const& req, qhttp::Response::Ptr const& resp,
Expand Down
6 changes: 6 additions & 0 deletions src/replica/HttpProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ void HttpProcessor::registerServices() {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp, "WORKER");
});
httpServer()->addHandler("GET", "/replication/qserv/worker/db/:worker",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp,
"WORKER-DB");
});
httpServer()->addHandler("GET", "/replication/qserv/master/query",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
Expand Down
30 changes: 30 additions & 0 deletions src/replica/HttpQservMonitorModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ json HttpQservMonitorModule::executeImpl(string const& subModuleName) {
return _workers();
else if (subModuleName == "WORKER")
return _worker();
else if (subModuleName == "WORKER-DB")
return _workerDb();
else if (subModuleName == "QUERIES")
return _userQueries();
else if (subModuleName == "QUERY")
Expand Down Expand Up @@ -217,6 +219,34 @@ json HttpQservMonitorModule::_worker() {
return result;
}

json HttpQservMonitorModule::_workerDb() {
debug(__func__);
checkApiVersion(__func__, 24);

auto const worker = params().at("worker");
unsigned int const timeoutSec = query().optionalUInt("timeout_sec", workerResponseTimeoutSec());
wbase::TaskSelector const taskSelector = _translateTaskSelector(__func__);

debug(__func__, "worker=" + worker);
debug(__func__, "timeout_sec=" + to_string(timeoutSec));

string const noParentJobId;
GetDbStatusQservMgtRequest::CallbackType const onFinish = nullptr;

auto const request = controller()->serviceProvider()->qservMgtServices()->databaseStatus(
worker, noParentJobId, onFinish, timeoutSec);
request->wait();

if (request->extendedState() != QservMgtRequest::ExtendedState::SUCCESS) {
string const msg = "database operation failed, error: " +
QservMgtRequest::state2string(request->extendedState());
throw HttpError(__func__, msg);
}
json result = json::object();
result["status"] = request->info();
return result;
}

wbase::TaskSelector HttpQservMonitorModule::_translateTaskSelector(string const& func) const {
wbase::TaskSelector selector;
selector.includeTasks = query().optionalUInt("include_tasks", 0) != 0;
Expand Down
7 changes: 7 additions & 0 deletions src/replica/HttpQservMonitorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class HttpQservMonitorModule : public HttpModule {
*
* WORKERS get the status info of many workers (possible selected by various criteria)
* WORKER get the status info of a specific worker
* WORKER-DB get the database status of a specific worker
* QUERIES get user query info (queries selected by various criteria)
* QUERY get user query info for a specific query
* CSS get CSS configurations (the shared scan settings, etc.)
Expand Down Expand Up @@ -94,6 +95,12 @@ class HttpQservMonitorModule : public HttpModule {
*/
nlohmann::json _worker();

/**
* Process a request for extracting various status info on the database
* service for select Qserv worker.
*/
nlohmann::json _workerDb();

/**
* Process a request for extracting a status on select user queries
* launched at Qserv.
Expand Down

0 comments on commit b6285f7

Please sign in to comment.