Skip to content

Commit

Permalink
Minor refactoring in the Controller REST services
Browse files Browse the repository at this point in the history
  • Loading branch information
iagaponenko committed Aug 8, 2023
1 parent 2245505 commit a483f2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
9 changes: 3 additions & 6 deletions src/replica/HttpProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ void HttpProcessor::registerServices() {
httpServer()->addHandler("GET", "/replication/qserv/worker/status/:worker",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp,
"SELECT-WORKER-BY-NAME");
self->_processorConfig, req, resp, "WORKER");
});
httpServer()->addHandler("GET", "/replication/qserv/master/query",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
Expand All @@ -248,14 +247,12 @@ void HttpProcessor::registerServices() {
httpServer()->addHandler("GET", "/replication/qserv/master/query/:id",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp,
"SELECT-QUERY-BY-ID");
self->_processorConfig, req, resp, "QUERY");
});
httpServer()->addHandler("GET", "/replication/qserv/css/shared-scan",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
HttpQservMonitorModule::process(self->controller(), self->name(),
self->_processorConfig, req, resp,
"CSS-SHARED-SCAN");
self->_processorConfig, req, resp, "CSS");
});
httpServer()->addHandler("GET", "/replication/sql/table/schema/:database/:table",
[self](qhttp::Request::Ptr const req, qhttp::Response::Ptr const resp) {
Expand Down
11 changes: 6 additions & 5 deletions src/replica/HttpQservMonitorModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "replica/Configuration.h"
#include "replica/ConfigDatabase.h"
#include "replica/DatabaseServices.h"
#include "replica/HttpExceptions.h"
#include "replica/QservMgtServices.h"
#include "replica/QservStatusJob.h"
#include "replica/ServiceProvider.h"
Expand Down Expand Up @@ -136,14 +137,14 @@ HttpQservMonitorModule::HttpQservMonitorModule(Controller::Ptr const& controller
json HttpQservMonitorModule::executeImpl(string const& subModuleName) {
if (subModuleName == "WORKERS")
return _workers();
else if (subModuleName == "SELECT-WORKER-BY-NAME")
else if (subModuleName == "WORKER")
return _worker();
else if (subModuleName == "QUERIES")
return _userQueries();
else if (subModuleName == "SELECT-QUERY-BY-ID")
else if (subModuleName == "QUERY")
return _userQuery();
else if (subModuleName == "CSS-SHARED-SCAN")
return _cssSharedScan();
else if (subModuleName == "CSS")
return _css();
throw invalid_argument(context() + "::" + string(__func__) + " unsupported sub-module: '" +
subModuleName + "'");
}
Expand Down Expand Up @@ -535,7 +536,7 @@ json HttpQservMonitorModule::_getQueries(json const& workerInfo) const {
return result;
}

json HttpQservMonitorModule::_cssSharedScan() {
json HttpQservMonitorModule::_css() {
debug(__func__);
checkApiVersion(__func__, 12);

Expand Down
14 changes: 7 additions & 7 deletions src/replica/HttpQservMonitorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class HttpQservMonitorModule : public HttpModule {
/**
* Supported values for parameter 'subModuleName':
*
* WORKERS for many workers (possible selected by various criteria)
* SELECT-WORKER-BY-NAME for a specific worker
* QUERIES for many queries (selected by various criteria)
* SELECT-QUERY-BY-ID for a specific query
* CSS-SHARED-SCAN get CSS configurations of the shared scan for all tables
* WORKERS get the status info of many workers (possible selected by various criteria)
* WORKER get the status info 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.)
*
* @throws std::invalid_argument for unknown values of parameter 'subModuleName'
*/
Expand Down Expand Up @@ -161,8 +161,8 @@ class HttpQservMonitorModule : public HttpModule {
*/
nlohmann::json _getQueries(nlohmann::json const& workerInfo) const;

/// @return The shared scan parameters of all partitioned tables (CSS)
nlohmann::json _cssSharedScan();
/// @return The CSS info (shared scan parameters of all partitioned tables, etc.)
nlohmann::json _css();

/**
* @param chunks collection of chunks numbers to be expanded
Expand Down

0 comments on commit a483f2a

Please sign in to comment.