xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 Message;
42  class FileSystemPlugIn;
43  struct MessageSendParams;
44 
45  //----------------------------------------------------------------------------
47  //----------------------------------------------------------------------------
48  struct QueryCode
49  {
50  //--------------------------------------------------------------------------
52  //--------------------------------------------------------------------------
53  enum Code
54  {
65  };
66  };
67 
68  //----------------------------------------------------------------------------
70  //----------------------------------------------------------------------------
71  struct OpenFlags
72  {
73  //--------------------------------------------------------------------------
75  //--------------------------------------------------------------------------
76  enum Flags
77  {
78  None = 0,
80  Delete = kXR_delete,
82  Force = kXR_force,
86  New = kXR_new,
88  NoWait = kXR_nowait,
100  Refresh = kXR_refresh,
102  Replica = kXR_replica,
104  SeqIO = kXR_seqio,
107  };
109  };
111 
112  //----------------------------------------------------------------------------
114  //----------------------------------------------------------------------------
115  struct Access
116  {
117  //--------------------------------------------------------------------------
119  //--------------------------------------------------------------------------
120  enum Mode
121  {
122  None = 0,
123  UR = kXR_ur,
124  UW = kXR_uw,
125  UX = kXR_ux,
126  GR = kXR_gr,
127  GW = kXR_gw,
128  GX = kXR_gx,
129  OR = kXR_or,
130  OW = kXR_ow,
131  OX = kXR_ox
132  };
133  };
135 
136  //----------------------------------------------------------------------------
138  //----------------------------------------------------------------------------
139  struct MkDirFlags
140  {
141  enum Flags
142  {
143  None = 0,
144  MakePath = 1
145  };
146  };
148 
149  //----------------------------------------------------------------------------
151  //----------------------------------------------------------------------------
153  {
154  enum Flags
155  {
156  None = 0,
157  Stat = 1,
158  Locate = 2,
159  Recursive = 4,
161  Merge = 8,
162  Chunked = 16,
163  Zip = 32
164  };
165  };
167 
168  //----------------------------------------------------------------------------
170  //----------------------------------------------------------------------------
172  {
173  enum Flags
174  {
175  None = 0,
176  Colocate = kXR_coloc,
177  Fresh = kXR_fresh,
178  Stage = kXR_stage,
180  WriteMode = kXR_wmode,
182  Cancel = kXR_cancel,
184  Evict = kXR_evict << 8
185  };
189  };
191 
192  //----------------------------------------------------------------------------
194  //----------------------------------------------------------------------------
196  {
197  friend class AssignLBHandler;
198  friend class ForkHandler;
199 
200  public:
201  typedef std::vector<LocationInfo> LocationList;
202 
203  //------------------------------------------------------------------------
208  //------------------------------------------------------------------------
209  FileSystem( const URL &url, bool enablePlugIns = true );
210 
211  //------------------------------------------------------------------------
213  //------------------------------------------------------------------------
214  ~FileSystem();
215 
216  //------------------------------------------------------------------------
227  //------------------------------------------------------------------------
228  XRootDStatus Locate( const std::string &path,
229  OpenFlags::Flags flags,
230  ResponseHandler *handler,
231  uint16_t timeout = 0 )
233 
234  //------------------------------------------------------------------------
243  //------------------------------------------------------------------------
244  XRootDStatus Locate( const std::string &path,
245  OpenFlags::Flags flags,
246  LocationInfo *&response,
247  uint16_t timeout = 0 )
249 
250  //------------------------------------------------------------------------
261  //------------------------------------------------------------------------
262  XRootDStatus DeepLocate( const std::string &path,
263  OpenFlags::Flags flags,
264  ResponseHandler *handler,
265  uint16_t timeout = 0 )
266  XRD_WARN_UNUSED_RESULT;
267 
268  //------------------------------------------------------------------------
277  //------------------------------------------------------------------------
278  XRootDStatus DeepLocate( const std::string &path,
279  OpenFlags::Flags flags,
280  LocationInfo *&response,
281  uint16_t timeout = 0 )
282  XRD_WARN_UNUSED_RESULT;
283 
284  //------------------------------------------------------------------------
293  //------------------------------------------------------------------------
294  XRootDStatus Mv( const std::string &source,
295  const std::string &dest,
296  ResponseHandler *handler,
297  uint16_t timeout = 0 )
298  XRD_WARN_UNUSED_RESULT;
299 
300  //------------------------------------------------------------------------
308  //------------------------------------------------------------------------
309  XRootDStatus Mv( const std::string &source,
310  const std::string &dest,
311  uint16_t timeout = 0 )
312  XRD_WARN_UNUSED_RESULT;
313 
314  //------------------------------------------------------------------------
325  //------------------------------------------------------------------------
326  XRootDStatus Query( QueryCode::Code queryCode,
327  const Buffer &arg,
328  ResponseHandler *handler,
329  uint16_t timeout = 0 )
330  XRD_WARN_UNUSED_RESULT;
331 
332  //------------------------------------------------------------------------
341  //------------------------------------------------------------------------
342  XRootDStatus Query( QueryCode::Code queryCode,
343  const Buffer &arg,
344  Buffer *&response,
345  uint16_t timeout = 0 )
346  XRD_WARN_UNUSED_RESULT;
347 
348  //------------------------------------------------------------------------
357  //------------------------------------------------------------------------
358  XRootDStatus Truncate( const std::string &path,
359  uint64_t size,
360  ResponseHandler *handler,
361  uint16_t timeout = 0 )
362  XRD_WARN_UNUSED_RESULT;
363 
364  //------------------------------------------------------------------------
372  //------------------------------------------------------------------------
373  XRootDStatus Truncate( const std::string &path,
374  uint64_t size,
375  uint16_t timeout = 0 )
376  XRD_WARN_UNUSED_RESULT;
377 
378  //------------------------------------------------------------------------
386  //------------------------------------------------------------------------
387  XRootDStatus Rm( const std::string &path,
388  ResponseHandler *handler,
389  uint16_t timeout = 0 )
390  XRD_WARN_UNUSED_RESULT;
391 
392  //------------------------------------------------------------------------
399  //------------------------------------------------------------------------
400  XRootDStatus Rm( const std::string &path,
401  uint16_t timeout = 0 )
402  XRD_WARN_UNUSED_RESULT;
403 
404  //------------------------------------------------------------------------
414  //------------------------------------------------------------------------
415  XRootDStatus MkDir( const std::string &path,
416  MkDirFlags::Flags flags,
417  Access::Mode mode,
418  ResponseHandler *handler,
419  uint16_t timeout = 0 )
420  XRD_WARN_UNUSED_RESULT;
421 
422  //------------------------------------------------------------------------
431  //------------------------------------------------------------------------
432  XRootDStatus MkDir( const std::string &path,
433  MkDirFlags::Flags flags,
434  Access::Mode mode,
435  uint16_t timeout = 0 )
436  XRD_WARN_UNUSED_RESULT;
437 
438  //------------------------------------------------------------------------
446  //------------------------------------------------------------------------
447  XRootDStatus RmDir( const std::string &path,
448  ResponseHandler *handler,
449  uint16_t timeout = 0 )
450  XRD_WARN_UNUSED_RESULT;
451 
452  //------------------------------------------------------------------------
459  //------------------------------------------------------------------------
460  XRootDStatus RmDir( const std::string &path,
461  uint16_t timeout = 0 )
462  XRD_WARN_UNUSED_RESULT;
463 
464  //------------------------------------------------------------------------
473  //------------------------------------------------------------------------
474  XRootDStatus ChMod( const std::string &path,
475  Access::Mode mode,
476  ResponseHandler *handler,
477  uint16_t timeout = 0 )
478  XRD_WARN_UNUSED_RESULT;
479 
480  //------------------------------------------------------------------------
488  //------------------------------------------------------------------------
489  XRootDStatus ChMod( const std::string &path,
490  Access::Mode mode,
491  uint16_t timeout = 0 )
492  XRD_WARN_UNUSED_RESULT;
493 
494  //------------------------------------------------------------------------
501  //------------------------------------------------------------------------
503  uint16_t timeout = 0 )
504  XRD_WARN_UNUSED_RESULT;
505 
506  //------------------------------------------------------------------------
512  //------------------------------------------------------------------------
513  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
514 
515  //------------------------------------------------------------------------
525  //------------------------------------------------------------------------
526  XRootDStatus Stat( const std::string &path,
527  ResponseHandler *handler,
528  uint16_t timeout = 0 )
529  XRD_WARN_UNUSED_RESULT;
530 
531  //------------------------------------------------------------------------
540  //------------------------------------------------------------------------
541  XRootDStatus Stat( const std::string &path,
542  StatInfo *&response,
543  uint16_t timeout = 0 )
544  XRD_WARN_UNUSED_RESULT;
545 
546  //------------------------------------------------------------------------
556  //------------------------------------------------------------------------
557  XRootDStatus StatVFS( const std::string &path,
558  ResponseHandler *handler,
559  uint16_t timeout = 0 )
560  XRD_WARN_UNUSED_RESULT;
561 
562  //------------------------------------------------------------------------
570  //------------------------------------------------------------------------
571  XRootDStatus StatVFS( const std::string &path,
572  StatInfoVFS *&response,
573  uint16_t timeout = 0 )
574  XRD_WARN_UNUSED_RESULT;
575 
576  //------------------------------------------------------------------------
585  //------------------------------------------------------------------------
587  uint16_t timeout = 0 )
588  XRD_WARN_UNUSED_RESULT;
589 
590  //------------------------------------------------------------------------
597  //------------------------------------------------------------------------
598  XRootDStatus Protocol( ProtocolInfo *&response,
599  uint16_t timeout = 0 )
600  XRD_WARN_UNUSED_RESULT;
601 
602  //------------------------------------------------------------------------
613  //------------------------------------------------------------------------
614  XRootDStatus DirList( const std::string &path,
615  DirListFlags::Flags flags,
616  ResponseHandler *handler,
617  uint16_t timeout = 0 )
618  XRD_WARN_UNUSED_RESULT;
619 
620  //------------------------------------------------------------------------
629  //------------------------------------------------------------------------
630  XRootDStatus DirList( const std::string &path,
631  DirListFlags::Flags flags,
632  DirectoryList *&response,
633  uint16_t timeout = 0 )
634  XRD_WARN_UNUSED_RESULT;
635 
636  //------------------------------------------------------------------------
646  //------------------------------------------------------------------------
647  XRootDStatus SendInfo( const std::string &info,
648  ResponseHandler *handler,
649  uint16_t timeout = 0 )
650  XRD_WARN_UNUSED_RESULT;
651 
652  //------------------------------------------------------------------------
660  //------------------------------------------------------------------------
661  XRootDStatus SendInfo( const std::string &info,
662  Buffer *&response,
663  uint16_t timeout = 0 )
664  XRD_WARN_UNUSED_RESULT;
665 
666  //------------------------------------------------------------------------
678  //------------------------------------------------------------------------
679  XRootDStatus Prepare( const std::vector<std::string> &fileList,
680  PrepareFlags::Flags flags,
681  uint8_t priority,
682  ResponseHandler *handler,
683  uint16_t timeout = 0 )
684  XRD_WARN_UNUSED_RESULT;
685 
686  //------------------------------------------------------------------------
696  //------------------------------------------------------------------------
697  XRootDStatus Prepare( const std::vector<std::string> &fileList,
698  PrepareFlags::Flags flags,
699  uint8_t priority,
700  Buffer *&response,
701  uint16_t timeout = 0 )
702  XRD_WARN_UNUSED_RESULT;
703 
704  //------------------------------------------------------------------------
709  //------------------------------------------------------------------------
710  bool SetProperty( const std::string &name, const std::string &value );
711 
712  //------------------------------------------------------------------------
716  //------------------------------------------------------------------------
717  bool GetProperty( const std::string &name, std::string &value ) const;
718 
719  private:
720  FileSystem(const FileSystem &other);
721  FileSystem &operator = (const FileSystem &other);
722 
723  //------------------------------------------------------------------------
724  // Send a message in a locked environment
725  //------------------------------------------------------------------------
726  Status Send( Message *msg,
727  ResponseHandler *handler,
728  MessageSendParams &params );
729 
730  //------------------------------------------------------------------------
731  // Assign a load balancer if it has not already been assigned
732  //------------------------------------------------------------------------
733  void AssignLoadBalancer( const URL &url );
734 
735  //------------------------------------------------------------------------
736  // Lock the internal lock
737  //------------------------------------------------------------------------
738  void Lock()
739  {
740  pMutex.Lock();
741  }
742 
743  //------------------------------------------------------------------------
744  // Unlock the internal lock
745  //------------------------------------------------------------------------
746  void UnLock()
747  {
748  pMutex.UnLock();
749  }
750 
756  };
757 }
758 
759 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:224
Definition: XrdClForkHandler.hh:35
Definition: XProtocol.hh:245
bool pFollowRedirects
Definition: XrdClFileSystem.hh:753
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:779
Definition: XProtocol.hh:269
Implementation dependent.
Definition: XrdClFileSystem.hh:59
Definition: XProtocol.hh:267
Definition: XProtocol.hh:221
Definition: XProtocol.hh:156
Definition: XrdClMessageUtils.hh:128
Definition: XProtocol.hh:154
Directory list.
Definition: XrdClXRootDResponses.hh:510
Open only for appending.
Definition: XrdClFileSystem.hh:95
Definition: XProtocol.hh:220
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Object stat info.
Definition: XrdClXRootDResponses.hh:332
Definition: XrdClFileSystem.hh:79
Definition: XProtocol.hh:246
Prepare flags.
Definition: XrdClFileSystem.hh:171
Definition: XProtocol.hh:155
Query file checksum.
Definition: XrdClFileSystem.hh:57
Definition: XProtocol.hh:247
Path location info.
Definition: XrdClXRootDResponses.hh:37
LocateImpl< false > Locate
Definition: XrdClFileSystemOperations.hh:154
Definition: XProtocol.hh:268
Visa operation (.
Definition: XrdClFileOperations.hh:806
Definition: XrdClFileSystem.hh:85
Definition: XProtocol.hh:240
Access mode.
Definition: XrdClFileSystem.hh:115
Read operation (.
Definition: XrdClFileOperations.hh:250
Definition: XProtocol.hh:152
Flags
Definition: XrdClFileSystem.hh:173
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:451
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:930
Procedure execution status.
Definition: XrdClStatus.hh:109
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:201
Ping operation (.
Definition: XrdClFileSystemOperations.hh:621
Definition: XrdClFileSystem.hh:101
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:230
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:752
DirList flags.
Definition: XrdClFileSystem.hh:152
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:71
Protocol response.
Definition: XrdClXRootDResponses.hh:279
Query operation (.
Definition: XrdClFileSystemOperations.hh:274
Definition: XrdSysPthread.hh:165
void UnLock()
Definition: XrdClFileSystem.hh:746
Definition: XProtocol.hh:151
Definition: XrdClFileSystem.hh:83
Definition: XProtocol.hh:153
Flags
Definition: XrdClFileSystem.hh:141
Definition: XrdClFileSystem.hh:99
Definition: XProtocol.hh:248
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:751
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:105
MkDir flags.
Definition: XrdClFileSystem.hh:139
Query file extended attributes.
Definition: XrdClFileSystem.hh:64
Open for reading and writing.
Definition: XrdClFileSystem.hh:97
Definition: XProtocol.hh:231
StatImpl< false > Stat(File *file, Arg< bool > force)
Definition: XrdClFileOperations.hh:398
Definition: XProtocol.hh:149
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:509
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Request status.
Definition: XrdClXRootDResponses.hh:212
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:723
Definition: XrdClFileSystem.hh:106
Definition: XProtocol.hh:249
Definition: XProtocol.hh:244
VFS stat info.
Definition: XrdClXRootDResponses.hh:433
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:564
Definition: XProtocol.hh:219
Definition: XProtocol.hh:150
Definition: XProtocol.hh:157
URL * pUrl
Definition: XrdClFileSystem.hh:754
Definition: XrdClFileSystem.hh:103
Definition: XProtocol.hh:217
Handle an async response.
Definition: XrdClXRootDResponses.hh:854
Definition: XProtocol.hh:241
Mv operation (.
Definition: XrdClFileSystemOperations.hh:217
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:53
URL representation.
Definition: XrdClURL.hh:30
Rm operation (.
Definition: XrdClFileSystemOperations.hh:397
Definition: XProtocol.hh:264
Definition: XProtocol.hh:216
Flags
Definition: XrdClFileSystem.hh:154
Definition: XProtocol.hh:270
Definition: XProtocol.hh:228
Query server stats.
Definition: XrdClFileSystem.hh:62
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:120
Definition: XrdClFileSystem.hh:87
Definition: XProtocol.hh:273
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:874
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:195
Definition: XProtocol.hh:229
Nothing.
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:223
Definition: XProtocol.hh:243
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Definition: XrdClFileSystem.hh:81
Definition: XProtocol.hh:232
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:755
Definition: XProtocol.hh:225
Query server configuration.
Definition: XrdClFileSystem.hh:55
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:76
TruncateImpl< false > Truncate(File *file, Arg< uint64_t > size)
Definition: XrdClFileOperations.hh:564
Locate operation (.
Definition: XrdClFileSystemOperations.hh:103
Write operation (.
Definition: XrdClFileOperations.hh:416
Definition: XProtocol.hh:226
Definition: XProtocol.hh:242
Definition: XProtocol.hh:218
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:190
Definition: XrdClFileSystem.hh:89
Binary blob representation.
Definition: XrdClBuffer.hh:33
DirList operation (.
Definition: XrdClFileSystemOperations.hh:817
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:160