XRootD
XrdClXRootDResponses.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_XROOTD_RESPONSES_HH__
20 #define __XRD_CL_XROOTD_RESPONSES_HH__
21 
22 #include "XrdCl/XrdClBuffer.hh"
23 #include "XrdCl/XrdClStatus.hh"
24 #include "XrdCl/XrdClURL.hh"
25 #include "XrdCl/XrdClAnyObject.hh"
26 #include "XProtocol/XProtocol.hh"
27 
28 #include <string>
29 #include <vector>
30 #include <list>
31 #include <ctime>
32 #include <tuple>
33 #include <memory>
34 #include <functional>
35 
36 #include <sys/uio.h>
37 
38 namespace XrdCl
39 {
40  //----------------------------------------------------------------------------
42  //----------------------------------------------------------------------------
44  {
45  public:
46  //------------------------------------------------------------------------
48  //------------------------------------------------------------------------
50  {
55  };
56 
57  //------------------------------------------------------------------------
59  //------------------------------------------------------------------------
61  {
62  Read,
63  ReadWrite
64  };
65 
66  //------------------------------------------------------------------------
68  //------------------------------------------------------------------------
69  class Location
70  {
71  public:
72 
73  //--------------------------------------------------------------------
75  //--------------------------------------------------------------------
76  Location( const std::string &address,
77  LocationType type,
79  pAddress( address ),
80  pType( type ),
81  pAccess( access ) {}
82 
83  //--------------------------------------------------------------------
85  //--------------------------------------------------------------------
86  const std::string &GetAddress() const
87  {
88  return pAddress;
89  }
90 
91  //--------------------------------------------------------------------
93  //--------------------------------------------------------------------
95  {
96  return pType;
97  }
98 
99  //--------------------------------------------------------------------
101  //--------------------------------------------------------------------
103  {
104  return pAccess;
105  }
106 
107  //--------------------------------------------------------------------
109  //--------------------------------------------------------------------
110  bool IsServer() const
111  {
112  return pType == ServerOnline || pType == ServerPending;
113  }
114 
115  //--------------------------------------------------------------------
117  //--------------------------------------------------------------------
118  bool IsManager() const
119  {
120  return pType == ManagerOnline || pType == ManagerPending;
121  }
122 
123  private:
124  std::string pAddress;
125  LocationType pType;
126  AccessType pAccess;
127  };
128 
129  //------------------------------------------------------------------------
131  //------------------------------------------------------------------------
132  typedef std::vector<Location> LocationList;
133 
134  //------------------------------------------------------------------------
136  //------------------------------------------------------------------------
137  typedef LocationList::iterator Iterator;
138 
139  //------------------------------------------------------------------------
141  //------------------------------------------------------------------------
142  typedef LocationList::const_iterator ConstIterator;
143 
144  //------------------------------------------------------------------------
146  //------------------------------------------------------------------------
147  LocationInfo();
148 
149  //------------------------------------------------------------------------
151  //------------------------------------------------------------------------
152  virtual ~LocationInfo() {}
153 
154  //------------------------------------------------------------------------
156  //------------------------------------------------------------------------
157  uint32_t GetSize() const
158  {
159  return pLocations.size();
160  }
161 
162  //------------------------------------------------------------------------
164  //------------------------------------------------------------------------
165  Location &At( uint32_t index )
166  {
167  return pLocations[index];
168  }
169 
170  //------------------------------------------------------------------------
172  //------------------------------------------------------------------------
174  {
175  return pLocations.begin();
176  }
177 
178  //------------------------------------------------------------------------
180  //------------------------------------------------------------------------
182  {
183  return pLocations.begin();
184  }
185 
186  //------------------------------------------------------------------------
188  //------------------------------------------------------------------------
190  {
191  return pLocations.end();
192  }
193 
194  //------------------------------------------------------------------------
196  //------------------------------------------------------------------------
198  {
199  return pLocations.end();
200  }
201 
202  //------------------------------------------------------------------------
204  //------------------------------------------------------------------------
205  void Add( const Location &location )
206  {
207  pLocations.push_back( location );
208  }
209 
210  //------------------------------------------------------------------------
212  //------------------------------------------------------------------------
213  bool ParseServerResponse( const char *data );
214 
215  private:
216  bool ProcessLocation( std::string &location );
217  LocationList pLocations;
218  };
219 
220  //----------------------------------------------------------------------------
222  //----------------------------------------------------------------------------
223  class XRootDStatus: public Status
224  {
225  public:
226  //------------------------------------------------------------------------
228  //------------------------------------------------------------------------
229  XRootDStatus( uint16_t st = 0,
230  uint16_t code = 0,
231  uint32_t errN = 0,
232  const std::string &message = "" ):
233  Status( st, code, errN ),
234  pMessage( message ) {}
235 
236  //------------------------------------------------------------------------
238  //------------------------------------------------------------------------
239  XRootDStatus( const Status &st,
240  const std::string &message = "" ):
241  Status( st ),
242  pMessage( message ) {}
243 
244  //------------------------------------------------------------------------
246  //------------------------------------------------------------------------
247  const std::string &GetErrorMessage() const
248  {
249  return pMessage;
250  }
251 
252  //------------------------------------------------------------------------
254  //------------------------------------------------------------------------
255  void SetErrorMessage( const std::string &message )
256  {
257  pMessage = message;
258  }
259 
260  //------------------------------------------------------------------------
262  //------------------------------------------------------------------------
263  std::string ToStr() const
264  {
265  if( code == errErrorResponse )
266  {
267  std::ostringstream o;
268  o << "[ERROR] Server responded with an error: [" << errNo << "] ";
269  o << pMessage << std::endl;
270  return o.str();
271  }
272  std::string str = ToString();
273  if( !pMessage.empty() )
274  str += ": " + pMessage;
275  return str;
276  }
277 
278  private:
279  std::string pMessage;
280  };
281 
282  //----------------------------------------------------------------------------
284  //----------------------------------------------------------------------------
285  enum
286  {
288  xattr_value = 1
289  };
290 
291  //----------------------------------------------------------------------------
293  //----------------------------------------------------------------------------
294  typedef std::tuple<std::string, std::string> xattr_t;
295 
296  //----------------------------------------------------------------------------
298  //----------------------------------------------------------------------------
299  struct XAttrStatus
300  {
301  friend class FileStateHandler;
302  friend class FileSystem;
303 
304  XAttrStatus( const std::string &name, const XRootDStatus &status ) :
305  name( name ), status( status )
306  {
307 
308  }
309 
310  virtual ~XAttrStatus(){}
311 
312  std::string name;
314  };
315 
316  //----------------------------------------------------------------------------
318  //----------------------------------------------------------------------------
319  struct XAttr : public XAttrStatus
320  {
321  friend class FileStateHandler;
322  friend class FileSystem;
323 
324  XAttr( const std::string &name, const XRootDStatus &status ) :
326  {
327 
328  }
329 
330  XAttr( const std::string &name, const std::string &value = "",
331  const XRootDStatus &status = XRootDStatus() ) :
333  {
334 
335  }
336 
337  virtual ~XAttr(){}
338 
339  std::string value;
340  };
341 
342  //----------------------------------------------------------------------------
344  //----------------------------------------------------------------------------
346 
347  //----------------------------------------------------------------------------
349  //----------------------------------------------------------------------------
351  {
352  public:
353  //------------------------------------------------------------------------
355  //------------------------------------------------------------------------
357  {
364  };
365 
366  //------------------------------------------------------------------------
368  //------------------------------------------------------------------------
369  ProtocolInfo( uint32_t version, uint32_t hostInfo ):
370  pVersion( version ), pHostInfo( hostInfo ) {}
371 
372  //------------------------------------------------------------------------
374  //------------------------------------------------------------------------
375  virtual ~ProtocolInfo() {}
376 
377  //------------------------------------------------------------------------
379  //------------------------------------------------------------------------
380  uint32_t GetVersion() const
381  {
382  return pVersion;
383  }
384 
385  //------------------------------------------------------------------------
387  //------------------------------------------------------------------------
388  uint32_t GetHostInfo() const
389  {
390  return pHostInfo;
391  }
392 
393  //------------------------------------------------------------------------
395  //------------------------------------------------------------------------
396  bool TestHostInfo( uint32_t flags )
397  {
398  return pHostInfo & flags;
399  }
400 
401  private:
402  uint32_t pVersion;
403  uint32_t pHostInfo;
404  };
405 
406  //----------------------------------------------------------------------------
408  //----------------------------------------------------------------------------
409  struct StatInfoImpl;
410 
411  //----------------------------------------------------------------------------
413  //----------------------------------------------------------------------------
414  class StatInfo
415  {
416  public:
417  //------------------------------------------------------------------------
419  //------------------------------------------------------------------------
420  enum Flags
421  {
431  };
432 
433  //------------------------------------------------------------------------
435  //------------------------------------------------------------------------
436  StatInfo();
437 
438  //------------------------------------------------------------------------
440  //------------------------------------------------------------------------
441  StatInfo( const std::string &id, uint64_t size, uint32_t flags,
442  uint64_t modTime );
443 
444  //------------------------------------------------------------------------
446  //------------------------------------------------------------------------
447  StatInfo( const StatInfo &info );
448 
449  //------------------------------------------------------------------------
451  //------------------------------------------------------------------------
452  virtual ~StatInfo();
453 
454  //------------------------------------------------------------------------
456  //------------------------------------------------------------------------
457  const std::string& GetId() const;
458 
459  //------------------------------------------------------------------------
461  //------------------------------------------------------------------------
462  uint64_t GetSize() const;
463 
464  //------------------------------------------------------------------------
466  //------------------------------------------------------------------------
467  void SetSize( uint64_t size );
468 
469  //------------------------------------------------------------------------
471  //------------------------------------------------------------------------
472  uint32_t GetFlags() const;
473 
474  //------------------------------------------------------------------------
476  //------------------------------------------------------------------------
477  void SetFlags( uint32_t flags );
478 
479  //------------------------------------------------------------------------
481  //------------------------------------------------------------------------
482  bool TestFlags( uint32_t flags ) const;
483 
484  //------------------------------------------------------------------------
486  //------------------------------------------------------------------------
487  uint64_t GetModTime() const;
488 
489  //------------------------------------------------------------------------
491  //------------------------------------------------------------------------
492  std::string GetModTimeAsString() const;
493 
494  //------------------------------------------------------------------------
496  //------------------------------------------------------------------------
497  uint64_t GetChangeTime() const;
498 
499  //------------------------------------------------------------------------
501  //------------------------------------------------------------------------
502  std::string GetChangeTimeAsString() const;
503 
504  //------------------------------------------------------------------------
506  //------------------------------------------------------------------------
507  uint64_t GetAccessTime() const;
508 
509  //------------------------------------------------------------------------
511  //------------------------------------------------------------------------
512  std::string GetAccessTimeAsString() const;
513 
514  //------------------------------------------------------------------------
516  //------------------------------------------------------------------------
517  const std::string& GetModeAsString() const;
518 
519  //------------------------------------------------------------------------
521  //------------------------------------------------------------------------
522  const std::string GetModeAsOctString() const;
523 
524  //------------------------------------------------------------------------
526  //------------------------------------------------------------------------
527  const std::string& GetOwner() const;
528 
529  //------------------------------------------------------------------------
531  //------------------------------------------------------------------------
532  const std::string& GetGroup() const;
533 
534  //------------------------------------------------------------------------
536  //------------------------------------------------------------------------
537  const std::string& GetChecksum() const;
538 
539  //------------------------------------------------------------------------
541  //------------------------------------------------------------------------
542  bool ParseServerResponse( const char *data );
543 
544  //------------------------------------------------------------------------
546  //------------------------------------------------------------------------
547  bool ExtendedFormat() const;
548 
549  //------------------------------------------------------------------------
551  //------------------------------------------------------------------------
552  bool HasChecksum() const;
553 
554  private:
555 
556  static inline std::string TimeToString( uint64_t time )
557  {
558  char ts[256];
559  time_t modTime = time;
560  tm t;
561  localtime_r( &modTime, &t );
562  strftime( ts, sizeof( ts ), "%F %T %z", &t );
563  return ts;
564  }
565 
566  static inline void OctToString( uint8_t oct, std::string &str )
567  {
568  static const uint8_t r_mask = 0x4;
569  static const uint8_t w_mask = 0x2;
570  static const uint8_t x_mask = 0x1;
571 
572  if( r_mask & oct ) str.push_back( 'r' );
573  else str.push_back( '-' );
574 
575  if( w_mask & oct ) str.push_back( 'w' );
576  else str.push_back( '-' );
577 
578  if( x_mask & oct ) str.push_back( 'x' );
579  else str.push_back( '-' );
580  }
581 
582  std::unique_ptr<StatInfoImpl> pImpl;
583  };
584 
585  //----------------------------------------------------------------------------
587  //----------------------------------------------------------------------------
589  {
590  public:
591  //------------------------------------------------------------------------
593  //------------------------------------------------------------------------
594  StatInfoVFS();
595 
596  //------------------------------------------------------------------------
598  //------------------------------------------------------------------------
599  virtual ~StatInfoVFS() {}
600 
601  //------------------------------------------------------------------------
603  //------------------------------------------------------------------------
604  uint64_t GetNodesRW() const
605  {
606  return pNodesRW;
607  }
608 
609  //------------------------------------------------------------------------
611  //------------------------------------------------------------------------
612  uint64_t GetFreeRW() const
613  {
614  return pFreeRW;
615  }
616 
617  //------------------------------------------------------------------------
619  //------------------------------------------------------------------------
620  uint8_t GetUtilizationRW() const
621  {
622  return pUtilizationRW;
623  }
624 
625  //------------------------------------------------------------------------
627  //------------------------------------------------------------------------
628  uint64_t GetNodesStaging() const
629  {
630  return pNodesStaging;
631  }
632 
633  //------------------------------------------------------------------------
635  //------------------------------------------------------------------------
636  uint64_t GetFreeStaging() const
637  {
638  return pFreeStaging;
639  }
640 
641  //------------------------------------------------------------------------
643  //------------------------------------------------------------------------
644  uint8_t GetUtilizationStaging() const
645  {
646  return pUtilizationStaging;
647  }
648 
649  //------------------------------------------------------------------------
651  //------------------------------------------------------------------------
652  bool ParseServerResponse( const char *data );
653 
654  private:
655 
656  //------------------------------------------------------------------------
657  // kXR_vfs stat
658  //------------------------------------------------------------------------
659  uint64_t pNodesRW;
660  uint64_t pFreeRW;
661  uint32_t pUtilizationRW;
662  uint64_t pNodesStaging;
663  uint64_t pFreeStaging;
664  uint32_t pUtilizationStaging;
665  };
666 
667  //----------------------------------------------------------------------------
669  //----------------------------------------------------------------------------
671  {
672  public:
673 
674  //------------------------------------------------------------------------
676  //------------------------------------------------------------------------
677  class ListEntry
678  {
679  public:
680  //--------------------------------------------------------------------
682  //--------------------------------------------------------------------
683  ListEntry( const std::string &hostAddress,
684  const std::string &name,
685  StatInfo *statInfo = 0):
686  pHostAddress( hostAddress ),
687  pName( SanitizeName( name ) ),
688  pStatInfo( statInfo )
689  {}
690 
691  //--------------------------------------------------------------------
693  //--------------------------------------------------------------------
695  {
696  delete pStatInfo;
697  }
698 
699  //--------------------------------------------------------------------
701  //--------------------------------------------------------------------
702  const std::string &GetHostAddress() const
703  {
704  return pHostAddress;
705  }
706 
707  //--------------------------------------------------------------------
709  //--------------------------------------------------------------------
710  const std::string &GetName() const
711  {
712  return pName;
713  }
714 
715  //--------------------------------------------------------------------
717  //--------------------------------------------------------------------
719  {
720  return pStatInfo;
721  }
722 
723  //--------------------------------------------------------------------
725  //--------------------------------------------------------------------
726  const StatInfo *GetStatInfo() const
727  {
728  return pStatInfo;
729  }
730 
731  //--------------------------------------------------------------------
733  //--------------------------------------------------------------------
734  void SetStatInfo( StatInfo *info )
735  {
736  pStatInfo = info;
737  }
738 
739  private:
740 
741  inline static std::string SanitizeName( const std::string &name )
742  {
743  const char *cstr = name.c_str();
744  while( *cstr == '/' ) // the C string is guaranteed to end with '\0'
745  ++cstr;
746  return cstr;
747  }
748 
749  std::string pHostAddress;
750  std::string pName;
751  StatInfo *pStatInfo;
752  };
753 
754  //------------------------------------------------------------------------
756  //------------------------------------------------------------------------
757  DirectoryList();
758 
759  //------------------------------------------------------------------------
761  //------------------------------------------------------------------------
762  virtual ~DirectoryList();
763 
764  //------------------------------------------------------------------------
766  //------------------------------------------------------------------------
767  typedef std::vector<ListEntry*> DirList;
768 
769  //------------------------------------------------------------------------
771  //------------------------------------------------------------------------
772  typedef DirList::iterator Iterator;
773 
774  //------------------------------------------------------------------------
776  //------------------------------------------------------------------------
777  typedef DirList::const_iterator ConstIterator;
778 
779  //------------------------------------------------------------------------
781  //------------------------------------------------------------------------
782  void Add( ListEntry *entry )
783  {
784  pDirList.push_back( entry );
785  }
786 
787  //------------------------------------------------------------------------
789  //------------------------------------------------------------------------
790  ListEntry *At( uint32_t index )
791  {
792  return pDirList[index];
793  }
794 
795  //------------------------------------------------------------------------
797  //------------------------------------------------------------------------
799  {
800  return pDirList.begin();
801  }
802 
803  //------------------------------------------------------------------------
805  //------------------------------------------------------------------------
807  {
808  return pDirList.begin();
809  }
810 
811  //------------------------------------------------------------------------
813  //------------------------------------------------------------------------
815  {
816  return pDirList.end();
817  }
818 
819  //------------------------------------------------------------------------
821  //------------------------------------------------------------------------
823  {
824  return pDirList.end();
825  }
826 
827  //------------------------------------------------------------------------
829  //------------------------------------------------------------------------
830  uint32_t GetSize() const
831  {
832  return pDirList.size();
833  }
834 
835  //------------------------------------------------------------------------
837  //------------------------------------------------------------------------
838  const std::string &GetParentName() const
839  {
840  return pParent;
841  }
842 
843  //------------------------------------------------------------------------
845  //------------------------------------------------------------------------
846  void SetParentName( const std::string &parent )
847  {
848  size_t pos = parent.find( '?' );
849  pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
850  if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
851  pParent += "/";
852  }
853 
854  //------------------------------------------------------------------------
856  //------------------------------------------------------------------------
857  bool ParseServerResponse( const std::string &hostId,
858  const char *data );
859 
860  //------------------------------------------------------------------------
862  //------------------------------------------------------------------------
863  bool ParseServerResponse( const std::string &hostId,
864  const char *data,
865  bool isDStat );
866 
867  //------------------------------------------------------------------------
869  //------------------------------------------------------------------------
870  static bool HasStatInfo( const char *data );
871 
872  private:
873  DirList pDirList;
874  std::string pParent;
875 
876  static const std::string dStatPrefix;
877  };
878 
879  //----------------------------------------------------------------------------
881  //----------------------------------------------------------------------------
882  class OpenInfo
883  {
884  public:
885  //------------------------------------------------------------------------
887  //------------------------------------------------------------------------
888  OpenInfo( const uint8_t *fileHandle,
889  uint64_t sessionId,
890  StatInfo *statInfo = 0 ):
891  pSessionId(sessionId), pStatInfo( statInfo )
892  {
893  memcpy( pFileHandle, fileHandle, 4 );
894  }
895 
896  //------------------------------------------------------------------------
898  //------------------------------------------------------------------------
899  virtual ~OpenInfo()
900  {
901  delete pStatInfo;
902  }
903 
904  //------------------------------------------------------------------------
906  //------------------------------------------------------------------------
907  void GetFileHandle( uint8_t *fileHandle ) const
908  {
909  memcpy( fileHandle, pFileHandle, 4 );
910  }
911 
912  //------------------------------------------------------------------------
914  //------------------------------------------------------------------------
915  const StatInfo *GetStatInfo() const
916  {
917  return pStatInfo;
918  }
919 
920  //------------------------------------------------------------------------
921  // Get session ID
922  //------------------------------------------------------------------------
923  uint64_t GetSessionId() const
924  {
925  return pSessionId;
926  }
927 
928  private:
929  uint8_t pFileHandle[4];
930  uint64_t pSessionId;
931  StatInfo *pStatInfo;
932  };
933 
934  //----------------------------------------------------------------------------
936  //----------------------------------------------------------------------------
937  struct ChunkInfo
938  {
939  //--------------------------------------------------------------------------
941  //--------------------------------------------------------------------------
942  ChunkInfo( uint64_t off = 0, uint32_t len = 0, void *buff = 0 ):
943  offset( off ), length( len ), buffer(buff) {}
944 
945  //--------------------------------------------------------------------------
947  //--------------------------------------------------------------------------
948  virtual ~ChunkInfo() {}
949 
950  //----------------------------------------------------------------------------
952  //----------------------------------------------------------------------------
953  inline uint64_t GetOffset() const
954  {
955  return offset;
956  }
957 
958  //----------------------------------------------------------------------------
960  //----------------------------------------------------------------------------
961  inline uint32_t GetLength() const
962  {
963  return length;
964  }
965 
966  //----------------------------------------------------------------------------
968  //----------------------------------------------------------------------------
969  inline void* GetBuffer()
970  {
971  return buffer;
972  }
973 
974  uint64_t offset;
975  uint32_t length;
976  void *buffer;
977  };
978 
979  struct PageInfoImpl;
980 
981  struct PageInfo
982  {
983  //----------------------------------------------------------------------------
985  //----------------------------------------------------------------------------
986  PageInfo( uint64_t offset = 0, uint32_t length = 0, void *buffer = 0,
987  std::vector<uint32_t> &&cksums = std::vector<uint32_t>() );
988 
989  //----------------------------------------------------------------------------
991  //----------------------------------------------------------------------------
992  PageInfo( PageInfo &&pginf );
993 
994  //----------------------------------------------------------------------------
996  //----------------------------------------------------------------------------
997  PageInfo& operator=( PageInfo &&pginf );
998 
999  //----------------------------------------------------------------------------
1001  //----------------------------------------------------------------------------
1002  virtual ~PageInfo();
1003 
1004  //----------------------------------------------------------------------------
1006  //----------------------------------------------------------------------------
1007  uint64_t GetOffset() const;
1008 
1009  //----------------------------------------------------------------------------
1011  //----------------------------------------------------------------------------
1012  uint32_t GetLength() const;
1013 
1014  //----------------------------------------------------------------------------
1016  //----------------------------------------------------------------------------
1017  void* GetBuffer();
1018 
1019  //----------------------------------------------------------------------------
1021  //----------------------------------------------------------------------------
1022  std::vector<uint32_t>& GetCksums();
1023 
1024  //----------------------------------------------------------------------------
1026  //----------------------------------------------------------------------------
1027  size_t GetNbRepair();
1028 
1029  //----------------------------------------------------------------------------
1031  //----------------------------------------------------------------------------
1032  void SetNbRepair( size_t nbrepair );
1033 
1034  private:
1035  //--------------------------------------------------------------------------
1037  //--------------------------------------------------------------------------
1038  std::unique_ptr<PageInfoImpl> pImpl;
1039  };
1040 
1041  struct RetryInfoImpl;
1042 
1043  struct RetryInfo
1044  {
1045  //----------------------------------------------------------------------------
1047  //----------------------------------------------------------------------------
1048  RetryInfo( std::vector<std::tuple<uint64_t, uint32_t>> && retries );
1049 
1050  //----------------------------------------------------------------------------
1052  //----------------------------------------------------------------------------
1053  virtual ~RetryInfo();
1054 
1055  //----------------------------------------------------------------------------
1057  //----------------------------------------------------------------------------
1058  bool NeedRetry();
1059 
1060  //----------------------------------------------------------------------------
1062  //----------------------------------------------------------------------------
1063  size_t Size();
1064 
1065  //----------------------------------------------------------------------------
1067  // retransmitted
1068  //----------------------------------------------------------------------------
1069  std::tuple<uint64_t, uint32_t> At( size_t i );
1070 
1071  private:
1072  //--------------------------------------------------------------------------
1074  //--------------------------------------------------------------------------
1075  std::unique_ptr<RetryInfoImpl> pImpl;
1076  };
1077 
1078  //----------------------------------------------------------------------------
1080  //----------------------------------------------------------------------------
1081  class File;
1082 
1083  struct TractInfo
1084  {
1085  //--------------------------------------------------------------------------
1087  //--------------------------------------------------------------------------
1088  TractInfo( uint64_t off = 0, uint32_t len = 0, File* fp = 0 ):
1089  offset( off ), length( len ), pFile( fp ) {}
1090 
1091  //--------------------------------------------------------------------------
1093  //--------------------------------------------------------------------------
1094  virtual ~TractInfo() {}
1095 
1096  uint64_t offset;
1097  uint32_t length;
1099  };
1100 
1101  //----------------------------------------------------------------------------
1103  //----------------------------------------------------------------------------
1104  typedef std::vector<ChunkInfo> ChunkList;
1105 
1106  //----------------------------------------------------------------------------
1108  //----------------------------------------------------------------------------
1109  typedef std::vector<TractInfo> TractList;
1110 
1111  //----------------------------------------------------------------------------
1113  //----------------------------------------------------------------------------
1115  {
1116  public:
1117  //------------------------------------------------------------------------
1119  //------------------------------------------------------------------------
1120  VectorReadInfo(): pSize( 0 ) {}
1121 
1122  //------------------------------------------------------------------------
1124  //------------------------------------------------------------------------
1125  virtual ~VectorReadInfo() {}
1126 
1127  //------------------------------------------------------------------------
1129  //------------------------------------------------------------------------
1130  uint32_t GetSize() const
1131  {
1132  return pSize;
1133  }
1134 
1135  //------------------------------------------------------------------------
1137  //------------------------------------------------------------------------
1138  void SetSize( uint32_t size )
1139  {
1140  pSize = size;
1141  }
1142 
1143  //------------------------------------------------------------------------
1145  //------------------------------------------------------------------------
1147  {
1148  return pChunks;
1149  }
1150 
1151  //------------------------------------------------------------------------
1153  //------------------------------------------------------------------------
1154  const ChunkList &GetChunks() const
1155  {
1156  return pChunks;
1157  }
1158 
1159  private:
1160  ChunkList pChunks;
1161  uint32_t pSize;
1162  };
1163 
1164  //----------------------------------------------------------------------------
1165  // List of URLs
1166  //----------------------------------------------------------------------------
1167  struct HostInfo
1168  {
1170  flags(0), protocol(0), loadBalancer(false) {}
1171  HostInfo( const URL &u, bool lb = false ):
1172  flags(0), protocol(0), loadBalancer(lb), url(u) {}
1173  virtual ~HostInfo(){};
1174 
1175  uint32_t flags;
1176  uint32_t protocol;
1179  };
1180 
1181  typedef std::vector<HostInfo> HostList;
1182 
1183  //----------------------------------------------------------------------------
1185  //----------------------------------------------------------------------------
1187  {
1188  public:
1189  virtual ~ResponseHandler() {}
1190 
1191  //------------------------------------------------------------------------
1199  //------------------------------------------------------------------------
1200  virtual void HandleResponseWithHosts( XRootDStatus *status,
1201  AnyObject *response,
1202  HostList *hostList )
1203  {
1204  delete hostList;
1205  HandleResponse( status, response );
1206  }
1207 
1208  //------------------------------------------------------------------------
1215  //------------------------------------------------------------------------
1216  virtual void HandleResponse( XRootDStatus *status,
1217  AnyObject *response )
1218  {
1219  (void)status; (void)response;
1220  }
1221 
1222  //------------------------------------------------------------------------
1227  //------------------------------------------------------------------------
1228  static ResponseHandler* Wrap( std::function<void(XRootDStatus&, AnyObject&)> func );
1229 
1230  //------------------------------------------------------------------------
1235  //------------------------------------------------------------------------
1236  static ResponseHandler* Wrap( std::function<void(XRootDStatus*, AnyObject*)> func );
1237  };
1238 }
1239 
1240 #endif // __XRD_CL_XROOTD_RESPONSES_HH__
#define kXR_isManager
Definition: XProtocol.hh:1198
#define kXR_attrMeta
Definition: XProtocol.hh:1201
#define kXR_attrSuper
Definition: XProtocol.hh:1203
#define kXR_isServer
Definition: XProtocol.hh:1199
#define kXR_attrCache
Definition: XProtocol.hh:1200
#define kXR_attrProxy
Definition: XProtocol.hh:1202
@ kXR_readable
Definition: XProtocol.hh:1266
@ kXR_isDir
Definition: XProtocol.hh:1263
@ kXR_offline
Definition: XProtocol.hh:1265
@ kXR_bkpexist
Definition: XProtocol.hh:1269
@ kXR_other
Definition: XProtocol.hh:1264
@ kXR_poscpend
Definition: XProtocol.hh:1268
@ kXR_writable
Definition: XProtocol.hh:1267
@ kXR_xset
Definition: XProtocol.hh:1262
static std::string ts()
timestamp output for logging messages
Definition: XrdCephOss.cc:53
static void parent()
int access(const char *path, int amode)
Binary blob representation.
Definition: XrdClBuffer.hh:34
void SetStatInfo(StatInfo *info)
Set the stat info object (and transfer the ownership)
const StatInfo * GetStatInfo() const
Get the stat info object.
ListEntry(const std::string &hostAddress, const std::string &name, StatInfo *statInfo=0)
Constructor.
const std::string & GetHostAddress() const
Get host address.
const std::string & GetName() const
Get file name.
StatInfo * GetStatInfo()
Get the stat info object.
DirList::const_iterator ConstIterator
Directory listing const iterator.
ListEntry * At(uint32_t index)
Get an entry at given index.
void Add(ListEntry *entry)
Add an entry to the list - takes ownership.
uint32_t GetSize() const
Get the size of the listing.
DirList::iterator Iterator
Directory listing iterator.
Iterator End()
Get the end iterator.
static bool HasStatInfo(const char *data)
Returns true if data contain stat info.
std::vector< ListEntry * > DirList
Directory listing.
virtual ~DirectoryList()
Destructor.
Iterator Begin()
Get the begin iterator.
ConstIterator End() const
Get the end iterator.
const std::string & GetParentName() const
Get parent directory name.
void SetParentName(const std::string &parent)
Set name of the parent directory.
bool ParseServerResponse(const std::string &hostId, const char *data)
Parse server response and fill up the object.
ConstIterator Begin() const
Get the begin iterator.
Handle the stateful operations.
Send file/filesystem queries to an XRootD cluster.
A file.
Definition: XrdClFile.hh:52
LocationType GetType() const
Get location type.
bool IsServer() const
Check whether the location is a server.
Location(const std::string &address, LocationType type, AccessType access)
Constructor.
const std::string & GetAddress() const
Get address.
AccessType GetAccessType() const
Get access type.
bool IsManager() const
Check whether the location is a manager.
Path location info.
uint32_t GetSize() const
Get number of locations.
Iterator Begin()
Get the location begin iterator.
Location & At(uint32_t index)
Get the location at index.
void Add(const Location &location)
Add a location.
std::vector< Location > LocationList
List of locations.
LocationList::const_iterator ConstIterator
Iterator over locations.
ConstIterator Begin() const
Get the location begin iterator.
virtual ~LocationInfo()
Destructor.
bool ParseServerResponse(const char *data)
Parse server response and fill up the object.
AccessType
Describes the allowed access type for the file at given location.
@ Read
read access is allowed
@ ReadWrite
write access is allowed
LocationType
Describes the node type and file status for a given location.
@ ServerPending
server node where the file is pending to be online
@ ManagerOnline
manager node where the file is online
@ ServerOnline
server node where the file is online
@ ManagerPending
manager node where the file is pending to be online
ConstIterator End() const
Get the location end iterator.
LocationList::iterator Iterator
Iterator over locations.
Iterator End()
Get the location end iterator.
Information returned by file open operation.
void GetFileHandle(uint8_t *fileHandle) const
Get the file handle (4bytes)
const StatInfo * GetStatInfo() const
Get the stat info.
OpenInfo(const uint8_t *fileHandle, uint64_t sessionId, StatInfo *statInfo=0)
Constructor.
uint64_t GetSessionId() const
virtual ~OpenInfo()
Destructor.
bool TestHostInfo(uint32_t flags)
Test host info flags.
HostTypes
Types of XRootD servers.
@ AttrProxy
Proxy attribute.
@ AttrSuper
Supervisor attribute.
@ AttrCache
Cache attribute.
virtual ~ProtocolInfo()
Destructor.
uint32_t GetVersion() const
Get version info.
ProtocolInfo(uint32_t version, uint32_t hostInfo)
Constructor.
uint32_t GetHostInfo() const
Get host info.
Handle an async response.
virtual void HandleResponseWithHosts(XRootDStatus *status, AnyObject *response, HostList *hostList)
static ResponseHandler * Wrap(std::function< void(XRootDStatus &, AnyObject &)> func)
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
uint64_t GetFreeRW() const
Get size of the largest contiguous area of free r/w space (in MB)
uint64_t GetNodesStaging() const
Get number of nodes that can provide staging space.
uint8_t GetUtilizationStaging() const
Get percentage of the partition utilization represented by FreeStaging.
uint64_t GetFreeStaging() const
Get size of the largest contiguous area of free staging space (in MB)
uint8_t GetUtilizationRW() const
Get percentage of the partition utilization represented by FreeRW.
bool ParseServerResponse(const char *data)
Parse server response and fill up the object.
uint64_t GetNodesRW() const
Get number of nodes that can provide read/write space.
virtual ~StatInfoVFS()
Destructor.
Object stat info.
uint64_t GetChangeTime() const
Get change time (in seconds since epoch)
std::string GetChangeTimeAsString() const
Get change time.
std::string GetModTimeAsString() const
Get modification time.
bool HasChecksum() const
Has checksum.
bool TestFlags(uint32_t flags) const
Test flags.
uint64_t GetSize() const
Get size (in bytes)
const std::string GetModeAsOctString() const
Get mode.
virtual ~StatInfo()
Destructor.
const std::string & GetOwner() const
Get owner.
bool ParseServerResponse(const char *data)
Parse server response and fill up the object.
@ IsReadable
Read access is allowed.
@ IsDir
This is a directory.
@ Other
Neither a file nor a directory.
@ BackUpExists
Back up copy exists.
@ XBitSet
Executable/searchable bit set.
@ Offline
File is not online (ie. on disk)
@ IsWritable
Write access is allowed.
uint32_t GetFlags() const
Get flags.
bool ExtendedFormat() const
Has extended stat information.
const std::string & GetModeAsString() const
Get mode.
const std::string & GetId() const
Get id.
const std::string & GetGroup() const
Get group.
uint64_t GetModTime() const
Get modification time (in seconds since epoch)
std::string GetAccessTimeAsString() const
Get change time.
void SetSize(uint64_t size)
Set size.
uint64_t GetAccessTime() const
Get change time (in seconds since epoch)
void SetFlags(uint32_t flags)
Set flags.
const std::string & GetChecksum() const
Get checksum.
URL representation.
Definition: XrdClURL.hh:31
virtual ~VectorReadInfo()
Destructor.
uint32_t GetSize() const
Get Size.
const ChunkList & GetChunks() const
Get chunks.
void SetSize(uint32_t size)
Set size.
ChunkList & GetChunks()
Get chunks.
void SetErrorMessage(const std::string &message)
Set the error message.
XRootDStatus(uint16_t st=0, uint16_t code=0, uint32_t errN=0, const std::string &message="")
Constructor.
const std::string & GetErrorMessage() const
Get error message.
XRootDStatus(const Status &st, const std::string &message="")
Constructor.
std::string ToStr() const
Convert to string.
const uint16_t errErrorResponse
Definition: XrdClStatus.hh:105
std::vector< HostInfo > HostList
std::vector< TractInfo > TractList
List of Tracts.
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
std::vector< ChunkInfo > ChunkList
List of chunks.
Buffer BinaryDataInfo
Binary buffer.
@ oct
Definition: XrdSysTrace.hh:42
Describe a data chunk for vector read.
void * buffer
length of the chunk
virtual ~ChunkInfo()
Destructor.
uint64_t GetOffset() const
Get the offset.
uint32_t GetLength() const
Get the data length.
uint32_t length
offset in the file
ChunkInfo(uint64_t off=0, uint32_t len=0, void *buff=0)
Constructor.
void * GetBuffer()
Get the buffer.
HostInfo(const URL &u, bool lb=false)
URL url
URL of the host.
uint32_t protocol
Version of the protocol the host is speaking.
bool loadBalancer
Was the host used as a load balancer.
uint32_t flags
Host type.
size_t GetNbRepair()
Get number of repaired pages.
void SetNbRepair(size_t nbrepair)
Set number of repaired pages.
virtual ~PageInfo()
Destructor.
PageInfo(uint64_t offset=0, uint32_t length=0, void *buffer=0, std::vector< uint32_t > &&cksums=std::vector< uint32_t >())
Default constructor.
PageInfo & operator=(PageInfo &&pginf)
Move assigment operator.
std::vector< uint32_t > & GetCksums()
Get the checksums.
uint32_t GetLength() const
Get the data length.
uint64_t GetOffset() const
Get the offset.
void * GetBuffer()
Get the buffer.
std::tuple< uint64_t, uint32_t > At(size_t i)
RetryInfo(std::vector< std::tuple< uint64_t, uint32_t >> &&retries)
Constructor.
virtual ~RetryInfo()
Destructor.
Procedure execution status.
Definition: XrdClStatus.hh:115
uint16_t code
Error type, or additional hints on what to do.
Definition: XrdClStatus.hh:147
std::string ToString() const
Create a string representation.
Definition: XrdClStatus.cc:97
uint32_t errNo
Errno, if any.
Definition: XrdClStatus.hh:148
TractInfo(uint64_t off=0, uint32_t len=0, File *fp=0)
Constructor.
File * pFile
length of the data
virtual ~TractInfo()
Destructor.
uint32_t length
offset in the file
Extended attribute operation status.
XAttrStatus(const std::string &name, const XRootDStatus &status)
Extended attributes with status.
XAttr(const std::string &name, const XRootDStatus &status)
XAttr(const std::string &name, const std::string &value="", const XRootDStatus &status=XRootDStatus())