Skip to content

Commit 7694472

Browse files
committed
Post-rebase corrections
The corrections were made to reconcile changes made in both the main branch and in the current one. The following problems were addressed: - both branches introduced changes to the Qmeta schema (up to version 10) - a configuration of the worker's result delivery REST service changed in the main branch - class move was made in the feature branch: qdisp::MessageStore -> qmeta::MessageStore
1 parent 67df437 commit 7694472

8 files changed

+59
-28
lines changed

src/ccontrol/UserQueryQueries.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// Qserv headers
3636
#include "css/CssAccess.h"
3737
#include "css/CssError.h"
38-
#include "qdisp/MessageStore.h"
38+
#include "qmeta/MessageStore.h"
3939
#include "qmeta/Exceptions.h"
4040
#include "qmeta/QMetaSelect.h"
4141
#include "query/FromList.h"
@@ -68,7 +68,7 @@ UserQueryQueries::UserQueryQueries(std::shared_ptr<query::SelectStmt> const& sta
6868
: _resultDbConn(resultDbConn),
6969
_qMetaSelect(qMetaSelect),
7070
_qMetaCzarId(qMetaCzarId),
71-
_messageStore(std::make_shared<qdisp::MessageStore>()),
71+
_messageStore(std::make_shared<qmeta::MessageStore>()),
7272
_resultTableName(::g_nextResultTableId(userQueryId)),
7373
_resultDb(resultDb) {
7474
// The SQL statement should be mostly OK alredy but we need to change

src/ccontrol/UserQueryQueries.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class UserQueryQueries : public UserQuery {
8989
void discard() override;
9090

9191
// Delegate objects
92-
std::shared_ptr<qdisp::MessageStore> getMessageStore() override { return _messageStore; }
92+
std::shared_ptr<qmeta::MessageStore> getMessageStore() override { return _messageStore; }
9393

9494
/// @return Name of the result table for this query, can be empty
9595
std::string getResultTableName() const override { return _resultTableName; }
@@ -108,7 +108,7 @@ class UserQueryQueries : public UserQuery {
108108
std::shared_ptr<qmeta::QMetaSelect> _qMetaSelect;
109109
qmeta::CzarId const _qMetaCzarId; ///< Czar ID in QMeta database
110110
QueryState _qState = UNKNOWN;
111-
std::shared_ptr<qdisp::MessageStore> _messageStore;
111+
std::shared_ptr<qmeta::MessageStore> _messageStore;
112112
std::string _resultTableName;
113113
std::string _query; ///< query to execute on QMeta database
114114
std::string _orderBy;

src/qmeta/QMetaMysql.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ using namespace std;
5050
namespace {
5151

5252
// Current version of QMeta schema
53-
char const VERSION_STR[] = "10";
53+
char const VERSION_STR[] = "11";
5454

5555
LOG_LOGGER _log = LOG_GET("lsst.qserv.qmeta.QMetaMysql");
5656

src/qmeta/schema/migrate-10-to-11.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE IF NOT EXISTS `chunkMap` (
2+
`worker` VARCHAR(256) NOT NULL COMMENT 'A unique identifier of a worker hosting the chunk replica',
3+
`database` VARCHAR(256) NOT NULL COMMENT 'The name of a database',
4+
`table` VARCHAR(256) NOT NULL COMMENT 'The name of a table',
5+
`chunk` INT UNSIGNED NOT NULL COMMENT 'The number of a chunk',
6+
`size` BIGINT UNSIGNED NOT NULL COMMENT 'The size of a chunk')
7+
ENGINE = InnoDB
8+
COMMENT = 'Chunk disposition across workers';
9+
10+
CREATE TABLE IF NOT EXISTS `chunkMapStatus` (
11+
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The most recent update time of the map')
12+
ENGINE = InnoDB
13+
COMMENT = 'Satus info on the chunk map';

src/qmeta/schema/migrate-None-to-10.sql.jinja renamed to src/qmeta/schema/migrate-None-to-11.sql.jinja

+24-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,28 @@ CREATE TABLE IF NOT EXISTS `QMessages` (
195195
ENGINE = InnoDB
196196
COMMENT = 'Table of messages generated during queries.';
197197

198+
-- -----------------------------------------------------
199+
-- Table `chunkMap`
200+
-- -----------------------------------------------------
201+
202+
CREATE TABLE IF NOT EXISTS `chunkMap` (
203+
`worker` VARCHAR(256) NOT NULL COMMENT 'A unique identifier of a worker hosting the chunk replica',
204+
`database` VARCHAR(256) NOT NULL COMMENT 'The name of a database',
205+
`table` VARCHAR(256) NOT NULL COMMENT 'The name of a table',
206+
`chunk` INT UNSIGNED NOT NULL COMMENT 'The number of a chunk',
207+
`size` BIGINT UNSIGNED NOT NULL COMMENT 'The size of a chunk')
208+
ENGINE = InnoDB
209+
COMMENT = 'Chunk disposition across workers';
210+
211+
-- -----------------------------------------------------
212+
-- Table `chunkMapStatus`
213+
-- -----------------------------------------------------
214+
215+
CREATE TABLE IF NOT EXISTS `chunkMapStatus` (
216+
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The most recent update time of the map')
217+
ENGINE = InnoDB
218+
COMMENT = 'Satus info on the chunk map';
219+
198220
-- Update version on every schema change.
199221
-- Version 0 corresponds to initial QMeta release and it had no
200222
-- QMetadata table at all.
@@ -208,4 +230,5 @@ COMMENT = 'Table of messages generated during queries.';
208230
-- Version 8 replaced INT with BIGINT in the byte and row counter columns of QInfo.
209231
-- Version 9 removed the full-text index on the query text from QInfo.
210232
-- Version 10 redefined schema of the ProcessList tables.
211-
INSERT INTO `QMetadata` (`metakey`, `value`) VALUES ('version', '10');
233+
-- Version 11 added the worker-to-chunk map tables chunkMap and chunkMapStatus
234+
INSERT INTO `QMetadata` (`metakey`, `value`) VALUES ('version', '11');

src/wbase/Task.cc

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ size_t const MB_SIZE_BYTES = 1024 * 1024;
7676

7777
namespace lsst::qserv::wbase {
7878

79-
string const Task::_fqdn = util::get_current_host_fqdn();
80-
8179
// Task::ChunkEqual functor
8280
bool Task::ChunkEqual::operator()(Task::Ptr const& x, Task::Ptr const& y) {
8381
if (!x || !y) {

src/wbase/UberJobData.cc

+11-16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
using namespace std;
4949
using namespace nlohmann;
5050

51+
namespace fs = boost::filesystem;
52+
5153
namespace {
5254

5355
LOG_LOGGER _log = LOG_GET("lsst.qserv.wbase.UberJobData");
@@ -180,35 +182,28 @@ void UberJobData::_queueUJResponse(http::Method method_, std::vector<std::string
180182
}
181183
}
182184

183-
string UberJobData::buildUjResultFilePath(string const& resultsDirname) {
184-
if (resultsDirname.empty()) return resultsDirname;
185-
boost::filesystem::path path(resultsDirname);
185+
string UberJobData::_resultFileName() const {
186186
// UberJobs have multiple chunks which can each have different attempt numbers.
187187
// However, each CzarID + UberJobId should be unique as UberJobs are not retried.
188-
path /= to_string(getCzarId()) + "-" + to_string(getQueryId()) + "-" + to_string(getUberJobId()) + "-0" +
189-
".proto";
190-
return path.string();
188+
return to_string(getCzarId()) + "-" + to_string(getQueryId()) + "-" + to_string(getUberJobId()) + "-0" +
189+
".proto";
191190
}
192191

193-
string UberJobData::resultFilePath() {
194-
auto const workerConfig = wconfig::WorkerConfig::instance();
195-
string resultFilePath = buildUjResultFilePath(workerConfig->resultsDirname());
196-
return resultFilePath;
192+
string UberJobData::resultFilePath() const {
193+
string const resultsDirname = wconfig::WorkerConfig::instance()->resultsDirname();
194+
if (resultsDirname.empty()) return resultsDirname;
195+
return (fs::path(resultsDirname) / _resultFileName()).string();
197196
}
198197

199-
std::string UberJobData::resultFileHttpUrl() {
198+
std::string UberJobData::resultFileHttpUrl() const {
200199
auto const workerConfig = wconfig::WorkerConfig::instance();
201200
auto const resultDeliveryProtocol = workerConfig->resultDeliveryProtocol();
202-
203-
string resFilePath = resultFilePath();
204-
auto const fqdn = _foreman->getFqdn();
205201
if (resultDeliveryProtocol != wconfig::ConfigValResultDeliveryProtocol::HTTP) {
206202
throw runtime_error("wbase::Task::Task: unsupported results delivery protocol: " +
207203
wconfig::ConfigValResultDeliveryProtocol::toString(resultDeliveryProtocol));
208204
}
209205
// TODO:UJ it seems like this should just be part of the FileChannelShared???
210-
string resultFileHttpUrl = "http://" + fqdn + ":" + to_string(_resultsHttpPort) + resFilePath;
211-
return resultFileHttpUrl;
206+
return "http://" + _foreman->getFqdn() + ":" + to_string(_resultsHttpPort) + "/" + _resultFileName();
212207
}
213208

214209
void UberJobData::cancelAllTasks() {

src/wbase/UberJobData.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ class UberJobData : public std::enable_shared_from_this<UberJobData> {
117117
/// that there is no limit to the number of rows sent back by the worker.
118118
/// Workers can only safely limit rows for queries that have the LIMIT clause without other related
119119
/// clauses like ORDER BY.
120-
int getRowLimit() { return _rowLimit; }
120+
int getRowLimit() const { return _rowLimit; }
121121

122-
std::string buildUjResultFilePath(std::string const& resultsDirname);
123-
std::string resultFilePath();
124-
std::string resultFileHttpUrl();
122+
std::string resultFilePath() const;
123+
std::string resultFileHttpUrl() const;
125124

126125
private:
127126
UberJobData(UberJobId uberJobId, std::string const& czarName, qmeta::CzarId czarId, std::string czarHost,
@@ -130,6 +129,9 @@ class UberJobData : public std::enable_shared_from_this<UberJobData> {
130129
std::string const& workerId, std::shared_ptr<wcontrol::Foreman> const& foreman,
131130
std::string const& authKey, uint16_t resultsHttpPort);
132131

132+
/// Return the name of the file that will contain the results of the query.
133+
std::string _resultFileName() const;
134+
133135
/// Queue the response to be sent to the originating czar.
134136
void _queueUJResponse(http::Method method_, std::vector<std::string> const& headers_,
135137
std::string const& url_, std::string const& requestContext_,

0 commit comments

Comments
 (0)