Skip to content

Commit

Permalink
Added the REST service to report info on known instances of Czar
Browse files Browse the repository at this point in the history
The service was added to the Replication Controller. It's meant to be
use bvy the Web Dashboard to visualize monitoring info of known
instances of Czar.
  • Loading branch information
iagaponenko committed Feb 5, 2024
1 parent beaa6d1 commit 72f54f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/replica/contr/HttpProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ void HttpProcessor::registerServices() {
self->_processorConfig, req, resp,
"WORKER-FILES");
});
httpServer()->addHandler("GET", "/replication/qserv/master/status",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp, "CZARS");
});
httpServer()->addHandler("GET", "/replication/qserv/master/status/:czar",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
Expand Down
17 changes: 17 additions & 0 deletions src/replica/contr/HttpQservMonitorModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ json HttpQservMonitorModule::executeImpl(string const& subModuleName) {
return _workerFiles();
else if (subModuleName == "CZAR")
return _czar();
else if (subModuleName == "CZARS")
return _czars();
else if (subModuleName == "CZAR-CONFIG")
return _czarConfig();
else if (subModuleName == "CZAR-DB")
Expand Down Expand Up @@ -308,6 +310,21 @@ json HttpQservMonitorModule::_workerFiles() {
return json::object({{"status", request->info()}});
}

json HttpQservMonitorModule::_czars() {
debug(__func__);
checkApiVersion(__func__, 30);

unsigned int const timeoutSec = query().optionalUInt("timeout_sec", czarResponseTimeoutSec());
debug(__func__, "timeout_sec=" + to_string(timeoutSec));

json czars = json::array();
auto const config = controller()->serviceProvider()->config();
for (string const& czarName : config->allCzars()) {
czars.push_back(config->czar(czarName).toJson());
}
return json::object({{"czars", czars}});
}

json HttpQservMonitorModule::_czar() {
debug(__func__);
checkApiVersion(__func__, 29);
Expand Down
4 changes: 4 additions & 0 deletions src/replica/contr/HttpQservMonitorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class HttpQservMonitorModule : public HttpModule {
* WORKER-CONFIG - get configuration parameters of a specific worker
* WORKER-DB - get the database status of a specific worker
* WORKER-FILES - get acollection of partial result files from a worker
* CZARS - get info on known instances of Czar
* CZAR - get the status info of Czar
* CZAR-CONFIG - get configuration parameters of Czar
* CZAR-DB - get the database status of Czar
Expand Down Expand Up @@ -133,6 +134,9 @@ class HttpQservMonitorModule : public HttpModule {
*/
nlohmann::json _workerFiles();

/// Process a request to return info on known instances of the Czar.
nlohmann::json _czars();

/**
* Process a request for extracting various status info of Czar.
*/
Expand Down

0 comments on commit 72f54f3

Please sign in to comment.