Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:10

0001 #ifndef Utilities_XrdAdaptor_XrdSource_h
0002 #define Utilities_XrdAdaptor_XrdSource_h
0003 
0004 #include "XrdCl/XrdClXRootDResponses.hh"
0005 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0006 
0007 #include <memory>
0008 #include <vector>
0009 
0010 #include "QualityMetric.h"
0011 
0012 namespace XrdCl {
0013   class File;
0014 }
0015 
0016 namespace XrdAdaptor {
0017 
0018   class RequestList;
0019   class ClientRequest;
0020   class XrdSiteStatistics;
0021   class XrdStatisticsService;
0022 
0023   class Source : public std::enable_shared_from_this<Source> {
0024   public:
0025     Source(const Source &) = delete;
0026     Source &operator=(const Source &) = delete;
0027 
0028     Source(timespec now, std::unique_ptr<XrdCl::File> fileHandle, const std::string &exclude);
0029 
0030     ~Source();
0031 
0032     void handle(std::shared_ptr<ClientRequest>);
0033 
0034     void handle(RequestList &);
0035 
0036     std::shared_ptr<XrdCl::File> getFileHandle();
0037 
0038     const std::string &ID() const { return m_id; }
0039     const std::string &Site() const { return m_site; }
0040     const std::string &PrettyID() const { return m_prettyid; }
0041     const std::string &ExcludeID() const { return m_exclude; }
0042 
0043     unsigned getQuality() { return m_qm->get(); }
0044 
0045     struct timespec getLastDowngrade() const {
0046       return m_lastDowngrade;
0047     }
0048     void setLastDowngrade(struct timespec now) { m_lastDowngrade = now; }
0049 
0050     static bool getDomain(const std::string &host, std::string &domain);
0051     static bool getXrootdSite(XrdCl::File &file, std::string &site);
0052     static bool getXrootdSiteFromURL(std::string url, std::string &site);
0053 
0054     // Given a file and (possibly) a host list, determine the exclude string.
0055     static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude);
0056 
0057     // Given a connected File object, determine whether we believe this to be a
0058     // dCache pool (dCache is a separate implementation and sometimes benefits from
0059     // implementation-specific behaviors.
0060     static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList = nullptr);
0061     static bool isDCachePool(const std::string &url);
0062 
0063     // Given an Xrootd server ID, determine the hostname to the best of our ability.
0064     static bool getHostname(const std::string &id, std::string &hostname);
0065 
0066   private:
0067     void requestCallback(/* TODO: type? */);
0068 
0069     void setXrootdSite();
0070 
0071     std::shared_ptr<XrdCl::File const> fh() const { return get_underlying_safe(m_fh); }
0072     std::shared_ptr<XrdCl::File> &fh() { return get_underlying_safe(m_fh); }
0073     std::shared_ptr<XrdSiteStatistics const> stats() const { return get_underlying_safe(m_stats); }
0074     std::shared_ptr<XrdSiteStatistics> &stats() { return get_underlying_safe(m_stats); }
0075 
0076     struct timespec m_lastDowngrade;
0077     std::string m_id;
0078     std::string m_prettyid;
0079     std::string m_site;
0080     std::string m_exclude;
0081     edm::propagate_const<std::shared_ptr<XrdCl::File>> m_fh;
0082 
0083     edm::propagate_const<std::unique_ptr<QualityMetricSource>> m_qm;
0084     edm::propagate_const<std::shared_ptr<XrdSiteStatistics>> m_stats;
0085 
0086 #ifdef XRD_FAKE_SLOW
0087     bool m_slow;
0088 #endif
0089   };
0090 
0091 }  // namespace XrdAdaptor
0092 
0093 #endif