-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated Czar management protocol to use the REST API
- Loading branch information
1 parent
33321ef
commit a10694d
Showing
12 changed files
with
618 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/GetConfigQservCzarMgtRequest.h" | ||
|
||
// LSST headers | ||
#include "lsst/log/Log.h" | ||
|
||
using namespace std; | ||
|
||
namespace { | ||
|
||
LOG_LOGGER _log = LOG_GET("lsst.qserv.replica.GetConfigQservCzarMgtRequest"); | ||
|
||
} // namespace | ||
|
||
namespace lsst::qserv::replica { | ||
|
||
shared_ptr<GetConfigQservCzarMgtRequest> GetConfigQservCzarMgtRequest::create( | ||
shared_ptr<ServiceProvider> const& serviceProvider, string const& czarName, | ||
GetConfigQservCzarMgtRequest::CallbackType const& onFinish) { | ||
return shared_ptr<GetConfigQservCzarMgtRequest>( | ||
new GetConfigQservCzarMgtRequest(serviceProvider, czarName, onFinish)); | ||
} | ||
|
||
GetConfigQservCzarMgtRequest::GetConfigQservCzarMgtRequest( | ||
shared_ptr<ServiceProvider> const& serviceProvider, string const& czarName, | ||
GetConfigQservCzarMgtRequest::CallbackType const& onFinish) | ||
: QservCzarMgtRequest(serviceProvider, "QSERV_CZAR_GET_CONFIG", czarName), _onFinish(onFinish) {} | ||
|
||
void GetConfigQservCzarMgtRequest::createHttpReqImpl(replica::Lock const& lock) { | ||
string const service = "/config"; | ||
createHttpReq(lock, service); | ||
} | ||
|
||
void GetConfigQservCzarMgtRequest::notify(replica::Lock const& lock) { | ||
LOGS(_log, LOG_LVL_TRACE, context() << __func__); | ||
notifyDefaultImpl<GetConfigQservCzarMgtRequest>(lock, _onFinish); | ||
} | ||
|
||
} // namespace lsst::qserv::replica |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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_GETCONFIGQSERVCZARMGTREQUEST_H | ||
#define LSST_QSERV_REPLICA_GETCONFIGQSERVCZARMGTREQUEST_H | ||
|
||
// System headers | ||
#include <memory> | ||
#include <string> | ||
|
||
// Qserv headers | ||
#include "replica/QservCzarMgtRequest.h" | ||
|
||
namespace lsst::qserv::replica { | ||
class ServiceProvider; | ||
} // namespace lsst::qserv::replica | ||
|
||
// This header declarations | ||
namespace lsst::qserv::replica { | ||
|
||
/** | ||
* Class GetConfigQservCzarMgtRequest is a request for obtaining configuration parameters | ||
* of the Qserv Czar. | ||
*/ | ||
class GetConfigQservCzarMgtRequest : public QservCzarMgtRequest { | ||
public: | ||
typedef std::shared_ptr<GetConfigQservCzarMgtRequest> Ptr; | ||
|
||
/// The function type for notifications on the completion of the request | ||
typedef std::function<void(Ptr)> CallbackType; | ||
|
||
GetConfigQservCzarMgtRequest() = delete; | ||
GetConfigQservCzarMgtRequest(GetConfigQservCzarMgtRequest const&) = delete; | ||
GetConfigQservCzarMgtRequest& operator=(GetConfigQservCzarMgtRequest const&) = delete; | ||
|
||
virtual ~GetConfigQservCzarMgtRequest() override = 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 czarName The name of a Czar 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<GetConfigQservCzarMgtRequest> create( | ||
std::shared_ptr<ServiceProvider> const& serviceProvider, std::string const& czarName, | ||
CallbackType const& onFinish = nullptr); | ||
|
||
protected: | ||
/// @see QservMgtRequest::createHttpReqImpl() | ||
virtual void createHttpReqImpl(replica::Lock const& lock) override; | ||
|
||
/// @see QservMgtRequest::notify() | ||
virtual void notify(replica::Lock const& lock) override; | ||
|
||
private: | ||
/// @see GetConfigQservCzarMgtRequest::create() | ||
GetConfigQservCzarMgtRequest(std::shared_ptr<ServiceProvider> const& serviceProvider, | ||
std::string const& czarName, CallbackType const& onFinish); | ||
|
||
// Input parameters | ||
|
||
CallbackType _onFinish; ///< This callback is reset after finishing the request. | ||
}; | ||
|
||
} // namespace lsst::qserv::replica | ||
|
||
#endif // LSST_QSERV_REPLICA_GETCONFIGQSERVCZARMGTREQUEST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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/GetQueryProgressQservCzarMgtRequest.h" | ||
|
||
// Qserv headers | ||
#include "util/String.h" | ||
|
||
// LSST headers | ||
#include "lsst/log/Log.h" | ||
|
||
using namespace std; | ||
|
||
namespace { | ||
|
||
LOG_LOGGER _log = LOG_GET("lsst.qserv.replica.GetQueryProgressQservCzarMgtRequest"); | ||
|
||
} // namespace | ||
|
||
namespace lsst::qserv::replica { | ||
|
||
shared_ptr<GetQueryProgressQservCzarMgtRequest> GetQueryProgressQservCzarMgtRequest::create( | ||
shared_ptr<ServiceProvider> const& serviceProvider, string const& czarName, | ||
vector<QueryId> const& queryIds, unsigned int lastSeconds, | ||
GetQueryProgressQservCzarMgtRequest::CallbackType const& onFinish) { | ||
return shared_ptr<GetQueryProgressQservCzarMgtRequest>(new GetQueryProgressQservCzarMgtRequest( | ||
serviceProvider, czarName, queryIds, lastSeconds, onFinish)); | ||
} | ||
|
||
GetQueryProgressQservCzarMgtRequest::GetQueryProgressQservCzarMgtRequest( | ||
shared_ptr<ServiceProvider> const& serviceProvider, string const& czarName, | ||
vector<QueryId> const& queryIds, unsigned int lastSeconds, | ||
GetQueryProgressQservCzarMgtRequest::CallbackType const& onFinish) | ||
: QservCzarMgtRequest(serviceProvider, "QSERV_CZAR_GET_QUERY_PROGRESS", czarName), | ||
_queryIds(queryIds), | ||
_lastSeconds(lastSeconds), | ||
_onFinish(onFinish) {} | ||
|
||
void GetQueryProgressQservCzarMgtRequest::createHttpReqImpl(replica::Lock const& lock) { | ||
string const service = "/query-progress"; | ||
string query; | ||
query += "?query_ids=" + util::String::toString(_queryIds); | ||
query += "&last_seconds=" + to_string(_lastSeconds); | ||
createHttpReq(lock, service, query); | ||
} | ||
|
||
void GetQueryProgressQservCzarMgtRequest::notify(replica::Lock const& lock) { | ||
LOGS(_log, LOG_LVL_TRACE, context() << __func__); | ||
notifyDefaultImpl<GetQueryProgressQservCzarMgtRequest>(lock, _onFinish); | ||
} | ||
|
||
} // namespace lsst::qserv::replica |
Oops, something went wrong.