xrootd
XrdTpcTPC.hh
Go to the documentation of this file.
1 
2 #include <memory>
3 #include <string>
4 #include <vector>
5 
7 
10 
11 class XrdOucErrInfo;
12 class XrdOucStream;
13 class XrdSfsFile;
14 class XrdSfsFileSystem;
15 typedef void CURL;
16 
17 namespace TPC {
18 class State;
19 
20 enum LogMask {
21  Debug = 0x01,
22  Info = 0x02,
23  Warning = 0x04,
24  Error = 0x08,
25  All = 0xff
26 };
27 
28 class TPCHandler : public XrdHttpExtHandler {
29 public:
30  TPCHandler(XrdSysError *log, const char *config, XrdOucEnv *myEnv);
31  virtual ~TPCHandler();
32 
33  virtual bool MatchesPath(const char *verb, const char *path);
34  virtual int ProcessReq(XrdHttpExtReq &req);
35  // Abstract method in the base class, but does not seem to be used
36  virtual int Init(const char *cfgfile) {return 0;}
37 
38 private:
39 
40  struct TPCLogRecord {
41 
42  TPCLogRecord() : status( -1 ),
43  tpc_status(-1),
44  streams( 1 ),
45  bytes_transferred( -1 )
46  {
47  }
48 
49  std::string log_prefix;
50  std::string local;
51  std::string remote;
52  std::string name;
53  int status;
55  unsigned streams;
57  };
58 
60 
61  static std::string GetAuthz(XrdHttpExtReq &req);
62 
63  // Redirect the transfer according to the contents of an XrdOucErrInfo object.
64  int RedirectTransfer(CURL *curl, const std::string &redirect_resource, XrdHttpExtReq &req,
65  XrdOucErrInfo &error, TPCLogRecord &);
66 
67  int OpenWaitStall(XrdSfsFile &fh, const std::string &resource, int mode,
68  int openMode, const XrdSecEntity &sec,
69  const std::string &authz);
70 
71 #ifdef XRD_CHUNK_RESP
72  int DetermineXferSize(CURL *curl, XrdHttpExtReq &req, TPC::State &state,
73  bool &success, TPCLogRecord &);
74 
75  // Send a 'performance marker' back to the TPC client, informing it of our
76  // progress. The TPC client will use this information to determine whether
77  // the transfer is making sufficient progress and/or other monitoring info
78  // (such as whether the transfer is happening over IPv4, IPv6, or both).
79  int SendPerfMarker(XrdHttpExtReq &req, TPCLogRecord &rec, TPC::State &state);
80  int SendPerfMarker(XrdHttpExtReq &req, TPCLogRecord &rec, std::vector<State*> &state,
81  off_t bytes_transferred);
82 
83  // Perform the libcurl transfer, periodically sending back chunked updates.
84  int RunCurlWithUpdates(CURL *curl, XrdHttpExtReq &req, TPC::State &state,
85  TPCLogRecord &rec);
86 
87  // Experimental multi-stream version of RunCurlWithUpdates
88  int RunCurlWithStreams(XrdHttpExtReq &req, TPC::State &state,
89  size_t streams, TPCLogRecord &rec);
90  int RunCurlWithStreamsImpl(XrdHttpExtReq &req, TPC::State &state,
91  size_t streams, std::vector<TPC::State*> streams_handles,
92  TPCLogRecord &rec);
93 #else
94  int RunCurlBasic(CURL *curl, XrdHttpExtReq &req, TPC::State &state,
95  const char *log_prefix);
96 #endif
97 
98  int ProcessPushReq(const std::string & resource, XrdHttpExtReq &req);
99  int ProcessPullReq(const std::string &resource, XrdHttpExtReq &req);
100 
101  bool ConfigureFSLib(XrdOucStream &Config, std::string &path1, bool &path1_alt,
102  std::string &path2, bool &path2_alt);
103  bool Configure(const char *configfn, XrdOucEnv *myEnv);
105 
106  // Generate a consistently-formatted log message.
107  void logTransferEvent(LogMask lvl, const TPCLogRecord &record,
108  const std::string &event, const std::string &message="");
109 
110  static int m_marker_period;
111  static size_t m_block_size;
112  static size_t m_small_block_size;
114  int m_timeout; // the 'timeout interval'; if no bytes have been received during this time period, abort the transfer.
115  int m_first_timeout; // the 'first timeout interval'; the amount of time we're willing to wait to get the first byte.
116  // Unless explicitly specified, this is 2x the timeout interval.
117  std::string m_cadir;
119  static uint64_t m_monid;
122 
123  // 16 blocks in flight at 16 MB each, meaning that there will be up to 256MB
124  // in flight; this is equal to the bandwidth delay product of a 200ms transcontinental
125  // connection at 10Gbps.
126 #ifdef USE_PIPELINING
127  static const int m_pipelining_multiplier = 16;
128 #else
129  static const int m_pipelining_multiplier = 1;
130 #endif
131 };
132 }
Utility functions for XrdHTTP.
void CURL
Definition: XrdTpcState.hh:12
void CURL
Definition: XrdTpcTPC.hh:14
Definition: XrdTpcState.hh:19
Definition: XrdTpcTPC.hh:28
int RunCurlBasic(CURL *curl, XrdHttpExtReq &req, TPC::State &state, const char *log_prefix)
int ProcessOptionsReq(XrdHttpExtReq &req)
std::string m_cadir
Definition: XrdTpcTPC.hh:117
TPCHandler(XrdSysError *log, const char *config, XrdOucEnv *myEnv)
bool ConfigureLogger(XrdOucStream &Config)
void logTransferEvent(LogMask lvl, const TPCLogRecord &record, const std::string &event, const std::string &message="")
static XrdSysMutex m_monid_mutex
Definition: XrdTpcTPC.hh:118
virtual ~TPCHandler()
static size_t m_small_block_size
Definition: XrdTpcTPC.hh:112
int m_timeout
Definition: XrdTpcTPC.hh:114
int ProcessPullReq(const std::string &resource, XrdHttpExtReq &req)
virtual int ProcessReq(XrdHttpExtReq &req)
static uint64_t m_monid
Definition: XrdTpcTPC.hh:119
static const int m_pipelining_multiplier
Definition: XrdTpcTPC.hh:129
bool m_desthttps
Definition: XrdTpcTPC.hh:113
static std::string GetAuthz(XrdHttpExtReq &req)
static int m_marker_period
Definition: XrdTpcTPC.hh:110
int OpenWaitStall(XrdSfsFile &fh, const std::string &resource, int mode, int openMode, const XrdSecEntity &sec, const std::string &authz)
int RedirectTransfer(CURL *curl, const std::string &redirect_resource, XrdHttpExtReq &req, XrdOucErrInfo &error, TPCLogRecord &)
virtual bool MatchesPath(const char *verb, const char *path)
Tells if the incoming path is recognized as one of the paths that have to be processed.
virtual int Init(const char *cfgfile)
Initializes the external request handler.
Definition: XrdTpcTPC.hh:36
int ProcessPushReq(const std::string &resource, XrdHttpExtReq &req)
XrdSysError m_log
Definition: XrdTpcTPC.hh:120
static size_t m_block_size
Definition: XrdTpcTPC.hh:111
bool ConfigureFSLib(XrdOucStream &Config, std::string &path1, bool &path1_alt, std::string &path2, bool &path2_alt)
XrdSfsFileSystem * m_sfs
Definition: XrdTpcTPC.hh:121
bool Configure(const char *configfn, XrdOucEnv *myEnv)
int m_first_timeout
Definition: XrdTpcTPC.hh:115
Definition: XrdHttpExtHandler.hh:79
Definition: XrdHttpExtHandler.hh:45
Definition: XrdOucEnv.hh:42
Definition: XrdOucErrInfo.hh:99
Definition: XrdOucStream.hh:47
Definition: XrdSecEntity.hh:64
Definition: XrdSfsInterface.hh:835
Definition: XrdSfsInterface.hh:365
Definition: XrdSysError.hh:90
Definition: XrdSysPthread.hh:166
Definition: XrdTpcState.hh:16
LogMask
Definition: XrdTpcTPC.hh:20
@ All
Definition: XrdTpcTPC.hh:25
@ Info
Definition: XrdTpcTPC.hh:22
@ Error
Definition: XrdTpcTPC.hh:24
@ Debug
Definition: XrdTpcTPC.hh:21
@ Warning
Definition: XrdTpcTPC.hh:23
XrdCmsConfig Config
Definition: XrdTpcTPC.hh:40
int tpc_status
Definition: XrdTpcTPC.hh:54
std::string remote
Definition: XrdTpcTPC.hh:51
TPCLogRecord()
Definition: XrdTpcTPC.hh:42
int status
Definition: XrdTpcTPC.hh:53
off_t bytes_transferred
Definition: XrdTpcTPC.hh:56
std::string name
Definition: XrdTpcTPC.hh:52
unsigned streams
Definition: XrdTpcTPC.hh:55
std::string local
Definition: XrdTpcTPC.hh:50
std::string log_prefix
Definition: XrdTpcTPC.hh:49