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 FileSystemPlugIn;
42  struct MessageSendParams;
43 
44  //----------------------------------------------------------------------------
46  //----------------------------------------------------------------------------
47  struct QueryCode
48  {
49  //--------------------------------------------------------------------------
51  //--------------------------------------------------------------------------
52  enum Code
53  {
64  };
65  };
66 
67  //----------------------------------------------------------------------------
69  //----------------------------------------------------------------------------
70  struct OpenFlags
71  {
72  //--------------------------------------------------------------------------
74  //--------------------------------------------------------------------------
75  enum Flags
76  {
77  None = 0,
79  Delete = kXR_delete,
81  Force = kXR_force,
85  New = kXR_new,
87  NoWait = kXR_nowait,
89 // Append = kXR_open_apnd, //!< Open only for appending
101  Replica = kXR_replica,
103  SeqIO = kXR_seqio,
108  };
110  };
112 
113  //----------------------------------------------------------------------------
115  //----------------------------------------------------------------------------
116  struct Access
117  {
118  //--------------------------------------------------------------------------
120  //--------------------------------------------------------------------------
121  enum Mode
122  {
123  None = 0,
124  UR = kXR_ur,
125  UW = kXR_uw,
126  UX = kXR_ux,
127  GR = kXR_gr,
128  GW = kXR_gw,
129  GX = kXR_gx,
130  OR = kXR_or,
131  OW = kXR_ow,
132  OX = kXR_ox
133  };
134  };
136 
137  //----------------------------------------------------------------------------
139  //----------------------------------------------------------------------------
140  struct MkDirFlags
141  {
142  enum Flags
143  {
144  None = 0,
145  MakePath = 1
146  };
147  };
149 
150  //----------------------------------------------------------------------------
152  //----------------------------------------------------------------------------
154  {
155  enum Flags
156  {
157  None = 0,
158  Stat = 1,
159  Locate = 2,
160  Recursive = 4,
162  Merge = 8,
163  Chunked = 16,
164  Zip = 32
165  };
166  };
168 
169  //----------------------------------------------------------------------------
171  //----------------------------------------------------------------------------
173  {
174  enum Flags
175  {
176  None = 0,
177  Colocate = kXR_coloc,
178  Fresh = kXR_fresh,
179  Stage = kXR_stage,
181  WriteMode = kXR_wmode,
183  Cancel = kXR_cancel,
185  Evict = kXR_evict << 8
186  };
190  };
192 
193  //----------------------------------------------------------------------------
195  //----------------------------------------------------------------------------
196  struct FileSystemImpl;
197 
198  //----------------------------------------------------------------------------
200  //----------------------------------------------------------------------------
202  {
203  friend class AssignLBHandler;
204  friend class ForkHandler;
205 
206  public:
207  typedef std::vector<LocationInfo> LocationList;
208 
209  //------------------------------------------------------------------------
214  //------------------------------------------------------------------------
215  FileSystem( const URL &url, bool enablePlugIns = true );
216 
217  //------------------------------------------------------------------------
219  //------------------------------------------------------------------------
220  ~FileSystem();
221 
222  //------------------------------------------------------------------------
233  //------------------------------------------------------------------------
234  XRootDStatus Locate( const std::string &path,
235  OpenFlags::Flags flags,
236  ResponseHandler *handler,
237  uint16_t timeout = 0 )
239 
240  //------------------------------------------------------------------------
249  //------------------------------------------------------------------------
250  XRootDStatus Locate( const std::string &path,
251  OpenFlags::Flags flags,
252  LocationInfo *&response,
253  uint16_t timeout = 0 )
255 
256  //------------------------------------------------------------------------
267  //------------------------------------------------------------------------
268  XRootDStatus DeepLocate( const std::string &path,
269  OpenFlags::Flags flags,
270  ResponseHandler *handler,
271  uint16_t timeout = 0 )
273 
274  //------------------------------------------------------------------------
283  //------------------------------------------------------------------------
284  XRootDStatus DeepLocate( const std::string &path,
285  OpenFlags::Flags flags,
286  LocationInfo *&response,
287  uint16_t timeout = 0 )
289 
290  //------------------------------------------------------------------------
299  //------------------------------------------------------------------------
300  XRootDStatus Mv( const std::string &source,
301  const std::string &dest,
302  ResponseHandler *handler,
303  uint16_t timeout = 0 )
305 
306  //------------------------------------------------------------------------
314  //------------------------------------------------------------------------
315  XRootDStatus Mv( const std::string &source,
316  const std::string &dest,
317  uint16_t timeout = 0 )
319 
320  //------------------------------------------------------------------------
331  //------------------------------------------------------------------------
332  XRootDStatus Query( QueryCode::Code queryCode,
333  const Buffer &arg,
334  ResponseHandler *handler,
335  uint16_t timeout = 0 )
337 
338  //------------------------------------------------------------------------
347  //------------------------------------------------------------------------
348  XRootDStatus Query( QueryCode::Code queryCode,
349  const Buffer &arg,
350  Buffer *&response,
351  uint16_t timeout = 0 )
353 
354  //------------------------------------------------------------------------
363  //------------------------------------------------------------------------
364  XRootDStatus Truncate( const std::string &path,
365  uint64_t size,
366  ResponseHandler *handler,
367  uint16_t timeout = 0 )
369 
370  //------------------------------------------------------------------------
378  //------------------------------------------------------------------------
379  XRootDStatus Truncate( const std::string &path,
380  uint64_t size,
381  uint16_t timeout = 0 )
383 
384  //------------------------------------------------------------------------
392  //------------------------------------------------------------------------
393  XRootDStatus Rm( const std::string &path,
394  ResponseHandler *handler,
395  uint16_t timeout = 0 )
397 
398  //------------------------------------------------------------------------
405  //------------------------------------------------------------------------
406  XRootDStatus Rm( const std::string &path,
407  uint16_t timeout = 0 )
409 
410  //------------------------------------------------------------------------
420  //------------------------------------------------------------------------
421  XRootDStatus MkDir( const std::string &path,
422  MkDirFlags::Flags flags,
423  Access::Mode mode,
424  ResponseHandler *handler,
425  uint16_t timeout = 0 )
427 
428  //------------------------------------------------------------------------
437  //------------------------------------------------------------------------
438  XRootDStatus MkDir( const std::string &path,
439  MkDirFlags::Flags flags,
440  Access::Mode mode,
441  uint16_t timeout = 0 )
443 
444  //------------------------------------------------------------------------
452  //------------------------------------------------------------------------
453  XRootDStatus RmDir( const std::string &path,
454  ResponseHandler *handler,
455  uint16_t timeout = 0 )
457 
458  //------------------------------------------------------------------------
465  //------------------------------------------------------------------------
466  XRootDStatus RmDir( const std::string &path,
467  uint16_t timeout = 0 )
469 
470  //------------------------------------------------------------------------
479  //------------------------------------------------------------------------
480  XRootDStatus ChMod( const std::string &path,
481  Access::Mode mode,
482  ResponseHandler *handler,
483  uint16_t timeout = 0 )
485 
486  //------------------------------------------------------------------------
494  //------------------------------------------------------------------------
495  XRootDStatus ChMod( const std::string &path,
496  Access::Mode mode,
497  uint16_t timeout = 0 )
499 
500  //------------------------------------------------------------------------
507  //------------------------------------------------------------------------
509  uint16_t timeout = 0 )
511 
512  //------------------------------------------------------------------------
518  //------------------------------------------------------------------------
519  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
520 
521  //------------------------------------------------------------------------
531  //------------------------------------------------------------------------
532  XRootDStatus Stat( const std::string &path,
533  ResponseHandler *handler,
534  uint16_t timeout = 0 )
536 
537  //------------------------------------------------------------------------
546  //------------------------------------------------------------------------
547  XRootDStatus Stat( const std::string &path,
548  StatInfo *&response,
549  uint16_t timeout = 0 )
551 
552  //------------------------------------------------------------------------
562  //------------------------------------------------------------------------
563  XRootDStatus StatVFS( const std::string &path,
564  ResponseHandler *handler,
565  uint16_t timeout = 0 )
567 
568  //------------------------------------------------------------------------
576  //------------------------------------------------------------------------
577  XRootDStatus StatVFS( const std::string &path,
578  StatInfoVFS *&response,
579  uint16_t timeout = 0 )
581 
582  //------------------------------------------------------------------------
591  //------------------------------------------------------------------------
593  uint16_t timeout = 0 )
595 
596  //------------------------------------------------------------------------
603  //------------------------------------------------------------------------
604  XRootDStatus Protocol( ProtocolInfo *&response,
605  uint16_t timeout = 0 )
607 
608  //------------------------------------------------------------------------
619  //------------------------------------------------------------------------
620  XRootDStatus DirList( const std::string &path,
621  DirListFlags::Flags flags,
622  ResponseHandler *handler,
623  uint16_t timeout = 0 )
625 
626  //------------------------------------------------------------------------
635  //------------------------------------------------------------------------
636  XRootDStatus DirList( const std::string &path,
637  DirListFlags::Flags flags,
638  DirectoryList *&response,
639  uint16_t timeout = 0 )
641 
642  //------------------------------------------------------------------------
652  //------------------------------------------------------------------------
653  XRootDStatus SendInfo( const std::string &info,
654  ResponseHandler *handler,
655  uint16_t timeout = 0 )
657 
658  //------------------------------------------------------------------------
666  //------------------------------------------------------------------------
667  XRootDStatus SendInfo( const std::string &info,
668  Buffer *&response,
669  uint16_t timeout = 0 )
671 
672  //------------------------------------------------------------------------
684  //------------------------------------------------------------------------
685  XRootDStatus Prepare( const std::vector<std::string> &fileList,
686  PrepareFlags::Flags flags,
687  uint8_t priority,
688  ResponseHandler *handler,
689  uint16_t timeout = 0 )
691 
692  //------------------------------------------------------------------------
702  //------------------------------------------------------------------------
703  XRootDStatus Prepare( const std::vector<std::string> &fileList,
704  PrepareFlags::Flags flags,
705  uint8_t priority,
706  Buffer *&response,
707  uint16_t timeout = 0 )
709 
710  //------------------------------------------------------------------------
721  //------------------------------------------------------------------------
722  XRootDStatus SetXAttr( const std::string &path,
723  const std::vector<xattr_t> &attrs,
724  ResponseHandler *handler,
725  uint16_t timeout = 0 );
726 
727  //------------------------------------------------------------------------
736  //------------------------------------------------------------------------
737  XRootDStatus SetXAttr( const std::string &path,
738  const std::vector<xattr_t> &attrs,
739  std::vector<XAttrStatus> &result,
740  uint16_t timeout = 0 );
741 
742  //------------------------------------------------------------------------
753  //------------------------------------------------------------------------
754  XRootDStatus GetXAttr( const std::string &path,
755  const std::vector<std::string> &attrs,
756  ResponseHandler *handler,
757  uint16_t timeout = 0 );
758 
759  //------------------------------------------------------------------------
768  //------------------------------------------------------------------------
769  XRootDStatus GetXAttr( const std::string &path,
770  const std::vector<std::string> &attrs,
771  std::vector<XAttr> &result,
772  uint16_t timeout = 0 );
773 
774  //------------------------------------------------------------------------
785  //------------------------------------------------------------------------
786  XRootDStatus DelXAttr( const std::string &path,
787  const std::vector<std::string> &attrs,
788  ResponseHandler *handler,
789  uint16_t timeout = 0 );
790 
791  //------------------------------------------------------------------------
800  //------------------------------------------------------------------------
801  XRootDStatus DelXAttr( const std::string &path,
802  const std::vector<std::string> &attrs,
803  std::vector<XAttrStatus> &result,
804  uint16_t timeout = 0 );
805 
806  //------------------------------------------------------------------------
816  //------------------------------------------------------------------------
817  XRootDStatus ListXAttr( const std::string &path,
818  ResponseHandler *handler,
819  uint16_t timeout = 0 );
820 
821  //------------------------------------------------------------------------
829  //------------------------------------------------------------------------
830  XRootDStatus ListXAttr( const std::string &path,
831  std::vector<XAttr> &result,
832  uint16_t timeout = 0 );
833 
834  //------------------------------------------------------------------------
839  //------------------------------------------------------------------------
840  bool SetProperty( const std::string &name, const std::string &value );
841 
842  //------------------------------------------------------------------------
846  //------------------------------------------------------------------------
847  bool GetProperty( const std::string &name, std::string &value ) const;
848 
849  private:
850  FileSystem(const FileSystem &other);
851  FileSystem &operator = (const FileSystem &other);
852 
853  //------------------------------------------------------------------------
854  // Lock the internal lock
855  //------------------------------------------------------------------------
856  void Lock();
857 
858  //------------------------------------------------------------------------
859  // Unlock the internal lock
860  //------------------------------------------------------------------------
861  void UnLock();
862 
863  //------------------------------------------------------------------------
871  //------------------------------------------------------------------------
872  template<typename T>
874  kXR_char options,
875  const std::string &path,
876  const std::vector<T> &attrs,
877  ResponseHandler *handler,
878  uint16_t timeout = 0 );
879 
880  FileSystemImpl *pImpl; //< pointer to implementation
881  FileSystemPlugIn *pPlugIn; //< file system plug-in
882  };
883 }
884 
885 #endif // __XRD_CL_FILE_SYSTEM_HH__
unsigned char kXR_char
Definition: XPtypes.hh:65
Definition: XProtocol.hh:420
Definition: XrdClForkHandler.hh:35
Definition: XrdClFileSystem.hh:107
Definition: XProtocol.hh:571
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:779
Definition: XProtocol.hh:543
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Definition: XProtocol.hh:541
Definition: XProtocol.hh:417
Definition: XProtocol.hh:407
XRootDStatus SetXAttr(const std::string &path, const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Stat(const std::string &path, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:290
Definition: XProtocol.hh:405
Directory list.
Definition: XrdClXRootDResponses.hh:630
Definition: XProtocol.hh:416
Object stat info.
Definition: XrdClXRootDResponses.hh:395
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:572
XRootDStatus Truncate(const std::string &path, uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Prepare flags.
Definition: XrdClFileSystem.hh:172
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:308
Definition: XProtocol.hh:406
bool SetProperty(const std::string &name, const std::string &value)
Query file checksum.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:573
Path location info.
Definition: XrdClXRootDResponses.hh:39
Definition: XProtocol.hh:542
Visa operation (.
Definition: XrdClFileOperations.hh:801
Definition: XrdClFileSystem.hh:84
Definition: XProtocol.hh:566
Access mode.
Definition: XrdClFileSystem.hh:116
~FileSystem()
Destructor.
Read operation (.
Definition: XrdClFileOperations.hh:245
Definition: XProtocol.hh:403
Flags
Definition: XrdClFileSystem.hh:174
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:451
Implementation dependent.
Definition: XrdClFileSystem.hh:57
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:930
Procedure execution status.
Definition: XrdClStatus.hh:110
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:207
Ping operation (.
Definition: XrdClFileSystemOperations.hh:621
Definition: XrdClFileSystem.hh:100
FileSystemImpl * pImpl
Definition: XrdClFileSystem.hh:880
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:55
Definition: XProtocol.hh:427
DirList flags.
Definition: XrdClFileSystem.hh:153
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Protocol response.
Definition: XrdClXRootDResponses.hh:337
Query operation (.
Definition: XrdClFileSystemOperations.hh:274
XRootDStatus ListXAttr(const std::string &path, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Locate(const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XProtocol.hh:402
Definition: XrdClFileSystem.hh:82
Definition: XProtocol.hh:404
Flags
Definition: XrdClFileSystem.hh:142
Definition: XrdClFileSystem.hh:98
Definition: XProtocol.hh:574
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:104
MkDir flags.
Definition: XrdClFileSystem.hh:140
Open for reading and writing.
Definition: XrdClFileSystem.hh:96
Definition: XProtocol.hh:428
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Definition: XProtocol.hh:424
StatImpl< false > Stat(File *file, Arg< bool > force)
Definition: XrdClFileOperations.hh:393
Definition: XProtocol.hh:400
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:509
XRootD query request codes.
Definition: XrdClFileSystem.hh:47
Request status.
Definition: XrdClXRootDResponses.hh:214
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:723
Definition: XrdClAnyObject.hh:25
Definition: XrdClFileSystem.hh:105
Definition: XProtocol.hh:575
Definition: XProtocol.hh:570
VFS stat info.
Definition: XrdClXRootDResponses.hh:553
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:564
Definition: XProtocol.hh:415
Definition: XProtocol.hh:401
Definition: XProtocol.hh:408
XRootDStatus DelXAttr(const std::string &path, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Definition: XrdClFileSystem.hh:102
Definition: XProtocol.hh:413
Handle an async response.
Definition: XrdClXRootDResponses.hh:974
Definition: XProtocol.hh:567
Mv operation (.
Definition: XrdClFileSystemOperations.hh:217
bool GetProperty(const std::string &name, std::string &value) const
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:52
URL representation.
Definition: XrdClURL.hh:30
Rm operation (.
Definition: XrdClFileSystemOperations.hh:397
FileSystem(const URL &url, bool enablePlugIns=true)
Definition: XProtocol.hh:538
Definition: XProtocol.hh:412
Flags
Definition: XrdClFileSystem.hh:155
Definition: XProtocol.hh:544
Definition: XProtocol.hh:425
Query server stats.
Definition: XrdClFileSystem.hh:61
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:121
Definition: XrdClFileSystem.hh:86
Definition: XProtocol.hh:547
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:874
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:201
Definition: XProtocol.hh:426
Definition: XProtocol.hh:419
Definition: XProtocol.hh:569
Query logical space stats.
Definition: XrdClFileSystem.hh:60
Definition: XrdClFileSystem.hh:80
Definition: XProtocol.hh:429
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:881
Definition: XProtocol.hh:421
Query server configuration.
Definition: XrdClFileSystem.hh:54
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:75
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition: XrdClXRootDResponses.hh:285
Locate operation (.
Definition: XrdClFileSystemOperations.hh:103
Write operation (.
Definition: XrdClFileOperations.hh:411
Definition: XProtocol.hh:568
Definition: XProtocol.hh:414
friend class AssignLBHandler
Definition: XrdClFileSystem.hh:203
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:283
Status XAttrOperationImpl(kXR_char subcode, kXR_char options, const std::string &path, const std::vector< T > &attrs, ResponseHandler *handler, uint16_t timeout=0)
Definition: XrdClFileSystem.hh:88
Binary blob representation.
Definition: XrdClBuffer.hh:33
XRootDStatus GetXAttr(const std::string &path, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
DirList operation (.
Definition: XrdClFileSystemOperations.hh:817
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:160