7 #include "XrdCl/XrdClFile.hh" 8 #include "XrdCl/XrdClDefaultEnv.hh" 9 #include "XrdCl/XrdClFileSystem.hh" 19 #include "Utilities/XrdAdaptor/src/XrdHostHandler.hh" 21 #define XRD_CL_MAX_CHUNK 512 * 1024 23 #define XRD_ADAPTOR_SHORT_OPEN_DELAY 5 25 #ifdef XRD_FAKE_OPEN_PROBE 26 #define XRD_ADAPTOR_OPEN_PROBE_PERCENT 100 27 #define XRD_ADAPTOR_LONG_OPEN_DELAY 20 29 #define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE 0 31 #define XRD_ADAPTOR_OPEN_PROBE_PERCENT 10 32 #define XRD_ADAPTOR_LONG_OPEN_DELAY 2 * 60 33 #define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE 100 36 #define XRD_ADAPTOR_CHUNK_THRESHOLD 1000 39 #include <mach/clock.h> 40 #include <mach/mach.h> 41 #define GET_CLOCK_MONOTONIC(ts) \ 43 clock_serv_t cclock; \ 44 mach_timespec_t mts; \ 45 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); \ 46 clock_get_time(cclock, &mts); \ 47 mach_port_deallocate(mach_task_self(), cclock); \ 48 ts.tv_sec = mts.tv_sec; \ 49 ts.tv_nsec = mts.tv_nsec; \ 52 #define GET_CLOCK_MONOTONIC(ts) clock_gettime(CLOCK_MONOTONIC, &ts); 58 long long diff = (a.tv_sec - b.tv_sec) * 1000;
59 diff += (a.tv_nsec - b.tv_nsec) / 1e6;
70 XrdCl::Buffer *
buffer =
nullptr;
71 response->Get(buffer);
72 response->Set(static_cast<int *>(
nullptr));
94 file.GetProperty(
"LastURL", lastUrl);
95 if (jobId && !lastUrl.empty()) {
96 XrdCl::URL
url(lastUrl);
97 XrdCl::FileSystem fs(url);
98 if (!(fs.SendInfo(jobId, &nullHandler, 30).IsOK())) {
100 <<
"Failed to send the monitoring information, monitoring ID is " << jobId <<
".";
102 edm::LogInfo(
"XrdAdaptorInternal") <<
"Set monitoring ID to " << jobId <<
".";
107 : m_serverToAdvertise(
nullptr),
108 m_timeout(XRD_DEFAULT_TIMEOUT),
109 m_nextInitialSourceToggle(
false),
113 m_distribution(0, 100),
114 m_excluded_active_count(0) {}
119 XrdCl::Env *
env = XrdCl::DefaultEnv::GetEnv();
121 env->GetInt(
"StreamErrorWindow",
m_timeout);
132 std::unique_ptr<XrdCl::File>
file;
134 bool validFile =
false;
135 const int retries = 5;
137 for (
int idx = 0;
idx < retries;
idx++) {
141 m_name + (!opaque.empty() ? ((
m_name.find(
"?") ==
m_name.npos) ?
"?" :
"&") + opaque :
"");
142 SyncHostResponseHandler handler;
143 XrdCl::XRootDStatus openStatus = file->Open(new_filename,
m_flags,
m_perms, &handler);
152 ex <<
"XrdCl::File::Open(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags <<
", permissions=0" 153 << std::oct <<
m_perms <<
std::dec <<
") => error '" << openStatus.ToStr() <<
"' (errno=" << openStatus.errNo
154 <<
", code=" << openStatus.code <<
")";
156 ex.
addAdditionalInfo(
"Remote server already encountered a fatal error; no redirections were performed.");
159 handler.WaitForResponse();
160 std::unique_ptr<XrdCl::XRootDStatus>
status = handler.GetStatus();
161 std::unique_ptr<XrdCl::HostList> hostList = handler.GetHosts();
164 if (status->IsOK()) {
171 ex <<
"XrdCl::File::Open(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags <<
", permissions=0" 172 << std::oct <<
m_perms <<
std::dec <<
") => error '" << status->ToStr() <<
"' (errno=" << status->errNo
173 <<
", code=" << status->code <<
")";
177 file->GetProperty(
"DataServer", dataServer);
178 file->GetProperty(
"LastURL", lastUrl);
179 if (!dataServer.empty()) {
182 if (!lastUrl.empty()) {
184 edm::LogWarning(
"XrdAdaptorInternal") <<
"Failed to open file at URL " << lastUrl <<
".";
188 ex <<
". No additional data servers were found.";
191 if (!dataServer.empty()) {
196 if (lastUrl == new_filename) {
197 edm::LogWarning(
"XrdAdaptorInternal") << lastUrl <<
", " << new_filename;
210 auto source = std::make_shared<Source>(ts,
std::move(file), excludeString);
241 std::unique_ptr<std::string> hostname(hostname_ptr);
250 auto hostname = std::make_unique<std::string>(
id);
260 std::string formatSites(std::vector<std::shared_ptr<Source>>
const &iSources) {
262 if (!iSources.empty()) {
263 siteA = iSources[0]->Site();
265 if (iSources.size() == 2) {
266 siteB = iSources[1]->Site();
269 if (!siteB.empty() && (siteB != siteA)) {
270 siteList = siteA +
", " + siteB;
277 std::vector<std::shared_ptr<Source>>
const &iNew,
279 auto siteList = formatSites(iNew);
280 if (!orig_site.empty() && (orig_site != siteList)) {
281 edm::LogWarning(
"XrdAdaptor") <<
"Data is served from " << siteList <<
" instead of original site " << orig_site;
283 auto oldSites = formatSites(iOld);
284 if (orig_site.empty() && (siteList != oldSites)) {
285 if (!oldSites.empty())
286 edm::LogWarning(
"XrdAdaptor") <<
"Data is now served from " << siteList <<
" instead of previous " << oldSites;
293 std::vector<std::shared_ptr<Source>> &activeSources,
294 std::vector<std::shared_ptr<Source>> &inactiveSources) {
312 std::vector<std::shared_ptr<Source>> &activeSources,
313 std::vector<std::shared_ptr<Source>> &inactiveSources)
const {
314 if (activeSources.size() <
std::max(a, b) + 1) {
318 bool findNewSource =
false;
319 if ((activeSources[a]->getQuality() > 5130) ||
320 ((activeSources[
a]->getQuality() > 260) &&
321 (activeSources[b]->getQuality() * 4 < activeSources[
a]->getQuality()))) {
323 <<
"Removing " << activeSources[
a]->PrettyID() <<
" from active sources due to poor quality (" 324 << activeSources[
a]->getQuality() <<
" vs " << activeSources[
b]->getQuality() <<
")" << std::endl;
325 if (activeSources[a]->getLastDowngrade().tv_sec != 0) {
326 findNewSource =
true;
328 activeSources[
a]->setLastDowngrade(now);
329 inactiveSources.emplace_back(activeSources[a]);
330 auto oldSources = activeSources;
331 activeSources.erase(activeSources.begin() +
a);
334 return findNewSource;
339 std::vector<std::shared_ptr<Source>> &activeSources,
340 std::vector<std::shared_ptr<Source>> &inactiveSources) {
341 bool findNewSource =
false;
342 if (activeSources.size() <= 1) {
343 findNewSource =
true;
344 }
else if (activeSources.size() > 1) {
345 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Source 0 quality " << activeSources[0]->getQuality()
346 <<
", source 1 quality " << activeSources[1]->getQuality() << std::endl;
347 findNewSource |=
compareSources(now, 0, 1, activeSources, inactiveSources);
348 findNewSource |=
compareSources(now, 1, 0, activeSources, inactiveSources);
352 std::vector<std::shared_ptr<Source>> eligibleInactiveSources;
353 eligibleInactiveSources.reserve(inactiveSources.size());
354 for (
const auto &
source : inactiveSources) {
356 eligibleInactiveSources.push_back(
source);
359 auto bestInactiveSource =
360 std::min_element(eligibleInactiveSources.begin(),
361 eligibleInactiveSources.end(),
362 [](
const std::shared_ptr<Source> &s1,
const std::shared_ptr<Source> &
s2) {
363 return s1->getQuality() <
s2->getQuality();
365 auto worstActiveSource = std::max_element(activeSources.cbegin(),
366 activeSources.cend(),
367 [](
const std::shared_ptr<Source> &s1,
const std::shared_ptr<Source> &
s2) {
368 return s1->getQuality() <
s2->getQuality();
370 if (bestInactiveSource != eligibleInactiveSources.end() && bestInactiveSource->get()) {
371 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Best inactive source: " << (*bestInactiveSource)->PrettyID()
372 <<
", quality " << (*bestInactiveSource)->getQuality();
374 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Worst active source: " << (*worstActiveSource)->PrettyID()
375 <<
", quality " << (*worstActiveSource)->getQuality();
378 if ((bestInactiveSource != eligibleInactiveSources.end()) && activeSources.size() == 1 &&
379 ((*bestInactiveSource)->getQuality() < 4 * activeSources[0]->getQuality())) {
380 auto oldSources = activeSources;
381 activeSources.push_back(*bestInactiveSource);
383 for (
auto it = inactiveSources.begin(); it != inactiveSources.end(); it++)
384 if (it->get() == bestInactiveSource->get()) {
385 inactiveSources.erase(it);
389 while ((bestInactiveSource != eligibleInactiveSources.end()) &&
390 (*worstActiveSource)->getQuality() >
393 <<
"Removing " << (*worstActiveSource)->PrettyID() <<
" from active sources due to quality (" 394 << (*worstActiveSource)->getQuality() <<
") and promoting " << (*bestInactiveSource)->PrettyID()
395 <<
" (quality: " << (*bestInactiveSource)->getQuality() <<
")" << std::endl;
396 (*worstActiveSource)->setLastDowngrade(now);
397 for (
auto it = inactiveSources.begin(); it != inactiveSources.end(); it++)
398 if (it->get() == bestInactiveSource->get()) {
399 inactiveSources.erase(it);
402 inactiveSources.emplace_back(
std::move(*worstActiveSource));
403 auto oldSources = activeSources;
404 activeSources.erase(worstActiveSource);
405 activeSources.emplace_back(
std::move(*bestInactiveSource));
407 eligibleInactiveSources.clear();
408 for (
const auto &
source : inactiveSources)
410 eligibleInactiveSources.push_back(
source);
411 bestInactiveSource = std::min_element(eligibleInactiveSources.begin(),
412 eligibleInactiveSources.end(),
413 [](
const std::shared_ptr<Source> &s1,
const std::shared_ptr<Source> &
s2) {
414 return s1->getQuality() <
s2->getQuality();
416 worstActiveSource = std::max_element(activeSources.begin(),
418 [](
const std::shared_ptr<Source> &s1,
const std::shared_ptr<Source> &
s2) {
419 return s1->getQuality() <
s2->getQuality();
425 findNewSource =
true;
435 if (activeSources.size() == 2) {
447 ex <<
"XrdAdaptor::RequestManager::getActiveFile(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 448 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
") => Source used after fatal exception.";
449 ex.
addContext(
"In XrdAdaptor::RequestManager::handle()");
460 sources.push_back(
source->ID());
468 sources.push_back(
source->PrettyID());
475 sources.push_back(
source);
480 std::vector<std::string> sources;
482 for (
auto const &
source : sources) {
487 for (
auto const &
source : sources) {
493 std::shared_ptr<Source>
source =
nullptr;
506 ex <<
"XrdAdaptor::RequestManager::handle read(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 507 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
") => Source used after fatal exception.";
508 ex.
addContext(
"In XrdAdaptor::RequestManager::handle()");
523 std::vector<std::shared_ptr<Source>> activeSources, inactiveSources;
531 std::shared_ptr<void *> guard(
nullptr, [
this, &activeSources, &inactiveSources](
void *) {
537 checkSources(now, c_ptr->getSize(), activeSources, inactiveSources);
541 source->handle(c_ptr);
542 return c_ptr->get_future();
546 std::stringstream ss;
554 ss << it->ExcludeID().substr(0, it->ExcludeID().find(
":")) <<
",";
558 ss << it->ExcludeID().substr(0, it->ExcludeID().find(
":")) <<
",";
563 ss << it.substr(0, it.find(
":")) <<
",";
567 return tmp_str.substr(0, tmp_str.size() - 1);
575 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Successfully opened new source: " << source->PrettyID() << std::endl;
577 if (source->ID() ==
s->ID()) {
579 <<
"Xrootd server returned excluded source " << source->PrettyID() <<
"; ignoring" << std::endl;
582 if (returned_count >= 3) {
589 if (source->ID() ==
s->ID()) {
591 <<
"Xrootd server returned excluded inactive source " << source->PrettyID() <<
"; ignoring" << std::endl;
596 if (m_activeSources.size() < 2) {
598 m_activeSources.push_back(source);
602 m_inactiveSources.push_back(source);
605 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Got failure when trying to open a new source" << std::endl;
614 std::vector<std::shared_ptr<Source>> activeSources, inactiveSources;
621 std::shared_ptr<void *> guard(
nullptr, [
this, &activeSources, &inactiveSources](
void *) {
635 if (activeSources.size() == 1) {
636 auto c_ptr = std::make_shared<XrdAdaptor::ClientRequest>(*
this, iolist);
637 checkSources(now, c_ptr->getSize(), activeSources, inactiveSources);
638 activeSources[0]->handle(c_ptr);
639 return c_ptr->get_future();
642 else if (activeSources.empty()) {
644 ex <<
"XrdAdaptor::RequestManager::handle readv(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 645 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
") => Source used after fatal exception.";
646 ex.
addContext(
"In XrdAdaptor::RequestManager::handle()");
651 assert(iolist.get());
652 auto req1 = std::make_shared<std::vector<IOPosBuffer>>();
653 auto req2 = std::make_shared<std::vector<IOPosBuffer>>();
656 checkSources(now, req1->size() + req2->size(), activeSources, inactiveSources);
658 if (activeSources.size() == 1) {
659 auto c_ptr = std::make_shared<XrdAdaptor::ClientRequest>(*
this, iolist);
660 activeSources[0]->handle(c_ptr);
661 return c_ptr->get_future();
664 std::shared_ptr<XrdAdaptor::ClientRequest> c_ptr1, c_ptr2;
665 std::future<IOSize> future1, future2;
666 if (!req1->empty()) {
668 activeSources[0]->handle(c_ptr1);
669 future1 = c_ptr1->get_future();
671 if (!req2->empty()) {
673 activeSources[1]->handle(c_ptr2);
674 future2 = c_ptr2->get_future();
676 if (!req1->empty() && !req2->empty()) {
677 std::future<IOSize> task =
678 std::async(std::launch::deferred,
679 [](std::future<IOSize>
a, std::future<IOSize>
b) {
693 return b.get() + a.get();
700 }
else if (!req1->empty()) {
702 }
else if (!req2->empty()) {
705 std::promise<IOSize>
p;
707 return p.get_future();
712 std::shared_ptr<Source> source_ptr = c_ptr->getCurrentSource();
715 if (c_status.code == XrdCl::errInvalidResponse) {
716 edm::LogWarning(
"XrdAdaptorInternal") <<
"Invalid response when reading from " << source_ptr->PrettyID();
718 ex <<
"XrdAdaptor::RequestManager::requestFailure readv(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 719 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
", old source=" << source_ptr->PrettyID()
720 <<
") => Invalid ReadV response from server";
721 ex.
addContext(
"In XrdAdaptor::RequestManager::requestFailure()");
725 edm::LogWarning(
"XrdAdaptorInternal") <<
"Request failure when reading from " << source_ptr->PrettyID();
744 std::shared_ptr<Source> new_source;
746 std::shared_future<std::shared_ptr<Source>> future =
m_open_handler->open();
757 ex <<
"XrdAdaptor::RequestManager::requestFailure Open(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 758 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
", old source=" << source_ptr->PrettyID()
759 <<
") => timeout when waiting for file open";
760 ex.
addContext(
"In XrdAdaptor::RequestManager::requestFailure()");
765 new_source = future.get();
767 ex.
addContext(
"Handling XrdAdaptor::RequestManager::requestFailure()");
777 ex <<
"XrdAdaptor::RequestManager::requestFailure Open(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 778 <<
", permissions=0" << std::oct <<
m_perms <<
std::dec <<
", old source=" << source_ptr->PrettyID()
779 <<
", new source=" << new_source->PrettyID() <<
") => Xrootd server returned an excluded source";
780 ex.
addContext(
"In XrdAdaptor::RequestManager::requestFailure()");
792 new_source->handle(c_ptr);
796 std::vector<IOPosBuffer> &
input,
797 std::vector<IOPosBuffer> &
output,
802 if (io.
size() > chunksize) {
810 consumed = chunksize;
814 consumed = chunksize;
817 chunksize -= consumed;
820 void *newdata =
static_cast<char *
>(io.
data()) + consumed;
824 }
else if (io.
size() == 0) {
827 output.push_back(io);
828 chunksize -= io.
size();
835 std::vector<IOPosBuffer> &
input,
836 std::vector<IOPosBuffer> &
output,
841 if (io.
size() > chunksize) {
849 consumed = chunksize;
853 consumed = chunksize;
856 chunksize -= consumed;
859 void *newdata =
static_cast<char *
>(io.
data()) + consumed;
863 }
else if (io.
size() == 0) {
866 output.push_back(io);
867 chunksize -= io.
size();
875 off_t last_offset = -1;
876 for (
const auto &it : req) {
878 assert(it.offset() > last_offset);
879 last_offset = it.offset();
881 assert(it.offset() < 0x1ffffffffff);
883 assert(req.size() <= 1024);
888 std::vector<IOPosBuffer> &req1,
889 std::vector<IOPosBuffer> &req2,
890 std::vector<std::shared_ptr<Source>>
const &activeSources)
const {
893 std::vector<IOPosBuffer> tmp_iolist(iolist.begin(), iolist.end());
894 req1.reserve(iolist.size() / 2 + 1);
895 req2.reserve(iolist.size() / 2 + 1);
899 float q1 =
static_cast<float>(activeSources[0]->getQuality()) + 5;
900 float q2 =
static_cast<float>(activeSources[1]->getQuality()) + 5;
904 static_cast<IOSize>(1024));
906 static_cast<IOSize>(1024));
909 for (
const auto &it : iolist)
910 size_orig += it.size();
912 while (tmp_iolist.size() - front > 0) {
921 ex <<
"XrdAdaptor::RequestManager::splitClientRequest(name='" <<
m_name <<
"', flags=0x" << std::hex <<
m_flags 923 <<
") => Unable to split request between active servers. This is an unexpected internal error and should be " 924 "reported to CMSSW developers.";
925 ex.
addContext(
"In XrdAdaptor::RequestManager::requestFailure()");
927 std::stringstream ss;
928 ss <<
"Original request size " << iolist.size() <<
"(" << size_orig <<
" bytes)";
930 std::stringstream ss2;
931 ss2 <<
"Quality source 1 " << q1 - 5 <<
", quality source 2: " << q2 - 5;
943 return left.
offset() < right.offset();
946 return left.
offset() < right.offset();
952 assert(size_orig == size1 + size2);
954 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Original request size " << iolist.size() <<
" (" << size_orig
955 <<
" bytes) split into requests size " << req1.size() <<
" (" << size1
956 <<
" bytes) and " << req2.size() <<
" (" << size2 <<
" bytes)" << std::endl;
967 XrdCl::HostList *hostList_ptr) {
971 std::unique_ptr<OpenHandler, std::function<void(OpenHandler *)>> outstanding_guard(
974 std::shared_ptr<Source>
source;
975 std::unique_ptr<XrdCl::XRootDStatus>
status(status_ptr);
976 std::unique_ptr<XrdCl::HostList> hostList(hostList_ptr);
979 std::shared_ptr<OpenHandler>
self =
m_self;
990 std::unique_ptr<XrdCl::File> releaseFile;
992 std::lock_guard<std::recursive_mutex> sentry(
m_mutex);
994 if (status->IsOK()) {
1007 ex <<
"XrdCl::File::Open(name='" << manager->m_name <<
"', flags=0x" << std::hex << manager->m_flags
1008 <<
", permissions=0" << std::oct << manager->m_perms <<
std::dec <<
") => error '" << status->ToStr()
1009 <<
"' (errno=" << status->errNo <<
", code=" << status->code <<
")";
1010 ex.
addContext(
"In XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts()");
1011 manager->addConnections(ex);
1013 m_promise.set_exception(std::make_exception_ptr(ex));
1016 manager->handleOpen(*status, source);
1020 std::lock_guard<std::recursive_mutex> sentry(
m_mutex);
1023 return "(no open in progress)";
1026 m_file->GetProperty(
"DataServer", dataServer);
1027 if (dataServer.empty()) {
1028 return "(unknown source)";
1037 ex <<
"XrdCl::File::Open() =>" 1038 <<
" error: OpenHandler called within an invalid RequestManager context." 1039 <<
" This is a logic error and should be reported to the CMSSW developers.";
1040 ex.
addContext(
"Calling XrdAdaptor::RequestManager::OpenHandler::open()");
1047 ex <<
"XrdCl::File::Open() => error: " 1048 <<
"OpenHandler called after it was deleted. This is a logic error " 1049 <<
"and should be reported to the CMSSW developers.";
1050 ex.
addContext(
"Calling XrdAdapter::RequestManager::OpenHandler::open()");
1066 std::lock_guard<std::recursive_mutex> sentry(
m_mutex);
1067 std::promise<std::shared_ptr<Source>> new_promise;
1073 edm::LogVerbatim(
"XrdAdaptorInternal") <<
"Trying to open URL: " << new_name;
1078 std::unique_ptr<OpenHandler, std::function<void(OpenHandler *)>> exit_guard(
this, [&](
OpenHandler *) {
1083 XrdCl::XRootDStatus
status;
1086 ex <<
"XrdCl::File::Open(name='" << new_name <<
"', flags=0x" << std::hex << manager.
m_flags <<
", permissions=0" 1087 << std::oct << manager.
m_perms <<
std::dec <<
") => error '" << status.ToStr() <<
"' (errno=" << status.errNo
1088 <<
", code=" << status.code <<
")";
1089 ex.
addContext(
"Calling XrdAdaptor::RequestManager::OpenHandler::open()");
1093 exit_guard.release();
std::shared_future< std::shared_ptr< Source > > open()
std::shared_ptr< XrdCl::File > getActiveFile() const
void getDisabledSourceNames(std::vector< std::string > &sources) const
RequestManager(const std::string &filename, XrdCl::OpenFlags::Flags flags, XrdCl::Access::Mode perms)
#define GET_CLOCK_MONOTONIC(ts)
std::uniform_real_distribution< float > m_distribution
static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude)
std::string prepareOpaqueString() const
std::vector< Variable::Flags > flags
std::atomic< bool > m_outstanding_open
OpenHandler(std::weak_ptr< RequestManager > manager)
std::shared_ptr< OpenHandler > m_self
virtual void handleOpen(XrdCl::XRootDStatus &status, std::shared_ptr< Source >)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::weak_ptr< OpenHandler > m_self_weak
SendMonitoringInfoHandler nullHandler
static std::string const input
#define XRD_ADAPTOR_CHUNK_THRESHOLD
#define XRD_ADAPTOR_SOURCE_QUALITY_FUDGE
static void SendMonitoringInfo(XrdCl::File &file)
void set_data(void *new_buffer)
void set_size(IOSize new_size)
void addConnections(cms::Exception &) const
void splitClientRequest(const std::vector< IOPosBuffer > &iolist, std::vector< IOPosBuffer > &req1, std::vector< IOPosBuffer > &req2, std::vector< std::shared_ptr< Source >> const &activeSources) const
std::shared_future< std::shared_ptr< Source > > m_shared_future
void queueUpdateCurrentServer(const std::string &)
std::weak_ptr< RequestManager > m_manager
long long timeDiffMS(const timespec &a, const timespec &b)
bool compareSources(const timespec &now, unsigned a, unsigned b, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources) const
void set_offset(IOOffset new_offset)
static bool getDomain(const std::string &host, std::string &domain)
std::vector< std::shared_ptr< Source > > m_inactiveSources
static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList=nullptr)
std::atomic< std::string * > m_serverToAdvertise
tbb::concurrent_unordered_set< std::string > m_disabledSourceStrings
void checkSourcesImpl(timespec &now, IOSize requestSize, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources)
#define XRD_ADAPTOR_OPEN_PROBE_PERCENT
void addAdditionalInfo(std::string const &info)
timespec m_nextActiveSourceCheck
void getPrettyActiveSourceNames(std::vector< std::string > &sources) const
tbb::concurrent_unordered_set< std::shared_ptr< Source >, SourceHash > m_disabledSources
std::string current_source()
std::shared_ptr< OpenHandler > m_open_handler
IOOffset offset(void) const
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
void requestFailure(std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr, XrdCl::Status &c_status)
void HandleResponseWithHosts(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response, XrdCl::HostList *hostList) override
void getActiveSourceNames(std::vector< std::string > &sources) const
XrdCl::OpenFlags::Flags m_flags
std::recursive_mutex m_mutex
static std::shared_ptr< OpenHandler > getInstance(std::weak_ptr< RequestManager > manager)
void setCurrentServer(const std::string &urlOrLfn, const std::string &servername)
static void consumeChunkFront(size_t &front, std::vector< IOPosBuffer > &input, std::vector< IOPosBuffer > &output, IOSize chunksize)
#define XRD_ADAPTOR_LONG_OPEN_DELAY
std::vector< std::shared_ptr< Source > > m_activeSources
XrdCl::Access::Mode m_perms
void addContext(std::string const &context)
tbb::concurrent_unordered_set< std::string > m_disabledExcludeStrings
std::atomic< unsigned > m_excluded_active_count
static const char * getJobID()
std::shared_ptr< Source > pickSingleSource()
static bool getXrootdSiteFromURL(std::string url, std::string &site)
static IOSize validateList(const std::vector< IOPosBuffer > req)
void updateCurrentServer()
std::unique_ptr< XrdCl::File > m_file
#define XRD_ADAPTOR_SHORT_OPEN_DELAY
static void consumeChunkBack(size_t front, std::vector< IOPosBuffer > &input, std::vector< IOPosBuffer > &output, IOSize chunksize)
void reportSiteChange(std::vector< std::shared_ptr< Source > > const &iOld, std::vector< std::shared_ptr< Source > > const &iNew, std::string orig_site=std::string{}) const
std::future< IOSize > handle(void *into, IOSize size, IOOffset off)
std::promise< std::shared_ptr< Source > > m_promise
static bool getHostname(const std::string &id, std::string &hostname)
static std::string const source
void clearAdditionalInfo()
std::recursive_mutex m_source_mutex
bool m_nextInitialSourceToggle
timespec m_lastSourceCheck
void initialize(std::weak_ptr< RequestManager > selfref)
void checkSources(timespec &now, IOSize requestSize, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources)