Skip to content

Commit

Permalink
Optimized implementation of the worker task to initialize the FQDN once
Browse files Browse the repository at this point in the history
This change increase stability of the worker for potential hiccups
of the DNS services during high frequency query processing.
  • Loading branch information
iagaponenko committed Feb 10, 2025
1 parent ddaef2f commit b23e5ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/wbase/Task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ size_t const MB_SIZE_BYTES = 1024 * 1024;

namespace lsst::qserv::wbase {

string const Task::_fqdn = util::get_current_host_fqdn();

// Task::ChunkEqual functor
bool Task::ChunkEqual::operator()(Task::Ptr const& x, Task::Ptr const& y) {
if (!x || !y) {
Expand Down Expand Up @@ -142,14 +144,13 @@ Task::Task(TaskMsgPtr const& t, int fragmentNumber, shared_ptr<UserQueryInfo> co
auto const resultDeliveryProtocol = workerConfig->resultDeliveryProtocol();
_resultFileName = ::buildResultFileName(t);
_resultFileAbsPath = ::buildResultFilePath(_resultFileName, workerConfig->resultsDirname());
auto const fqdn = util::get_current_host_fqdn();
if (resultDeliveryProtocol == wconfig::ConfigValResultDeliveryProtocol::XROOT) {
// NOTE: one extra '/' after the <host>[:<port>] spec is required to make
// a "valid" XROOTD url.
_resultFileXrootUrl = "xroot://" + fqdn + ":" + to_string(workerConfig->resultsXrootdPort()) + "/" +
_resultFileXrootUrl = "xroot://" + _fqdn + ":" + to_string(workerConfig->resultsXrootdPort()) + "/" +
_resultFileAbsPath;
} else if (resultDeliveryProtocol == wconfig::ConfigValResultDeliveryProtocol::HTTP) {
_resultFileHttpUrl = "http://" + fqdn + ":" + to_string(resultsHttpPort) + "/" + _resultFileName;
_resultFileHttpUrl = "http://" + _fqdn + ":" + to_string(resultsHttpPort) + "/" + _resultFileName;
} else {
throw runtime_error("wbase::Task::Task: unsupported results delivery protocol: " +
wconfig::ConfigValResultDeliveryProtocol::toString(resultDeliveryProtocol));
Expand Down
2 changes: 2 additions & 0 deletions src/wbase/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ class Task : public util::CommandForThreadPool {
TIMEPOINT _bootedTime;

bool _unitTest = false; ///<

static std::string const _fqdn; ///< Fully qualified domain name of the host. Acquired once at startup.
};

} // namespace lsst::qserv::wbase
Expand Down

0 comments on commit b23e5ee

Please sign in to comment.