From 62a3a1ab1c0bf17f4da92ffa26b027cfe02545bc Mon Sep 17 00:00:00 2001 From: Igor Gaponenko Date: Mon, 7 Aug 2023 17:36:02 +0000 Subject: [PATCH] Minor refactoring in the Controller REST services --- src/replica/HttpProcessor.cc | 9 +++------ src/replica/HttpQservMonitorModule.cc | 11 ++++++----- src/replica/HttpQservMonitorModule.h | 14 +++++++------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/replica/HttpProcessor.cc b/src/replica/HttpProcessor.cc index e00f385f12..7ab0dff2ba 100644 --- a/src/replica/HttpProcessor.cc +++ b/src/replica/HttpProcessor.cc @@ -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) { @@ -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) { diff --git a/src/replica/HttpQservMonitorModule.cc b/src/replica/HttpQservMonitorModule.cc index 447da0f360..3f8c10074f 100644 --- a/src/replica/HttpQservMonitorModule.cc +++ b/src/replica/HttpQservMonitorModule.cc @@ -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" @@ -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 + "'"); } @@ -535,7 +536,7 @@ json HttpQservMonitorModule::_getQueries(json const& workerInfo) const { return result; } -json HttpQservMonitorModule::_cssSharedScan() { +json HttpQservMonitorModule::_css() { debug(__func__); checkApiVersion(__func__, 12); diff --git a/src/replica/HttpQservMonitorModule.h b/src/replica/HttpQservMonitorModule.h index d2565061e3..76cd396880 100644 --- a/src/replica/HttpQservMonitorModule.h +++ b/src/replica/HttpQservMonitorModule.h @@ -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' */ @@ -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