xrootd
XrdClientSid.hh
Go to the documentation of this file.
1 #ifndef XRC_SID_H
2 #define XRC_SID_H
3 /******************************************************************************/
4 /* */
5 /* X r d C l i e n t S i d . h h */
6 /* */
7 /* Author: Fabrizio Furano (INFN Padova, 2005) */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /* XRootD is free software: you can redistribute it and/or modify it under */
12 /* the terms of the GNU Lesser General Public License as published by the */
13 /* Free Software Foundation, either version 3 of the License, or (at your */
14 /* option) any later version. */
15 /* */
16 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19 /* License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24 /* */
25 /* The copyright holder's institutional names and contributor's names may not */
26 /* be used to endorse or promote products derived from this software without */
27 /* specific prior written permission of the institution or contributor. */
28 /******************************************************************************/
29 
31 // //
32 // Utility classes to handle the mapping between xrootd streamids. //
33 // A single streamid can have multiple "parallel" streamids. //
34 // Their use is typically to support the client to submit multiple //
35 // parallel requests (belonging to the same LogConnectionID), //
36 // whose answers are to be processed asynchronously when they arrive. //
37 // //
39 
40 #include "XrdOuc/XrdOucRash.hh"
41 #include "XProtocol/XProtocol.hh"
44 #include "XrdSys/XrdSysPthread.hh"
45 
46 struct SidInfo {
49  long long reqbyteprogress;
50  time_t sendtime;
51 
54  char *rsperrmsg;
55 };
56 
57 class XrdClientSid {
58 
59  private:
60  // Used to quickly get info about a sid being used
61  // as a child of another sid. A child sid is used to parallely
62  // interact with a server for the same logical connection using its father sid
63  // Only child sids are inserted here. If a sid is not here but is not free,
64  // then it's a father sid, i.e. normally a sid used for the non async xrootd traffic
65  // Remember: for any child sid, it's mandatory to keep the request
66  // which is outstanding for that stream. This struct can be used to
67  // read data, but also for preparing many files in advance.
69 
70  // To quickly get a sid which is not being used
71  // This one has constant time operations if the ops
72  // are performed at the back of the vector
73  // Remember: 0 is NOT a valid sid
75 
77 
78  public:
79  XrdClientSid();
80  virtual ~XrdClientSid();
81 
82  // Gets an available sid
83  // From now on it will be no more available.
84  // A retval of 0 means that there are no more available sids
86 
87  // Gets an available sid for a request which is to be outstanding
88  // This means that this sid will be inserted into the Rash
89  // The request gets inserted the new sid in the right place
90  // Also the one passed as parameter gets the new sid, as should be expected
92 
93 
94  // Releases a sid.
95  // It is re-inserted into the available set
96  // Its info is rmeoved from the tree
97  void ReleaseSid(kXR_unt16 sid);
98 
99  // Releases a sid and all its childs
100  void ReleaseSidTree(kXR_unt16 fathersid);
101 
102  // Report the response for an outstanding request
103  // Typically this is used to keep track of the received errors, expecially
104  // for async writes
105  void ReportSidResp(kXR_unt16 sid, kXR_unt16 statuscode, kXR_unt32 errcode, char *errmsg);
106 
110 
111  // 0 if non existent as a child sid
112  inline struct SidInfo *GetSidInfo(kXR_unt16 sid) {
114  return (childsidnfo.Find(sid));
115  };
116 
117  inline bool JoinedSids(kXR_unt16 father, kXR_unt16 child) {
119 
120  struct SidInfo *si = childsidnfo.Find(child);
121 
122  if (!si) return false;
123  return (si->fathersid == father);
124  }
125 
126 
127  // Useful for debugging
129 };
130 #endif
SidInfo::rsperrmsg
char * rsperrmsg
Definition: XrdClientSid.hh:54
XrdOucRash.hh
XrdClientSid::ReportSidResp
void ReportSidResp(kXR_unt16 sid, kXR_unt16 statuscode, kXR_unt32 errcode, char *errmsg)
SidInfo::sendtime
time_t sendtime
Definition: XrdClientSid.hh:50
XrdSysMutex
Definition: XrdSysPthread.hh:165
XrdSysPthread.hh
XrdClientSid::fMutex
XrdSysMutex fMutex
Definition: XrdClientSid.hh:76
XrdClientSid::GetAllOutstandingWriteRequests
int GetAllOutstandingWriteRequests(kXR_unt16 fathersid, XrdClientVector< ClientRequest > &reqvect)
XrdClientSid::XrdClientSid
XrdClientSid()
SidInfo::rsperrno
kXR_unt32 rsperrno
Definition: XrdClientSid.hh:53
SidInfo::outstandingreq
ClientRequest outstandingreq
Definition: XrdClientSid.hh:48
XProtocol.hh
XrdClientSid::freesids
XrdClientVector< kXR_unt16 > freesids
Definition: XrdClientSid.hh:74
kXR_unt32
unsigned int kXR_unt32
Definition: XPtypes.hh:90
kXR_unt16
unsigned short kXR_unt16
Definition: XPtypes.hh:67
XrdOucRash< kXR_unt16, struct SidInfo >
SidInfo::rspstatuscode
kXR_unt16 rspstatuscode
Definition: XrdClientSid.hh:52
XrdClientSid::PrintoutOutstandingRequests
void PrintoutOutstandingRequests()
XrdOucRash::Find
V * Find(K KeyVal, time_t *KeyTime=0)
XrdClientVector< kXR_unt16 >
XrdClientSid::childsidnfo
XrdOucRash< kXR_unt16, struct SidInfo > childsidnfo
Definition: XrdClientSid.hh:68
XrdClientSid::~XrdClientSid
virtual ~XrdClientSid()
ClientRequest
Definition: XProtocol.hh:628
XrdClientSid::GetOutstandingWriteRequestCnt
int GetOutstandingWriteRequestCnt(kXR_unt16 fathersid)
XrdClientSid::GetNewSid
kXR_unt16 GetNewSid()
XrdClientSid::ReleaseSidTree
void ReleaseSidTree(kXR_unt16 fathersid)
XrdClientSid::GetSidInfo
struct SidInfo * GetSidInfo(kXR_unt16 sid)
Definition: XrdClientSid.hh:112
SidInfo
Definition: XrdClientSid.hh:46
SidInfo::fathersid
kXR_unt16 fathersid
Definition: XrdClientSid.hh:47
SidInfo::reqbyteprogress
long long reqbyteprogress
Definition: XrdClientSid.hh:49
XrdClientVector.hh
XrdClientSid::ReleaseSid
void ReleaseSid(kXR_unt16 sid)
XrdClientProtocol.hh
XrdSysMutexHelper
Definition: XrdSysPthread.hh:260
XrdClientSid::GetFailedOutstandingWriteRequests
int GetFailedOutstandingWriteRequests(kXR_unt16 fathersid, XrdClientVector< ClientRequest > &reqvect)
XrdClientSid::JoinedSids
bool JoinedSids(kXR_unt16 father, kXR_unt16 child)
Definition: XrdClientSid.hh:117
XrdClientSid
Definition: XrdClientSid.hh:57