File indexing completed on 2025-04-02 02:42:53
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
0024
0025
0026 class Source : public std::enable_shared_from_this<Source> {
0027 public:
0028 Source(const Source &) = delete;
0029 Source &operator=(const Source &) = delete;
0030
0031 Source(timespec now, std::unique_ptr<XrdCl::File> fileHandle, const std::string &exclude);
0032
0033 ~Source();
0034
0035 void handle(std::shared_ptr<ClientRequest>);
0036
0037 void handle(RequestList &);
0038
0039 std::shared_ptr<XrdCl::File> getFileHandle();
0040
0041 const std::string &ID() const { return m_id; }
0042 const std::string &Site() const { return m_site; }
0043 const std::string &PrettyID() const { return m_prettyid; }
0044 const std::string &ExcludeID() const { return m_exclude; }
0045
0046 unsigned getQuality() { return m_qm->get(); }
0047
0048 struct timespec getLastDowngrade() const { return m_lastDowngrade; }
0049 void setLastDowngrade(struct timespec now) { m_lastDowngrade = now; }
0050
0051 static bool getDomain(const std::string &host, std::string &domain);
0052 static bool getXrootdSite(XrdCl::File &file, std::string &site);
0053 static bool getXrootdSiteFromURL(std::string url, std::string &site);
0054
0055
0056 static void determineHostExcludeString(XrdCl::File &file, const XrdCl::HostList *hostList, std::string &exclude);
0057
0058
0059
0060
0061 static bool isDCachePool(XrdCl::File &file, const XrdCl::HostList *hostList = nullptr);
0062 static bool isDCachePool(const std::string &url);
0063
0064
0065 static bool getHostname(const std::string &id, std::string &hostname);
0066
0067 private:
0068 void requestCallback();
0069
0070 void setXrootdSite();
0071
0072 std::shared_ptr<XrdCl::File const> fh() const { return get_underlying_safe(m_fh); }
0073 std::shared_ptr<XrdCl::File> &fh() { return get_underlying_safe(m_fh); }
0074 std::shared_ptr<XrdSiteStatistics const> stats() const { return get_underlying_safe(m_stats); }
0075 std::shared_ptr<XrdSiteStatistics> &stats() { return get_underlying_safe(m_stats); }
0076
0077 struct timespec m_lastDowngrade;
0078 std::string m_id;
0079 std::string m_prettyid;
0080 std::string m_site;
0081 std::string m_exclude;
0082 edm::propagate_const<std::shared_ptr<XrdCl::File>> m_fh;
0083
0084 edm::propagate_const<std::unique_ptr<QualityMetricSource>> m_qm;
0085 edm::propagate_const<std::shared_ptr<XrdSiteStatistics>> m_stats;
0086
0087 #ifdef XRD_FAKE_SLOW
0088 bool m_slow;
0089 #endif
0090 };
0091
0092 }
0093
0094 #endif