XRootD
Loading...
Searching...
No Matches
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"
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
38namespace XrdCl
39{
40 //----------------------------------------------------------------------------
42 //----------------------------------------------------------------------------
44 {
45 public:
46 //------------------------------------------------------------------------
48 //------------------------------------------------------------------------
56
57 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
65
66 //------------------------------------------------------------------------
68 //------------------------------------------------------------------------
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 //------------------------------------------------------------------------
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 {
289 };
290
291 //----------------------------------------------------------------------------
293 //----------------------------------------------------------------------------
294 typedef std::tuple<std::string, std::string> xattr_t;
295
296 //----------------------------------------------------------------------------
298 //----------------------------------------------------------------------------
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 //------------------------------------------------------------------------
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 //----------------------------------------------------------------------------
415 {
416 public:
417 //------------------------------------------------------------------------
419 //------------------------------------------------------------------------
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 = gmtime( &modTime );
561 strftime( ts, 255, "%F %T", t );
562 return ts;
563 }
564
565 static inline void OctToString( uint8_t oct, std::string &str )
566 {
567 static const uint8_t r_mask = 0x4;
568 static const uint8_t w_mask = 0x2;
569 static const uint8_t x_mask = 0x1;
570
571 if( r_mask & oct ) str.push_back( 'r' );
572 else str.push_back( '-' );
573
574 if( w_mask & oct ) str.push_back( 'w' );
575 else str.push_back( '-' );
576
577 if( x_mask & oct ) str.push_back( 'x' );
578 else str.push_back( '-' );
579 }
580
581 std::unique_ptr<StatInfoImpl> pImpl;
582 };
583
584 //----------------------------------------------------------------------------
586 //----------------------------------------------------------------------------
588 {
589 public:
590 //------------------------------------------------------------------------
592 //------------------------------------------------------------------------
593 StatInfoVFS();
594
595 //------------------------------------------------------------------------
597 //------------------------------------------------------------------------
598 virtual ~StatInfoVFS() {}
599
600 //------------------------------------------------------------------------
602 //------------------------------------------------------------------------
603 uint64_t GetNodesRW() const
604 {
605 return pNodesRW;
606 }
607
608 //------------------------------------------------------------------------
610 //------------------------------------------------------------------------
611 uint64_t GetFreeRW() const
612 {
613 return pFreeRW;
614 }
615
616 //------------------------------------------------------------------------
618 //------------------------------------------------------------------------
619 uint8_t GetUtilizationRW() const
620 {
621 return pUtilizationRW;
622 }
623
624 //------------------------------------------------------------------------
626 //------------------------------------------------------------------------
627 uint64_t GetNodesStaging() const
628 {
629 return pNodesStaging;
630 }
631
632 //------------------------------------------------------------------------
634 //------------------------------------------------------------------------
635 uint64_t GetFreeStaging() const
636 {
637 return pFreeStaging;
638 }
639
640 //------------------------------------------------------------------------
642 //------------------------------------------------------------------------
643 uint8_t GetUtilizationStaging() const
644 {
645 return pUtilizationStaging;
646 }
647
648 //------------------------------------------------------------------------
650 //------------------------------------------------------------------------
651 bool ParseServerResponse( const char *data );
652
653 private:
654
655 //------------------------------------------------------------------------
656 // kXR_vfs stat
657 //------------------------------------------------------------------------
658 uint64_t pNodesRW;
659 uint64_t pFreeRW;
660 uint32_t pUtilizationRW;
661 uint64_t pNodesStaging;
662 uint64_t pFreeStaging;
663 uint32_t pUtilizationStaging;
664 };
665
666 //----------------------------------------------------------------------------
668 //----------------------------------------------------------------------------
670 {
671 public:
672
673 //------------------------------------------------------------------------
675 //------------------------------------------------------------------------
677 {
678 public:
679 //--------------------------------------------------------------------
681 //--------------------------------------------------------------------
682 ListEntry( const std::string &hostAddress,
683 const std::string &name,
684 StatInfo *statInfo = 0):
685 pHostAddress( hostAddress ),
686 pName( SanitizeName( name ) ),
687 pStatInfo( statInfo )
688 {}
689
690 //--------------------------------------------------------------------
692 //--------------------------------------------------------------------
694 {
695 delete pStatInfo;
696 }
697
698 //--------------------------------------------------------------------
700 //--------------------------------------------------------------------
701 const std::string &GetHostAddress() const
702 {
703 return pHostAddress;
704 }
705
706 //--------------------------------------------------------------------
708 //--------------------------------------------------------------------
709 const std::string &GetName() const
710 {
711 return pName;
712 }
713
714 //--------------------------------------------------------------------
716 //--------------------------------------------------------------------
718 {
719 return pStatInfo;
720 }
721
722 //--------------------------------------------------------------------
724 //--------------------------------------------------------------------
725 const StatInfo *GetStatInfo() const
726 {
727 return pStatInfo;
728 }
729
730 //--------------------------------------------------------------------
732 //--------------------------------------------------------------------
733 void SetStatInfo( StatInfo *info )
734 {
735 pStatInfo = info;
736 }
737
738 private:
739
740 inline static std::string SanitizeName( const std::string &name )
741 {
742 const char *cstr = name.c_str();
743 while( *cstr == '/' ) // the C string is guaranteed to end with '\0'
744 ++cstr;
745 return cstr;
746 }
747
748 std::string pHostAddress;
749 std::string pName;
750 StatInfo *pStatInfo;
751 };
752
753 //------------------------------------------------------------------------
755 //------------------------------------------------------------------------
757
758 //------------------------------------------------------------------------
760 //------------------------------------------------------------------------
761 virtual ~DirectoryList();
762
763 //------------------------------------------------------------------------
765 //------------------------------------------------------------------------
766 typedef std::vector<ListEntry*> DirList;
767
768 //------------------------------------------------------------------------
770 //------------------------------------------------------------------------
771 typedef DirList::iterator Iterator;
772
773 //------------------------------------------------------------------------
775 //------------------------------------------------------------------------
776 typedef DirList::const_iterator ConstIterator;
777
778 //------------------------------------------------------------------------
780 //------------------------------------------------------------------------
781 void Add( ListEntry *entry )
782 {
783 pDirList.push_back( entry );
784 }
785
786 //------------------------------------------------------------------------
788 //------------------------------------------------------------------------
789 ListEntry *At( uint32_t index )
790 {
791 return pDirList[index];
792 }
793
794 //------------------------------------------------------------------------
796 //------------------------------------------------------------------------
798 {
799 return pDirList.begin();
800 }
801
802 //------------------------------------------------------------------------
804 //------------------------------------------------------------------------
806 {
807 return pDirList.begin();
808 }
809
810 //------------------------------------------------------------------------
812 //------------------------------------------------------------------------
814 {
815 return pDirList.end();
816 }
817
818 //------------------------------------------------------------------------
820 //------------------------------------------------------------------------
822 {
823 return pDirList.end();
824 }
825
826 //------------------------------------------------------------------------
828 //------------------------------------------------------------------------
829 uint32_t GetSize() const
830 {
831 return pDirList.size();
832 }
833
834 //------------------------------------------------------------------------
836 //------------------------------------------------------------------------
837 const std::string &GetParentName() const
838 {
839 return pParent;
840 }
841
842 //------------------------------------------------------------------------
844 //------------------------------------------------------------------------
845 void SetParentName( const std::string &parent )
846 {
847 size_t pos = parent.find( '?' );
848 pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
849 if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
850 pParent += "/";
851 }
852
853 //------------------------------------------------------------------------
855 //------------------------------------------------------------------------
856 bool ParseServerResponse( const std::string &hostId,
857 const char *data );
858
859 //------------------------------------------------------------------------
861 //------------------------------------------------------------------------
862 bool ParseServerResponse( const std::string &hostId,
863 const char *data,
864 bool isDStat );
865
866 //------------------------------------------------------------------------
868 //------------------------------------------------------------------------
869 static bool HasStatInfo( const char *data );
870
871 private:
872 DirList pDirList;
873 std::string pParent;
874
875 static const std::string dStatPrefix;
876 };
877
878 //----------------------------------------------------------------------------
880 //----------------------------------------------------------------------------
882 {
883 public:
884 //------------------------------------------------------------------------
886 //------------------------------------------------------------------------
887 OpenInfo( const uint8_t *fileHandle,
888 uint64_t sessionId,
889 StatInfo *statInfo = 0 ):
890 pSessionId(sessionId), pStatInfo( statInfo )
891 {
892 memcpy( pFileHandle, fileHandle, 4 );
893 }
894
895 //------------------------------------------------------------------------
897 //------------------------------------------------------------------------
898 virtual ~OpenInfo()
899 {
900 delete pStatInfo;
901 }
902
903 //------------------------------------------------------------------------
905 //------------------------------------------------------------------------
906 void GetFileHandle( uint8_t *fileHandle ) const
907 {
908 memcpy( fileHandle, pFileHandle, 4 );
909 }
910
911 //------------------------------------------------------------------------
913 //------------------------------------------------------------------------
914 const StatInfo *GetStatInfo() const
915 {
916 return pStatInfo;
917 }
918
919 //------------------------------------------------------------------------
920 // Get session ID
921 //------------------------------------------------------------------------
922 uint64_t GetSessionId() const
923 {
924 return pSessionId;
925 }
926
927 private:
928 uint8_t pFileHandle[4];
929 uint64_t pSessionId;
930 StatInfo *pStatInfo;
931 };
932
933 //----------------------------------------------------------------------------
935 //----------------------------------------------------------------------------
937 {
938 //--------------------------------------------------------------------------
940 //--------------------------------------------------------------------------
941 ChunkInfo( uint64_t off = 0, uint32_t len = 0, void *buff = 0 ):
942 offset( off ), length( len ), buffer(buff) {}
943
944 //--------------------------------------------------------------------------
946 //--------------------------------------------------------------------------
947 virtual ~ChunkInfo() {}
948
949 //----------------------------------------------------------------------------
951 //----------------------------------------------------------------------------
952 inline uint64_t GetOffset() const
953 {
954 return offset;
955 }
956
957 //----------------------------------------------------------------------------
959 //----------------------------------------------------------------------------
960 inline uint32_t GetLength() const
961 {
962 return length;
963 }
964
965 //----------------------------------------------------------------------------
967 //----------------------------------------------------------------------------
968 inline void* GetBuffer()
969 {
970 return buffer;
971 }
972
973 uint64_t offset;
974 uint32_t length;
975 void *buffer;
976 };
977
978 struct PageInfoImpl;
979
980 struct PageInfo
981 {
982 //----------------------------------------------------------------------------
984 //----------------------------------------------------------------------------
985 PageInfo( uint64_t offset = 0, uint32_t length = 0, void *buffer = 0,
986 std::vector<uint32_t> &&cksums = std::vector<uint32_t>() );
987
988 //----------------------------------------------------------------------------
990 //----------------------------------------------------------------------------
991 PageInfo( PageInfo &&pginf );
992
993 //----------------------------------------------------------------------------
995 //----------------------------------------------------------------------------
996 PageInfo& operator=( PageInfo &&pginf );
997
998 //----------------------------------------------------------------------------
1000 //----------------------------------------------------------------------------
1001 virtual ~PageInfo();
1002
1003 //----------------------------------------------------------------------------
1005 //----------------------------------------------------------------------------
1006 uint64_t GetOffset() const;
1007
1008 //----------------------------------------------------------------------------
1010 //----------------------------------------------------------------------------
1011 uint32_t GetLength() const;
1012
1013 //----------------------------------------------------------------------------
1015 //----------------------------------------------------------------------------
1016 void* GetBuffer();
1017
1018 //----------------------------------------------------------------------------
1020 //----------------------------------------------------------------------------
1021 std::vector<uint32_t>& GetCksums();
1022
1023 //----------------------------------------------------------------------------
1025 //----------------------------------------------------------------------------
1026 size_t GetNbRepair();
1027
1028 //----------------------------------------------------------------------------
1030 //----------------------------------------------------------------------------
1031 void SetNbRepair( size_t nbrepair );
1032
1033 private:
1034 //--------------------------------------------------------------------------
1036 //--------------------------------------------------------------------------
1037 std::unique_ptr<PageInfoImpl> pImpl;
1038 };
1039
1040 struct RetryInfoImpl;
1041
1043 {
1044 //----------------------------------------------------------------------------
1046 //----------------------------------------------------------------------------
1047 RetryInfo( std::vector<std::tuple<uint64_t, uint32_t>> && retries );
1048
1049 //----------------------------------------------------------------------------
1051 //----------------------------------------------------------------------------
1052 virtual ~RetryInfo();
1053
1054 //----------------------------------------------------------------------------
1056 //----------------------------------------------------------------------------
1057 bool NeedRetry();
1058
1059 //----------------------------------------------------------------------------
1061 //----------------------------------------------------------------------------
1062 size_t Size();
1063
1064 //----------------------------------------------------------------------------
1066 // retransmitted
1067 //----------------------------------------------------------------------------
1068 std::tuple<uint64_t, uint32_t> At( size_t i );
1069
1070 private:
1071 //--------------------------------------------------------------------------
1073 //--------------------------------------------------------------------------
1074 std::unique_ptr<RetryInfoImpl> pImpl;
1075 };
1076
1077 //----------------------------------------------------------------------------
1079 //----------------------------------------------------------------------------
1080 class File;
1081
1083 {
1084 //--------------------------------------------------------------------------
1086 //--------------------------------------------------------------------------
1087 TractInfo( uint64_t off = 0, uint32_t len = 0, File* fp = 0 ):
1088 offset( off ), length( len ), pFile( fp ) {}
1089
1090 //--------------------------------------------------------------------------
1092 //--------------------------------------------------------------------------
1093 virtual ~TractInfo() {}
1094
1095 uint64_t offset;
1096 uint32_t length;
1098 };
1099
1100 //----------------------------------------------------------------------------
1102 //----------------------------------------------------------------------------
1103 typedef std::vector<ChunkInfo> ChunkList;
1104
1105 //----------------------------------------------------------------------------
1107 //----------------------------------------------------------------------------
1108 typedef std::vector<TractInfo> TractList;
1109
1110 //----------------------------------------------------------------------------
1112 //----------------------------------------------------------------------------
1114 {
1115 public:
1116 //------------------------------------------------------------------------
1118 //------------------------------------------------------------------------
1119 VectorReadInfo(): pSize( 0 ) {}
1120
1121 //------------------------------------------------------------------------
1123 //------------------------------------------------------------------------
1124 virtual ~VectorReadInfo() {}
1125
1126 //------------------------------------------------------------------------
1128 //------------------------------------------------------------------------
1129 uint32_t GetSize() const
1130 {
1131 return pSize;
1132 }
1133
1134 //------------------------------------------------------------------------
1136 //------------------------------------------------------------------------
1137 void SetSize( uint32_t size )
1138 {
1139 pSize = size;
1140 }
1141
1142 //------------------------------------------------------------------------
1144 //------------------------------------------------------------------------
1146 {
1147 return pChunks;
1148 }
1149
1150 //------------------------------------------------------------------------
1152 //------------------------------------------------------------------------
1153 const ChunkList &GetChunks() const
1154 {
1155 return pChunks;
1156 }
1157
1158 private:
1159 ChunkList pChunks;
1160 uint32_t pSize;
1161 };
1162
1163 //----------------------------------------------------------------------------
1164 // List of URLs
1165 //----------------------------------------------------------------------------
1167 {
1169 flags(0), protocol(0), loadBalancer(false) {}
1170 HostInfo( const URL &u, bool lb = false ):
1171 flags(0), protocol(0), loadBalancer(lb), url(u) {}
1172 virtual ~HostInfo(){};
1173
1174 uint32_t flags;
1175 uint32_t protocol;
1178 };
1179
1180 typedef std::vector<HostInfo> HostList;
1181
1182 //----------------------------------------------------------------------------
1184 //----------------------------------------------------------------------------
1186 {
1187 public:
1188 virtual ~ResponseHandler() {}
1189
1190 //------------------------------------------------------------------------
1198 //------------------------------------------------------------------------
1200 AnyObject *response,
1201 HostList *hostList )
1202 {
1203 delete hostList;
1204 HandleResponse( status, response );
1205 }
1206
1207 //------------------------------------------------------------------------
1214 //------------------------------------------------------------------------
1215 virtual void HandleResponse( XRootDStatus *status,
1216 AnyObject *response )
1217 {
1218 (void)status; (void)response;
1219 }
1220
1221 //------------------------------------------------------------------------
1226 //------------------------------------------------------------------------
1227 static ResponseHandler* Wrap( std::function<void(XRootDStatus&, AnyObject&)> func );
1228
1229 //------------------------------------------------------------------------
1234 //------------------------------------------------------------------------
1235 static ResponseHandler* Wrap( std::function<void(XRootDStatus*, AnyObject*)> func );
1236 };
1237}
1238
1239#endif // __XRD_CL_XROOTD_RESPONSES_HH__
#define kXR_isManager
#define kXR_attrMeta
#define kXR_attrSuper
#define kXR_isServer
#define kXR_attrCache
#define kXR_attrProxy
@ kXR_readable
@ kXR_isDir
@ kXR_offline
@ kXR_bkpexist
@ kXR_other
@ kXR_poscpend
@ kXR_writable
@ kXR_xset
static std::string ts()
timestamp output for logging messages
Definition XrdCephOss.cc:53
static void parent()
#define access(a, b)
Definition XrdPosix.hh:44
Binary blob representation.
void SetStatInfo(StatInfo *info)
Set the stat info object (and transfer the ownership).
const StatInfo * GetStatInfo() const
Get the stat info object.
const std::string & GetName() const
Get file name.
const std::string & GetHostAddress() const
Get host address.
ListEntry(const std::string &hostAddress, const std::string &name, StatInfo *statInfo=0)
Constructor.
StatInfo * GetStatInfo()
Get the stat info object.
DirList::const_iterator ConstIterator
Directory listing const iterator.
void Add(ListEntry *entry)
Add an entry to the list - takes ownership.
uint32_t GetSize() const
Get the size of the listing.
const std::string & GetParentName() const
Get parent directory name.
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.
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.
ListEntry * At(uint32_t index)
Get an entry at given index.
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.
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.
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.
ChunkList & GetChunks()
Get chunks.
void SetSize(uint32_t size)
Set size.
const std::string & GetErrorMessage() const
Get error message.
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.
XRootDStatus(const Status &st, const std::string &message="")
Constructor.
std::string ToStr() const
Convert to string.
const uint16_t errErrorResponse
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.
DirListImpl< false > DirList
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
void * GetBuffer()
Get the buffer.
ChunkInfo(uint64_t off=0, uint32_t len=0, void *buff=0)
Constructor.
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.
RetryInfo(std::vector< std::tuple< uint64_t, uint32_t > > &&retries)
Constructor.
std::tuple< uint64_t, uint32_t > At(size_t i)
virtual ~RetryInfo()
Destructor.
Status(uint16_t st=stOK, uint16_t cod=errNone, uint32_t errN=0)
Constructor.
uint16_t code
Error type, or additional hints on what to do.
std::string ToString() const
Create a string representation.
uint32_t errNo
Errno, if any.
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
XAttrStatus(const std::string &name, const XRootDStatus &status)
friend class FileSystem
XAttr(const std::string &name, const XRootDStatus &status)
friend class FileStateHandler
XAttr(const std::string &name, const std::string &value="", const XRootDStatus &status=XRootDStatus())