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;
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  //------------------------------------------------------------------------
148 
149  //------------------------------------------------------------------------
151  //------------------------------------------------------------------------
152  uint32_t GetSize() const
153  {
154  return pLocations.size();
155  }
156 
157  //------------------------------------------------------------------------
159  //------------------------------------------------------------------------
160  Location &At( uint32_t index )
161  {
162  return pLocations[index];
163  }
164 
165  //------------------------------------------------------------------------
167  //------------------------------------------------------------------------
169  {
170  return pLocations.begin();
171  }
172 
173  //------------------------------------------------------------------------
175  //------------------------------------------------------------------------
177  {
178  return pLocations.begin();
179  }
180 
181  //------------------------------------------------------------------------
183  //------------------------------------------------------------------------
185  {
186  return pLocations.end();
187  }
188 
189  //------------------------------------------------------------------------
191  //------------------------------------------------------------------------
193  {
194  return pLocations.end();
195  }
196 
197  //------------------------------------------------------------------------
199  //------------------------------------------------------------------------
200  void Add( const Location &location )
201  {
202  pLocations.push_back( location );
203  }
204 
205  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  bool ParseServerResponse( const char *data );
209 
210  private:
211  bool ProcessLocation( std::string &location );
213  };
214 
215  //----------------------------------------------------------------------------
217  //----------------------------------------------------------------------------
218  class XRootDStatus: public Status
219  {
220  public:
221  //------------------------------------------------------------------------
223  //------------------------------------------------------------------------
224  XRootDStatus( uint16_t st = 0,
225  uint16_t code = 0,
226  uint32_t errN = 0,
227  const std::string &message = "" ):
228  Status( st, code, errN ),
229  pMessage( message ) {}
230 
231  //------------------------------------------------------------------------
233  //------------------------------------------------------------------------
234  XRootDStatus( const Status &st,
235  const std::string &message = "" ):
236  Status( st ),
237  pMessage( message ) {}
238 
239  //------------------------------------------------------------------------
241  //------------------------------------------------------------------------
242  const std::string &GetErrorMessage() const
243  {
244  return pMessage;
245  }
246 
247  //------------------------------------------------------------------------
249  //------------------------------------------------------------------------
250  void SetErrorMessage( const std::string &message )
251  {
252  pMessage = message;
253  }
254 
255  //------------------------------------------------------------------------
257  //------------------------------------------------------------------------
258  std::string ToStr() const
259  {
260  if( code == errErrorResponse )
261  {
262  std::ostringstream o;
263  o << "[ERROR] Server responded with an error: [" << errNo << "] ";
264  o << pMessage << std::endl;
265  return o.str();
266  }
267  std::string str = ToString();
268  if( !pMessage.empty() )
269  str += ": " + pMessage;
270  return str;
271  }
272 
273  private:
274  std::string pMessage;
275  };
276 
277  //----------------------------------------------------------------------------
279  //----------------------------------------------------------------------------
280  enum
281  {
283  xattr_value = 1
284  };
285 
286  //----------------------------------------------------------------------------
288  //----------------------------------------------------------------------------
289  typedef std::tuple<std::string, std::string> xattr_t;
290 
291  //----------------------------------------------------------------------------
293  //----------------------------------------------------------------------------
294  struct XAttrStatus
295  {
296  friend class FileStateHandler;
297  friend class FileSystem;
298 
299  XAttrStatus( const std::string &name, const XRootDStatus &status ) :
300  name( name ), status( status )
301  {
302 
303  }
304 
305  std::string name;
307  };
308 
309  //----------------------------------------------------------------------------
311  //----------------------------------------------------------------------------
312  struct XAttr : public XAttrStatus
313  {
314  friend class FileStateHandler;
315  friend class FileSystem;
316 
317  XAttr( const std::string &name, const XRootDStatus &status ) :
319  {
320 
321  }
322 
323  XAttr( const std::string &name, const std::string &value = "",
324  const XRootDStatus &status = XRootDStatus() ) :
326  {
327 
328  }
329 
330  std::string value;
331  };
332 
333  //----------------------------------------------------------------------------
335  //----------------------------------------------------------------------------
337 
338  //----------------------------------------------------------------------------
340  //----------------------------------------------------------------------------
342  {
343  public:
344  //------------------------------------------------------------------------
346  //------------------------------------------------------------------------
348  {
354  };
355 
356  //------------------------------------------------------------------------
358  //------------------------------------------------------------------------
359  ProtocolInfo( uint32_t version, uint32_t hostInfo ):
360  pVersion( version ), pHostInfo( hostInfo ) {}
361 
362  //------------------------------------------------------------------------
364  //------------------------------------------------------------------------
365  uint32_t GetVersion() const
366  {
367  return pVersion;
368  }
369 
370  //------------------------------------------------------------------------
372  //------------------------------------------------------------------------
373  uint32_t GetHostInfo() const
374  {
375  return pHostInfo;
376  }
377 
378  //------------------------------------------------------------------------
380  //------------------------------------------------------------------------
381  bool TestHostInfo( uint32_t flags )
382  {
383  return pHostInfo & flags;
384  }
385 
386  private:
387  uint32_t pVersion;
388  uint32_t pHostInfo;
389  };
390 
391  //----------------------------------------------------------------------------
393  //----------------------------------------------------------------------------
394  struct StatInfoImpl;
395 
396  //----------------------------------------------------------------------------
398  //----------------------------------------------------------------------------
399  class StatInfo
400  {
401  public:
402  //------------------------------------------------------------------------
404  //------------------------------------------------------------------------
405  enum Flags
406  {
416  };
417 
418  //------------------------------------------------------------------------
420  //------------------------------------------------------------------------
422 
423  //------------------------------------------------------------------------
425  //------------------------------------------------------------------------
426  StatInfo( const std::string &id, uint64_t size, uint32_t flags,
427  uint64_t modTime );
428 
429  //------------------------------------------------------------------------
431  //------------------------------------------------------------------------
432  StatInfo( const StatInfo &info );
433 
434  //------------------------------------------------------------------------
436  //------------------------------------------------------------------------
438 
439  //------------------------------------------------------------------------
441  //------------------------------------------------------------------------
442  const std::string& GetId() const;
443 
444  //------------------------------------------------------------------------
446  //------------------------------------------------------------------------
447  uint64_t GetSize() const;
448 
449  //------------------------------------------------------------------------
451  //------------------------------------------------------------------------
452  void SetSize( uint64_t size );
453 
454  //------------------------------------------------------------------------
456  //------------------------------------------------------------------------
457  uint32_t GetFlags() const;
458 
459  //------------------------------------------------------------------------
461  //------------------------------------------------------------------------
462  void SetFlags( uint32_t flags );
463 
464  //------------------------------------------------------------------------
466  //------------------------------------------------------------------------
467  bool TestFlags( uint32_t flags ) const;
468 
469  //------------------------------------------------------------------------
471  //------------------------------------------------------------------------
472  uint64_t GetModTime() const;
473 
474  //------------------------------------------------------------------------
476  //------------------------------------------------------------------------
477  std::string GetModTimeAsString() const;
478 
479  //------------------------------------------------------------------------
481  //------------------------------------------------------------------------
482  uint64_t GetChangeTime() const;
483 
484  //------------------------------------------------------------------------
486  //------------------------------------------------------------------------
487  std::string GetChangeTimeAsString() const;
488 
489  //------------------------------------------------------------------------
491  //------------------------------------------------------------------------
492  uint64_t GetAccessTime() const;
493 
494  //------------------------------------------------------------------------
496  //------------------------------------------------------------------------
497  std::string GetAccessTimeAsString() const;
498 
499  //------------------------------------------------------------------------
501  //------------------------------------------------------------------------
502  const std::string& GetModeAsString() const;
503 
504  //------------------------------------------------------------------------
506  //------------------------------------------------------------------------
507  const std::string GetModeAsOctString() const;
508 
509  //------------------------------------------------------------------------
511  //------------------------------------------------------------------------
512  const std::string& GetOwner() const;
513 
514  //------------------------------------------------------------------------
516  //------------------------------------------------------------------------
517  const std::string& GetGroup() const;
518 
519  //------------------------------------------------------------------------
521  //------------------------------------------------------------------------
522  const std::string& GetChecksum() const;
523 
524  //------------------------------------------------------------------------
526  //------------------------------------------------------------------------
527  bool ParseServerResponse( const char *data );
528 
529  //------------------------------------------------------------------------
531  //------------------------------------------------------------------------
532  bool ExtendedFormat() const;
533 
534  //------------------------------------------------------------------------
536  //------------------------------------------------------------------------
537  bool HasChecksum() const;
538 
539  private:
540 
541  static inline std::string TimeToString( uint64_t time )
542  {
543  char ts[256];
544  time_t modTime = time;
545  tm *t = gmtime( &modTime );
546  strftime( ts, 255, "%F %T", t );
547  return ts;
548  }
549 
550  static inline void OctToString( uint8_t oct, std::string &str )
551  {
552  static const uint8_t r_mask = 0x4;
553  static const uint8_t w_mask = 0x2;
554  static const uint8_t x_mask = 0x1;
555 
556  if( r_mask & oct ) str.push_back( 'r' );
557  else str.push_back( '-' );
558 
559  if( w_mask & oct ) str.push_back( 'w' );
560  else str.push_back( '-' );
561 
562  if( x_mask & oct ) str.push_back( 'x' );
563  else str.push_back( '-' );
564  }
565 
566  std::unique_ptr<StatInfoImpl> pImpl;
567  };
568 
569  //----------------------------------------------------------------------------
571  //----------------------------------------------------------------------------
573  {
574  public:
575  //------------------------------------------------------------------------
577  //------------------------------------------------------------------------
579 
580  //------------------------------------------------------------------------
582  //------------------------------------------------------------------------
583  uint64_t GetNodesRW() const
584  {
585  return pNodesRW;
586  }
587 
588  //------------------------------------------------------------------------
590  //------------------------------------------------------------------------
591  uint64_t GetFreeRW() const
592  {
593  return pFreeRW;
594  }
595 
596  //------------------------------------------------------------------------
598  //------------------------------------------------------------------------
599  uint8_t GetUtilizationRW() const
600  {
601  return pUtilizationRW;
602  }
603 
604  //------------------------------------------------------------------------
606  //------------------------------------------------------------------------
607  uint64_t GetNodesStaging() const
608  {
609  return pNodesStaging;
610  }
611 
612  //------------------------------------------------------------------------
614  //------------------------------------------------------------------------
615  uint64_t GetFreeStaging() const
616  {
617  return pFreeStaging;
618  }
619 
620  //------------------------------------------------------------------------
622  //------------------------------------------------------------------------
623  uint8_t GetUtilizationStaging() const
624  {
625  return pUtilizationStaging;
626  }
627 
628  //------------------------------------------------------------------------
630  //------------------------------------------------------------------------
631  bool ParseServerResponse( const char *data );
632 
633  private:
634 
635  //------------------------------------------------------------------------
636  // kXR_vfs stat
637  //------------------------------------------------------------------------
638  uint64_t pNodesRW;
639  uint64_t pFreeRW;
640  uint32_t pUtilizationRW;
641  uint64_t pNodesStaging;
642  uint64_t pFreeStaging;
644  };
645 
646  //----------------------------------------------------------------------------
648  //----------------------------------------------------------------------------
650  {
651  public:
652 
653  //------------------------------------------------------------------------
655  //------------------------------------------------------------------------
656  class ListEntry
657  {
658  public:
659  //--------------------------------------------------------------------
661  //--------------------------------------------------------------------
662  ListEntry( const std::string &hostAddress,
663  const std::string &name,
664  StatInfo *statInfo = 0):
665  pHostAddress( hostAddress ),
666  pName( name ),
667  pStatInfo( statInfo )
668  {}
669 
670  //--------------------------------------------------------------------
672  //--------------------------------------------------------------------
674  {
675  delete pStatInfo;
676  }
677 
678  //--------------------------------------------------------------------
680  //--------------------------------------------------------------------
681  const std::string &GetHostAddress() const
682  {
683  return pHostAddress;
684  }
685 
686  //--------------------------------------------------------------------
688  //--------------------------------------------------------------------
689  const std::string &GetName() const
690  {
691  return pName;
692  }
693 
694  //--------------------------------------------------------------------
696  //--------------------------------------------------------------------
698  {
699  return pStatInfo;
700  }
701 
702  //--------------------------------------------------------------------
704  //--------------------------------------------------------------------
705  const StatInfo *GetStatInfo() const
706  {
707  return pStatInfo;
708  }
709 
710  //--------------------------------------------------------------------
712  //--------------------------------------------------------------------
713  void SetStatInfo( StatInfo *info )
714  {
715  pStatInfo = info;
716  }
717 
718  private:
719  std::string pHostAddress;
720  std::string pName;
722  };
723 
724  //------------------------------------------------------------------------
726  //------------------------------------------------------------------------
728 
729  //------------------------------------------------------------------------
731  //------------------------------------------------------------------------
733 
734  //------------------------------------------------------------------------
736  //------------------------------------------------------------------------
737  typedef std::vector<ListEntry*> DirList;
738 
739  //------------------------------------------------------------------------
741  //------------------------------------------------------------------------
742  typedef DirList::iterator Iterator;
743 
744  //------------------------------------------------------------------------
746  //------------------------------------------------------------------------
747  typedef DirList::const_iterator ConstIterator;
748 
749  //------------------------------------------------------------------------
751  //------------------------------------------------------------------------
752  void Add( ListEntry *entry )
753  {
754  pDirList.push_back( entry );
755  }
756 
757  //------------------------------------------------------------------------
759  //------------------------------------------------------------------------
760  ListEntry *At( uint32_t index )
761  {
762  return pDirList[index];
763  }
764 
765  //------------------------------------------------------------------------
767  //------------------------------------------------------------------------
769  {
770  return pDirList.begin();
771  }
772 
773  //------------------------------------------------------------------------
775  //------------------------------------------------------------------------
777  {
778  return pDirList.begin();
779  }
780 
781  //------------------------------------------------------------------------
783  //------------------------------------------------------------------------
785  {
786  return pDirList.end();
787  }
788 
789  //------------------------------------------------------------------------
791  //------------------------------------------------------------------------
793  {
794  return pDirList.end();
795  }
796 
797  //------------------------------------------------------------------------
799  //------------------------------------------------------------------------
800  uint32_t GetSize() const
801  {
802  return pDirList.size();
803  }
804 
805  //------------------------------------------------------------------------
807  //------------------------------------------------------------------------
808  const std::string &GetParentName() const
809  {
810  return pParent;
811  }
812 
813  //------------------------------------------------------------------------
815  //------------------------------------------------------------------------
816  void SetParentName( const std::string &parent )
817  {
818  size_t pos = parent.find( '?' );
819  pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
820  if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
821  pParent += "/";
822  }
823 
824  //------------------------------------------------------------------------
826  //------------------------------------------------------------------------
827  bool ParseServerResponse( const std::string &hostId,
828  const char *data );
829 
830  //------------------------------------------------------------------------
832  //------------------------------------------------------------------------
833  bool ParseServerResponse( const std::string &hostId,
834  const char *data,
835  bool isDStat );
836 
837  //------------------------------------------------------------------------
839  //------------------------------------------------------------------------
840  static bool HasStatInfo( const char *data );
841 
842  private:
844  std::string pParent;
845 
846  static const std::string dStatPrefix;
847  };
848 
849  //----------------------------------------------------------------------------
851  //----------------------------------------------------------------------------
852  class OpenInfo
853  {
854  public:
855  //------------------------------------------------------------------------
857  //------------------------------------------------------------------------
858  OpenInfo( const uint8_t *fileHandle,
859  uint64_t sessionId,
860  StatInfo *statInfo = 0 ):
861  pSessionId(sessionId), pStatInfo( statInfo )
862  {
863  memcpy( pFileHandle, fileHandle, 4 );
864  }
865 
866  //------------------------------------------------------------------------
868  //------------------------------------------------------------------------
870  {
871  delete pStatInfo;
872  }
873 
874  //------------------------------------------------------------------------
876  //------------------------------------------------------------------------
877  void GetFileHandle( uint8_t *fileHandle ) const
878  {
879  memcpy( fileHandle, pFileHandle, 4 );
880  }
881 
882  //------------------------------------------------------------------------
884  //------------------------------------------------------------------------
885  const StatInfo *GetStatInfo() const
886  {
887  return pStatInfo;
888  }
889 
890  //------------------------------------------------------------------------
891  // Get session ID
892  //------------------------------------------------------------------------
893  uint64_t GetSessionId() const
894  {
895  return pSessionId;
896  }
897 
898  private:
899  uint8_t pFileHandle[4];
900  uint64_t pSessionId;
902  };
903 
904  //----------------------------------------------------------------------------
906  //----------------------------------------------------------------------------
907  struct ChunkInfo
908  {
909  //--------------------------------------------------------------------------
911  //--------------------------------------------------------------------------
912  ChunkInfo( uint64_t off = 0, uint32_t len = 0, void *buff = 0 ):
913  offset( off ), length( len ), buffer(buff) {}
914 
915  uint64_t offset;
916  uint32_t length;
917  void *buffer;
918  };
919 
920  struct PageInfoImpl;
921 
922  struct PageInfo
923  {
924  //----------------------------------------------------------------------------
926  //----------------------------------------------------------------------------
927  PageInfo( uint64_t offset = 0, uint32_t length = 0, void *buffer = 0,
928  std::vector<uint32_t> &&cksums = std::vector<uint32_t>() );
929 
930  //----------------------------------------------------------------------------
932  //----------------------------------------------------------------------------
933  PageInfo( PageInfo &&pginf );
934 
935  //----------------------------------------------------------------------------
937  //----------------------------------------------------------------------------
939 
940  //----------------------------------------------------------------------------
942  //----------------------------------------------------------------------------
943  uint64_t GetOffset() const;
944 
945  //----------------------------------------------------------------------------
947  //----------------------------------------------------------------------------
948  uint32_t GetLength() const;
949 
950  //----------------------------------------------------------------------------
952  //----------------------------------------------------------------------------
953  void* GetBuffer();
954 
955  //----------------------------------------------------------------------------
957  //----------------------------------------------------------------------------
958  std::vector<uint32_t>& GetCksums();
959 
960  //----------------------------------------------------------------------------
962  //----------------------------------------------------------------------------
963  size_t GetNbRepair();
964 
965  //----------------------------------------------------------------------------
967  //----------------------------------------------------------------------------
968  void SetNbRepair( size_t nbrepair );
969 
970  private:
971  //--------------------------------------------------------------------------
973  //--------------------------------------------------------------------------
974  std::unique_ptr<PageInfoImpl> pImpl;
975  };
976 
977  //----------------------------------------------------------------------------
979  //----------------------------------------------------------------------------
980  typedef std::vector<ChunkInfo> ChunkList;
981 
982  //----------------------------------------------------------------------------
984  //----------------------------------------------------------------------------
986  {
987  public:
988  //------------------------------------------------------------------------
990  //------------------------------------------------------------------------
992 
993  //------------------------------------------------------------------------
995  //------------------------------------------------------------------------
996  uint32_t GetSize() const
997  {
998  return pSize;
999  }
1000 
1001  //------------------------------------------------------------------------
1003  //------------------------------------------------------------------------
1004  void SetSize( uint32_t size )
1005  {
1006  pSize = size;
1007  }
1008 
1009  //------------------------------------------------------------------------
1011  //------------------------------------------------------------------------
1013  {
1014  return pChunks;
1015  }
1016 
1017  //------------------------------------------------------------------------
1019  //------------------------------------------------------------------------
1020  const ChunkList &GetChunks() const
1021  {
1022  return pChunks;
1023  }
1024 
1025  private:
1027  uint32_t pSize;
1028  };
1029 
1030  //----------------------------------------------------------------------------
1031  // List of URLs
1032  //----------------------------------------------------------------------------
1033  struct HostInfo
1034  {
1036  flags(0), protocol(0), loadBalancer(false) {}
1037  HostInfo( const URL &u, bool lb = false ):
1038  flags(0), protocol(0), loadBalancer(lb), url(u) {}
1039  uint32_t flags;
1040  uint32_t protocol;
1043  };
1044 
1045  typedef std::vector<HostInfo> HostList;
1046 
1047  //----------------------------------------------------------------------------
1049  //----------------------------------------------------------------------------
1051  {
1052  public:
1053  virtual ~ResponseHandler() {}
1054 
1055  //------------------------------------------------------------------------
1063  //------------------------------------------------------------------------
1064  virtual void HandleResponseWithHosts( XRootDStatus *status,
1065  AnyObject *response,
1066  HostList *hostList )
1067  {
1068  delete hostList;
1069  HandleResponse( status, response );
1070  }
1071 
1072  //------------------------------------------------------------------------
1079  //------------------------------------------------------------------------
1080  virtual void HandleResponse( XRootDStatus *status,
1081  AnyObject *response )
1082  {
1083  (void)status; (void)response;
1084  }
1085 
1086  //------------------------------------------------------------------------
1091  //------------------------------------------------------------------------
1092  static ResponseHandler* Wrap( std::function<void(XRootDStatus&, AnyObject&)> func );
1093 
1094  //------------------------------------------------------------------------
1099  //------------------------------------------------------------------------
1100  static ResponseHandler* Wrap( std::function<void(XRootDStatus*, AnyObject*)> func );
1101  };
1102 }
1103 
1104 #endif // __XRD_CL_XROOTD_RESPONSES_HH__
#define kXR_isManager
Definition: XProtocol.hh:1127
#define kXR_attrMeta
Definition: XProtocol.hh:1129
#define kXR_attrSuper
Definition: XProtocol.hh:1131
#define kXR_isServer
Definition: XProtocol.hh:1128
#define kXR_attrProxy
Definition: XProtocol.hh:1130
@ kXR_readable
Definition: XProtocol.hh:1194
@ kXR_isDir
Definition: XProtocol.hh:1191
@ kXR_offline
Definition: XProtocol.hh:1193
@ kXR_bkpexist
Definition: XProtocol.hh:1197
@ kXR_other
Definition: XProtocol.hh:1192
@ kXR_poscpend
Definition: XProtocol.hh:1196
@ kXR_writable
Definition: XProtocol.hh:1195
@ kXR_xset
Definition: XProtocol.hh:1190
#define access(a, b)
Definition: XrdPosix.hh:39
Definition: XrdClAnyObject.hh:33
Binary blob representation.
Definition: XrdClBuffer.hh:34
Directory entry.
Definition: XrdClXRootDResponses.hh:657
void SetStatInfo(StatInfo *info)
Set the stat info object (and transfer the ownership)
Definition: XrdClXRootDResponses.hh:713
std::string pHostAddress
Definition: XrdClXRootDResponses.hh:719
const StatInfo * GetStatInfo() const
Get the stat info object.
Definition: XrdClXRootDResponses.hh:705
StatInfo * pStatInfo
Definition: XrdClXRootDResponses.hh:721
std::string pName
Definition: XrdClXRootDResponses.hh:720
ListEntry(const std::string &hostAddress, const std::string &name, StatInfo *statInfo=0)
Constructor.
Definition: XrdClXRootDResponses.hh:662
~ListEntry()
Destructor.
Definition: XrdClXRootDResponses.hh:673
const std::string & GetHostAddress() const
Get host address.
Definition: XrdClXRootDResponses.hh:681
const std::string & GetName() const
Get file name.
Definition: XrdClXRootDResponses.hh:689
StatInfo * GetStatInfo()
Get the stat info object.
Definition: XrdClXRootDResponses.hh:697
Directory list.
Definition: XrdClXRootDResponses.hh:650
DirList pDirList
Definition: XrdClXRootDResponses.hh:843
DirList::const_iterator ConstIterator
Directory listing const iterator.
Definition: XrdClXRootDResponses.hh:747
DirectoryList()
Constructor.
bool ParseServerResponse(const std::string &hostId, const char *data, bool isDStat)
Parse chunked server response and fill up the object.
ListEntry * At(uint32_t index)
Get an entry at given index.
Definition: XrdClXRootDResponses.hh:760
void Add(ListEntry *entry)
Add an entry to the list - takes ownership.
Definition: XrdClXRootDResponses.hh:752
uint32_t GetSize() const
Get the size of the listing.
Definition: XrdClXRootDResponses.hh:800
DirList::iterator Iterator
Directory listing iterator.
Definition: XrdClXRootDResponses.hh:742
Iterator End()
Get the end iterator.
Definition: XrdClXRootDResponses.hh:784
static bool HasStatInfo(const char *data)
Returns true if data contain stat info.
std::vector< ListEntry * > DirList
Directory listing.
Definition: XrdClXRootDResponses.hh:737
~DirectoryList()
Destructor.
Iterator Begin()
Get the begin iterator.
Definition: XrdClXRootDResponses.hh:768
ConstIterator End() const
Get the end iterator.
Definition: XrdClXRootDResponses.hh:792
const std::string & GetParentName() const
Get parent directory name.
Definition: XrdClXRootDResponses.hh:808
void SetParentName(const std::string &parent)
Set name of the parent directory.
Definition: XrdClXRootDResponses.hh:816
bool ParseServerResponse(const std::string &hostId, const char *data)
Parse server response and fill up the object.
ConstIterator Begin() const
Get the begin iterator.
Definition: XrdClXRootDResponses.hh:776
std::string pParent
Definition: XrdClXRootDResponses.hh:844
static const std::string dStatPrefix
Definition: XrdClXRootDResponses.hh:846
Handle the stateful operations.
Definition: XrdClFileStateHandler.hh:80
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:203
Location.
Definition: XrdClXRootDResponses.hh:70
AccessType pAccess
Definition: XrdClXRootDResponses.hh:126
std::string pAddress
Definition: XrdClXRootDResponses.hh:124
LocationType GetType() const
Get location type.
Definition: XrdClXRootDResponses.hh:94
bool IsServer() const
Check whether the location is a server.
Definition: XrdClXRootDResponses.hh:110
Location(const std::string &address, LocationType type, AccessType access)
Constructor.
Definition: XrdClXRootDResponses.hh:76
const std::string & GetAddress() const
Get address.
Definition: XrdClXRootDResponses.hh:86
LocationType pType
Definition: XrdClXRootDResponses.hh:125
AccessType GetAccessType() const
Get access type.
Definition: XrdClXRootDResponses.hh:102
bool IsManager() const
Check whether the location is a manager.
Definition: XrdClXRootDResponses.hh:118
Path location info.
Definition: XrdClXRootDResponses.hh:44
uint32_t GetSize() const
Get number of locations.
Definition: XrdClXRootDResponses.hh:152
LocationInfo()
Constructor.
Iterator Begin()
Get the location begin iterator.
Definition: XrdClXRootDResponses.hh:168
Location & At(uint32_t index)
Get the location at index.
Definition: XrdClXRootDResponses.hh:160
void Add(const Location &location)
Add a location.
Definition: XrdClXRootDResponses.hh:200
std::vector< Location > LocationList
List of locations.
Definition: XrdClXRootDResponses.hh:132
LocationList pLocations
Definition: XrdClXRootDResponses.hh:212
LocationList::const_iterator ConstIterator
Iterator over locations.
Definition: XrdClXRootDResponses.hh:142
ConstIterator Begin() const
Get the location begin iterator.
Definition: XrdClXRootDResponses.hh:176
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.
Definition: XrdClXRootDResponses.hh:61
@ Read
read access is allowed
Definition: XrdClXRootDResponses.hh:62
@ ReadWrite
write access is allowed
Definition: XrdClXRootDResponses.hh:63
LocationType
Describes the node type and file status for a given location.
Definition: XrdClXRootDResponses.hh:50
@ ServerPending
server node where the file is pending to be online
Definition: XrdClXRootDResponses.hh:54
@ ManagerOnline
manager node where the file is online
Definition: XrdClXRootDResponses.hh:51
@ ServerOnline
server node where the file is online
Definition: XrdClXRootDResponses.hh:53
@ ManagerPending
manager node where the file is pending to be online
Definition: XrdClXRootDResponses.hh:52
ConstIterator End() const
Get the location end iterator.
Definition: XrdClXRootDResponses.hh:192
bool ProcessLocation(std::string &location)
LocationList::iterator Iterator
Iterator over locations.
Definition: XrdClXRootDResponses.hh:137
Iterator End()
Get the location end iterator.
Definition: XrdClXRootDResponses.hh:184
Information returned by file open operation.
Definition: XrdClXRootDResponses.hh:853
void GetFileHandle(uint8_t *fileHandle) const
Get the file handle (4bytes)
Definition: XrdClXRootDResponses.hh:877
const StatInfo * GetStatInfo() const
Get the stat info.
Definition: XrdClXRootDResponses.hh:885
OpenInfo(const uint8_t *fileHandle, uint64_t sessionId, StatInfo *statInfo=0)
Constructor.
Definition: XrdClXRootDResponses.hh:858
uint64_t pSessionId
Definition: XrdClXRootDResponses.hh:900
uint64_t GetSessionId() const
Definition: XrdClXRootDResponses.hh:893
StatInfo * pStatInfo
Definition: XrdClXRootDResponses.hh:901
uint8_t pFileHandle[4]
Definition: XrdClXRootDResponses.hh:899
~OpenInfo()
Destructor.
Definition: XrdClXRootDResponses.hh:869
Protocol response.
Definition: XrdClXRootDResponses.hh:342
uint32_t pHostInfo
Definition: XrdClXRootDResponses.hh:388
bool TestHostInfo(uint32_t flags)
Test host info flags.
Definition: XrdClXRootDResponses.hh:381
HostTypes
Types of XRootD servers.
Definition: XrdClXRootDResponses.hh:348
@ AttrProxy
Proxy attribute.
Definition: XrdClXRootDResponses.hh:352
@ AttrMeta
Meta attribute.
Definition: XrdClXRootDResponses.hh:351
@ IsManager
Manager.
Definition: XrdClXRootDResponses.hh:349
@ AttrSuper
Supervisor attribute.
Definition: XrdClXRootDResponses.hh:353
@ IsServer
Data server.
Definition: XrdClXRootDResponses.hh:350
uint32_t GetVersion() const
Get version info.
Definition: XrdClXRootDResponses.hh:365
ProtocolInfo(uint32_t version, uint32_t hostInfo)
Constructor.
Definition: XrdClXRootDResponses.hh:359
uint32_t GetHostInfo() const
Get host info.
Definition: XrdClXRootDResponses.hh:373
uint32_t pVersion
Definition: XrdClXRootDResponses.hh:387
Handle an async response.
Definition: XrdClXRootDResponses.hh:1051
static ResponseHandler * Wrap(std::function< void(XRootDStatus &, AnyObject &)> func)
static ResponseHandler * Wrap(std::function< void(XRootDStatus *, AnyObject *)> func)
virtual void HandleResponseWithHosts(XRootDStatus *status, AnyObject *response, HostList *hostList)
Definition: XrdClXRootDResponses.hh:1064
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
Definition: XrdClXRootDResponses.hh:1080
virtual ~ResponseHandler()
Definition: XrdClXRootDResponses.hh:1053
VFS stat info.
Definition: XrdClXRootDResponses.hh:573
uint64_t GetFreeRW() const
Get size of the largest contiguous area of free r/w space (in MB)
Definition: XrdClXRootDResponses.hh:591
uint32_t pUtilizationRW
Definition: XrdClXRootDResponses.hh:640
uint64_t GetNodesStaging() const
Get number of nodes that can provide staging space.
Definition: XrdClXRootDResponses.hh:607
uint32_t pUtilizationStaging
Definition: XrdClXRootDResponses.hh:643
uint8_t GetUtilizationStaging() const
Get percentage of the partition utilization represented by FreeStaging.
Definition: XrdClXRootDResponses.hh:623
StatInfoVFS()
Constructor.
uint64_t GetFreeStaging() const
Get size of the largest contiguous area of free staging space (in MB)
Definition: XrdClXRootDResponses.hh:615
uint64_t pFreeRW
Definition: XrdClXRootDResponses.hh:639
uint64_t pFreeStaging
Definition: XrdClXRootDResponses.hh:642
uint8_t GetUtilizationRW() const
Get percentage of the partition utilization represented by FreeRW.
Definition: XrdClXRootDResponses.hh:599
bool ParseServerResponse(const char *data)
Parse server response and fill up the object.
uint64_t pNodesStaging
Definition: XrdClXRootDResponses.hh:641
uint64_t GetNodesRW() const
Get number of nodes that can provide read/write space.
Definition: XrdClXRootDResponses.hh:583
uint64_t pNodesRW
Definition: XrdClXRootDResponses.hh:638
Object stat info.
Definition: XrdClXRootDResponses.hh:400
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.
const std::string & GetGroup() const
Get group.
const std::string & GetModeAsString() const
Get mode.
const std::string & GetChecksum() const
Get checksum.
static void OctToString(uint8_t oct, std::string &str)
Definition: XrdClXRootDResponses.hh:550
uint64_t GetSize() const
Get size (in bytes)
static std::string TimeToString(uint64_t time)
Definition: XrdClXRootDResponses.hh:541
const std::string & GetId() const
Get id.
const std::string GetModeAsOctString() const
Get mode.
~StatInfo()
Destructor.
bool ParseServerResponse(const char *data)
Parse server response and fill up the object.
Flags
Flags.
Definition: XrdClXRootDResponses.hh:406
@ IsReadable
Read access is allowed.
Definition: XrdClXRootDResponses.hh:413
@ IsDir
This is a directory.
Definition: XrdClXRootDResponses.hh:408
@ Other
Neither a file nor a directory.
Definition: XrdClXRootDResponses.hh:409
@ BackUpExists
Back up copy exists.
Definition: XrdClXRootDResponses.hh:415
@ POSCPending
Definition: XrdClXRootDResponses.hh:411
@ XBitSet
Executable/searchable bit set.
Definition: XrdClXRootDResponses.hh:407
@ Offline
File is not online (ie. on disk)
Definition: XrdClXRootDResponses.hh:410
@ IsWritable
Write access is allowed.
Definition: XrdClXRootDResponses.hh:414
uint32_t GetFlags() const
Get flags.
bool ExtendedFormat() const
Has extended stat information.
uint64_t GetModTime() const
Get modification time (in seconds since epoch)
StatInfo(const StatInfo &info)
Copy constructor.
StatInfo()
Constructor.
std::string GetAccessTimeAsString() const
Get change time.
const std::string & GetOwner() const
Get owner.
void SetSize(uint64_t size)
Set size.
uint64_t GetAccessTime() const
Get change time (in seconds since epoch)
std::unique_ptr< StatInfoImpl > pImpl
Definition: XrdClXRootDResponses.hh:566
void SetFlags(uint32_t flags)
Set flags.
StatInfo(const std::string &id, uint64_t size, uint32_t flags, uint64_t modTime)
Constructor.
URL representation.
Definition: XrdClURL.hh:31
Vector read info.
Definition: XrdClXRootDResponses.hh:986
uint32_t GetSize() const
Get Size.
Definition: XrdClXRootDResponses.hh:996
ChunkList pChunks
Definition: XrdClXRootDResponses.hh:1026
const ChunkList & GetChunks() const
Get chunks.
Definition: XrdClXRootDResponses.hh:1020
VectorReadInfo()
Constructor.
Definition: XrdClXRootDResponses.hh:991
void SetSize(uint32_t size)
Set size.
Definition: XrdClXRootDResponses.hh:1004
ChunkList & GetChunks()
Get chunks.
Definition: XrdClXRootDResponses.hh:1012
uint32_t pSize
Definition: XrdClXRootDResponses.hh:1027
Request status.
Definition: XrdClXRootDResponses.hh:219
void SetErrorMessage(const std::string &message)
Set the error message.
Definition: XrdClXRootDResponses.hh:250
XRootDStatus(uint16_t st=0, uint16_t code=0, uint32_t errN=0, const std::string &message="")
Constructor.
Definition: XrdClXRootDResponses.hh:224
std::string pMessage
Definition: XrdClXRootDResponses.hh:274
const std::string & GetErrorMessage() const
Get error message.
Definition: XrdClXRootDResponses.hh:242
XRootDStatus(const Status &st, const std::string &message="")
Constructor.
Definition: XrdClXRootDResponses.hh:234
std::string ToStr() const
Convert to string.
Definition: XrdClXRootDResponses.hh:258
Definition: XrdClAnyObject.hh:26
const uint16_t errErrorResponse
Definition: XrdClStatus.hh:104
@ xattr_name
Definition: XrdClXRootDResponses.hh:282
@ xattr_value
Definition: XrdClXRootDResponses.hh:283
std::vector< HostInfo > HostList
Definition: XrdClXRootDResponses.hh:1045
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition: XrdClXRootDResponses.hh:289
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:980
Buffer BinaryDataInfo
Binary buffer.
Definition: XrdClXRootDResponses.hh:336
Describe a data chunk for vector read.
Definition: XrdClXRootDResponses.hh:908
void * buffer
length of the chunk
Definition: XrdClXRootDResponses.hh:917
uint32_t length
offset in the file
Definition: XrdClXRootDResponses.hh:916
ChunkInfo(uint64_t off=0, uint32_t len=0, void *buff=0)
Constructor.
Definition: XrdClXRootDResponses.hh:912
uint64_t offset
Definition: XrdClXRootDResponses.hh:915
Definition: XrdClXRootDResponses.hh:1034
HostInfo(const URL &u, bool lb=false)
Definition: XrdClXRootDResponses.hh:1037
URL url
URL of the host.
Definition: XrdClXRootDResponses.hh:1042
HostInfo()
Definition: XrdClXRootDResponses.hh:1035
uint32_t protocol
Version of the protocol the host is speaking.
Definition: XrdClXRootDResponses.hh:1040
bool loadBalancer
Was the host used as a load balancer.
Definition: XrdClXRootDResponses.hh:1041
uint32_t flags
Host type.
Definition: XrdClXRootDResponses.hh:1039
Definition: XrdClXRootDResponses.hh:923
PageInfo(PageInfo &&pginf)
Move constructor.
size_t GetNbRepair()
Get number of repaired pages.
void SetNbRepair(size_t nbrepair)
Set number of repaired pages.
std::vector< uint32_t > & GetCksums()
Get the checksums.
~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.
uint32_t GetLength() const
Get the data length.
uint64_t GetOffset() const
Get the offset.
std::unique_ptr< PageInfoImpl > pImpl
pointer to implementation
Definition: XrdClXRootDResponses.hh:974
void * GetBuffer()
Get the buffer.
Procedure execution status.
Definition: XrdClStatus.hh:113
uint16_t code
Error type, or additional hints on what to do.
Definition: XrdClStatus.hh:145
std::string ToString() const
Create a string representation.
uint32_t errNo
Errno, if any.
Definition: XrdClStatus.hh:146
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:295
XAttrStatus(const std::string &name, const XRootDStatus &status)
Definition: XrdClXRootDResponses.hh:299
XRootDStatus status
Definition: XrdClXRootDResponses.hh:306
std::string name
Definition: XrdClXRootDResponses.hh:305
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:313
XAttr(const std::string &name, const XRootDStatus &status)
Definition: XrdClXRootDResponses.hh:317
std::string value
Definition: XrdClXRootDResponses.hh:330
XAttr(const std::string &name, const std::string &value="", const XRootDStatus &status=XRootDStatus())
Definition: XrdClXRootDResponses.hh:323