Skip to content

Commit

Permalink
Extended Replication system's framework
Browse files Browse the repository at this point in the history
The new design of the Qserv managememt control plain now relies upon
the HTTP protocol to communicate with workers.
  • Loading branch information
iagaponenko committed Nov 18, 2023
1 parent fe9bdf8 commit 2050406
Show file tree
Hide file tree
Showing 14 changed files with 1,516 additions and 21 deletions.
5 changes: 5 additions & 0 deletions src/replica/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ target_sources(replica PRIVATE
FixUpApp.cc
FixUpJob.cc
GetReplicasQservMgtRequest.cc
GetDbStatusQservHttpMgtRequest.cc
GetDbStatusQservMgtRequest.cc
GetConfigQservHttpMgtRequest.cc
GetConfigQservMgtRequest.cc
GetStatusQservHttpMgtRequest.cc
GetStatusQservMgtRequest.cc
HealthMonitorTask.cc
HttpAsyncReqApp.cc
Expand Down Expand Up @@ -130,6 +133,7 @@ target_sources(replica PRIVATE
PurgeJob.cc
QhttpTestApp.cc
QservGetReplicasJob.cc
QservHttpMgtRequest.cc
QservMgtRequest.cc
QservMgtServices.cc
QservStatusJob.cc
Expand Down Expand Up @@ -202,6 +206,7 @@ target_sources(replica PRIVATE
SuccessRateGenerator.cc
SyncApp.cc
Task.cc
TestEchoQservHttpMgtRequest.cc
TestEchoQservMgtRequest.cc
TransactionContrib.cc
TransactionsApp.cc
Expand Down
60 changes: 60 additions & 0 deletions src/replica/GetConfigQservHttpMgtRequest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* LSST Data Management System
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

// Class header
#include "replica/GetConfigQservHttpMgtRequest.h"

// LSST headers
#include "lsst/log/Log.h"

using namespace std;

namespace {

LOG_LOGGER _log = LOG_GET("lsst.qserv.replica.GetConfigQservHttpMgtRequest");

} // namespace

namespace lsst::qserv::replica {

shared_ptr<GetConfigQservHttpMgtRequest> GetConfigQservHttpMgtRequest::create(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
GetConfigQservHttpMgtRequest::CallbackType const& onFinish) {
return shared_ptr<GetConfigQservHttpMgtRequest>(
new GetConfigQservHttpMgtRequest(serviceProvider, worker, onFinish));
}

GetConfigQservHttpMgtRequest::GetConfigQservHttpMgtRequest(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
GetConfigQservHttpMgtRequest::CallbackType const& onFinish)
: QservHttpMgtRequest(serviceProvider, "QSERV_GET_DATABASE_STATUS", worker), _onFinish(onFinish) {}

void GetConfigQservHttpMgtRequest::createHttpReqImpl(replica::Lock const& lock) {
string const service = "/config";
createHttpReq(lock, service);
}

void GetConfigQservHttpMgtRequest::notify(replica::Lock const& lock) {
LOGS(_log, LOG_LVL_TRACE, context() << __func__);
notifyDefaultImpl<GetConfigQservHttpMgtRequest>(lock, _onFinish);
}

} // namespace lsst::qserv::replica
86 changes: 86 additions & 0 deletions src/replica/GetConfigQservHttpMgtRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* LSST Data Management System
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#ifndef LSST_QSERV_REPLICA_GETCONFIGQSERVHTTPMGTREQUEST_H
#define LSST_QSERV_REPLICA_GETCONFIGQSERVHTTPMGTREQUEST_H

// System headers
#include <memory>
#include <string>

// Qserv headers
#include "replica/QservHttpMgtRequest.h"

namespace lsst::qserv::replica {
class ServiceProvider;
} // namespace lsst::qserv::replica

// This header declarations
namespace lsst::qserv::replica {

/**
* Class GetConfigQservHttpMgtRequest is a request for obtaining various info
* on the database service of the Qserv worker.
*/
class GetConfigQservHttpMgtRequest : public QservHttpMgtRequest {
public:
/// The function type for notifications on the completion of the request
typedef std::function<void(std::shared_ptr<GetConfigQservHttpMgtRequest> const&)> CallbackType;

GetConfigQservHttpMgtRequest() = delete;
GetConfigQservHttpMgtRequest(GetConfigQservHttpMgtRequest const&) = delete;
GetConfigQservHttpMgtRequest& operator=(GetConfigQservHttpMgtRequest const&) = delete;

~GetConfigQservHttpMgtRequest() final = default;

/**
* Static factory method is needed to prevent issues with the lifespan
* and memory management of instances created otherwise (as values or via
* low-level pointers).
* @param serviceProvider A reference to a provider of services for accessing
* Configuration, saving the request's persistent state to the database.
* @param worker The name of a worker to send the request to.
* @param onFinish (optional) callback function to be called upon request completion.
* @return A pointer to the created object.
*/
static std::shared_ptr<GetConfigQservHttpMgtRequest> create(
std::shared_ptr<ServiceProvider> const& serviceProvider, std::string const& worker,
CallbackType const& onFinish = nullptr);

protected:
/// @see QservHttpMgtRequest::createHttpReq()
virtual void createHttpReqImpl(replica::Lock const& lock) final;

/// @see QservHttpMgtRequest::notify()
virtual void notify(replica::Lock const& lock) final;

private:
/// @see GetConfigQservHttpMgtRequest::create()
GetConfigQservHttpMgtRequest(std::shared_ptr<ServiceProvider> const& serviceProvider,
std::string const& worker, CallbackType const& onFinish);

// Input parameters

CallbackType _onFinish; ///< this object is reset after finishing the request
};

} // namespace lsst::qserv::replica

#endif // LSST_QSERV_REPLICA_GETCONFIGQSERVHTTPMGTREQUEST_H
60 changes: 60 additions & 0 deletions src/replica/GetDbStatusQservHttpMgtRequest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* LSST Data Management System
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

// Class header
#include "replica/GetDbStatusQservHttpMgtRequest.h"

// LSST headers
#include "lsst/log/Log.h"

using namespace std;

namespace {

LOG_LOGGER _log = LOG_GET("lsst.qserv.replica.GetDbStatusQservHttpMgtRequest");

} // namespace

namespace lsst::qserv::replica {

shared_ptr<GetDbStatusQservHttpMgtRequest> GetDbStatusQservHttpMgtRequest::create(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
GetDbStatusQservHttpMgtRequest::CallbackType const& onFinish) {
return shared_ptr<GetDbStatusQservHttpMgtRequest>(
new GetDbStatusQservHttpMgtRequest(serviceProvider, worker, onFinish));
}

GetDbStatusQservHttpMgtRequest::GetDbStatusQservHttpMgtRequest(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
GetDbStatusQservHttpMgtRequest::CallbackType const& onFinish)
: QservHttpMgtRequest(serviceProvider, "QSERV_GET_DATABASE_STATUS", worker), _onFinish(onFinish) {}

void GetDbStatusQservHttpMgtRequest::createHttpReqImpl(replica::Lock const& lock) {
string const service = "/mysql";
createHttpReq(lock, service);
}

void GetDbStatusQservHttpMgtRequest::notify(replica::Lock const& lock) {
LOGS(_log, LOG_LVL_TRACE, context() << __func__);
notifyDefaultImpl<GetDbStatusQservHttpMgtRequest>(lock, _onFinish);
}

} // namespace lsst::qserv::replica
86 changes: 86 additions & 0 deletions src/replica/GetDbStatusQservHttpMgtRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* LSST Data Management System
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#ifndef LSST_QSERV_REPLICA_GETDBSTATUSQSERVHTTPMGTREQUEST_H
#define LSST_QSERV_REPLICA_GETDBSTATUSQSERVHTTPMGTREQUEST_H

// System headers
#include <memory>
#include <string>

// Qserv headers
#include "replica/QservHttpMgtRequest.h"

namespace lsst::qserv::replica {
class ServiceProvider;
} // namespace lsst::qserv::replica

// This header declarations
namespace lsst::qserv::replica {

/**
* Class GetDbStatusQservHttpMgtRequest is a request for obtaining various info
* on the database service of the Qserv worker.
*/
class GetDbStatusQservHttpMgtRequest : public QservHttpMgtRequest {
public:
/// The function type for notifications on the completion of the request
typedef std::function<void(std::shared_ptr<GetDbStatusQservHttpMgtRequest> const&)> CallbackType;

GetDbStatusQservHttpMgtRequest() = delete;
GetDbStatusQservHttpMgtRequest(GetDbStatusQservHttpMgtRequest const&) = delete;
GetDbStatusQservHttpMgtRequest& operator=(GetDbStatusQservHttpMgtRequest const&) = delete;

~GetDbStatusQservHttpMgtRequest() final = default;

/**
* Static factory method is needed to prevent issues with the lifespan
* and memory management of instances created otherwise (as values or via
* low-level pointers).
* @param serviceProvider A reference to a provider of services for accessing
* Configuration, saving the request's persistent state to the database.
* @param worker The name of a worker to send the request to.
* @param onFinish (optional) callback function to be called upon request completion.
* @return A pointer to the created object.
*/
static std::shared_ptr<GetDbStatusQservHttpMgtRequest> create(
std::shared_ptr<ServiceProvider> const& serviceProvider, std::string const& worker,
CallbackType const& onFinish = nullptr);

protected:
/// @see QservHttpMgtRequest::createHttpReq()
virtual void createHttpReqImpl(replica::Lock const& lock) final;

/// @see QservHttpMgtRequest::notify()
virtual void notify(replica::Lock const& lock) final;

private:
/// @see GetDbStatusQservHttpMgtRequest::create()
GetDbStatusQservHttpMgtRequest(std::shared_ptr<ServiceProvider> const& serviceProvider,
std::string const& worker, CallbackType const& onFinish);

// Input parameters

CallbackType _onFinish; ///< this object is reset after finishing the request
};

} // namespace lsst::qserv::replica

#endif // LSST_QSERV_REPLICA_GETDBSTATUSQSERVHTTPMGTREQUEST_H
63 changes: 63 additions & 0 deletions src/replica/GetStatusQservHttpMgtRequest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* LSST Data Management System
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

// Class header
#include "replica/GetStatusQservHttpMgtRequest.h"

// LSST headers
#include "lsst/log/Log.h"

using namespace std;

namespace {

LOG_LOGGER _log = LOG_GET("lsst.qserv.replica.GetStatusQservHttpMgtRequest");

} // namespace

namespace lsst::qserv::replica {

shared_ptr<GetStatusQservHttpMgtRequest> GetStatusQservHttpMgtRequest::create(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
wbase::TaskSelector const& taskSelector, GetStatusQservHttpMgtRequest::CallbackType const& onFinish) {
return shared_ptr<GetStatusQservHttpMgtRequest>(
new GetStatusQservHttpMgtRequest(serviceProvider, worker, taskSelector, onFinish));
}

GetStatusQservHttpMgtRequest::GetStatusQservHttpMgtRequest(
shared_ptr<ServiceProvider> const& serviceProvider, string const& worker,
wbase::TaskSelector const& taskSelector, GetStatusQservHttpMgtRequest::CallbackType const& onFinish)
: QservHttpMgtRequest(serviceProvider, "QSERV_GET_STATUS", worker),
_taskSelector(taskSelector),
_onFinish(onFinish) {}

void GetStatusQservHttpMgtRequest::createHttpReqImpl(replica::Lock const& lock) {
string const service = "/status";
string const query = wbase::taskSelectorToHttpQuery(_taskSelector);
createHttpReq(lock, service, query);
}

void GetStatusQservHttpMgtRequest::notify(replica::Lock const& lock) {
LOGS(_log, LOG_LVL_TRACE, context() << __func__);
notifyDefaultImpl<GetStatusQservHttpMgtRequest>(lock, _onFinish);
}

} // namespace lsst::qserv::replica
Loading

0 comments on commit 2050406

Please sign in to comment.