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 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  Force = kXR_force,
84  New = kXR_new,
86  NoWait = kXR_nowait,
100  Replica = kXR_replica,
102  SeqIO = kXR_seqio,
105  };
107  };
109 
110  //----------------------------------------------------------------------------
112  //----------------------------------------------------------------------------
113  struct Access
114  {
115  //--------------------------------------------------------------------------
117  //--------------------------------------------------------------------------
118  enum Mode
119  {
120  None = 0,
121  UR = kXR_ur,
122  UW = kXR_uw,
123  UX = kXR_ux,
124  GR = kXR_gr,
125  GW = kXR_gw,
126  GX = kXR_gx,
127  OR = kXR_or,
128  OW = kXR_ow,
129  OX = kXR_ox
130  };
131  };
133 
134  //----------------------------------------------------------------------------
136  //----------------------------------------------------------------------------
137  struct MkDirFlags
138  {
139  enum Flags
140  {
141  None = 0,
142  MakePath = 1
143  };
144  };
146 
147  //----------------------------------------------------------------------------
149  //----------------------------------------------------------------------------
151  {
152  enum Flags
153  {
154  None = 0,
155  Stat = 1,
156  Locate = 2
157  };
159  };
161 
162  //----------------------------------------------------------------------------
164  //----------------------------------------------------------------------------
166  {
167  enum Flags
168  {
169  None = 0,
170  Colocate = kXR_coloc,
171  Fresh = kXR_fresh,
172  Stage = kXR_stage,
174  WriteMode = kXR_wmode
176  };
178  };
180 
181  //----------------------------------------------------------------------------
183  //----------------------------------------------------------------------------
185  {
186  friend class AssignLBHandler;
187  friend class ForkHandler;
188 
189  public:
190  typedef std::vector<LocationInfo> LocationList;
191 
192  //------------------------------------------------------------------------
197  //------------------------------------------------------------------------
198  FileSystem( const URL &url, bool enablePlugIns = true );
199 
200  //------------------------------------------------------------------------
202  //------------------------------------------------------------------------
203  ~FileSystem();
204 
205  //------------------------------------------------------------------------
216  //------------------------------------------------------------------------
217  XRootDStatus Locate( const std::string &path,
218  OpenFlags::Flags flags,
219  ResponseHandler *handler,
220  uint16_t timeout = 0 )
221  XRD_WARN_UNUSED_RESULT;
222 
223  //------------------------------------------------------------------------
232  //------------------------------------------------------------------------
233  XRootDStatus Locate( const std::string &path,
234  OpenFlags::Flags flags,
235  LocationInfo *&response,
236  uint16_t timeout = 0 )
237  XRD_WARN_UNUSED_RESULT;
238 
239  //------------------------------------------------------------------------
250  //------------------------------------------------------------------------
251  XRootDStatus DeepLocate( const std::string &path,
252  OpenFlags::Flags flags,
253  ResponseHandler *handler,
254  uint16_t timeout = 0 )
255  XRD_WARN_UNUSED_RESULT;
256 
257  //------------------------------------------------------------------------
266  //------------------------------------------------------------------------
267  XRootDStatus DeepLocate( const std::string &path,
268  OpenFlags::Flags flags,
269  LocationInfo *&response,
270  uint16_t timeout = 0 )
271  XRD_WARN_UNUSED_RESULT;
272 
273  //------------------------------------------------------------------------
282  //------------------------------------------------------------------------
283  XRootDStatus Mv( const std::string &source,
284  const std::string &dest,
285  ResponseHandler *handler,
286  uint16_t timeout = 0 )
287  XRD_WARN_UNUSED_RESULT;
288 
289  //------------------------------------------------------------------------
297  //------------------------------------------------------------------------
298  XRootDStatus Mv( const std::string &source,
299  const std::string &dest,
300  uint16_t timeout = 0 )
301  XRD_WARN_UNUSED_RESULT;
302 
303  //------------------------------------------------------------------------
314  //------------------------------------------------------------------------
315  XRootDStatus Query( QueryCode::Code queryCode,
316  const Buffer &arg,
317  ResponseHandler *handler,
318  uint16_t timeout = 0 )
319  XRD_WARN_UNUSED_RESULT;
320 
321  //------------------------------------------------------------------------
330  //------------------------------------------------------------------------
331  XRootDStatus Query( QueryCode::Code queryCode,
332  const Buffer &arg,
333  Buffer *&response,
334  uint16_t timeout = 0 )
335  XRD_WARN_UNUSED_RESULT;
336 
337  //------------------------------------------------------------------------
346  //------------------------------------------------------------------------
347  XRootDStatus Truncate( const std::string &path,
348  uint64_t size,
349  ResponseHandler *handler,
350  uint16_t timeout = 0 )
351  XRD_WARN_UNUSED_RESULT;
352 
353  //------------------------------------------------------------------------
361  //------------------------------------------------------------------------
362  XRootDStatus Truncate( const std::string &path,
363  uint64_t size,
364  uint16_t timeout = 0 )
365  XRD_WARN_UNUSED_RESULT;
366 
367  //------------------------------------------------------------------------
375  //------------------------------------------------------------------------
376  XRootDStatus Rm( const std::string &path,
377  ResponseHandler *handler,
378  uint16_t timeout = 0 )
379  XRD_WARN_UNUSED_RESULT;
380 
381  //------------------------------------------------------------------------
388  //------------------------------------------------------------------------
389  XRootDStatus Rm( const std::string &path,
390  uint16_t timeout = 0 )
391  XRD_WARN_UNUSED_RESULT;
392 
393  //------------------------------------------------------------------------
403  //------------------------------------------------------------------------
404  XRootDStatus MkDir( const std::string &path,
405  MkDirFlags::Flags flags,
406  Access::Mode mode,
407  ResponseHandler *handler,
408  uint16_t timeout = 0 )
409  XRD_WARN_UNUSED_RESULT;
410 
411  //------------------------------------------------------------------------
420  //------------------------------------------------------------------------
421  XRootDStatus MkDir( const std::string &path,
422  MkDirFlags::Flags flags,
423  Access::Mode mode,
424  uint16_t timeout = 0 )
425  XRD_WARN_UNUSED_RESULT;
426 
427  //------------------------------------------------------------------------
435  //------------------------------------------------------------------------
436  XRootDStatus RmDir( const std::string &path,
437  ResponseHandler *handler,
438  uint16_t timeout = 0 )
439  XRD_WARN_UNUSED_RESULT;
440 
441  //------------------------------------------------------------------------
448  //------------------------------------------------------------------------
449  XRootDStatus RmDir( const std::string &path,
450  uint16_t timeout = 0 )
451  XRD_WARN_UNUSED_RESULT;
452 
453  //------------------------------------------------------------------------
462  //------------------------------------------------------------------------
463  XRootDStatus ChMod( const std::string &path,
464  Access::Mode mode,
465  ResponseHandler *handler,
466  uint16_t timeout = 0 )
467  XRD_WARN_UNUSED_RESULT;
468 
469  //------------------------------------------------------------------------
477  //------------------------------------------------------------------------
478  XRootDStatus ChMod( const std::string &path,
479  Access::Mode mode,
480  uint16_t timeout = 0 )
481  XRD_WARN_UNUSED_RESULT;
482 
483  //------------------------------------------------------------------------
490  //------------------------------------------------------------------------
491  XRootDStatus Ping( ResponseHandler *handler,
492  uint16_t timeout = 0 )
493  XRD_WARN_UNUSED_RESULT;
494 
495  //------------------------------------------------------------------------
501  //------------------------------------------------------------------------
502  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
503 
504  //------------------------------------------------------------------------
514  //------------------------------------------------------------------------
515  XRootDStatus Stat( const std::string &path,
516  ResponseHandler *handler,
517  uint16_t timeout = 0 )
518  XRD_WARN_UNUSED_RESULT;
519 
520  //------------------------------------------------------------------------
528  //------------------------------------------------------------------------
529  XRootDStatus Stat( const std::string &path,
530  StatInfo *&response,
531  uint16_t timeout = 0 )
532  XRD_WARN_UNUSED_RESULT;
533 
534  //------------------------------------------------------------------------
544  //------------------------------------------------------------------------
545  XRootDStatus StatVFS( const std::string &path,
546  ResponseHandler *handler,
547  uint16_t timeout = 0 )
548  XRD_WARN_UNUSED_RESULT;
549 
550  //------------------------------------------------------------------------
558  //------------------------------------------------------------------------
559  XRootDStatus StatVFS( const std::string &path,
560  StatInfoVFS *&response,
561  uint16_t timeout = 0 )
562  XRD_WARN_UNUSED_RESULT;
563 
564  //------------------------------------------------------------------------
573  //------------------------------------------------------------------------
574  XRootDStatus Protocol( ResponseHandler *handler,
575  uint16_t timeout = 0 )
576  XRD_WARN_UNUSED_RESULT;
577 
578  //------------------------------------------------------------------------
585  //------------------------------------------------------------------------
586  XRootDStatus Protocol( ProtocolInfo *&response,
587  uint16_t timeout = 0 )
588  XRD_WARN_UNUSED_RESULT;
589 
590  //------------------------------------------------------------------------
601  //------------------------------------------------------------------------
602  XRootDStatus DirList( const std::string &path,
603  DirListFlags::Flags flags,
604  ResponseHandler *handler,
605  uint16_t timeout = 0 )
606  XRD_WARN_UNUSED_RESULT;
607 
608  //------------------------------------------------------------------------
617  //------------------------------------------------------------------------
618  XRootDStatus DirList( const std::string &path,
619  DirListFlags::Flags flags,
620  DirectoryList *&response,
621  uint16_t timeout = 0 )
622  XRD_WARN_UNUSED_RESULT;
623 
624  //------------------------------------------------------------------------
634  //------------------------------------------------------------------------
635  XRootDStatus SendInfo( const std::string &info,
636  ResponseHandler *handler,
637  uint16_t timeout = 0 )
638  XRD_WARN_UNUSED_RESULT;
639 
640  //------------------------------------------------------------------------
648  //------------------------------------------------------------------------
649  XRootDStatus SendInfo( const std::string &info,
650  Buffer *&response,
651  uint16_t timeout = 0 )
652  XRD_WARN_UNUSED_RESULT;
653 
654  //------------------------------------------------------------------------
666  //------------------------------------------------------------------------
667  XRootDStatus Prepare( const std::vector<std::string> &fileList,
668  PrepareFlags::Flags flags,
669  uint8_t priority,
670  ResponseHandler *handler,
671  uint16_t timeout = 0 )
672  XRD_WARN_UNUSED_RESULT;
673 
674  //------------------------------------------------------------------------
684  //------------------------------------------------------------------------
685  XRootDStatus Prepare( const std::vector<std::string> &fileList,
686  PrepareFlags::Flags flags,
687  uint8_t priority,
688  Buffer *&response,
689  uint16_t timeout = 0 )
690  XRD_WARN_UNUSED_RESULT;
691 
692  //------------------------------------------------------------------------
697  //------------------------------------------------------------------------
698  bool SetProperty( const std::string &name, const std::string &value );
699 
700  //------------------------------------------------------------------------
704  //------------------------------------------------------------------------
705  bool GetProperty( const std::string &name, std::string &value ) const;
706 
707  private:
708  FileSystem(const FileSystem &other);
709  FileSystem &operator = (const FileSystem &other);
710 
711  //------------------------------------------------------------------------
712  // Send a message in a locked environment
713  //------------------------------------------------------------------------
714  Status Send( Message *msg,
715  ResponseHandler *handler,
716  MessageSendParams &params );
717 
718  //------------------------------------------------------------------------
719  // Assign a load balancer if it has not already been assigned
720  //------------------------------------------------------------------------
721  void AssignLoadBalancer( const URL &url );
722 
723  //------------------------------------------------------------------------
724  // Lock the internal lock
725  //------------------------------------------------------------------------
726  void Lock()
727  {
728  pMutex.Lock();
729  }
730 
731  //------------------------------------------------------------------------
732  // Unlock the internal lock
733  //------------------------------------------------------------------------
734  void UnLock()
735  {
736  pMutex.UnLock();
737  }
738 
743  FileSystemPlugIn *pPlugIn;
744  };
745 }
746 
747 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:193
Definition: XProtocol.hh:210
bool pFollowRedirects
Definition: XrdClFileSystem.hh:741
Definition: XProtocol.hh:235
Implementation dependent.
Definition: XrdClFileSystem.hh:59
Definition: XProtocol.hh:233
Definition: XProtocol.hh:190
Definition: XProtocol.hh:127
Definition: XProtocol.hh:125
Directory list.
Definition: XrdClXRootDResponses.hh:504
Open only for appending.
Definition: XrdClFileSystem.hh:93
Definition: XProtocol.hh:189
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Object stat info.
Definition: XrdClXRootDResponses.hh:332
Definition: XProtocol.hh:211
Open only for writing.
Definition: XrdClFileSystem.hh:96
Prepare flags.
Definition: XrdClFileSystem.hh:165
Definition: XProtocol.hh:126
Query file visa attributes.
Definition: XrdClFileSystem.hh:63
Query file checksum.
Definition: XrdClFileSystem.hh:57
Definition: XProtocol.hh:212
Query prepare status.
Definition: XrdClFileSystem.hh:60
Path location info.
Definition: XrdClXRootDResponses.hh:37
Definition: XProtocol.hh:234
Definition: XrdClFileSystem.hh:83
Definition: XProtocol.hh:205
Access mode.
Definition: XrdClFileSystem.hh:113
Definition: XProtocol.hh:123
Flags
Definition: XrdClFileSystem.hh:167
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Procedure execution status.
Definition: XrdClStatus.hh:106
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:190
Definition: XrdClFileSystem.hh:99
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:199
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:740
DirList flags.
Definition: XrdClFileSystem.hh:150
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:71
Protocol response.
Definition: XrdClXRootDResponses.hh:279
Definition: XrdSysPthread.hh:140
void UnLock()
Definition: XrdClFileSystem.hh:734
Definition: XProtocol.hh:122
Definition: XrdClFileSystem.hh:81
Definition: XProtocol.hh:124
Flags
Definition: XrdClFileSystem.hh:139
Definition: XrdClFileSystem.hh:97
Definition: XProtocol.hh:213
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:739
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:103
MkDir flags.
Definition: XrdClFileSystem.hh:137
Query file extended attributes.
Definition: XrdClFileSystem.hh:64
Open for reading and writing.
Definition: XrdClFileSystem.hh:95
Definition: XProtocol.hh:200
Definition: XProtocol.hh:120
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Request status.
Definition: XrdClXRootDResponses.hh:212
Definition: XrdClEnv.hh:28
Definition: XrdClFileSystem.hh:104
Definition: XProtocol.hh:214
Definition: XProtocol.hh:209
VFS stat info.
Definition: XrdClXRootDResponses.hh:427
Definition: XProtocol.hh:188
Definition: XProtocol.hh:121
Definition: XProtocol.hh:128
URL * pUrl
Definition: XrdClFileSystem.hh:742
Definition: XrdClFileSystem.hh:101
Definition: XProtocol.hh:186
Handle an async response.
Definition: XrdClXRootDResponses.hh:832
Definition: XProtocol.hh:206
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:53
Open only for reading.
Definition: XrdClFileSystem.hh:94
URL representation.
Definition: XrdClURL.hh:30
Flags
Definition: XrdClFileSystem.hh:152
Definition: XProtocol.hh:236
Definition: XProtocol.hh:197
Query server stats.
Definition: XrdClFileSystem.hh:62
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:118
Definition: XrdClFileSystem.hh:85
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:184
Definition: XProtocol.hh:198
Nothing.
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:192
Definition: XProtocol.hh:208
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Definition: XrdClFileSystem.hh:79
Definition: XProtocol.hh:201
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:743
Definition: XProtocol.hh:194
Query server configuration.
Definition: XrdClFileSystem.hh:55
Flags
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:76
Definition: XProtocol.hh:195
Definition: XProtocol.hh:207
Definition: XProtocol.hh:187
Definition: XrdClFileSystem.hh:87
Binary blob representation.
Definition: XrdClBuffer.hh:33