#include <XrdRequestManager.h>
Classes | |
class | OpenHandler |
Public Types | |
using | IOOffset = edm::storage::IOOffset |
using | IOPosBuffer = edm::storage::IOPosBuffer |
using | IOSize = edm::storage::IOSize |
Public Member Functions | |
void | addConnections (cms::Exception &) const |
std::shared_ptr< XrdCl::File > | getActiveFile () const |
void | getActiveSourceNames (std::vector< std::string > &sources) const |
void | getDisabledSourceNames (std::vector< std::string > &sources) const |
const std::string & | getFilename () const |
void | getPrettyActiveSourceNames (std::vector< std::string > &sources) const |
std::future< IOSize > | handle (void *into, IOSize size, IOOffset off) |
std::future< IOSize > | handle (std::shared_ptr< std::vector< IOPosBuffer >> iolist) |
std::future< IOSize > | handle (std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr) |
RequestManager & | operator= (const RequestManager &)=delete |
void | requestFailure (std::shared_ptr< XrdAdaptor::ClientRequest > c_ptr, XrdCl::Status &c_status) |
RequestManager (const RequestManager &)=delete | |
virtual | ~RequestManager ()=default |
Static Public Member Functions | |
static std::shared_ptr< RequestManager > | getInstance (const std::string &filename, XrdCl::OpenFlags::Flags flags, XrdCl::Access::Mode perms) |
Static Public Attributes | |
static const unsigned int | XRD_DEFAULT_TIMEOUT = 3 * 60 |
Private Member Functions | |
void | broadcastRequest (const ClientRequest &, bool active) |
void | checkSources (timespec &now, IOSize requestSize, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources) |
void | checkSourcesImpl (timespec &now, IOSize requestSize, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources) |
bool | compareSources (const timespec &now, unsigned a, unsigned b, std::vector< std::shared_ptr< Source >> &activeSources, std::vector< std::shared_ptr< Source >> &inactiveSources) const |
virtual void | handleOpen (XrdCl::XRootDStatus &status, std::shared_ptr< Source >) |
void | initialize (std::weak_ptr< RequestManager > selfref) |
std::shared_ptr< Source > | pickSingleSource () |
std::string | prepareOpaqueString () const |
void | queueUpdateCurrentServer (const std::string &) |
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 |
RequestManager (const std::string &filename, XrdCl::OpenFlags::Flags flags, XrdCl::Access::Mode perms) | |
void | splitClientRequest (const std::vector< IOPosBuffer > &iolist, std::vector< IOPosBuffer > &req1, std::vector< IOPosBuffer > &req2, std::vector< std::shared_ptr< Source >> const &activeSources) const |
void | updateCurrentServer () |
Private Attributes | |
std::vector< std::shared_ptr< Source > > | m_activeSources |
oneapi::tbb::concurrent_unordered_set< std::string > | m_disabledExcludeStrings |
oneapi::tbb::concurrent_unordered_set< std::shared_ptr< Source >, SourceHash > | m_disabledSources |
oneapi::tbb::concurrent_unordered_set< std::string > | m_disabledSourceStrings |
std::uniform_real_distribution< float > | m_distribution |
std::atomic< unsigned > | m_excluded_active_count |
XrdCl::OpenFlags::Flags | m_flags |
std::mt19937 | m_generator |
std::vector< std::shared_ptr< Source > > | m_inactiveSources |
timespec | m_lastSourceCheck |
const std::string | m_name |
timespec | m_nextActiveSourceCheck |
bool | m_nextInitialSourceToggle |
std::shared_ptr< OpenHandler > | m_open_handler |
XrdCl::Access::Mode | m_perms |
int | m_redirectLimitDelayScale |
std::atomic< std::string * > | m_serverToAdvertise |
std::recursive_mutex | m_source_mutex |
int | m_timeout |
bool | searchMode |
Definition at line 44 of file XrdRequestManager.h.
Definition at line 48 of file XrdRequestManager.h.
Definition at line 47 of file XrdRequestManager.h.
Definition at line 46 of file XrdRequestManager.h.
|
delete |
Referenced by getInstance().
|
virtualdefault |
|
private |
Definition at line 169 of file XrdRequestManager.cc.
void RequestManager::addConnections | ( | cms::Exception & | ex | ) | const |
Add the list of active connections to the exception extra info.
Definition at line 573 of file XrdRequestManager.cc.
References cms::Exception::addAdditionalInfo(), getDisabledSourceNames(), getPrettyActiveSourceNames(), source, and CalibrationSummaryClient_cfi::sources.
Referenced by getActiveFile(), initialize(), XrdAdaptor::RequestManager::OpenHandler::open(), pickSingleSource(), and requestFailure().
|
private |
Given a request, broadcast it to all sources. If active is true, broadcast is made to all active sources. Otherwise, broadcast is made to the inactive sources.
|
private |
Check our set of active sources. If necessary, this will kick off a search for a new source. The source check is somewhat expensive so it is only done once every second.
Definition at line 371 of file XrdRequestManager.cc.
References CalibrationSummaryClient_cfi::activeSources, checkSourcesImpl(), compareSources(), m_lastSourceCheck, m_nextActiveSourceCheck, submitPVValidationJobs::now, and timeDiffMS().
Referenced by handle().
|
private |
Definition at line 429 of file XrdRequestManager.cc.
References CalibrationSummaryClient_cfi::activeSources, compareSources(), m_distribution, m_generator, m_lastSourceCheck, m_nextActiveSourceCheck, m_open_handler, eostools::move(), submitPVValidationJobs::now, reportSiteChange(), source, timeDiffMS(), XRD_ADAPTOR_LONG_OPEN_DELAY, XRD_ADAPTOR_OPEN_PROBE_PERCENT, XRD_ADAPTOR_SHORT_OPEN_DELAY, and XRD_ADAPTOR_SOURCE_QUALITY_FUDGE.
Referenced by checkSources().
|
private |
Helper function for checkSources; compares the quality of source A versus source B; if source A is significantly worse, remove it from the list of active sources.
NOTE: assumes two sources are active and the caller must already hold m_source_mutex
Definition at line 389 of file XrdRequestManager.cc.
References a, CalibrationSummaryClient_cfi::activeSources, b, XrdAdaptor::Source::getHostname(), SiStripPI::max, submitPVValidationJobs::now, reportSiteChange(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by checkSources(), and checkSourcesImpl().
std::shared_ptr< XrdCl::File > RequestManager::getActiveFile | ( | void | ) | const |
Return a pointer to an active file. Useful for metadata operations.
Definition at line 537 of file XrdRequestManager.cc.
References addConnections(), cms::Exception::addContext(), TauDecayModes::dec, edm::errors::FileReadError, m_activeSources, m_flags, m_name, m_perms, and m_source_mutex.
void RequestManager::getActiveSourceNames | ( | std::vector< std::string > & | sources | ) | const |
Retrieve the names of the active sources (primarily meant to enable meaningful log messages).
Definition at line 550 of file XrdRequestManager.cc.
References m_activeSources, m_source_mutex, source, and CalibrationSummaryClient_cfi::sources.
void RequestManager::getDisabledSourceNames | ( | std::vector< std::string > & | sources | ) | const |
Retrieve the names of the disabled sources (primarily meant to enable meaningful log messages).
Definition at line 566 of file XrdRequestManager.cc.
References m_disabledSourceStrings, source, and CalibrationSummaryClient_cfi::sources.
Referenced by addConnections().
|
inline |
|
inlinestatic |
Some of the callback handlers need a weak_ptr reference to the RequestManager. This allows the callback handler to know when it is OK to invoke RequestManager methods.
Hence, all instances need to be created through this factory function.
Definition at line 116 of file XrdRequestManager.h.
References corrVsCorr::filename, HLT_2023v12_cff::flags, instance, and RequestManager().
void RequestManager::getPrettyActiveSourceNames | ( | std::vector< std::string > & | sources | ) | const |
Definition at line 558 of file XrdRequestManager.cc.
References m_activeSources, m_source_mutex, source, and CalibrationSummaryClient_cfi::sources.
Referenced by addConnections().
|
inline |
Interface for handling a client request.
Definition at line 60 of file XrdRequestManager.h.
References findQualityFiles::size.
std::future< IOSize > XrdAdaptor::RequestManager::handle | ( | std::shared_ptr< std::vector< IOPosBuffer >> | iolist | ) |
Definition at line 717 of file XrdRequestManager.cc.
References a, CalibrationSummaryClient_cfi::activeSources, cms::Exception::addContext(), cms::cuda::assert(), b, TauDecayModes::dec, edm::errors::FileReadError, GET_CLOCK_MONOTONIC, eostools::move(), submitPVValidationJobs::now, AlCaHLTBitMon_ParallelJobs::p, edm::CPUTimer::start(), edm::CPUTimer::stop(), and TrackValidation_cff::task.
std::future< IOSize > RequestManager::handle | ( | std::shared_ptr< XrdAdaptor::ClientRequest > | c_ptr | ) |
Handle a client request. NOTE: The shared_ptr interface is required. Depending on the state of the manager, it may decide to issue multiple requests and return the first successful. In that case, some references to the client request may still be outstanding when this function returns.
Definition at line 612 of file XrdRequestManager.cc.
References CalibrationSummaryClient_cfi::activeSources, cms::cuda::assert(), checkSources(), GET_CLOCK_MONOTONIC, m_activeSources, m_inactiveSources, m_source_mutex, eostools::move(), submitPVValidationJobs::now, pickSingleSource(), and source.
|
privatevirtual |
Handle the file-open response
Definition at line 673 of file XrdRequestManager.cc.
References SiStripPI::min, alignCSCRings::s, source, mps_update::status, XRD_ADAPTOR_LONG_OPEN_DELAY, and XRD_ADAPTOR_SHORT_OPEN_DELAY.
|
private |
Some of the callback handlers (particularly, file-open one) will want to call back into the RequestManager. However, the XrdFile may have already thrown away the reference. Hence, we need a weak_ptr to the original object before we can initialize. This way, callback knows to not reference the RequestManager.
Definition at line 180 of file XrdRequestManager.cc.
References cms::Exception::addAdditionalInfo(), addConnections(), cms::Exception::addContext(), cms::cuda::assert(), cms::Exception::clearAdditionalInfo(), cms::Exception::clearContext(), cms::Exception::clearMessage(), TauDecayModes::dec, XrdAdaptor::Source::determineHostExcludeString(), web.browse_db::env, geometryDiff::file, edm::errors::FileOpenError, spr::find(), GET_CLOCK_MONOTONIC, XrdAdaptor::Source::getDomain(), XrdAdaptor::Source::getHostname(), XrdAdaptor::RequestManager::OpenHandler::getInstance(), XrdAdaptor::Source::getXrootdSiteFromURL(), heavyIonCSV_trainingSettings::idx, m_activeSources, m_disabledExcludeStrings, m_disabledSourceStrings, m_flags, m_lastSourceCheck, m_name, m_nextActiveSourceCheck, m_open_handler, m_perms, m_source_mutex, m_timeout, eostools::move(), pileupDistInMC::oldList, prepareOpaqueString(), queueUpdateCurrentServer(), reportSiteChange(), SendMonitoringInfo(), source, mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, updateCurrentServer(), and XRD_ADAPTOR_SHORT_OPEN_DELAY.
|
delete |
|
private |
Picks a single source for the next operation.
Definition at line 586 of file XrdRequestManager.cc.
References addConnections(), cms::Exception::addContext(), TauDecayModes::dec, edm::errors::FileReadError, m_activeSources, m_flags, m_name, m_nextInitialSourceToggle, m_perms, m_source_mutex, and source.
Referenced by handle().
|
private |
Prepare an opaque string appropriate for asking a redirector to open the current file but avoiding servers which we already have connections to.
Definition at line 639 of file XrdRequestManager.cc.
References submitPVResolutionJobs::count, m_activeSources, m_disabledExcludeStrings, m_inactiveSources, m_source_mutex, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by initialize(), and XrdAdaptor::RequestManager::OpenHandler::open().
|
private |
Definition at line 314 of file XrdRequestManager.cc.
References XrdAdaptor::Source::getHostname(), l1ctLayer2EG_cff::id, m_serverToAdvertise, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by initialize().
|
private |
Anytime we potentially switch sources, update the internal site source list; alert the user if necessary.
Definition at line 341 of file XrdRequestManager.cc.
References XrdAdaptor::Source::getHostname(), mps_fire::i, quality, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().
Referenced by checkSourcesImpl(), compareSources(), initialize(), and requestFailure().
void RequestManager::requestFailure | ( | std::shared_ptr< XrdAdaptor::ClientRequest > | c_ptr, |
XrdCl::Status & | c_status | ||
) |
Handle a failed client request.
Definition at line 818 of file XrdRequestManager.cc.
References cms::Exception::addAdditionalInfo(), addConnections(), cms::Exception::addContext(), TauDecayModes::dec, edm::errors::FileOpenError, edm::errors::FileReadError, spr::find(), GET_CLOCK_MONOTONIC, m_activeSources, m_disabledExcludeStrings, m_disabledSources, m_disabledSourceStrings, m_flags, m_lastSourceCheck, m_name, m_open_handler, m_perms, m_source_mutex, m_timeout, submitPVValidationJobs::now, reportSiteChange(), seconds(), mps_update::status, and mps_check::timeout.
|
private |
Given a client request, split it into two requests lists.
Definition at line 994 of file XrdRequestManager.cc.
References CalibrationSummaryClient_cfi::activeSources, cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cms::cuda::assert(), consumeChunkBack(), consumeChunkFront(), TauDecayModes::dec, edm::errors::FileReadError, SiStripPI::max, edm::storage::IOPosBuffer::offset(), jetUpdater_cfi::sort, contentValuesCheck::ss, validateList(), XRD_ADAPTOR_CHUNK_THRESHOLD, and XRD_CL_MAX_CHUNK.
|
inlineprivate |
Update the StatisticsSenderService, if necessary, with the current server.
Update the StatisticsSenderService with the current server info.
As this accesses the edm::Service infrastructure, this MUST be called from an edm-managed thread. It CANNOT be called from an Xrootd-managed thread.
Definition at line 297 of file XrdRequestManager.cc.
References edm::Service< T >::isAvailable(), LIKELY, m_name, m_serverToAdvertise, edm::storage::StatisticsSenderService::setCurrentServer(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by initialize().
|
private |
Note these member variables can only be accessed when the source mutex is held.
Definition at line 212 of file XrdRequestManager.h.
Referenced by getActiveFile(), getActiveSourceNames(), getPrettyActiveSourceNames(), handle(), initialize(), pickSingleSource(), prepareOpaqueString(), and requestFailure().
|
private |
Definition at line 216 of file XrdRequestManager.h.
Referenced by initialize(), prepareOpaqueString(), and requestFailure().
|
private |
Definition at line 217 of file XrdRequestManager.h.
Referenced by requestFailure().
|
private |
Definition at line 215 of file XrdRequestManager.h.
Referenced by getDisabledSourceNames(), initialize(), and requestFailure().
|
private |
Definition at line 238 of file XrdRequestManager.h.
Referenced by checkSourcesImpl().
|
private |
Definition at line 240 of file XrdRequestManager.h.
|
private |
Definition at line 233 of file XrdRequestManager.h.
Referenced by getActiveFile(), initialize(), XrdAdaptor::RequestManager::OpenHandler::open(), pickSingleSource(), and requestFailure().
|
private |
Definition at line 237 of file XrdRequestManager.h.
Referenced by checkSourcesImpl().
|
private |
Definition at line 213 of file XrdRequestManager.h.
Referenced by handle(), and prepareOpaqueString().
|
private |
Definition at line 223 of file XrdRequestManager.h.
Referenced by checkSources(), checkSourcesImpl(), initialize(), and requestFailure().
|
private |
Definition at line 232 of file XrdRequestManager.h.
Referenced by getActiveFile(), getFilename(), initialize(), XrdAdaptor::RequestManager::OpenHandler::open(), pickSingleSource(), requestFailure(), and updateCurrentServer().
|
private |
Definition at line 228 of file XrdRequestManager.h.
Referenced by checkSources(), checkSourcesImpl(), and initialize().
|
private |
Definition at line 226 of file XrdRequestManager.h.
Referenced by pickSingleSource().
|
private |
Definition at line 299 of file XrdRequestManager.h.
Referenced by checkSourcesImpl(), initialize(), and requestFailure().
|
private |
Definition at line 234 of file XrdRequestManager.h.
Referenced by getActiveFile(), initialize(), XrdAdaptor::RequestManager::OpenHandler::open(), pickSingleSource(), and requestFailure().
|
private |
Definition at line 229 of file XrdRequestManager.h.
|
private |
Definition at line 221 of file XrdRequestManager.h.
Referenced by queueUpdateCurrentServer(), and updateCurrentServer().
|
mutableprivate |
Definition at line 235 of file XrdRequestManager.h.
Referenced by getActiveFile(), getActiveSourceNames(), getPrettyActiveSourceNames(), handle(), initialize(), pickSingleSource(), prepareOpaqueString(), and requestFailure().
|
private |
Definition at line 224 of file XrdRequestManager.h.
Referenced by initialize(), and requestFailure().
|
private |
Definition at line 230 of file XrdRequestManager.h.
|
static |
Definition at line 53 of file XrdRequestManager.h.