CMS 3D CMS Logo

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