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 
5 
6 #include <memory>
7 #include <vector>
8 
9 #include <boost/utility.hpp>
10 
11 #include "QualityMetric.h"
12 
13 namespace XrdCl {
14  class File;
15 }
16 
17 namespace XrdAdaptor {
18 
19 class RequestList;
20 class ClientRequest;
21 class XrdSiteStatistics;
22 class XrdStatisticsService;
23 
24 class Source : public std::enable_shared_from_this<Source>, boost::noncopyable {
25 
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 {return m_lastDowngrade;}
45  void setLastDowngrade(struct timespec now) {m_lastDowngrade = now;}
46 
47  static bool getDomain(const std::string &host, std::string &domain);
48  static bool getXrootdSite(XrdCl::File &file, std::string &site);
49  static bool getXrootdSiteFromURL(std::string url, std::string &site);
50 
51  // Given a file and (possibly) a host list, determine the exclude string.
52  static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude);
53 
54  // Given a connected File object, determine whether we believe this to be a
55  // dCache pool (dCache is a separate implementation and sometimes benefits from
56  // implementation-specific behaviors.
57  static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList=nullptr);
58  static bool isDCachePool(const std::string &url);
59 
60  // Given an Xrootd server ID, determine the hostname to the best of our ability.
61  static bool getHostname(const std::string & id, std::string &hostname);
62 
63 private:
64  void requestCallback(/* TODO: type? */);
65 
66  void setXrootdSite();
67 
68  std::shared_ptr<XrdCl::File const> fh() const {return get_underlying_safe(m_fh);}
69  std::shared_ptr<XrdCl::File>& fh() {return get_underlying_safe(m_fh);}
70  std::shared_ptr<XrdSiteStatistics const> stats() const {return get_underlying_safe(m_stats);}
71  std::shared_ptr<XrdSiteStatistics>& stats() {return get_underlying_safe(m_stats);}
72 
73  struct timespec m_lastDowngrade;
79 
82 
83 #ifdef XRD_FAKE_SLOW
84  bool m_slow;
85 #endif
86 };
87 
88 }
89 
90 #endif
host
Definition: query.py:114
std::string m_id
Definition: XrdSource.h:74
std::string m_exclude
Definition: XrdSource.h:77
edm::propagate_const< std::shared_ptr< XrdSiteStatistics > > m_stats
Definition: XrdSource.h:81
std::string m_site
Definition: XrdSource.h:76
void setLastDowngrade(struct timespec now)
Definition: XrdSource.h:45
const std::string & PrettyID() const
Definition: XrdSource.h:39
std::shared_ptr< XrdSiteStatistics const > stats() const
Definition: XrdSource.h:70
edm::propagate_const< std::shared_ptr< XrdCl::File > > m_fh
Definition: XrdSource.h:78
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr< XrdCl::File const > fh() const
Definition: XrdSource.h:68
const std::string & Site() const
Definition: XrdSource.h:38
std::string m_prettyid
Definition: XrdSource.h:75
edm::propagate_const< std::unique_ptr< QualityMetricSource > > m_qm
Definition: XrdSource.h:80
Definition: File.h:11
const std::string & ExcludeID() const
Definition: XrdSource.h:40
std::shared_ptr< XrdCl::File > & fh()
Definition: XrdSource.h:69
const std::string & ID() const
Definition: XrdSource.h:37
unsigned getQuality()
Definition: XrdSource.h:42
std::shared_ptr< XrdSiteStatistics > & stats()
Definition: XrdSource.h:71