Loading...
Searching...
No Matches
XrdCl::FileSystemUtils Class Reference

`#include <XrdClFileSystemUtils.hh>`

Collaboration diagram for XrdCl::FileSystemUtils:

## Classes

class | SpaceInfo
| Container for space information. More...
struct | SpaceInfoImpl

## Static Public Member Functions

static XRootDStatus | GetSpaceInfo (SpaceInfo *&result, FileSystem *fs, const std::string &path)
| Recursively get space information for given path.

## Detailed Description

A container for file system utility functions that do not belong in FileSystem

Definition at line 42 of file XrdClFileSystemUtils.hh.

## Member Function Documentation

## GetSpaceInfo()

XRootDStatus XrdCl::FileSystemUtils::GetSpaceInfo | ( | SpaceInfo *& | result,
|  | FileSystem * | fs,
|  | const std::string & | path )

static

Recursively get space information for given path.

Definition at line 98 of file XrdClFileSystemUtils.cc.

{
//--------------------------------------------------------------------------
// Locate all the disk servers containing the space
//--------------------------------------------------------------------------
LocationInfo *locationInfo = 0;
OpenFlags::Flags flags = OpenFlags::Compress | OpenFlags::PrefName;
XRootDStatus st = fs->DeepLocate( path, flags, locationInfo );
if( !st.IsOK() )
return st;
std::unique_ptr<LocationInfo> locationInfoPtr( locationInfo );
bool partial = st.code == suPartial ? true : false;
std::vector<std::pair<std::string, uint64_t> > resp;
resp.push_back( std::make_pair( std::string("oss.space"), (uint64_t)0 ) );
resp.push_back( std::make_pair( std::string("oss.free"), (uint64_t)0 ) );
resp.push_back( std::make_pair( std::string("oss.used"), (uint64_t)0 ) );
resp.push_back( std::make_pair( std::string("oss.maxf"), (uint64_t)0 ) );
//--------------------------------------------------------------------------
// Loop over the file servers and get the space info from each of them
//--------------------------------------------------------------------------
LocationInfo::Iterator it;
Buffer pathArg; pathArg.FromString( path );
for( it = locationInfo->Begin(); it != locationInfo->End(); ++it )
{
//------------------------------------------------------------------------
// Query the server
//------------------------------------------------------------------------
Buffer *spaceInfo = 0;
FileSystem fs1( it->GetAddress() );
st = fs1.Query( QueryCode::Space, pathArg, spaceInfo );
if( !st.IsOK() )
return st;
std::unique_ptr<Buffer> spaceInfoPtr( spaceInfo );
//------------------------------------------------------------------------
// Parse the cgi
//------------------------------------------------------------------------
std::string fakeUrl = "root://fake/fake?" + spaceInfo->ToString();
URL url( fakeUrl );
if( !url.IsValid() )
return XRootDStatus( stError, errInvalidResponse );
URL::ParamsMap params = url.GetParams();
//------------------------------------------------------------------------
// Convert and add up the params
//------------------------------------------------------------------------
st = XRootDStatus( stError, errInvalidResponse );
for( size_t i = 0; i < resp.size(); ++i )
{
URL::ParamsMap::iterator paramIt = params.find( resp[i].first );
if( paramIt == params.end() ) return st;
char *res;
uint64_t num = ::strtoll( paramIt->second.c_str(), &res, 0 );
if( *res != 0 ) return st;
if( resp[i].first == "oss.maxf" )
{ if( num > resp[i].second ) resp[i].second = num; }
else
resp[i].second += num;
}
}
result = new SpaceInfo( resp[0].second, resp[1].second, resp[2].second,
resp[3].second );
st = XRootDStatus(); if( partial ) st.code = suPartial;
return st;
}
XrdCl::FileSystemUtils::SpaceInfo
Container for space information.
Definition XrdClFileSystemUtils.hh:54
XrdCl::LocationInfo::Iterator
LocationList::iterator Iterator
Iterator over locations.
Definition XrdClXRootDResponses.hh:137
XrdCl::URL::ParamsMap
std::map< std::string, std::string > ParamsMap
Definition XrdClURL.hh:33
XrdCl::suPartial
const uint16_t suPartial
Definition XrdClStatus.hh:41
XrdCl::stError
const uint16_t stError
An error occurred that could potentially be retried.
Definition XrdClStatus.hh:32
XrdCl::errInvalidResponse
const uint16_t errInvalidResponse
Definition XrdClStatus.hh:99
XrdCl::OpenFlags::Flags
Flags
Open flags, may be or'd when appropriate.
Definition XrdClFileSystem.hh:76
XrdCl::OpenFlags::Compress
@ Compress
Definition XrdClFileSystem.hh:78
XrdCl::OpenFlags::PrefName
@ PrefName
Definition XrdClFileSystem.hh:105
XrdCl::QueryCode::Space
@ Space
Query logical space stats.
Definition XrdClFileSystem.hh:60

References XrdCl::LocationInfo::Begin(), XrdCl::Status::code, XrdCl::OpenFlags::Compress, XrdCl::FileSystem::DeepLocate(), XrdCl::LocationInfo::End(), XrdCl::errInvalidResponse, XrdCl::Buffer::FromString(), XrdCl::URL::GetParams(), XrdCl::Status::IsOK(), XrdCl::URL::IsValid(), XrdCl::OpenFlags::PrefName, XrdCl::FileSystem::Query(), XrdCl::QueryCode::Space, XrdCl::stError, XrdCl::suPartial, and XrdCl::Buffer::ToString().

Referenced by DoSpaceInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- XrdClFileSystemUtils.hh
- XrdClFileSystemUtils.cc