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  Cksm = 64
166  };
167  };
169 
170  //----------------------------------------------------------------------------
172  //----------------------------------------------------------------------------
174  {
175  enum Flags
176  {
177  None = 0,
178  Colocate = kXR_coloc,
179  Fresh = kXR_fresh,
181  Stage = kXR_stage,
183  WriteMode = kXR_wmode,
185  Cancel = kXR_cancel,
186  Evict = kXR_evict << 8
190  };
191  };
193 
194  //----------------------------------------------------------------------------
196  //----------------------------------------------------------------------------
197  struct FileSystemImpl;
198 
199  //----------------------------------------------------------------------------
201  //----------------------------------------------------------------------------
203  {
204  friend class AssignLBHandler;
205  friend class ForkHandler;
206 
207  public:
208  typedef std::vector<LocationInfo> LocationList;
209 
210  //------------------------------------------------------------------------
215  //------------------------------------------------------------------------
216  FileSystem( const URL &url, bool enablePlugIns = true );
217 
218  //------------------------------------------------------------------------
220  //------------------------------------------------------------------------
222 
223  //------------------------------------------------------------------------
234  //------------------------------------------------------------------------
235  XRootDStatus Locate( const std::string &path,
236  OpenFlags::Flags flags,
237  ResponseHandler *handler,
238  uint16_t timeout = 0 )
240 
241  //------------------------------------------------------------------------
250  //------------------------------------------------------------------------
251  XRootDStatus Locate( const std::string &path,
252  OpenFlags::Flags flags,
253  LocationInfo *&response,
254  uint16_t timeout = 0 )
256 
257  //------------------------------------------------------------------------
268  //------------------------------------------------------------------------
269  XRootDStatus DeepLocate( const std::string &path,
270  OpenFlags::Flags flags,
271  ResponseHandler *handler,
272  uint16_t timeout = 0 )
274 
275  //------------------------------------------------------------------------
284  //------------------------------------------------------------------------
285  XRootDStatus DeepLocate( const std::string &path,
286  OpenFlags::Flags flags,
287  LocationInfo *&response,
288  uint16_t timeout = 0 )
290 
291  //------------------------------------------------------------------------
300  //------------------------------------------------------------------------
301  XRootDStatus Mv( const std::string &source,
302  const std::string &dest,
303  ResponseHandler *handler,
304  uint16_t timeout = 0 )
306 
307  //------------------------------------------------------------------------
315  //------------------------------------------------------------------------
316  XRootDStatus Mv( const std::string &source,
317  const std::string &dest,
318  uint16_t timeout = 0 )
320 
321  //------------------------------------------------------------------------
332  //------------------------------------------------------------------------
333  XRootDStatus Query( QueryCode::Code queryCode,
334  const Buffer &arg,
335  ResponseHandler *handler,
336  uint16_t timeout = 0 )
338 
339  //------------------------------------------------------------------------
348  //------------------------------------------------------------------------
349  XRootDStatus Query( QueryCode::Code queryCode,
350  const Buffer &arg,
351  Buffer *&response,
352  uint16_t timeout = 0 )
354 
355  //------------------------------------------------------------------------
364  //------------------------------------------------------------------------
365  XRootDStatus Truncate( const std::string &path,
366  uint64_t size,
367  ResponseHandler *handler,
368  uint16_t timeout = 0 )
370 
371  //------------------------------------------------------------------------
379  //------------------------------------------------------------------------
380  XRootDStatus Truncate( const std::string &path,
381  uint64_t size,
382  uint16_t timeout = 0 )
384 
385  //------------------------------------------------------------------------
393  //------------------------------------------------------------------------
394  XRootDStatus Rm( const std::string &path,
395  ResponseHandler *handler,
396  uint16_t timeout = 0 )
398 
399  //------------------------------------------------------------------------
406  //------------------------------------------------------------------------
407  XRootDStatus Rm( const std::string &path,
408  uint16_t timeout = 0 )
410 
411  //------------------------------------------------------------------------
421  //------------------------------------------------------------------------
422  XRootDStatus MkDir( const std::string &path,
423  MkDirFlags::Flags flags,
424  Access::Mode mode,
425  ResponseHandler *handler,
426  uint16_t timeout = 0 )
428 
429  //------------------------------------------------------------------------
438  //------------------------------------------------------------------------
439  XRootDStatus MkDir( const std::string &path,
440  MkDirFlags::Flags flags,
441  Access::Mode mode,
442  uint16_t timeout = 0 )
444 
445  //------------------------------------------------------------------------
453  //------------------------------------------------------------------------
454  XRootDStatus RmDir( const std::string &path,
455  ResponseHandler *handler,
456  uint16_t timeout = 0 )
458 
459  //------------------------------------------------------------------------
466  //------------------------------------------------------------------------
467  XRootDStatus RmDir( const std::string &path,
468  uint16_t timeout = 0 )
470 
471  //------------------------------------------------------------------------
480  //------------------------------------------------------------------------
481  XRootDStatus ChMod( const std::string &path,
482  Access::Mode mode,
483  ResponseHandler *handler,
484  uint16_t timeout = 0 )
486 
487  //------------------------------------------------------------------------
495  //------------------------------------------------------------------------
496  XRootDStatus ChMod( const std::string &path,
497  Access::Mode mode,
498  uint16_t timeout = 0 )
500 
501  //------------------------------------------------------------------------
508  //------------------------------------------------------------------------
510  uint16_t timeout = 0 )
512 
513  //------------------------------------------------------------------------
519  //------------------------------------------------------------------------
520  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
521 
522  //------------------------------------------------------------------------
532  //------------------------------------------------------------------------
533  XRootDStatus Stat( const std::string &path,
534  ResponseHandler *handler,
535  uint16_t timeout = 0 )
537 
538  //------------------------------------------------------------------------
547  //------------------------------------------------------------------------
548  XRootDStatus Stat( const std::string &path,
549  StatInfo *&response,
550  uint16_t timeout = 0 )
552 
553  //------------------------------------------------------------------------
563  //------------------------------------------------------------------------
564  XRootDStatus StatVFS( const std::string &path,
565  ResponseHandler *handler,
566  uint16_t timeout = 0 )
568 
569  //------------------------------------------------------------------------
577  //------------------------------------------------------------------------
578  XRootDStatus StatVFS( const std::string &path,
579  StatInfoVFS *&response,
580  uint16_t timeout = 0 )
582 
583  //------------------------------------------------------------------------
592  //------------------------------------------------------------------------
594  uint16_t timeout = 0 )
596 
597  //------------------------------------------------------------------------
604  //------------------------------------------------------------------------
606  uint16_t timeout = 0 )
608 
609  //------------------------------------------------------------------------
620  //------------------------------------------------------------------------
621  XRootDStatus DirList( const std::string &path,
622  DirListFlags::Flags flags,
623  ResponseHandler *handler,
624  uint16_t timeout = 0 )
626 
627  //------------------------------------------------------------------------
636  //------------------------------------------------------------------------
637  XRootDStatus DirList( const std::string &path,
638  DirListFlags::Flags flags,
639  DirectoryList *&response,
640  uint16_t timeout = 0 )
642 
643  //------------------------------------------------------------------------
653  //------------------------------------------------------------------------
654  XRootDStatus SendInfo( const std::string &info,
655  ResponseHandler *handler,
656  uint16_t timeout = 0 )
658 
659  //------------------------------------------------------------------------
667  //------------------------------------------------------------------------
668  XRootDStatus SendInfo( const std::string &info,
669  Buffer *&response,
670  uint16_t timeout = 0 )
672 
673  //------------------------------------------------------------------------
685  //------------------------------------------------------------------------
686  XRootDStatus Prepare( const std::vector<std::string> &fileList,
687  PrepareFlags::Flags flags,
688  uint8_t priority,
689  ResponseHandler *handler,
690  uint16_t timeout = 0 )
692 
693  //------------------------------------------------------------------------
703  //------------------------------------------------------------------------
704  XRootDStatus Prepare( const std::vector<std::string> &fileList,
705  PrepareFlags::Flags flags,
706  uint8_t priority,
707  Buffer *&response,
708  uint16_t timeout = 0 )
710 
711  //------------------------------------------------------------------------
722  //------------------------------------------------------------------------
723  XRootDStatus SetXAttr( const std::string &path,
724  const std::vector<xattr_t> &attrs,
725  ResponseHandler *handler,
726  uint16_t timeout = 0 );
727 
728  //------------------------------------------------------------------------
737  //------------------------------------------------------------------------
738  XRootDStatus SetXAttr( const std::string &path,
739  const std::vector<xattr_t> &attrs,
740  std::vector<XAttrStatus> &result,
741  uint16_t timeout = 0 );
742 
743  //------------------------------------------------------------------------
754  //------------------------------------------------------------------------
755  XRootDStatus GetXAttr( const std::string &path,
756  const std::vector<std::string> &attrs,
757  ResponseHandler *handler,
758  uint16_t timeout = 0 );
759 
760  //------------------------------------------------------------------------
769  //------------------------------------------------------------------------
770  XRootDStatus GetXAttr( const std::string &path,
771  const std::vector<std::string> &attrs,
772  std::vector<XAttr> &result,
773  uint16_t timeout = 0 );
774 
775  //------------------------------------------------------------------------
786  //------------------------------------------------------------------------
787  XRootDStatus DelXAttr( const std::string &path,
788  const std::vector<std::string> &attrs,
789  ResponseHandler *handler,
790  uint16_t timeout = 0 );
791 
792  //------------------------------------------------------------------------
801  //------------------------------------------------------------------------
802  XRootDStatus DelXAttr( const std::string &path,
803  const std::vector<std::string> &attrs,
804  std::vector<XAttrStatus> &result,
805  uint16_t timeout = 0 );
806 
807  //------------------------------------------------------------------------
817  //------------------------------------------------------------------------
818  XRootDStatus ListXAttr( const std::string &path,
819  ResponseHandler *handler,
820  uint16_t timeout = 0 );
821 
822  //------------------------------------------------------------------------
830  //------------------------------------------------------------------------
831  XRootDStatus ListXAttr( const std::string &path,
832  std::vector<XAttr> &result,
833  uint16_t timeout = 0 );
834 
835  //------------------------------------------------------------------------
840  //------------------------------------------------------------------------
841  bool SetProperty( const std::string &name, const std::string &value );
842 
843  //------------------------------------------------------------------------
847  //------------------------------------------------------------------------
848  bool GetProperty( const std::string &name, std::string &value ) const;
849 
850  private:
851  FileSystem(const FileSystem &other);
852  FileSystem &operator = (const FileSystem &other);
853 
854  //------------------------------------------------------------------------
855  // Lock the internal lock
856  //------------------------------------------------------------------------
857  void Lock();
858 
859  //------------------------------------------------------------------------
860  // Unlock the internal lock
861  //------------------------------------------------------------------------
862  void UnLock();
863 
864  //------------------------------------------------------------------------
872  //------------------------------------------------------------------------
873  template<typename T>
875  kXR_char options,
876  const std::string &path,
877  const std::vector<T> &attrs,
878  ResponseHandler *handler,
879  uint16_t timeout = 0 );
880 
881  FileSystemImpl *pImpl; //< pointer to implementation
882  FileSystemPlugIn *pPlugIn; //< file system plug-in
883  };
884 }
885 
886 #endif // __XRD_CL_FILE_SYSTEM_HH__
@ kXR_open_wrto
Definition: XProtocol.hh:456
@ kXR_compress
Definition: XProtocol.hh:439
@ kXR_delete
Definition: XProtocol.hh:440
@ kXR_prefname
Definition: XProtocol.hh:448
@ kXR_nowait
Definition: XProtocol.hh:454
@ kXR_open_read
Definition: XProtocol.hh:443
@ kXR_open_updt
Definition: XProtocol.hh:444
@ kXR_mkpath
Definition: XProtocol.hh:447
@ kXR_seqio
Definition: XProtocol.hh:455
@ kXR_replica
Definition: XProtocol.hh:452
@ kXR_posc
Definition: XProtocol.hh:453
@ kXR_refresh
Definition: XProtocol.hh:446
@ kXR_new
Definition: XProtocol.hh:442
@ kXR_force
Definition: XProtocol.hh:441
@ kXR_4dirlist
Definition: XProtocol.hh:451
@ kXR_wmode
Definition: XProtocol.hh:569
@ kXR_evict
Definition: XProtocol.hh:574
@ kXR_cancel
Definition: XProtocol.hh:565
@ kXR_fresh
Definition: XProtocol.hh:571
@ kXR_coloc
Definition: XProtocol.hh:570
@ kXR_stage
Definition: XProtocol.hh:568
@ kXR_gw
Definition: XProtocol.hh:431
@ kXR_ur
Definition: XProtocol.hh:427
@ kXR_uw
Definition: XProtocol.hh:428
@ kXR_gr
Definition: XProtocol.hh:430
@ kXR_ow
Definition: XProtocol.hh:434
@ kXR_gx
Definition: XProtocol.hh:432
@ kXR_or
Definition: XProtocol.hh:433
@ kXR_ox
Definition: XProtocol.hh:435
@ kXR_ux
Definition: XProtocol.hh:429
@ kXR_QPrep
Definition: XProtocol.hh:594
@ kXR_Qconfig
Definition: XProtocol.hh:599
@ kXR_Qopaquf
Definition: XProtocol.hh:602
@ kXR_Qckscan
Definition: XProtocol.hh:598
@ kXR_Qxattr
Definition: XProtocol.hh:596
@ kXR_Qspace
Definition: XProtocol.hh:597
@ kXR_Qvisa
Definition: XProtocol.hh:600
@ kXR_QStats
Definition: XProtocol.hh:593
@ kXR_Qcksum
Definition: XProtocol.hh:595
@ kXR_Qopaque
Definition: XProtocol.hh:601
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:481
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:144
DirList operation (.
Definition: XrdClFileSystemOperations.hh:706
Directory list.
Definition: XrdClXRootDResponses.hh:646
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:284
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:203
XRootDStatus SetXAttr(const std::string &path, const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
FileSystemImpl * pImpl
Definition: XrdClFileSystem.hh:881
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:882
XRootDStatus Stat(const std::string &path, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
friend class AssignLBHandler
Definition: XrdClFileSystem.hh:204
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:208
Definition: XrdClForkHandler.hh:36
Locate operation (.
Definition: XrdClFileSystemOperations.hh:96
Path location info.
Definition: XrdClXRootDResponses.hh:40
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:386
Mv operation (.
Definition: XrdClFileSystemOperations.hh:192
Ping operation (.
Definition: XrdClFileSystemOperations.hh:528
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:801
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:666
Protocol response.
Definition: XrdClXRootDResponses.hh:338
Query operation (.
Definition: XrdClFileSystemOperations.hh:240
Handle an async response.
Definition: XrdClXRootDResponses.hh:1037
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:435
Rm operation (.
Definition: XrdClFileSystemOperations.hh:340
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:754
VFS stat info.
Definition: XrdClXRootDResponses.hh:569
Object stat info.
Definition: XrdClXRootDResponses.hh:396
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:619
URL representation.
Definition: XrdClURL.hh:31
Visa operation (.
Definition: XrdClFileOperations.hh:706
Request status.
Definition: XrdClXRootDResponses.hh:215
Definition: XrdClAnyObject.hh:26
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
Definition: XrdClFileOperations.hh:358
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
@ Read
Open only for reading.
Definition: XrdClFileSystem.hh:95
@ Force
Definition: XrdClFileSystem.hh:82
@ New
Definition: XrdClFileSystem.hh:86
@ PrefName
Definition: XrdClFileSystem.hh:105
@ Write
Open only for writing.
Definition: XrdClFileSystem.hh:97
@ 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:174
Flags
Definition: XrdClFileSystem.hh:176
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