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 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 );
212 LocationList pLocations;
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 //------------------------------------------------------------------------
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 //----------------------------------------------------------------------------
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 //------------------------------------------------------------------------
356
357 //------------------------------------------------------------------------
359 //------------------------------------------------------------------------
360 ProtocolInfo( uint32_t version, uint32_t hostInfo ):
361 pVersion( version ), pHostInfo( hostInfo ) {}
362
363 //------------------------------------------------------------------------
365 //------------------------------------------------------------------------
366 uint32_t GetVersion() const
367 {
368 return pVersion;
369 }
370
371 //------------------------------------------------------------------------
373 //------------------------------------------------------------------------
374 uint32_t GetHostInfo() const
375 {
376 return pHostInfo;
377 }
378
379 //------------------------------------------------------------------------
381 //------------------------------------------------------------------------
382 bool TestHostInfo( uint32_t flags )
383 {
384 return pHostInfo & flags;
385 }
386
387 private:
388 uint32_t pVersion;
389 uint32_t pHostInfo;
390 };
391
392 //----------------------------------------------------------------------------
394 //----------------------------------------------------------------------------
395 struct StatInfoImpl;
396
397 //----------------------------------------------------------------------------
399 //----------------------------------------------------------------------------
401 {
402 public:
403 //------------------------------------------------------------------------
405 //------------------------------------------------------------------------
418
419 //------------------------------------------------------------------------
421 //------------------------------------------------------------------------
422 StatInfo();
423
424 //------------------------------------------------------------------------
426 //------------------------------------------------------------------------
427 StatInfo( const std::string &id, uint64_t size, uint32_t flags,
428 uint64_t modTime );
429
430 //------------------------------------------------------------------------
432 //------------------------------------------------------------------------
433 StatInfo( const StatInfo &info );
434
435 //------------------------------------------------------------------------
437 //------------------------------------------------------------------------
439
440 //------------------------------------------------------------------------
442 //------------------------------------------------------------------------
443 const std::string& GetId() const;
444
445 //------------------------------------------------------------------------
447 //------------------------------------------------------------------------
448 uint64_t GetSize() const;
449
450 //------------------------------------------------------------------------
452 //------------------------------------------------------------------------
453 void SetSize( uint64_t size );
454
455 //------------------------------------------------------------------------
457 //------------------------------------------------------------------------
458 uint32_t GetFlags() const;
459
460 //------------------------------------------------------------------------
462 //------------------------------------------------------------------------
463 void SetFlags( uint32_t flags );
464
465 //------------------------------------------------------------------------
467 //------------------------------------------------------------------------
468 bool TestFlags( uint32_t flags ) const;
469
470 //------------------------------------------------------------------------
472 //------------------------------------------------------------------------
473 uint64_t GetModTime() const;
474
475 //------------------------------------------------------------------------
477 //------------------------------------------------------------------------
478 std::string GetModTimeAsString() const;
479
480 //------------------------------------------------------------------------
482 //------------------------------------------------------------------------
483 uint64_t GetChangeTime() const;
484
485 //------------------------------------------------------------------------
487 //------------------------------------------------------------------------
488 std::string GetChangeTimeAsString() const;
489
490 //------------------------------------------------------------------------
492 //------------------------------------------------------------------------
493 uint64_t GetAccessTime() const;
494
495 //------------------------------------------------------------------------
497 //------------------------------------------------------------------------
498 std::string GetAccessTimeAsString() const;
499
500 //------------------------------------------------------------------------
502 //------------------------------------------------------------------------
503 const std::string& GetModeAsString() const;
504
505 //------------------------------------------------------------------------
507 //------------------------------------------------------------------------
508 const std::string GetModeAsOctString() const;
509
510 //------------------------------------------------------------------------
512 //------------------------------------------------------------------------
513 const std::string& GetOwner() const;
514
515 //------------------------------------------------------------------------
517 //------------------------------------------------------------------------
518 const std::string& GetGroup() const;
519
520 //------------------------------------------------------------------------
522 //------------------------------------------------------------------------
523 const std::string& GetChecksum() const;
524
525 //------------------------------------------------------------------------
527 //------------------------------------------------------------------------
528 bool ParseServerResponse( const char *data );
529
530 //------------------------------------------------------------------------
532 //------------------------------------------------------------------------
533 bool ExtendedFormat() const;
534
535 //------------------------------------------------------------------------
537 //------------------------------------------------------------------------
538 bool HasChecksum() const;
539
540 private:
541
542 static inline std::string TimeToString( uint64_t time )
543 {
544 char ts[256];
545 time_t modTime = time;
546 tm *t = gmtime( &modTime );
547 strftime( ts, 255, "%F %T", t );
548 return ts;
549 }
550
551 static inline void OctToString( uint8_t oct, std::string &str )
552 {
553 static const uint8_t r_mask = 0x4;
554 static const uint8_t w_mask = 0x2;
555 static const uint8_t x_mask = 0x1;
556
557 if( r_mask & oct ) str.push_back( 'r' );
558 else str.push_back( '-' );
559
560 if( w_mask & oct ) str.push_back( 'w' );
561 else str.push_back( '-' );
562
563 if( x_mask & oct ) str.push_back( 'x' );
564 else str.push_back( '-' );
565 }
566
567 std::unique_ptr<StatInfoImpl> pImpl;
568 };
569
570 //----------------------------------------------------------------------------
572 //----------------------------------------------------------------------------
574 {
575 public:
576 //------------------------------------------------------------------------
578 //------------------------------------------------------------------------
579 StatInfoVFS();
580
581 //------------------------------------------------------------------------
583 //------------------------------------------------------------------------
584 uint64_t GetNodesRW() const
585 {
586 return pNodesRW;
587 }
588
589 //------------------------------------------------------------------------
591 //------------------------------------------------------------------------
592 uint64_t GetFreeRW() const
593 {
594 return pFreeRW;
595 }
596
597 //------------------------------------------------------------------------
599 //------------------------------------------------------------------------
600 uint8_t GetUtilizationRW() const
601 {
602 return pUtilizationRW;
603 }
604
605 //------------------------------------------------------------------------
607 //------------------------------------------------------------------------
608 uint64_t GetNodesStaging() const
609 {
610 return pNodesStaging;
611 }
612
613 //------------------------------------------------------------------------
615 //------------------------------------------------------------------------
616 uint64_t GetFreeStaging() const
617 {
618 return pFreeStaging;
619 }
620
621 //------------------------------------------------------------------------
623 //------------------------------------------------------------------------
624 uint8_t GetUtilizationStaging() const
625 {
626 return pUtilizationStaging;
627 }
628
629 //------------------------------------------------------------------------
631 //------------------------------------------------------------------------
632 bool ParseServerResponse( const char *data );
633
634 private:
635
636 //------------------------------------------------------------------------
637 // kXR_vfs stat
638 //------------------------------------------------------------------------
639 uint64_t pNodesRW;
640 uint64_t pFreeRW;
641 uint32_t pUtilizationRW;
642 uint64_t pNodesStaging;
643 uint64_t pFreeStaging;
644 uint32_t pUtilizationStaging;
645 };
646
647 //----------------------------------------------------------------------------
649 //----------------------------------------------------------------------------
651 {
652 public:
653
654 //------------------------------------------------------------------------
656 //------------------------------------------------------------------------
658 {
659 public:
660 //--------------------------------------------------------------------
662 //--------------------------------------------------------------------
663 ListEntry( const std::string &hostAddress,
664 const std::string &name,
665 StatInfo *statInfo = 0):
666 pHostAddress( hostAddress ),
667 pName( SanitizeName( name ) ),
668 pStatInfo( statInfo )
669 {}
670
671 //--------------------------------------------------------------------
673 //--------------------------------------------------------------------
675 {
676 delete pStatInfo;
677 }
678
679 //--------------------------------------------------------------------
681 //--------------------------------------------------------------------
682 const std::string &GetHostAddress() const
683 {
684 return pHostAddress;
685 }
686
687 //--------------------------------------------------------------------
689 //--------------------------------------------------------------------
690 const std::string &GetName() const
691 {
692 return pName;
693 }
694
695 //--------------------------------------------------------------------
697 //--------------------------------------------------------------------
699 {
700 return pStatInfo;
701 }
702
703 //--------------------------------------------------------------------
705 //--------------------------------------------------------------------
706 const StatInfo *GetStatInfo() const
707 {
708 return pStatInfo;
709 }
710
711 //--------------------------------------------------------------------
713 //--------------------------------------------------------------------
714 void SetStatInfo( StatInfo *info )
715 {
716 pStatInfo = info;
717 }
718
719 private:
720
721 inline static std::string SanitizeName( const std::string &name )
722 {
723 const char *cstr = name.c_str();
724 while( *cstr == '/' ) // the C string is guaranteed to end with '\0'
725 ++cstr;
726 return cstr;
727 }
728
729 std::string pHostAddress;
730 std::string pName;
731 StatInfo *pStatInfo;
732 };
733
734 //------------------------------------------------------------------------
736 //------------------------------------------------------------------------
738
739 //------------------------------------------------------------------------
741 //------------------------------------------------------------------------
743
744 //------------------------------------------------------------------------
746 //------------------------------------------------------------------------
747 typedef std::vector<ListEntry*> DirList;
748
749 //------------------------------------------------------------------------
751 //------------------------------------------------------------------------
752 typedef DirList::iterator Iterator;
753
754 //------------------------------------------------------------------------
756 //------------------------------------------------------------------------
757 typedef DirList::const_iterator ConstIterator;
758
759 //------------------------------------------------------------------------
761 //------------------------------------------------------------------------
762 void Add( ListEntry *entry )
763 {
764 pDirList.push_back( entry );
765 }
766
767 //------------------------------------------------------------------------
769 //------------------------------------------------------------------------
770 ListEntry *At( uint32_t index )
771 {
772 return pDirList[index];
773 }
774
775 //------------------------------------------------------------------------
777 //------------------------------------------------------------------------
779 {
780 return pDirList.begin();
781 }
782
783 //------------------------------------------------------------------------
785 //------------------------------------------------------------------------
787 {
788 return pDirList.begin();
789 }
790
791 //------------------------------------------------------------------------
793 //------------------------------------------------------------------------
795 {
796 return pDirList.end();
797 }
798
799 //------------------------------------------------------------------------
801 //------------------------------------------------------------------------
803 {
804 return pDirList.end();
805 }
806
807 //------------------------------------------------------------------------
809 //------------------------------------------------------------------------
810 uint32_t GetSize() const
811 {
812 return pDirList.size();
813 }
814
815 //------------------------------------------------------------------------
817 //------------------------------------------------------------------------
818 const std::string &GetParentName() const
819 {
820 return pParent;
821 }
822
823 //------------------------------------------------------------------------
825 //------------------------------------------------------------------------
826 void SetParentName( const std::string &parent )
827 {
828 size_t pos = parent.find( '?' );
829 pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
830 if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
831 pParent += "/";
832 }
833
834 //------------------------------------------------------------------------
836 //------------------------------------------------------------------------
837 bool ParseServerResponse( const std::string &hostId,
838 const char *data );
839
840 //------------------------------------------------------------------------
842 //------------------------------------------------------------------------
843 bool ParseServerResponse( const std::string &hostId,
844 const char *data,
845 bool isDStat );
846
847 //------------------------------------------------------------------------
849 //------------------------------------------------------------------------
850 static bool HasStatInfo( const char *data );
851
852 private:
853 DirList pDirList;
854 std::string pParent;
855
856 static const std::string dStatPrefix;
857 };
858
859 //----------------------------------------------------------------------------
861 //----------------------------------------------------------------------------
863 {
864 public:
865 //------------------------------------------------------------------------
867 //------------------------------------------------------------------------
868 OpenInfo( const uint8_t *fileHandle,
869 uint64_t sessionId,
870 StatInfo *statInfo = 0 ):
871 pSessionId(sessionId), pStatInfo( statInfo )
872 {
873 memcpy( pFileHandle, fileHandle, 4 );
874 }
875
876 //------------------------------------------------------------------------
878 //------------------------------------------------------------------------
880 {
881 delete pStatInfo;
882 }
883
884 //------------------------------------------------------------------------
886 //------------------------------------------------------------------------
887 void GetFileHandle( uint8_t *fileHandle ) const
888 {
889 memcpy( fileHandle, pFileHandle, 4 );
890 }
891
892 //------------------------------------------------------------------------
894 //------------------------------------------------------------------------
895 const StatInfo *GetStatInfo() const
896 {
897 return pStatInfo;
898 }
899
900 //------------------------------------------------------------------------
901 // Get session ID
902 //------------------------------------------------------------------------
903 uint64_t GetSessionId() const
904 {
905 return pSessionId;
906 }
907
908 private:
909 uint8_t pFileHandle[4];
910 uint64_t pSessionId;
911 StatInfo *pStatInfo;
912 };
913
914 //----------------------------------------------------------------------------
916 //----------------------------------------------------------------------------
918 {
919 //--------------------------------------------------------------------------
921 //--------------------------------------------------------------------------
922 ChunkInfo( uint64_t off = 0, uint32_t len = 0, void *buff = 0 ):
923 offset( off ), length( len ), buffer(buff) {}
924
925 //----------------------------------------------------------------------------
927 //----------------------------------------------------------------------------
928 inline uint64_t GetOffset() const
929 {
930 return offset;
931 }
932
933 //----------------------------------------------------------------------------
935 //----------------------------------------------------------------------------
936 inline uint32_t GetLength() const
937 {
938 return length;
939 }
940
941 //----------------------------------------------------------------------------
943 //----------------------------------------------------------------------------
944 inline void* GetBuffer()
945 {
946 return buffer;
947 }
948
949 uint64_t offset;
950 uint32_t length;
951 void *buffer;
952 };
953
954 struct PageInfoImpl;
955
956 struct PageInfo
957 {
958 //----------------------------------------------------------------------------
960 //----------------------------------------------------------------------------
961 PageInfo( uint64_t offset = 0, uint32_t length = 0, void *buffer = 0,
962 std::vector<uint32_t> &&cksums = std::vector<uint32_t>() );
963
964 //----------------------------------------------------------------------------
966 //----------------------------------------------------------------------------
967 PageInfo( PageInfo &&pginf );
968
969 //----------------------------------------------------------------------------
971 //----------------------------------------------------------------------------
972 PageInfo& operator=( PageInfo &&pginf );
973
974 //----------------------------------------------------------------------------
976 //----------------------------------------------------------------------------
977 ~PageInfo();
978
979 //----------------------------------------------------------------------------
981 //----------------------------------------------------------------------------
982 uint64_t GetOffset() const;
983
984 //----------------------------------------------------------------------------
986 //----------------------------------------------------------------------------
987 uint32_t GetLength() const;
988
989 //----------------------------------------------------------------------------
991 //----------------------------------------------------------------------------
992 void* GetBuffer();
993
994 //----------------------------------------------------------------------------
996 //----------------------------------------------------------------------------
997 std::vector<uint32_t>& GetCksums();
998
999 //----------------------------------------------------------------------------
1001 //----------------------------------------------------------------------------
1002 size_t GetNbRepair();
1003
1004 //----------------------------------------------------------------------------
1006 //----------------------------------------------------------------------------
1007 void SetNbRepair( size_t nbrepair );
1008
1009 private:
1010 //--------------------------------------------------------------------------
1012 //--------------------------------------------------------------------------
1013 std::unique_ptr<PageInfoImpl> pImpl;
1014 };
1015
1016 struct RetryInfoImpl;
1017
1019 {
1020 //----------------------------------------------------------------------------
1022 //----------------------------------------------------------------------------
1023 RetryInfo( std::vector<std::tuple<uint64_t, uint32_t>> && retries );
1024
1025 //----------------------------------------------------------------------------
1027 //----------------------------------------------------------------------------
1028 ~RetryInfo();
1029
1030 //----------------------------------------------------------------------------
1032 //----------------------------------------------------------------------------
1033 bool NeedRetry();
1034
1035 //----------------------------------------------------------------------------
1037 //----------------------------------------------------------------------------
1038 size_t Size();
1039
1040 //----------------------------------------------------------------------------
1042 // retransmitted
1043 //----------------------------------------------------------------------------
1044 std::tuple<uint64_t, uint32_t> At( size_t i );
1045
1046 private:
1047 //--------------------------------------------------------------------------
1049 //--------------------------------------------------------------------------
1050 std::unique_ptr<RetryInfoImpl> pImpl;
1051 };
1052
1053 //----------------------------------------------------------------------------
1055 //----------------------------------------------------------------------------
1056 typedef std::vector<ChunkInfo> ChunkList;
1057
1058 //----------------------------------------------------------------------------
1060 //----------------------------------------------------------------------------
1062 {
1063 public:
1064 //------------------------------------------------------------------------
1066 //------------------------------------------------------------------------
1067 VectorReadInfo(): pSize( 0 ) {}
1068
1069 //------------------------------------------------------------------------
1071 //------------------------------------------------------------------------
1072 uint32_t GetSize() const
1073 {
1074 return pSize;
1075 }
1076
1077 //------------------------------------------------------------------------
1079 //------------------------------------------------------------------------
1080 void SetSize( uint32_t size )
1081 {
1082 pSize = size;
1083 }
1084
1085 //------------------------------------------------------------------------
1087 //------------------------------------------------------------------------
1089 {
1090 return pChunks;
1091 }
1092
1093 //------------------------------------------------------------------------
1095 //------------------------------------------------------------------------
1096 const ChunkList &GetChunks() const
1097 {
1098 return pChunks;
1099 }
1100
1101 private:
1102 ChunkList pChunks;
1103 uint32_t pSize;
1104 };
1105
1106 //----------------------------------------------------------------------------
1107 // List of URLs
1108 //----------------------------------------------------------------------------
1110 {
1112 flags(0), protocol(0), loadBalancer(false) {}
1113 HostInfo( const URL &u, bool lb = false ):
1114 flags(0), protocol(0), loadBalancer(lb), url(u) {}
1115 uint32_t flags;
1116 uint32_t protocol;
1119 };
1120
1121 typedef std::vector<HostInfo> HostList;
1122
1123 //----------------------------------------------------------------------------
1125 //----------------------------------------------------------------------------
1127 {
1128 public:
1129 virtual ~ResponseHandler() {}
1130
1131 //------------------------------------------------------------------------
1139 //------------------------------------------------------------------------
1141 AnyObject *response,
1142 HostList *hostList )
1143 {
1144 delete hostList;
1145 HandleResponse( status, response );
1146 }
1147
1148 //------------------------------------------------------------------------
1155 //------------------------------------------------------------------------
1156 virtual void HandleResponse( XRootDStatus *status,
1157 AnyObject *response )
1158 {
1159 (void)status; (void)response;
1160 }
1161
1162 //------------------------------------------------------------------------
1167 //------------------------------------------------------------------------
1168 static ResponseHandler* Wrap( std::function<void(XRootDStatus&, AnyObject&)> func );
1169
1170 //------------------------------------------------------------------------
1175 //------------------------------------------------------------------------
1176 static ResponseHandler* Wrap( std::function<void(XRootDStatus*, AnyObject*)> func );
1177 };
1178}
1179
1180#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.
Iterator End()
Get the end iterator.
static bool HasStatInfo(const char *data)
Returns true if data contain stat info.
DirList::iterator Iterator
Directory listing iterator.
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.
std::vector< ListEntry * > DirList
Directory listing.
ListEntry * At(uint32_t index)
Get an entry at given index.
Handle the stateful operations.
Send file/filesystem queries to an XRootD cluster.
LocationType GetType() const
Get location type.
bool IsServer() const
Check whether the location is a server.
Location(const std::string &address, LocationType type, AccessType access)
Constructor.
const std::string & GetAddress() const
Get address.
AccessType GetAccessType() const
Get access type.
bool IsManager() const
Check whether the location is a manager.
Path location info.
LocationList::iterator Iterator
Iterator over locations.
uint32_t GetSize() const
Get number of locations.
Iterator Begin()
Get the location begin iterator.
LocationList::const_iterator ConstIterator
Iterator over locations.
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.
ConstIterator Begin() const
Get the location begin iterator.
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.
Iterator End()
Get the location end iterator.
Information returned by file open operation.
void GetFileHandle(uint8_t *fileHandle) const
Get the file handle (4bytes)
const StatInfo * GetStatInfo() const
Get the stat info.
OpenInfo(const uint8_t *fileHandle, uint64_t sessionId, StatInfo *statInfo=0)
Constructor.
uint64_t GetSessionId() const
bool TestHostInfo(uint32_t flags)
Test host info flags.
HostTypes
Types of XRootD servers.
@ AttrProxy
Proxy attribute.
@ AttrSuper
Supervisor attribute.
@ AttrCache
Cache attribute.
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.
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.
~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
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::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
std::vector< ChunkInfo > ChunkList
List of chunks.
Buffer BinaryDataInfo
Binary buffer.
Describe a data chunk for vector read.
void * buffer
length of the chunk
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.
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)
Procedure execution status.
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.
Extended attribute operation status.
XAttrStatus(const std::string &name, const XRootDStatus &status)
Extended attributes with status.
XAttr(const std::string &name, const XRootDStatus &status)
XAttr(const std::string &name, const std::string &value="", const XRootDStatus &status=XRootDStatus())