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,
79  Compress = kXR_compress,
80  Delete = kXR_delete,
82  Force = kXR_force,
84  MakePath = kXR_mkpath,
86  New = kXR_new,
88  NoWait = kXR_nowait,
90  Append = kXR_open_apnd,
96  Read = kXR_open_read,
97  Update = kXR_open_updt,
98  Write = kXR_open_wrto,
99  POSC = kXR_posc,
100  Refresh = kXR_refresh,
102  Replica = kXR_replica,
104  SeqIO = kXR_seqio,
106  PrefName = kXR_prefname
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  };
162  };
164 
165  //----------------------------------------------------------------------------
167  //----------------------------------------------------------------------------
169  {
170  enum Flags
171  {
172  None = 0,
173  Colocate = kXR_coloc,
174  Fresh = kXR_fresh,
175  Stage = kXR_stage,
177  WriteMode = kXR_wmode
179  };
181  };
183 
184  //----------------------------------------------------------------------------
186  //----------------------------------------------------------------------------
188  {
189  friend class AssignLBHandler;
190  friend class ForkHandler;
191 
192  public:
193  typedef std::vector<LocationInfo> LocationList;
194 
195  //------------------------------------------------------------------------
200  //------------------------------------------------------------------------
201  FileSystem( const URL &url, bool enablePlugIns = true );
202 
203  //------------------------------------------------------------------------
205  //------------------------------------------------------------------------
206  ~FileSystem();
207 
208  //------------------------------------------------------------------------
219  //------------------------------------------------------------------------
220  XRootDStatus Locate( const std::string &path,
221  OpenFlags::Flags flags,
222  ResponseHandler *handler,
223  uint16_t timeout = 0 )
224  XRD_WARN_UNUSED_RESULT;
225 
226  //------------------------------------------------------------------------
235  //------------------------------------------------------------------------
236  XRootDStatus Locate( const std::string &path,
237  OpenFlags::Flags flags,
238  LocationInfo *&response,
239  uint16_t timeout = 0 )
240  XRD_WARN_UNUSED_RESULT;
241 
242  //------------------------------------------------------------------------
253  //------------------------------------------------------------------------
254  XRootDStatus DeepLocate( const std::string &path,
255  OpenFlags::Flags flags,
256  ResponseHandler *handler,
257  uint16_t timeout = 0 )
258  XRD_WARN_UNUSED_RESULT;
259 
260  //------------------------------------------------------------------------
269  //------------------------------------------------------------------------
270  XRootDStatus DeepLocate( const std::string &path,
271  OpenFlags::Flags flags,
272  LocationInfo *&response,
273  uint16_t timeout = 0 )
274  XRD_WARN_UNUSED_RESULT;
275 
276  //------------------------------------------------------------------------
285  //------------------------------------------------------------------------
286  XRootDStatus Mv( const std::string &source,
287  const std::string &dest,
288  ResponseHandler *handler,
289  uint16_t timeout = 0 )
290  XRD_WARN_UNUSED_RESULT;
291 
292  //------------------------------------------------------------------------
300  //------------------------------------------------------------------------
301  XRootDStatus Mv( const std::string &source,
302  const std::string &dest,
303  uint16_t timeout = 0 )
304  XRD_WARN_UNUSED_RESULT;
305 
306  //------------------------------------------------------------------------
317  //------------------------------------------------------------------------
318  XRootDStatus Query( QueryCode::Code queryCode,
319  const Buffer &arg,
320  ResponseHandler *handler,
321  uint16_t timeout = 0 )
322  XRD_WARN_UNUSED_RESULT;
323 
324  //------------------------------------------------------------------------
333  //------------------------------------------------------------------------
334  XRootDStatus Query( QueryCode::Code queryCode,
335  const Buffer &arg,
336  Buffer *&response,
337  uint16_t timeout = 0 )
338  XRD_WARN_UNUSED_RESULT;
339 
340  //------------------------------------------------------------------------
349  //------------------------------------------------------------------------
350  XRootDStatus Truncate( const std::string &path,
351  uint64_t size,
352  ResponseHandler *handler,
353  uint16_t timeout = 0 )
354  XRD_WARN_UNUSED_RESULT;
355 
356  //------------------------------------------------------------------------
364  //------------------------------------------------------------------------
365  XRootDStatus Truncate( const std::string &path,
366  uint64_t size,
367  uint16_t timeout = 0 )
368  XRD_WARN_UNUSED_RESULT;
369 
370  //------------------------------------------------------------------------
378  //------------------------------------------------------------------------
379  XRootDStatus Rm( const std::string &path,
380  ResponseHandler *handler,
381  uint16_t timeout = 0 )
382  XRD_WARN_UNUSED_RESULT;
383 
384  //------------------------------------------------------------------------
391  //------------------------------------------------------------------------
392  XRootDStatus Rm( const std::string &path,
393  uint16_t timeout = 0 )
394  XRD_WARN_UNUSED_RESULT;
395 
396  //------------------------------------------------------------------------
406  //------------------------------------------------------------------------
407  XRootDStatus MkDir( const std::string &path,
408  MkDirFlags::Flags flags,
409  Access::Mode mode,
410  ResponseHandler *handler,
411  uint16_t timeout = 0 )
412  XRD_WARN_UNUSED_RESULT;
413 
414  //------------------------------------------------------------------------
423  //------------------------------------------------------------------------
424  XRootDStatus MkDir( const std::string &path,
425  MkDirFlags::Flags flags,
426  Access::Mode mode,
427  uint16_t timeout = 0 )
428  XRD_WARN_UNUSED_RESULT;
429 
430  //------------------------------------------------------------------------
438  //------------------------------------------------------------------------
439  XRootDStatus RmDir( const std::string &path,
440  ResponseHandler *handler,
441  uint16_t timeout = 0 )
442  XRD_WARN_UNUSED_RESULT;
443 
444  //------------------------------------------------------------------------
451  //------------------------------------------------------------------------
452  XRootDStatus RmDir( const std::string &path,
453  uint16_t timeout = 0 )
454  XRD_WARN_UNUSED_RESULT;
455 
456  //------------------------------------------------------------------------
465  //------------------------------------------------------------------------
466  XRootDStatus ChMod( const std::string &path,
467  Access::Mode mode,
468  ResponseHandler *handler,
469  uint16_t timeout = 0 )
470  XRD_WARN_UNUSED_RESULT;
471 
472  //------------------------------------------------------------------------
480  //------------------------------------------------------------------------
481  XRootDStatus ChMod( const std::string &path,
482  Access::Mode mode,
483  uint16_t timeout = 0 )
484  XRD_WARN_UNUSED_RESULT;
485 
486  //------------------------------------------------------------------------
493  //------------------------------------------------------------------------
494  XRootDStatus Ping( ResponseHandler *handler,
495  uint16_t timeout = 0 )
496  XRD_WARN_UNUSED_RESULT;
497 
498  //------------------------------------------------------------------------
504  //------------------------------------------------------------------------
505  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
506 
507  //------------------------------------------------------------------------
517  //------------------------------------------------------------------------
518  XRootDStatus Stat( const std::string &path,
519  ResponseHandler *handler,
520  uint16_t timeout = 0 )
521  XRD_WARN_UNUSED_RESULT;
522 
523  //------------------------------------------------------------------------
532  //------------------------------------------------------------------------
533  XRootDStatus Stat( const std::string &path,
534  StatInfo *&response,
535  uint16_t timeout = 0 )
536  XRD_WARN_UNUSED_RESULT;
537 
538  //------------------------------------------------------------------------
548  //------------------------------------------------------------------------
549  XRootDStatus StatVFS( const std::string &path,
550  ResponseHandler *handler,
551  uint16_t timeout = 0 )
552  XRD_WARN_UNUSED_RESULT;
553 
554  //------------------------------------------------------------------------
562  //------------------------------------------------------------------------
563  XRootDStatus StatVFS( const std::string &path,
564  StatInfoVFS *&response,
565  uint16_t timeout = 0 )
566  XRD_WARN_UNUSED_RESULT;
567 
568  //------------------------------------------------------------------------
577  //------------------------------------------------------------------------
578  XRootDStatus Protocol( ResponseHandler *handler,
579  uint16_t timeout = 0 )
580  XRD_WARN_UNUSED_RESULT;
581 
582  //------------------------------------------------------------------------
589  //------------------------------------------------------------------------
590  XRootDStatus Protocol( ProtocolInfo *&response,
591  uint16_t timeout = 0 )
592  XRD_WARN_UNUSED_RESULT;
593 
594  //------------------------------------------------------------------------
605  //------------------------------------------------------------------------
606  XRootDStatus DirList( const std::string &path,
607  DirListFlags::Flags flags,
608  ResponseHandler *handler,
609  uint16_t timeout = 0 )
610  XRD_WARN_UNUSED_RESULT;
611 
612  //------------------------------------------------------------------------
621  //------------------------------------------------------------------------
622  XRootDStatus DirList( const std::string &path,
623  DirListFlags::Flags flags,
624  DirectoryList *&response,
625  uint16_t timeout = 0 )
626  XRD_WARN_UNUSED_RESULT;
627 
628  //------------------------------------------------------------------------
638  //------------------------------------------------------------------------
639  XRootDStatus SendInfo( const std::string &info,
640  ResponseHandler *handler,
641  uint16_t timeout = 0 )
642  XRD_WARN_UNUSED_RESULT;
643 
644  //------------------------------------------------------------------------
652  //------------------------------------------------------------------------
653  XRootDStatus SendInfo( const std::string &info,
654  Buffer *&response,
655  uint16_t timeout = 0 )
656  XRD_WARN_UNUSED_RESULT;
657 
658  //------------------------------------------------------------------------
670  //------------------------------------------------------------------------
671  XRootDStatus Prepare( const std::vector<std::string> &fileList,
672  PrepareFlags::Flags flags,
673  uint8_t priority,
674  ResponseHandler *handler,
675  uint16_t timeout = 0 )
676  XRD_WARN_UNUSED_RESULT;
677 
678  //------------------------------------------------------------------------
688  //------------------------------------------------------------------------
689  XRootDStatus Prepare( const std::vector<std::string> &fileList,
690  PrepareFlags::Flags flags,
691  uint8_t priority,
692  Buffer *&response,
693  uint16_t timeout = 0 )
694  XRD_WARN_UNUSED_RESULT;
695 
696  //------------------------------------------------------------------------
701  //------------------------------------------------------------------------
702  bool SetProperty( const std::string &name, const std::string &value );
703 
704  //------------------------------------------------------------------------
708  //------------------------------------------------------------------------
709  bool GetProperty( const std::string &name, std::string &value ) const;
710 
711  private:
712  FileSystem(const FileSystem &other);
713  FileSystem &operator = (const FileSystem &other);
714 
715  //------------------------------------------------------------------------
716  // Send a message in a locked environment
717  //------------------------------------------------------------------------
718  Status Send( Message *msg,
719  ResponseHandler *handler,
720  MessageSendParams &params );
721 
722  //------------------------------------------------------------------------
723  // Assign a load balancer if it has not already been assigned
724  //------------------------------------------------------------------------
725  void AssignLoadBalancer( const URL &url );
726 
727  //------------------------------------------------------------------------
728  // Lock the internal lock
729  //------------------------------------------------------------------------
730  void Lock()
731  {
732  pMutex.Lock();
733  }
734 
735  //------------------------------------------------------------------------
736  // Unlock the internal lock
737  //------------------------------------------------------------------------
738  void UnLock()
739  {
740  pMutex.UnLock();
741  }
742 
747  FileSystemPlugIn *pPlugIn;
748  };
749 }
750 
751 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:199
Definition: XProtocol.hh:220
bool pFollowRedirects
Definition: XrdClFileSystem.hh:745
Definition: XProtocol.hh:245
Implementation dependent.
Definition: XrdClFileSystem.hh:59
Definition: XProtocol.hh:243
Definition: XProtocol.hh:196
Definition: XProtocol.hh:132
Definition: XProtocol.hh:130
Directory list.
Definition: XrdClXRootDResponses.hh:504
Definition: XProtocol.hh:195
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Object stat info.
Definition: XrdClXRootDResponses.hh:332
Definition: XProtocol.hh:221
Prepare flags.
Definition: XrdClFileSystem.hh:168
Definition: XProtocol.hh:131
Query file visa attributes.
Definition: XrdClFileSystem.hh:63
Query file checksum.
Definition: XrdClFileSystem.hh:57
Definition: XProtocol.hh:222
Query prepare status.
Definition: XrdClFileSystem.hh:60
Path location info.
Definition: XrdClXRootDResponses.hh:37
Definition: XProtocol.hh:244
Definition: XProtocol.hh:215
Access mode.
Definition: XrdClFileSystem.hh:115
Definition: XProtocol.hh:128
Flags
Definition: XrdClFileSystem.hh:170
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Procedure execution status.
Definition: XrdClStatus.hh:107
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:193
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:205
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:744
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
Definition: XrdSysPthread.hh:140
void UnLock()
Definition: XrdClFileSystem.hh:738
Definition: XProtocol.hh:127
Definition: XProtocol.hh:129
Flags
Definition: XrdClFileSystem.hh:141
Definition: XProtocol.hh:223
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:743
MkDir flags.
Definition: XrdClFileSystem.hh:139
Query file extended attributes.
Definition: XrdClFileSystem.hh:64
Definition: XProtocol.hh:206
Definition: XProtocol.hh:125
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Request status.
Definition: XrdClXRootDResponses.hh:212
Definition: XrdClEnv.hh:28
Definition: XProtocol.hh:224
Definition: XProtocol.hh:219
VFS stat info.
Definition: XrdClXRootDResponses.hh:427
Definition: XProtocol.hh:194
Definition: XProtocol.hh:126
Definition: XProtocol.hh:133
URL * pUrl
Definition: XrdClFileSystem.hh:746
Definition: XProtocol.hh:192
Handle an async response.
Definition: XrdClXRootDResponses.hh:833
Definition: XProtocol.hh:216
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:53
URL representation.
Definition: XrdClURL.hh:30
Definition: XProtocol.hh:191
Flags
Definition: XrdClFileSystem.hh:154
Definition: XProtocol.hh:246
Definition: XProtocol.hh:203
Query server stats.
Definition: XrdClFileSystem.hh:62
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:120
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:187
Definition: XProtocol.hh:204
Definition: XProtocol.hh:198
Definition: XProtocol.hh:218
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Definition: XProtocol.hh:207
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:747
Definition: XProtocol.hh:200
Query server configuration.
Definition: XrdClFileSystem.hh:55
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:76
Definition: XProtocol.hh:201
Definition: XProtocol.hh:217
Definition: XProtocol.hh:193
Binary blob representation.
Definition: XrdClBuffer.hh:33