CMS 3D CMS Logo

XrdSource.h
Go to the documentation of this file.
1 #ifndef Utilities_XrdAdaptor_XrdSource_h
2 #define Utilities_XrdAdaptor_XrdSource_h
3 
4 #include "XrdCl/XrdClXRootDResponses.hh"
6 
7 #include <memory>
8 #include <vector>
9 
10 #include <boost/utility.hpp>
11 
12 #include "QualityMetric.h"
13 
14 namespace XrdCl {
15  class File;
16 }
17 
18 namespace XrdAdaptor {
19 
20  class RequestList;
21  class ClientRequest;
22  class XrdSiteStatistics;
23  class XrdStatisticsService;
24 
25  class Source : public std::enable_shared_from_this<Source>, boost::noncopyable {
26  public:
27  Source(timespec now, std::unique_ptr<XrdCl::File> fileHandle, const std::string &exclude);
28 
29  ~Source();
30 
31  void handle(std::shared_ptr<ClientRequest>);
32 
33  void handle(RequestList &);
34 
35  std::shared_ptr<XrdCl::File> getFileHandle();
36 
37  const std::string &ID() const { return m_id; }
38  const std::string &Site() const { return m_site; }
39  const std::string &PrettyID() const { return m_prettyid; }
40  const std::string &ExcludeID() const { return m_exclude; }
41 
42  unsigned getQuality() { return m_qm->get(); }
43 
44  struct timespec getLastDowngrade() const {
45  return m_lastDowngrade;
46  }
47  void setLastDowngrade(struct timespec now) { m_lastDowngrade = now; }
48 
49  static bool getDomain(const std::string &host, std::string &domain);
50  static bool getXrootdSite(XrdCl::File &file, std::string &site);
51  static bool getXrootdSiteFromURL(std::string url, std::string &site);
52 
53  // Given a file and (possibly) a host list, determine the exclude string.
54  static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude);
55 
56  // Given a connected File object, determine whether we believe this to be a
57  // dCache pool (dCache is a separate implementation and sometimes benefits from
58  // implementation-specific behaviors.
59  static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList = nullptr);
60  static bool isDCachePool(const std::string &url);
61 
62  // Given an Xrootd server ID, determine the hostname to the best of our ability.
63  static bool getHostname(const std::string &id, std::string &hostname);
64 
65  private:
66  void requestCallback(/* TODO: type? */);
67 
68  void setXrootdSite();
69 
70  std::shared_ptr<XrdCl::File const> fh() const { return get_underlying_safe(m_fh); }
71  std::shared_ptr<XrdCl::File> &fh() { return get_underlying_safe(m_fh); }
72  std::shared_ptr<XrdSiteStatistics const> stats() const { return get_underlying_safe(m_stats); }
73  std::shared_ptr<XrdSiteStatistics> &stats() { return get_underlying_safe(m_stats); }
74 
75  struct timespec m_lastDowngrade;
81 
84 
85 #ifdef XRD_FAKE_SLOW
86  bool m_slow;
87 #endif
88  };
89 
90 } // namespace XrdAdaptor
91 
92 #endif
XrdAdaptor::Source::m_id
std::string m_id
Definition: XrdSource.h:76
XrdAdaptor::Source::getQuality
unsigned getQuality()
Definition: XrdSource.h:42
XrdAdaptor::Source::stats
std::shared_ptr< XrdSiteStatistics const > stats() const
Definition: XrdSource.h:72
XrdAdaptor::Source::determineHostExcludeString
static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude)
Definition: XrdSource.cc:283
relmon_authenticated_wget.url
url
Definition: relmon_authenticated_wget.py:22
XrdAdaptor::Source::m_site
std::string m_site
Definition: XrdSource.h:78
XrdAdaptor::Source::m_qm
edm::propagate_const< std::unique_ptr< QualityMetricSource > > m_qm
Definition: XrdSource.h:82
XrdAdaptor::Source::Site
const std::string & Site() const
Definition: XrdSource.h:38
XrdAdaptor::Source::fh
std::shared_ptr< XrdCl::File const > fh() const
Definition: XrdSource.h:70
XrdAdaptor::Source::getLastDowngrade
struct timespec getLastDowngrade() const
Definition: XrdSource.h:44
XrdAdaptor::Source::m_stats
edm::propagate_const< std::shared_ptr< XrdSiteStatistics > > m_stats
Definition: XrdSource.h:83
XrdAdaptor::Source::handle
void handle(std::shared_ptr< ClientRequest >)
Definition: XrdSource.cc:377
XrdAdaptor::Source::setLastDowngrade
void setLastDowngrade(struct timespec now)
Definition: XrdSource.h:47
watchdog.const
const
Definition: watchdog.py:83
query.host
host
Definition: query.py:115
fileCollector.now
now
Definition: fileCollector.py:207
edm::propagate_const
Definition: propagate_const.h:32
XrdAdaptor::Source::m_fh
edm::propagate_const< std::shared_ptr< XrdCl::File > > m_fh
Definition: XrdSource.h:80
File
Definition: File.h:11
XrdAdaptor::Source::getDomain
static bool getDomain(const std::string &host, std::string &domain)
Definition: XrdSource.cc:241
XrdAdaptor::Source::m_exclude
std::string m_exclude
Definition: XrdSource.h:79
XrdAdaptor::Source::m_lastDowngrade
struct timespec m_lastDowngrade
Definition: XrdSource.h:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::get_underlying_safe
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:40
XrdAdaptor::Source::isDCachePool
static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList=nullptr)
Definition: XrdSource.cc:251
XrdAdaptor::Source::requestCallback
void requestCallback()
XrdAdaptor::Source::getXrootdSiteFromURL
static bool getXrootdSiteFromURL(std::string url, std::string &site)
Definition: XrdSource.cc:321
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
XrdAdaptor::Source::stats
std::shared_ptr< XrdSiteStatistics > & stats()
Definition: XrdSource.h:73
XrdAdaptor::Source::m_prettyid
std::string m_prettyid
Definition: XrdSource.h:77
XrdAdaptor::Source
Definition: XrdSource.h:25
XrdCl
Definition: XrdRequestManager.h:21
QualityMetric.h
XrdAdaptor::Source::ExcludeID
const std::string & ExcludeID() const
Definition: XrdSource.h:40
VtxSmearedBeamProfile_cfi.File
File
Definition: VtxSmearedBeamProfile_cfi.py:30
XrdAdaptor::Source::getXrootdSite
static bool getXrootdSite(XrdCl::File &file, std::string &site)
Definition: XrdSource.cc:299
XrdAdaptor::Source::PrettyID
const std::string & PrettyID() const
Definition: XrdSource.h:39
XrdAdaptor::Source::getFileHandle
std::shared_ptr< XrdCl::File > getFileHandle()
Definition: XrdSource.cc:363
XrdAdaptor::Source::Source
Source(timespec now, std::unique_ptr< XrdCl::File > fileHandle, const std::string &exclude)
Definition: XrdSource.cc:176
XrdAdaptor::Source::fh
std::shared_ptr< XrdCl::File > & fh()
Definition: XrdSource.h:71
XrdAdaptor::Source::setXrootdSite
void setXrootdSite()
Definition: XrdSource.cc:348
XrdAdaptor::Source::ID
const std::string & ID() const
Definition: XrdSource.h:37
get_underlying_safe.h
XrdAdaptor::Source::getHostname
static bool getHostname(const std::string &id, std::string &hostname)
Definition: XrdSource.cc:214
XrdAdaptor
Definition: QualityMetric.h:15
XrdAdaptor::Source::~Source
~Source()
Definition: XrdSource.cc:361