XRootD
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.

101 {
102 //--------------------------------------------------------------------------
103 // Locate all the disk servers containing the space
104 //--------------------------------------------------------------------------
105 LocationInfo *locationInfo = 0;
107 XRootDStatus st = fs->DeepLocate( path, flags, locationInfo );
108 if( !st.IsOK() )
109 return st;
110
111 std::unique_ptr<LocationInfo> locationInfoPtr( locationInfo );
112
113 bool partial = st.code == suPartial ? true : false;
114
115 std::vector<std::pair<std::string, uint64_t> > resp;
116 resp.push_back( std::make_pair( std::string("oss.space"), (uint64_t)0 ) );
117 resp.push_back( std::make_pair( std::string("oss.free"), (uint64_t)0 ) );
118 resp.push_back( std::make_pair( std::string("oss.used"), (uint64_t)0 ) );
119 resp.push_back( std::make_pair( std::string("oss.maxf"), (uint64_t)0 ) );
120
121 //--------------------------------------------------------------------------
122 // Loop over the file servers and get the space info from each of them
123 //--------------------------------------------------------------------------
125 Buffer pathArg; pathArg.FromString( path );
126 for( it = locationInfo->Begin(); it != locationInfo->End(); ++it )
127 {
128 //------------------------------------------------------------------------
129 // Query the server
130 //------------------------------------------------------------------------
131 Buffer *spaceInfo = 0;
132 FileSystem fs1( it->GetAddress() );
133 st = fs1.Query( QueryCode::Space, pathArg, spaceInfo );
134 if( !st.IsOK() )
135 return st;
136
137 std::unique_ptr<Buffer> spaceInfoPtr( spaceInfo );
138
139 //------------------------------------------------------------------------
140 // Parse the cgi
141 //------------------------------------------------------------------------
142 std::string fakeUrl = "root://fake/fake?" + spaceInfo->ToString();
143 URL url( fakeUrl );
144
145 if( !url.IsValid() )
146 return XRootDStatus( stError, errInvalidResponse );
147
148 URL::ParamsMap params = url.GetParams();
149
150 //------------------------------------------------------------------------
151 // Convert and add up the params
152 //------------------------------------------------------------------------
153 st = XRootDStatus( stError, errInvalidResponse );
154 for( size_t i = 0; i < resp.size(); ++i )
155 {
156 URL::ParamsMap::iterator paramIt = params.find( resp[i].first );
157 if( paramIt == params.end() ) return st;
158 char *res;
159 uint64_t num = ::strtoll( paramIt->second.c_str(), &res, 0 );
160 if( *res != 0 ) return st;
161 if( resp[i].first == "oss.maxf" )
162 { if( num > resp[i].second ) resp[i].second = num; }
163 else
164 resp[i].second += num;
165 }
166 }
167
168 result = new SpaceInfo( resp[0].second, resp[1].second, resp[2].second,
169 resp[3].second );
170
171 st = XRootDStatus(); if( partial ) st.code = suPartial;
172 return st;
173 }
Container for space information.
LocationList::iterator Iterator
Iterator over locations.
std::map< std::string, std::string > ParamsMap
Definition XrdClURL.hh:33
const uint16_t suPartial
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errInvalidResponse
Flags
Open flags, may be or'd when appropriate.
@ Space
Query logical space stats.

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: