CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "QualityMetric.h"
11 
12 namespace XrdCl {
13  class File;
14 }
15 
16 namespace XrdAdaptor {
17 
18  class RequestList;
19  class ClientRequest;
20  class XrdSiteStatistics;
21  class XrdStatisticsService;
22 
23  class Source : public std::enable_shared_from_this<Source> {
24  public:
25  Source(const Source &) = delete;
26  Source &operator=(const Source &) = delete;
27 
28  Source(timespec now, std::unique_ptr<XrdCl::File> fileHandle, const std::string &exclude);
29 
30  ~Source();
31 
32  void handle(std::shared_ptr<ClientRequest>);
33 
34  void handle(RequestList &);
35 
36  std::shared_ptr<XrdCl::File> getFileHandle();
37 
38  const std::string &ID() const { return m_id; }
39  const std::string &Site() const { return m_site; }
40  const std::string &PrettyID() const { return m_prettyid; }
41  const std::string &ExcludeID() const { return m_exclude; }
42 
43  unsigned getQuality() { return m_qm->get(); }
44 
45  struct timespec getLastDowngrade() const {
46  return m_lastDowngrade;
47  }
48  void setLastDowngrade(struct timespec now) { m_lastDowngrade = now; }
49 
50  static bool getDomain(const std::string &host, std::string &domain);
51  static bool getXrootdSite(XrdCl::File &file, std::string &site);
52  static bool getXrootdSiteFromURL(std::string url, std::string &site);
53 
54  // Given a file and (possibly) a host list, determine the exclude string.
55  static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude);
56 
57  // Given a connected File object, determine whether we believe this to be a
58  // dCache pool (dCache is a separate implementation and sometimes benefits from
59  // implementation-specific behaviors.
60  static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList = nullptr);
61  static bool isDCachePool(const std::string &url);
62 
63  // Given an Xrootd server ID, determine the hostname to the best of our ability.
64  static bool getHostname(const std::string &id, std::string &hostname);
65 
66  private:
67  void requestCallback(/* TODO: type? */);
68 
69  void setXrootdSite();
70 
71  std::shared_ptr<XrdCl::File const> fh() const { return get_underlying_safe(m_fh); }
72  std::shared_ptr<XrdCl::File> &fh() { return get_underlying_safe(m_fh); }
73  std::shared_ptr<XrdSiteStatistics const> stats() const { return get_underlying_safe(m_stats); }
74  std::shared_ptr<XrdSiteStatistics> &stats() { return get_underlying_safe(m_stats); }
75 
76  struct timespec m_lastDowngrade;
82 
85 
86 #ifdef XRD_FAKE_SLOW
87  bool m_slow;
88 #endif
89  };
90 
91 } // namespace XrdAdaptor
92 
93 #endif
static bool getXrootdSite(XrdCl::File &file, std::string &site)
Definition: XrdSource.cc:304
std::string m_id
Definition: XrdSource.h:77
std::string m_exclude
Definition: XrdSource.h:80
struct timespec m_lastDowngrade
Definition: XrdSource.h:76
struct timespec getLastDowngrade() const
Definition: XrdSource.h:45
edm::propagate_const< std::shared_ptr< XrdSiteStatistics > > m_stats
Definition: XrdSource.h:84
static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude)
Definition: XrdSource.cc:288
std::string m_site
Definition: XrdSource.h:79
void handle(std::shared_ptr< ClientRequest >)
Definition: XrdSource.cc:382
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void setLastDowngrade(struct timespec now)
Definition: XrdSource.h:48
const std::string & PrettyID() const
Definition: XrdSource.h:40
std::shared_ptr< XrdSiteStatistics const > stats() const
Definition: XrdSource.h:73
edm::propagate_const< std::shared_ptr< XrdCl::File > > m_fh
Definition: XrdSource.h:81
static bool getDomain(const std::string &host, std::string &domain)
Definition: XrdSource.cc:246
static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList=nullptr)
Definition: XrdSource.cc:256
std::shared_ptr< XrdCl::File const > fh() const
Definition: XrdSource.h:71
Source & operator=(const Source &)=delete
string host
Definition: query.py:115
const std::string & Site() const
Definition: XrdSource.h:39
std::string m_prettyid
Definition: XrdSource.h:78
std::shared_ptr< XrdCl::File > getFileHandle()
Definition: XrdSource.cc:368
static bool getXrootdSiteFromURL(std::string url, std::string &site)
Definition: XrdSource.cc:326
edm::propagate_const< std::unique_ptr< QualityMetricSource > > m_qm
Definition: XrdSource.h:83
const std::string & ExcludeID() const
Definition: XrdSource.h:41
static bool getHostname(const std::string &id, std::string &hostname)
Definition: XrdSource.cc:219
std::shared_ptr< XrdCl::File > & fh()
Definition: XrdSource.h:72
const std::string & ID() const
Definition: XrdSource.h:38
unsigned getQuality()
Definition: XrdSource.h:43
std::shared_ptr< XrdSiteStatistics > & stats()
Definition: XrdSource.h:74
Source(const Source &)=delete