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  //------------------------------------------------------------------------
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 SendCache( const std::string &info,
655  ResponseHandler *handler,
656  uint16_t timeout = 0 )
658 
659  //------------------------------------------------------------------------
667  //------------------------------------------------------------------------
668  XRootDStatus SendCache( const std::string &info,
669  Buffer *&response,
670  uint16_t timeout = 0 )
672 
673  //------------------------------------------------------------------------
683  //------------------------------------------------------------------------
684  XRootDStatus SendInfo( const std::string &info,
685  ResponseHandler *handler,
686  uint16_t timeout = 0 )
688 
689  //------------------------------------------------------------------------
697  //------------------------------------------------------------------------
698  XRootDStatus SendInfo( const std::string &info,
699  Buffer *&response,
700  uint16_t timeout = 0 )
702 
703  //------------------------------------------------------------------------
715  //------------------------------------------------------------------------
716  XRootDStatus Prepare( const std::vector<std::string> &fileList,
717  PrepareFlags::Flags flags,
718  uint8_t priority,
719  ResponseHandler *handler,
720  uint16_t timeout = 0 )
722 
723  //------------------------------------------------------------------------
733  //------------------------------------------------------------------------
734  XRootDStatus Prepare( const std::vector<std::string> &fileList,
735  PrepareFlags::Flags flags,
736  uint8_t priority,
737  Buffer *&response,
738  uint16_t timeout = 0 )
740 
741  //------------------------------------------------------------------------
752  //------------------------------------------------------------------------
753  XRootDStatus SetXAttr( const std::string &path,
754  const std::vector<xattr_t> &attrs,
755  ResponseHandler *handler,
756  uint16_t timeout = 0 );
757 
758  //------------------------------------------------------------------------
767  //------------------------------------------------------------------------
768  XRootDStatus SetXAttr( const std::string &path,
769  const std::vector<xattr_t> &attrs,
770  std::vector<XAttrStatus> &result,
771  uint16_t timeout = 0 );
772 
773  //------------------------------------------------------------------------
784  //------------------------------------------------------------------------
785  XRootDStatus GetXAttr( const std::string &path,
786  const std::vector<std::string> &attrs,
787  ResponseHandler *handler,
788  uint16_t timeout = 0 );
789 
790  //------------------------------------------------------------------------
799  //------------------------------------------------------------------------
800  XRootDStatus GetXAttr( const std::string &path,
801  const std::vector<std::string> &attrs,
802  std::vector<XAttr> &result,
803  uint16_t timeout = 0 );
804 
805  //------------------------------------------------------------------------
816  //------------------------------------------------------------------------
817  XRootDStatus DelXAttr( const std::string &path,
818  const std::vector<std::string> &attrs,
819  ResponseHandler *handler,
820  uint16_t timeout = 0 );
821 
822  //------------------------------------------------------------------------
831  //------------------------------------------------------------------------
832  XRootDStatus DelXAttr( const std::string &path,
833  const std::vector<std::string> &attrs,
834  std::vector<XAttrStatus> &result,
835  uint16_t timeout = 0 );
836 
837  //------------------------------------------------------------------------
847  //------------------------------------------------------------------------
848  XRootDStatus ListXAttr( const std::string &path,
849  ResponseHandler *handler,
850  uint16_t timeout = 0 );
851 
852  //------------------------------------------------------------------------
860  //------------------------------------------------------------------------
861  XRootDStatus ListXAttr( const std::string &path,
862  std::vector<XAttr> &result,
863  uint16_t timeout = 0 );
864 
865  //------------------------------------------------------------------------
870  //------------------------------------------------------------------------
871  bool SetProperty( const std::string &name, const std::string &value );
872 
873  //------------------------------------------------------------------------
877  //------------------------------------------------------------------------
878  bool GetProperty( const std::string &name, std::string &value ) const;
879 
880  private:
881  FileSystem(const FileSystem &other);
882  FileSystem &operator = (const FileSystem &other);
883 
884  //------------------------------------------------------------------------
885  // Lock the internal lock
886  //------------------------------------------------------------------------
887  void Lock();
888 
889  //------------------------------------------------------------------------
890  // Unlock the internal lock
891  //------------------------------------------------------------------------
892  void UnLock();
893 
894  //------------------------------------------------------------------------
901  //------------------------------------------------------------------------
902  XRootDStatus SendSet( const char *prefix,
903  const std::string &info,
904  ResponseHandler *handler,
905  uint16_t timeout = 0 )
907 
908  //------------------------------------------------------------------------
916  //------------------------------------------------------------------------
917  template<typename T>
918  Status XAttrOperationImpl( kXR_char subcode,
919  kXR_char options,
920  const std::string &path,
921  const std::vector<T> &attrs,
922  ResponseHandler *handler,
923  uint16_t timeout = 0 );
924 
925  FileSystemImpl *pImpl; //< pointer to implementation (TODO: once we can break ABI we can use a shared pointer here, and then we can drop the FileSystemData in source file)
926  FileSystemPlugIn *pPlugIn; //< file system plug-in
927  };
928 }
929 
930 #endif // __XRD_CL_FILE_SYSTEM_HH__
@ kXR_open_wrto
Definition: XProtocol.hh:469
@ kXR_compress
Definition: XProtocol.hh:452
@ kXR_delete
Definition: XProtocol.hh:453
@ kXR_prefname
Definition: XProtocol.hh:461
@ kXR_nowait
Definition: XProtocol.hh:467
@ kXR_open_read
Definition: XProtocol.hh:456
@ kXR_open_updt
Definition: XProtocol.hh:457
@ kXR_mkpath
Definition: XProtocol.hh:460
@ kXR_seqio
Definition: XProtocol.hh:468
@ kXR_replica
Definition: XProtocol.hh:465
@ kXR_posc
Definition: XProtocol.hh:466
@ kXR_refresh
Definition: XProtocol.hh:459
@ kXR_new
Definition: XProtocol.hh:455
@ kXR_force
Definition: XProtocol.hh:454
@ kXR_4dirlist
Definition: XProtocol.hh:464
@ kXR_wmode
Definition: XProtocol.hh:591
@ kXR_evict
Definition: XProtocol.hh:596
@ kXR_cancel
Definition: XProtocol.hh:587
@ kXR_fresh
Definition: XProtocol.hh:593
@ kXR_coloc
Definition: XProtocol.hh:592
@ kXR_stage
Definition: XProtocol.hh:590
@ kXR_gw
Definition: XProtocol.hh:444
@ kXR_ur
Definition: XProtocol.hh:440
@ kXR_uw
Definition: XProtocol.hh:441
@ kXR_gr
Definition: XProtocol.hh:443
@ kXR_ow
Definition: XProtocol.hh:447
@ kXR_gx
Definition: XProtocol.hh:445
@ kXR_or
Definition: XProtocol.hh:446
@ kXR_ox
Definition: XProtocol.hh:448
@ kXR_ux
Definition: XProtocol.hh:442
@ kXR_QPrep
Definition: XProtocol.hh:616
@ kXR_Qconfig
Definition: XProtocol.hh:621
@ kXR_Qopaquf
Definition: XProtocol.hh:624
@ kXR_Qckscan
Definition: XProtocol.hh:620
@ kXR_Qxattr
Definition: XProtocol.hh:618
@ kXR_Qspace
Definition: XProtocol.hh:619
@ kXR_Qvisa
Definition: XProtocol.hh:622
@ kXR_QStats
Definition: XProtocol.hh:615
@ kXR_Qcksum
Definition: XProtocol.hh:617
@ kXR_Qopaque
Definition: XProtocol.hh:623
unsigned char kXR_char
Definition: XPtypes.hh:65
#define XRD_WARN_UNUSED_RESULT
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
int Mode
Wrapper class used to assign a load balancer.
Binary blob representation.
Definition: XrdClBuffer.hh:34
An interface for file plug-ins.
Send file/filesystem queries to an XRootD cluster.
XRootDStatus SetXAttr(const std::string &path, const std::vector< xattr_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
XRootDStatus Stat(const std::string &path, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
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)
XRootDStatus SendCache(const std::string &info, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
~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.
Path location info.
Handle an async response.
Object stat info.
URL representation.
Definition: XrdClURL.hh:31
Visa operation (.
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
std::tuple< std::string, std::string > xattr_t
Extended attribute key - value pair.
none object for initializing empty Optional
Access mode.
Mode
Access mode.
Implementation holding the data members.
Open flags, may be or'd when appropriate.
Flags
Open flags, may be or'd when appropriate.
@ Read
Open only for reading.
@ Write
Open only for writing.
@ SeqIO
File will be read or written sequentially.
@ Update
Open for reading and writing.
XRootD query request codes.
Code
XRootD query request codes.
@ OpaqueFile
Implementation dependent.
@ Opaque
Implementation dependent.
@ Config
Query server configuration.
@ Stats
Query server stats.
@ ChecksumCancel
Query file checksum cancellation.
@ Checksum
Query file checksum.
@ Space
Query logical space stats.
Procedure execution status.
Definition: XrdClStatus.hh:115
Extended attribute operation status.
Extended attributes with status.