xrootd
XrdClFileSystem.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // This file is part of the XRootD software suite.
6 //
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // In applying this licence, CERN does not waive the privileges and immunities
21 // granted to it by virtue of its status as an Intergovernmental Organization
22 // or submit itself to any jurisdiction.
23 //------------------------------------------------------------------------------
24 
25 #ifndef __XRD_CL_FILE_SYSTEM_HH__
26 #define __XRD_CL_FILE_SYSTEM_HH__
27 
28 #include "XrdCl/XrdClURL.hh"
29 #include "XrdCl/XrdClStatus.hh"
30 #include "XrdOuc/XrdOucEnum.hh"
31 #include "XrdOuc/XrdOucCompiler.hh"
33 #include "XrdSys/XrdSysPthread.hh"
34 #include "XProtocol/XProtocol.hh"
35 #include <string>
36 #include <vector>
37 
38 namespace XrdCl
39 {
40  class PostMaster;
41  class Message;
42  class FileSystemPlugIn;
43  struct MessageSendParams;
44 
45  //----------------------------------------------------------------------------
47  //----------------------------------------------------------------------------
48  struct QueryCode
49  {
50  //--------------------------------------------------------------------------
52  //--------------------------------------------------------------------------
53  enum Code
54  {
65  };
66  };
67 
68  //----------------------------------------------------------------------------
70  //----------------------------------------------------------------------------
71  struct OpenFlags
72  {
73  //--------------------------------------------------------------------------
75  //--------------------------------------------------------------------------
76  enum Flags
77  {
78  None = 0,
80  Delete = kXR_delete,
82  Force = kXR_force,
86  New = kXR_new,
88  NoWait = kXR_nowait,
100  Refresh = kXR_refresh,
102  Replica = kXR_replica,
104  SeqIO = kXR_seqio,
109  };
111  };
113 
114  //----------------------------------------------------------------------------
116  //----------------------------------------------------------------------------
117  struct Access
118  {
119  //--------------------------------------------------------------------------
121  //--------------------------------------------------------------------------
122  enum Mode
123  {
124  None = 0,
125  UR = kXR_ur,
126  UW = kXR_uw,
127  UX = kXR_ux,
128  GR = kXR_gr,
129  GW = kXR_gw,
130  GX = kXR_gx,
131  OR = kXR_or,
132  OW = kXR_ow,
133  OX = kXR_ox
134  };
135  };
137 
138  //----------------------------------------------------------------------------
140  //----------------------------------------------------------------------------
141  struct MkDirFlags
142  {
143  enum Flags
144  {
145  None = 0,
146  MakePath = 1
147  };
148  };
150 
151  //----------------------------------------------------------------------------
153  //----------------------------------------------------------------------------
155  {
156  enum Flags
157  {
158  None = 0,
159  Stat = 1,
160  Locate = 2,
161  Recursive = 4,
163  Merge = 8,
164  Chunked = 16,
165  Zip = 32
166  };
167  };
169 
170  //----------------------------------------------------------------------------
172  //----------------------------------------------------------------------------
174  {
175  enum Flags
176  {
177  None = 0,
178  Colocate = kXR_coloc,
179  Fresh = kXR_fresh,
180  Stage = kXR_stage,
182  WriteMode = kXR_wmode,
184  Cancel = kXR_cancel,
186  Evict = kXR_evict << 8
187  };
191  };
193 
194  //----------------------------------------------------------------------------
196  //----------------------------------------------------------------------------
198  {
199  friend class AssignLBHandler;
200  friend class ForkHandler;
201 
202  public:
203  typedef std::vector<LocationInfo> LocationList;
204 
205  //------------------------------------------------------------------------
210  //------------------------------------------------------------------------
211  FileSystem( const URL &url, bool enablePlugIns = true );
212 
213  //------------------------------------------------------------------------
215  //------------------------------------------------------------------------
216  ~FileSystem();
217 
218  //------------------------------------------------------------------------
229  //------------------------------------------------------------------------
230  XRootDStatus Locate( const std::string &path,
231  OpenFlags::Flags flags,
232  ResponseHandler *handler,
233  uint16_t timeout = 0 )
235 
236  //------------------------------------------------------------------------
245  //------------------------------------------------------------------------
246  XRootDStatus Locate( const std::string &path,
247  OpenFlags::Flags flags,
248  LocationInfo *&response,
249  uint16_t timeout = 0 )
251 
252  //------------------------------------------------------------------------
263  //------------------------------------------------------------------------
264  XRootDStatus DeepLocate( const std::string &path,
265  OpenFlags::Flags flags,
266  ResponseHandler *handler,
267  uint16_t timeout = 0 )
269 
270  //------------------------------------------------------------------------
279  //------------------------------------------------------------------------
280  XRootDStatus DeepLocate( const std::string &path,
281  OpenFlags::Flags flags,
282  LocationInfo *&response,
283  uint16_t timeout = 0 )
285 
286  //------------------------------------------------------------------------
295  //------------------------------------------------------------------------
296  XRootDStatus Mv( const std::string &source,
297  const std::string &dest,
298  ResponseHandler *handler,
299  uint16_t timeout = 0 )
301 
302  //------------------------------------------------------------------------
310  //------------------------------------------------------------------------
311  XRootDStatus Mv( const std::string &source,
312  const std::string &dest,
313  uint16_t timeout = 0 )
315 
316  //------------------------------------------------------------------------
327  //------------------------------------------------------------------------
328  XRootDStatus Query( QueryCode::Code queryCode,
329  const Buffer &arg,
330  ResponseHandler *handler,
331  uint16_t timeout = 0 )
333 
334  //------------------------------------------------------------------------
343  //------------------------------------------------------------------------
344  XRootDStatus Query( QueryCode::Code queryCode,
345  const Buffer &arg,
346  Buffer *&response,
347  uint16_t timeout = 0 )
349 
350  //------------------------------------------------------------------------
359  //------------------------------------------------------------------------
360  XRootDStatus Truncate( const std::string &path,
361  uint64_t size,
362  ResponseHandler *handler,
363  uint16_t timeout = 0 )
365 
366  //------------------------------------------------------------------------
374  //------------------------------------------------------------------------
375  XRootDStatus Truncate( const std::string &path,
376  uint64_t size,
377  uint16_t timeout = 0 )
379 
380  //------------------------------------------------------------------------
388  //------------------------------------------------------------------------
389  XRootDStatus Rm( const std::string &path,
390  ResponseHandler *handler,
391  uint16_t timeout = 0 )
393 
394  //------------------------------------------------------------------------
401  //------------------------------------------------------------------------
402  XRootDStatus Rm( const std::string &path,
403  uint16_t timeout = 0 )
405 
406  //------------------------------------------------------------------------
416  //------------------------------------------------------------------------
417  XRootDStatus MkDir( const std::string &path,
418  MkDirFlags::Flags flags,
419  Access::Mode mode,
420  ResponseHandler *handler,
421  uint16_t timeout = 0 )
423 
424  //------------------------------------------------------------------------
433  //------------------------------------------------------------------------
434  XRootDStatus MkDir( const std::string &path,
435  MkDirFlags::Flags flags,
436  Access::Mode mode,
437  uint16_t timeout = 0 )
439 
440  //------------------------------------------------------------------------
448  //------------------------------------------------------------------------
449  XRootDStatus RmDir( const std::string &path,
450  ResponseHandler *handler,
451  uint16_t timeout = 0 )
453 
454  //------------------------------------------------------------------------
461  //------------------------------------------------------------------------
462  XRootDStatus RmDir( const std::string &path,
463  uint16_t timeout = 0 )
465 
466  //------------------------------------------------------------------------
475  //------------------------------------------------------------------------
476  XRootDStatus ChMod( const std::string &path,
477  Access::Mode mode,
478  ResponseHandler *handler,
479  uint16_t timeout = 0 )
481 
482  //------------------------------------------------------------------------
490  //------------------------------------------------------------------------
491  XRootDStatus ChMod( const std::string &path,
492  Access::Mode mode,
493  uint16_t timeout = 0 )
495 
496  //------------------------------------------------------------------------
503  //------------------------------------------------------------------------
505  uint16_t timeout = 0 )
507 
508  //------------------------------------------------------------------------
514  //------------------------------------------------------------------------
515  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
516 
517  //------------------------------------------------------------------------
527  //------------------------------------------------------------------------
528  XRootDStatus Stat( const std::string &path,
529  ResponseHandler *handler,
530  uint16_t timeout = 0 )
532 
533  //------------------------------------------------------------------------
542  //------------------------------------------------------------------------
543  XRootDStatus Stat( const std::string &path,
544  StatInfo *&response,
545  uint16_t timeout = 0 )
547 
548  //------------------------------------------------------------------------
558  //------------------------------------------------------------------------
559  XRootDStatus StatVFS( const std::string &path,
560  ResponseHandler *handler,
561  uint16_t timeout = 0 )
563 
564  //------------------------------------------------------------------------
572  //------------------------------------------------------------------------
573  XRootDStatus StatVFS( const std::string &path,
574  StatInfoVFS *&response,
575  uint16_t timeout = 0 )
577 
578  //------------------------------------------------------------------------
587  //------------------------------------------------------------------------
589  uint16_t timeout = 0 )
591 
592  //------------------------------------------------------------------------
599  //------------------------------------------------------------------------
600  XRootDStatus Protocol( ProtocolInfo *&response,
601  uint16_t timeout = 0 )
603 
604  //------------------------------------------------------------------------
615  //------------------------------------------------------------------------
616  XRootDStatus DirList( const std::string &path,
617  DirListFlags::Flags flags,
618  ResponseHandler *handler,
619  uint16_t timeout = 0 )
621 
622  //------------------------------------------------------------------------
631  //------------------------------------------------------------------------
632  XRootDStatus DirList( const std::string &path,
633  DirListFlags::Flags flags,
634  DirectoryList *&response,
635  uint16_t timeout = 0 )
637 
638  //------------------------------------------------------------------------
648  //------------------------------------------------------------------------
649  XRootDStatus SendInfo( const std::string &info,
650  ResponseHandler *handler,
651  uint16_t timeout = 0 )
653 
654  //------------------------------------------------------------------------
662  //------------------------------------------------------------------------
663  XRootDStatus SendInfo( const std::string &info,
664  Buffer *&response,
665  uint16_t timeout = 0 )
667 
668  //------------------------------------------------------------------------
680  //------------------------------------------------------------------------
681  XRootDStatus Prepare( const std::vector<std::string> &fileList,
682  PrepareFlags::Flags flags,
683  uint8_t priority,
684  ResponseHandler *handler,
685  uint16_t timeout = 0 )
687 
688  //------------------------------------------------------------------------
698  //------------------------------------------------------------------------
699  XRootDStatus Prepare( const std::vector<std::string> &fileList,
700  PrepareFlags::Flags flags,
701  uint8_t priority,
702  Buffer *&response,
703  uint16_t timeout = 0 )
705 
706  //------------------------------------------------------------------------
711  //------------------------------------------------------------------------
712  bool SetProperty( const std::string &name, const std::string &value );
713 
714  //------------------------------------------------------------------------
718  //------------------------------------------------------------------------
719  bool GetProperty( const std::string &name, std::string &value ) const;
720 
721  private:
722  FileSystem(const FileSystem &other);
723  FileSystem &operator = (const FileSystem &other);
724 
725  //------------------------------------------------------------------------
726  // Send a message in a locked environment
727  //------------------------------------------------------------------------
728  Status Send( Message *msg,
729  ResponseHandler *handler,
730  MessageSendParams &params );
731 
732  //------------------------------------------------------------------------
733  // Assign a load balancer if it has not already been assigned
734  //------------------------------------------------------------------------
735  void AssignLoadBalancer( const URL &url );
736 
737  //------------------------------------------------------------------------
738  // Lock the internal lock
739  //------------------------------------------------------------------------
740  void Lock()
741  {
742  pMutex.Lock();
743  }
744 
745  //------------------------------------------------------------------------
746  // Unlock the internal lock
747  //------------------------------------------------------------------------
748  void UnLock()
749  {
750  pMutex.UnLock();
751  }
752 
758  };
759 }
760 
761 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:224
Definition: XrdClForkHandler.hh:35
Definition: XrdClFileSystem.hh:108
Definition: XProtocol.hh:246
bool pFollowRedirects
Definition: XrdClFileSystem.hh:755
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:779
Definition: XProtocol.hh:270
Implementation dependent.
Definition: XrdClFileSystem.hh:59
Definition: XProtocol.hh:268
Definition: XProtocol.hh:221
Definition: XProtocol.hh:156
Definition: XrdClMessageUtils.hh:128
Definition: XProtocol.hh:154
Directory list.
Definition: XrdClXRootDResponses.hh:510
Open only for appending.
Definition: XrdClFileSystem.hh:95
Definition: XProtocol.hh:220
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Object stat info.
Definition: XrdClXRootDResponses.hh:332
Definition: XrdClFileSystem.hh:79
Definition: XProtocol.hh:247
Prepare flags.
Definition: XrdClFileSystem.hh:173
Definition: XProtocol.hh:155
Query file checksum.
Definition: XrdClFileSystem.hh:57
Definition: XProtocol.hh:248
Path location info.
Definition: XrdClXRootDResponses.hh:37
LocateImpl< false > Locate
Definition: XrdClFileSystemOperations.hh:154
Definition: XProtocol.hh:269
Visa operation (.
Definition: XrdClFileOperations.hh:806
Definition: XrdClFileSystem.hh:85
Definition: XProtocol.hh:241
Access mode.
Definition: XrdClFileSystem.hh:117
Read operation (.
Definition: XrdClFileOperations.hh:250
Definition: XProtocol.hh:152
Flags
Definition: XrdClFileSystem.hh:175
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:451
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:930
Procedure execution status.
Definition: XrdClStatus.hh:109
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:203
Ping operation (.
Definition: XrdClFileSystemOperations.hh:621
Definition: XrdClFileSystem.hh:101
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:231
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:754
DirList flags.
Definition: XrdClFileSystem.hh:154
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:71
Protocol response.
Definition: XrdClXRootDResponses.hh:279
Query operation (.
Definition: XrdClFileSystemOperations.hh:274
Definition: XrdSysPthread.hh:165
void UnLock()
Definition: XrdClFileSystem.hh:748
Definition: XProtocol.hh:151
Definition: XrdClFileSystem.hh:83
Definition: XProtocol.hh:153
Flags
Definition: XrdClFileSystem.hh:143
Definition: XrdClFileSystem.hh:99
Definition: XProtocol.hh:249
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:753
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:105
MkDir flags.
Definition: XrdClFileSystem.hh:141
Query file extended attributes.
Definition: XrdClFileSystem.hh:64
Open for reading and writing.
Definition: XrdClFileSystem.hh:97
Definition: XProtocol.hh:232
Definition: XProtocol.hh:228
StatImpl< false > Stat(File *file, Arg< bool > force)
Definition: XrdClFileOperations.hh:398
Definition: XProtocol.hh:149
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:509
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Request status.
Definition: XrdClXRootDResponses.hh:212
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:723
Definition: XrdClAnyObject.hh:25
Definition: XrdClFileSystem.hh:106
Definition: XProtocol.hh:250
Definition: XProtocol.hh:245
VFS stat info.
Definition: XrdClXRootDResponses.hh:433
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:564
Definition: XProtocol.hh:219
Definition: XProtocol.hh:150
Definition: XProtocol.hh:157
URL * pUrl
Definition: XrdClFileSystem.hh:756
Definition: XrdClFileSystem.hh:103
Definition: XProtocol.hh:217
Handle an async response.
Definition: XrdClXRootDResponses.hh:854
Definition: XProtocol.hh:242
Mv operation (.
Definition: XrdClFileSystemOperations.hh:217
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:53
URL representation.
Definition: XrdClURL.hh:30
Rm operation (.
Definition: XrdClFileSystemOperations.hh:397
Definition: XProtocol.hh:265
Definition: XProtocol.hh:216
Flags
Definition: XrdClFileSystem.hh:156
Definition: XProtocol.hh:271
Definition: XProtocol.hh:229
Query server stats.
Definition: XrdClFileSystem.hh:62
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:122
Definition: XrdClFileSystem.hh:87
Definition: XProtocol.hh:274
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:874
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:197
Definition: XProtocol.hh:230
Nothing.
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:223
Definition: XProtocol.hh:244
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Definition: XrdClFileSystem.hh:81
Definition: XProtocol.hh:233
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:757
Definition: XProtocol.hh:225
Query server configuration.
Definition: XrdClFileSystem.hh:55
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:76
TruncateImpl< false > Truncate(File *file, Arg< uint64_t > size)
Definition: XrdClFileOperations.hh:564
Locate operation (.
Definition: XrdClFileSystemOperations.hh:103
Write operation (.
Definition: XrdClFileOperations.hh:416
Definition: XProtocol.hh:226
Definition: XProtocol.hh:243
Definition: XProtocol.hh:218
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:190
Definition: XrdClFileSystem.hh:89
Binary blob representation.
Definition: XrdClBuffer.hh:33
DirList operation (.
Definition: XrdClFileSystemOperations.hh:817
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:160