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  Cksm = 64
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  //----------------------------------------------------------------------------
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  //------------------------------------------------------------------------
221  ~FileSystem();
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  //------------------------------------------------------------------------
605  XRootDStatus Protocol( ProtocolInfo *&response,
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__
unsigned char kXR_char
Definition: XPtypes.hh:65
Definition: XProtocol.hh:459
Definition: XrdClForkHandler.hh:35
Definition: XrdClFileSystem.hh:107
Definition: XProtocol.hh:613
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:664
Definition: XProtocol.hh:585
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Definition: XProtocol.hh:583
Definition: XProtocol.hh:456
Definition: XProtocol.hh:446
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:294
Definition: XProtocol.hh:444
Directory list.
Definition: XrdClXRootDResponses.hh:649
Definition: XProtocol.hh:455
Object stat info.
Definition: XrdClXRootDResponses.hh:399
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:614
Open only for writing.
Definition: XrdClFileSystem.hh:97
XRootDStatus Truncate(const std::string &path, uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Prepare flags.
Definition: XrdClFileSystem.hh:173
Extended attributes with status.
Definition: XrdClXRootDResponses.hh:312
Definition: XProtocol.hh:445
bool SetProperty(const std::string &name, const std::string &value)
Query file checksum.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:615
Path location info.
Definition: XrdClXRootDResponses.hh:43
Definition: XProtocol.hh:584
Visa operation (.
Definition: XrdClFileOperations.hh:705
Definition: XrdClFileSystem.hh:84
Definition: XProtocol.hh:608
Access mode.
Definition: XrdClFileSystem.hh:116
~FileSystem()
Destructor.
Definition: XProtocol.hh:442
Flags
Definition: XrdClFileSystem.hh:175
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:384
Implementation dependent.
Definition: XrdClFileSystem.hh:57
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:799
Procedure execution status.
Definition: XrdClStatus.hh:112
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:208
Ping operation (.
Definition: XrdClFileSystemOperations.hh:527
Definition: XrdClFileSystem.hh:100
FileSystemImpl * pImpl
Definition: XrdClFileSystem.hh:881
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:55
Definition: XProtocol.hh:466
DirList flags.
Definition: XrdClFileSystem.hh:153
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Protocol response.
Definition: XrdClXRootDResponses.hh:341
Query operation (.
Definition: XrdClFileSystemOperations.hh:238
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:441
Definition: XrdClFileSystem.hh:82
Definition: XProtocol.hh:443
Flags
Definition: XrdClFileSystem.hh:142
Definition: XrdClFileSystem.hh:98
Definition: XProtocol.hh:616
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:467
none object for initializing empty Optional
Definition: XrdClOptional.hh:35
Definition: XProtocol.hh:463
Definition: XProtocol.hh:439
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:433
XRootD query request codes.
Definition: XrdClFileSystem.hh:47
Request status.
Definition: XrdClXRootDResponses.hh:218
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:617
Definition: XrdClAnyObject.hh:25
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
Definition: XrdClFileOperations.hh:358
Definition: XrdClFileSystem.hh:105
Definition: XProtocol.hh:617
Definition: XProtocol.hh:612
VFS stat info.
Definition: XrdClXRootDResponses.hh:572
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:479
Definition: XProtocol.hh:454
Definition: XProtocol.hh:440
Definition: XProtocol.hh:447
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:452
Handle an async response.
Definition: XrdClXRootDResponses.hh:1040
Definition: XProtocol.hh:609
Mv operation (.
Definition: XrdClFileSystemOperations.hh:190
bool GetProperty(const std::string &name, std::string &value) const
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:52
Open only for reading.
Definition: XrdClFileSystem.hh:95
URL representation.
Definition: XrdClURL.hh:30
Rm operation (.
Definition: XrdClFileSystemOperations.hh:339
FileSystem(const URL &url, bool enablePlugIns=true)
Definition: XProtocol.hh:580
Definition: XProtocol.hh:451
Flags
Definition: XrdClFileSystem.hh:155
Definition: XProtocol.hh:586
Definition: XProtocol.hh:464
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:589
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:752
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:202
Definition: XProtocol.hh:465
Definition: XProtocol.hh:458
Definition: XProtocol.hh:611
Query logical space stats.
Definition: XrdClFileSystem.hh:60
Definition: XrdClFileSystem.hh:80
Definition: XProtocol.hh:468
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:882
Definition: XProtocol.hh:460
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:289
Locate operation (.
Definition: XrdClFileSystemOperations.hh:94
Definition: XProtocol.hh:610
Definition: XProtocol.hh:453
friend class AssignLBHandler
Definition: XrdClFileSystem.hh:204
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:704
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:142