-
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.
Czar and workers can send http messages to each other.
- Loading branch information
Showing
40 changed files
with
1,043 additions
and
399 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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/>. | ||
*/ | ||
|
||
// Class header | ||
#include "czar/HttpCzarWorkerModule.h" | ||
|
||
// System headers | ||
#include <set> | ||
#include <stdexcept> | ||
|
||
// Qserv headers | ||
#include "cconfig/CzarConfig.h" | ||
#include "global/intTypes.h" | ||
#include "http/Exceptions.h" | ||
#include "http/RequestQuery.h" | ||
#include "util/String.h" | ||
|
||
// LSST headers | ||
#include "lsst/log/Log.h" | ||
|
||
using namespace std; | ||
using json = nlohmann::json; | ||
|
||
namespace { | ||
LOG_LOGGER _log = LOG_GET("lsst.qserv.czar.HttpCzarWorkerModule"); | ||
} | ||
|
||
namespace lsst::qserv::czar { | ||
|
||
void HttpCzarWorkerModule::process(string const& context, shared_ptr<qhttp::Request> const& req, | ||
shared_ptr<qhttp::Response> const& resp, string const& subModuleName, | ||
http::AuthType const authType) { | ||
HttpCzarWorkerModule module(context, req, resp); | ||
module.execute(subModuleName, authType); | ||
} | ||
|
||
HttpCzarWorkerModule::HttpCzarWorkerModule(string const& context, shared_ptr<qhttp::Request> const& req, | ||
shared_ptr<qhttp::Response> const& resp) | ||
: HttpModule(context, req, resp) {} | ||
|
||
json HttpCzarWorkerModule::executeImpl(string const& subModuleName) { | ||
string const func = string(__func__) + "[sub-module='" + subModuleName + "']"; | ||
debug(func); | ||
//&&&uj this seems irrelevant for a worker enforceInstanceId(func, cconfig::CzarConfig::instance()->replicationInstanceId()); | ||
enforceCzarName(func); | ||
if (subModuleName == "QUERYJOB-ERROR") | ||
return _queryJobError(); | ||
else if (subModuleName == "QUERYJOB-READY") | ||
return _queryJobReady(); | ||
throw invalid_argument(context() + func + " unsupported sub-module"); | ||
} | ||
|
||
json HttpCzarWorkerModule::_queryJobError() { | ||
debug(__func__); | ||
checkApiVersion(__func__, 34); | ||
LOGS(_log, LOG_LVL_INFO, __func__ << "&&&uj queryJobError json=" << body().objJson); //&&& | ||
//&&&uj NEED CODE for this | ||
return json::object(); | ||
} | ||
|
||
json HttpCzarWorkerModule::_queryJobReady() { | ||
debug(__func__); | ||
checkApiVersion(__func__, 34); | ||
LOGS(_log, LOG_LVL_INFO, __func__ << "&&&uj queryJobReady json=" << body().objJson); //&&& | ||
//&&&uj NEED CODE for this | ||
json ret = {{"success", 1}}; | ||
return json::object(); | ||
} | ||
|
||
} // namespace lsst::qserv::czar |
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,77 @@ | ||
/* | ||
* 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_CZAR_HTTPCZARWORKERMODULE_H | ||
#define LSST_QSERV_CZAR_HTTPCZARWORKERMODULE_H | ||
|
||
// System headers | ||
#include <memory> | ||
#include <string> | ||
|
||
// Third party headers | ||
#include "nlohmann/json.hpp" | ||
|
||
// Qserv headers | ||
#include "czar/HttpModule.h" | ||
|
||
// Forward declarations | ||
namespace lsst::qserv::qhttp { | ||
class Request; | ||
class Response; | ||
} // namespace lsst::qserv::qhttp | ||
|
||
// This header declarations | ||
namespace lsst::qserv::czar { | ||
|
||
/// &&& doc This class is used to handle messages to this czar from workers. | ||
class HttpCzarWorkerModule : public czar::HttpModule { | ||
public: | ||
/// @note supported values for parameter 'subModuleName' are: | ||
/// 'QUERYJOB-ERROR' - error in a QUERYJOB | ||
/// 'QUERYJOB-READY' - | ||
/// @throws std::invalid_argument for unknown values of parameter 'subModuleName' | ||
static void process(std::string const& context, std::shared_ptr<qhttp::Request> const& req, | ||
std::shared_ptr<qhttp::Response> const& resp, std::string const& subModuleName, | ||
http::AuthType const authType = http::AuthType::NONE); | ||
|
||
HttpCzarWorkerModule() = delete; | ||
HttpCzarWorkerModule(HttpCzarWorkerModule const&) = delete; | ||
HttpCzarWorkerModule& operator=(HttpCzarWorkerModule const&) = delete; | ||
|
||
~HttpCzarWorkerModule() final = default; | ||
|
||
protected: | ||
nlohmann::json executeImpl(std::string const& subModuleName) final; | ||
|
||
private: | ||
HttpCzarWorkerModule(std::string const& context, std::shared_ptr<qhttp::Request> const& req, | ||
std::shared_ptr<qhttp::Response> const& resp); | ||
|
||
/// &&& doc | ||
nlohmann::json _queryJobError(); | ||
|
||
/// &&& doc | ||
nlohmann::json _queryJobReady(); | ||
|
||
}; | ||
|
||
} // namespace lsst::qserv::czar | ||
|
||
#endif // LSST_QSERV_CZAR_HTTPCZARWORKERMODULE_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
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
Oops, something went wrong.