19#ifndef __XRD_CL_XROOTD_RESPONSES_HH__
20#define __XRD_CL_XROOTD_RESPONSES_HH__
124 std::string pAddress;
154 return pLocations.size();
162 return pLocations[index];
170 return pLocations.begin();
178 return pLocations.begin();
186 return pLocations.end();
194 return pLocations.end();
202 pLocations.push_back( location );
211 bool ProcessLocation( std::string &location );
227 const std::string &message =
"" ):
229 pMessage( message ) {}
235 const std::string &message =
"" ):
237 pMessage( message ) {}
262 std::ostringstream o;
263 o <<
"[ERROR] Server responded with an error: [" <<
errNo <<
"] ";
264 o << pMessage << std::endl;
268 if( !pMessage.empty() )
269 str +=
": " + pMessage;
274 std::string pMessage;
289 typedef std::tuple<std::string, std::string>
xattr_t;
361 pVersion( version ), pHostInfo( hostInfo ) {}
384 return pHostInfo & flags;
427 StatInfo(
const std::string &
id, uint64_t size, uint32_t flags,
443 const std::string&
GetId()
const;
513 const std::string&
GetOwner()
const;
518 const std::string&
GetGroup()
const;
542 static inline std::string TimeToString( uint64_t time )
545 time_t modTime = time;
546 tm *t = gmtime( &modTime );
547 strftime( ts, 255,
"%F %T", t );
551 static inline void OctToString( uint8_t oct, std::string &str )
553 static const uint8_t r_mask = 0x4;
554 static const uint8_t w_mask = 0x2;
555 static const uint8_t x_mask = 0x1;
557 if( r_mask & oct ) str.push_back(
'r' );
558 else str.push_back(
'-' );
560 if( w_mask & oct ) str.push_back(
'w' );
561 else str.push_back(
'-' );
563 if( x_mask & oct ) str.push_back(
'x' );
564 else str.push_back(
'-' );
567 std::unique_ptr<StatInfoImpl> pImpl;
602 return pUtilizationRW;
610 return pNodesStaging;
626 return pUtilizationStaging;
641 uint32_t pUtilizationRW;
642 uint64_t pNodesStaging;
643 uint64_t pFreeStaging;
644 uint32_t pUtilizationStaging;
664 const std::string &name,
666 pHostAddress( hostAddress ),
667 pName( SanitizeName( name ) ),
668 pStatInfo( statInfo )
721 inline static std::string SanitizeName(
const std::string &name )
723 const char *cstr = name.c_str();
724 while( *cstr ==
'/' )
729 std::string pHostAddress;
764 pDirList.push_back( entry );
772 return pDirList[index];
780 return pDirList.begin();
788 return pDirList.begin();
796 return pDirList.end();
804 return pDirList.end();
812 return pDirList.size();
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] !=
'/' )
856 static const std::string dStatPrefix;
871 pSessionId(sessionId), pStatInfo( statInfo )
873 memcpy( pFileHandle, fileHandle, 4 );
889 memcpy( fileHandle, pFileHandle, 4 );
909 uint8_t pFileHandle[4];
922 ChunkInfo( uint64_t off = 0, uint32_t len = 0,
void *buff = 0 ):
961 PageInfo( uint64_t offset = 0, uint32_t length = 0,
void *buffer = 0,
962 std::vector<uint32_t> &&cksums = std::vector<uint32_t>() );
1013 std::unique_ptr<PageInfoImpl> pImpl;
1023 RetryInfo( std::vector<std::tuple<uint64_t, uint32_t>> && retries );
1044 std::tuple<uint64_t, uint32_t>
At(
size_t i );
1050 std::unique_ptr<RetryInfoImpl> pImpl;
1159 (void)status; (void)response;
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.
DirectoryList()
Constructor.
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.
~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.
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.
LocationList::iterator Iterator
Iterator over locations.
uint32_t GetSize() const
Get number of locations.
LocationInfo()
Constructor.
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.
@ AttrMeta
Meta 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)
virtual ~ResponseHandler()
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.
StatInfoVFS()
Constructor.
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.
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.
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.
uint32_t GetSize() const
Get Size.
const ChunkList & GetChunks() const
Get chunks.
ChunkList & GetChunks()
Get chunks.
VectorReadInfo()
Constructor.
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)
uint32_t protocol
Version of the protocol the host is speaking.
bool loadBalancer
Was the host used as a load balancer.
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())