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  {
63  XAttr = kXR_Qxattr
64  };
65  };
66 
67  //----------------------------------------------------------------------------
69  //----------------------------------------------------------------------------
70  struct OpenFlags
71  {
72  //--------------------------------------------------------------------------
74  //--------------------------------------------------------------------------
75  enum Flags
76  {
77  None = 0,
80  Delete = kXR_delete,
82  Force = kXR_force,
86  New = kXR_new,
88  NoWait = kXR_nowait,
94 // Append = kXR_open_apnd, //!< Open only for appending
98  POSC = kXR_posc,
100  Refresh = kXR_refresh,
102  Replica = kXR_replica,
109  };
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,
161  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,
180  Stage = kXR_stage,
182  WriteMode = kXR_wmode,
184  Cancel = kXR_cancel,
185  Evict = kXR_evict << 8
189  };
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  //------------------------------------------------------------------------
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  //------------------------------------------------------------------------
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__
@ kXR_open_wrto
Definition: XProtocol.hh:429
@ kXR_compress
Definition: XProtocol.hh:412
@ kXR_delete
Definition: XProtocol.hh:413
@ kXR_prefname
Definition: XProtocol.hh:421
@ kXR_nowait
Definition: XProtocol.hh:427
@ kXR_open_read
Definition: XProtocol.hh:416
@ kXR_open_updt
Definition: XProtocol.hh:417
@ kXR_mkpath
Definition: XProtocol.hh:420
@ kXR_seqio
Definition: XProtocol.hh:428
@ kXR_replica
Definition: XProtocol.hh:425
@ kXR_posc
Definition: XProtocol.hh:426
@ kXR_refresh
Definition: XProtocol.hh:419
@ kXR_new
Definition: XProtocol.hh:415
@ kXR_force
Definition: XProtocol.hh:414
@ kXR_4dirlist
Definition: XProtocol.hh:424
@ kXR_wmode
Definition: XProtocol.hh:542
@ kXR_evict
Definition: XProtocol.hh:547
@ kXR_cancel
Definition: XProtocol.hh:538
@ kXR_fresh
Definition: XProtocol.hh:544
@ kXR_coloc
Definition: XProtocol.hh:543
@ kXR_stage
Definition: XProtocol.hh:541
@ kXR_gw
Definition: XProtocol.hh:404
@ kXR_ur
Definition: XProtocol.hh:400
@ kXR_uw
Definition: XProtocol.hh:401
@ kXR_gr
Definition: XProtocol.hh:403
@ kXR_ow
Definition: XProtocol.hh:407
@ kXR_gx
Definition: XProtocol.hh:405
@ kXR_or
Definition: XProtocol.hh:406
@ kXR_ox
Definition: XProtocol.hh:408
@ kXR_ux
Definition: XProtocol.hh:402
@ kXR_QPrep
Definition: XProtocol.hh:567
@ kXR_Qconfig
Definition: XProtocol.hh:572
@ kXR_Qopaquf
Definition: XProtocol.hh:575
@ kXR_Qckscan
Definition: XProtocol.hh:571
@ kXR_Qxattr
Definition: XProtocol.hh:569
@ kXR_Qspace
Definition: XProtocol.hh:570
@ kXR_Qvisa
Definition: XProtocol.hh:573
@ kXR_QStats
Definition: XProtocol.hh:566
@ kXR_Qcksum
Definition: XProtocol.hh:568
@ kXR_Qopaque
Definition: XProtocol.hh:574
unsigned char kXR_char
Definition: XPtypes.hh:65
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Binary blob representation.
Definition: XrdClBuffer.hh:34
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:566
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:162
DirList operation (.
Definition: XrdClFileSystemOperations.hh:819
Directory list.
Definition: XrdClXRootDResponses.hh:631
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:284
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:202
XRootDStatus SetXAttr(const std::string &path, const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
FileSystemImpl * pImpl
Definition: XrdClFileSystem.hh:880
Status XAttrOperationImpl(kXR_char subcode, kXR_char options, const std::string &path, const std::vector< T > &attrs, ResponseHandler *handler, uint16_t timeout=0)
bool SetProperty(const std::string &name, const std::string &value)
XRootDStatus Locate(const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:881
XRootDStatus Stat(const std::string &path, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
friend class AssignLBHandler
Definition: XrdClFileSystem.hh:203
XRootDStatus DelXAttr(const std::string &path, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus ListXAttr(const std::string &path, ResponseHandler *handler, uint16_t timeout=0)
FileSystem(const URL &url, bool enablePlugIns=true)
~FileSystem()
Destructor.
XRootDStatus GetXAttr(const std::string &path, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Truncate(const std::string &path, uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool GetProperty(const std::string &name, std::string &value) const
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:207
Definition: XrdClForkHandler.hh:36
Locate operation (.
Definition: XrdClFileSystemOperations.hh:105
Path location info.
Definition: XrdClXRootDResponses.hh:40
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:453
Mv operation (.
Definition: XrdClFileSystemOperations.hh:219
Ping operation (.
Definition: XrdClFileSystemOperations.hh:622
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:932
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:781
Protocol response.
Definition: XrdClXRootDResponses.hh:338
Query operation (.
Definition: XrdClFileSystemOperations.hh:276
Read operation (.
Definition: XrdClFileOperations.hh:247
Handle an async response.
Definition: XrdClXRootDResponses.hh:975
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:511
Rm operation (.
Definition: XrdClFileSystemOperations.hh:398
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:876
VFS stat info.
Definition: XrdClXRootDResponses.hh:554
Object stat info.
Definition: XrdClXRootDResponses.hh:396
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:725
URL representation.
Definition: XrdClURL.hh:31
Visa operation (.
Definition: XrdClFileOperations.hh:802
Write operation (.
Definition: XrdClFileOperations.hh:413
Request status.
Definition: XrdClXRootDResponses.hh:215
Definition: XrdClAnyObject.hh:26
StatImpl< false > Stat(File *file, Arg< bool > force)
Definition: XrdClFileOperations.hh:393
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
Definition: XrdClXRootDResponses.hh:285
Access mode.
Definition: XrdClFileSystem.hh:117
Mode
Access mode.
Definition: XrdClFileSystem.hh:122
DirList flags.
Definition: XrdClFileSystem.hh:154
Flags
Definition: XrdClFileSystem.hh:156
MkDir flags.
Definition: XrdClFileSystem.hh:141
Flags
Definition: XrdClFileSystem.hh:143
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:71
Flags
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:76
@ Compress
Definition: XrdClFileSystem.hh:78
@ Delete
Definition: XrdClFileSystem.hh:80
@ Force
Definition: XrdClFileSystem.hh:82
@ New
Definition: XrdClFileSystem.hh:86
@ PrefName
Definition: XrdClFileSystem.hh:105
@ Replica
Definition: XrdClFileSystem.hh:102
@ MakePath
Definition: XrdClFileSystem.hh:84
@ POSC
Definition: XrdClFileSystem.hh:98
@ Refresh
Definition: XrdClFileSystem.hh:100
@ SeqIO
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:104
@ Update
Open for reading and writing.
Definition: XrdClFileSystem.hh:96
@ IntentDirList
Definition: XrdClFileSystem.hh:107
@ NoWait
Definition: XrdClFileSystem.hh:88
Prepare flags.
Definition: XrdClFileSystem.hh:173
Flags
Definition: XrdClFileSystem.hh:175
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:53
@ OpaqueFile
Implementation dependent.
Definition: XrdClFileSystem.hh:58
@ Opaque
Implementation dependent.
Definition: XrdClFileSystem.hh:57
@ Config
Query server configuration.
Definition: XrdClFileSystem.hh:54
@ Stats
Query server stats.
Definition: XrdClFileSystem.hh:61
@ ChecksumCancel
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:55
@ Checksum
Query file checksum.
Definition: XrdClFileSystem.hh:56
@ Space
Query logical space stats.
Definition: XrdClFileSystem.hh:60
Procedure execution status.
Definition: XrdClStatus.hh:111
Extended attribute operation status.
Definition: XrdClXRootDResponses.hh:291
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:309