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  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  };
161  };
163 
164  //----------------------------------------------------------------------------
166  //----------------------------------------------------------------------------
168  {
169  enum Flags
170  {
171  None = 0,
172  Colocate = kXR_coloc,
173  Fresh = kXR_fresh,
174  Stage = kXR_stage,
176  WriteMode = kXR_wmode
178  };
180  };
182 
183  //----------------------------------------------------------------------------
185  //----------------------------------------------------------------------------
187  {
188  friend class AssignLBHandler;
189  friend class ForkHandler;
190 
191  public:
192  typedef std::vector<LocationInfo> LocationList;
193 
194  //------------------------------------------------------------------------
199  //------------------------------------------------------------------------
200  FileSystem( const URL &url, bool enablePlugIns = true );
201 
202  //------------------------------------------------------------------------
204  //------------------------------------------------------------------------
205  ~FileSystem();
206 
207  //------------------------------------------------------------------------
218  //------------------------------------------------------------------------
219  XRootDStatus Locate( const std::string &path,
220  OpenFlags::Flags flags,
221  ResponseHandler *handler,
222  uint16_t timeout = 0 )
223  XRD_WARN_UNUSED_RESULT;
224 
225  //------------------------------------------------------------------------
234  //------------------------------------------------------------------------
235  XRootDStatus Locate( const std::string &path,
236  OpenFlags::Flags flags,
237  LocationInfo *&response,
238  uint16_t timeout = 0 )
239  XRD_WARN_UNUSED_RESULT;
240 
241  //------------------------------------------------------------------------
252  //------------------------------------------------------------------------
253  XRootDStatus DeepLocate( const std::string &path,
254  OpenFlags::Flags flags,
255  ResponseHandler *handler,
256  uint16_t timeout = 0 )
257  XRD_WARN_UNUSED_RESULT;
258 
259  //------------------------------------------------------------------------
268  //------------------------------------------------------------------------
269  XRootDStatus DeepLocate( const std::string &path,
270  OpenFlags::Flags flags,
271  LocationInfo *&response,
272  uint16_t timeout = 0 )
273  XRD_WARN_UNUSED_RESULT;
274 
275  //------------------------------------------------------------------------
284  //------------------------------------------------------------------------
285  XRootDStatus Mv( const std::string &source,
286  const std::string &dest,
287  ResponseHandler *handler,
288  uint16_t timeout = 0 )
289  XRD_WARN_UNUSED_RESULT;
290 
291  //------------------------------------------------------------------------
299  //------------------------------------------------------------------------
300  XRootDStatus Mv( const std::string &source,
301  const std::string &dest,
302  uint16_t timeout = 0 )
303  XRD_WARN_UNUSED_RESULT;
304 
305  //------------------------------------------------------------------------
316  //------------------------------------------------------------------------
317  XRootDStatus Query( QueryCode::Code queryCode,
318  const Buffer &arg,
319  ResponseHandler *handler,
320  uint16_t timeout = 0 )
321  XRD_WARN_UNUSED_RESULT;
322 
323  //------------------------------------------------------------------------
332  //------------------------------------------------------------------------
333  XRootDStatus Query( QueryCode::Code queryCode,
334  const Buffer &arg,
335  Buffer *&response,
336  uint16_t timeout = 0 )
337  XRD_WARN_UNUSED_RESULT;
338 
339  //------------------------------------------------------------------------
348  //------------------------------------------------------------------------
349  XRootDStatus Truncate( const std::string &path,
350  uint64_t size,
351  ResponseHandler *handler,
352  uint16_t timeout = 0 )
353  XRD_WARN_UNUSED_RESULT;
354 
355  //------------------------------------------------------------------------
363  //------------------------------------------------------------------------
364  XRootDStatus Truncate( const std::string &path,
365  uint64_t size,
366  uint16_t timeout = 0 )
367  XRD_WARN_UNUSED_RESULT;
368 
369  //------------------------------------------------------------------------
377  //------------------------------------------------------------------------
378  XRootDStatus Rm( const std::string &path,
379  ResponseHandler *handler,
380  uint16_t timeout = 0 )
381  XRD_WARN_UNUSED_RESULT;
382 
383  //------------------------------------------------------------------------
390  //------------------------------------------------------------------------
391  XRootDStatus Rm( const std::string &path,
392  uint16_t timeout = 0 )
393  XRD_WARN_UNUSED_RESULT;
394 
395  //------------------------------------------------------------------------
405  //------------------------------------------------------------------------
406  XRootDStatus MkDir( const std::string &path,
407  MkDirFlags::Flags flags,
408  Access::Mode mode,
409  ResponseHandler *handler,
410  uint16_t timeout = 0 )
411  XRD_WARN_UNUSED_RESULT;
412 
413  //------------------------------------------------------------------------
422  //------------------------------------------------------------------------
423  XRootDStatus MkDir( const std::string &path,
424  MkDirFlags::Flags flags,
425  Access::Mode mode,
426  uint16_t timeout = 0 )
427  XRD_WARN_UNUSED_RESULT;
428 
429  //------------------------------------------------------------------------
437  //------------------------------------------------------------------------
438  XRootDStatus RmDir( const std::string &path,
439  ResponseHandler *handler,
440  uint16_t timeout = 0 )
441  XRD_WARN_UNUSED_RESULT;
442 
443  //------------------------------------------------------------------------
450  //------------------------------------------------------------------------
451  XRootDStatus RmDir( const std::string &path,
452  uint16_t timeout = 0 )
453  XRD_WARN_UNUSED_RESULT;
454 
455  //------------------------------------------------------------------------
464  //------------------------------------------------------------------------
465  XRootDStatus ChMod( const std::string &path,
466  Access::Mode mode,
467  ResponseHandler *handler,
468  uint16_t timeout = 0 )
469  XRD_WARN_UNUSED_RESULT;
470 
471  //------------------------------------------------------------------------
479  //------------------------------------------------------------------------
480  XRootDStatus ChMod( const std::string &path,
481  Access::Mode mode,
482  uint16_t timeout = 0 )
483  XRD_WARN_UNUSED_RESULT;
484 
485  //------------------------------------------------------------------------
492  //------------------------------------------------------------------------
493  XRootDStatus Ping( ResponseHandler *handler,
494  uint16_t timeout = 0 )
495  XRD_WARN_UNUSED_RESULT;
496 
497  //------------------------------------------------------------------------
503  //------------------------------------------------------------------------
504  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
505 
506  //------------------------------------------------------------------------
516  //------------------------------------------------------------------------
517  XRootDStatus Stat( const std::string &path,
518  ResponseHandler *handler,
519  uint16_t timeout = 0 )
520  XRD_WARN_UNUSED_RESULT;
521 
522  //------------------------------------------------------------------------
531  //------------------------------------------------------------------------
532  XRootDStatus Stat( const std::string &path,
533  StatInfo *&response,
534  uint16_t timeout = 0 )
535  XRD_WARN_UNUSED_RESULT;
536 
537  //------------------------------------------------------------------------
547  //------------------------------------------------------------------------
548  XRootDStatus StatVFS( const std::string &path,
549  ResponseHandler *handler,
550  uint16_t timeout = 0 )
551  XRD_WARN_UNUSED_RESULT;
552 
553  //------------------------------------------------------------------------
561  //------------------------------------------------------------------------
562  XRootDStatus StatVFS( const std::string &path,
563  StatInfoVFS *&response,
564  uint16_t timeout = 0 )
565  XRD_WARN_UNUSED_RESULT;
566 
567  //------------------------------------------------------------------------
576  //------------------------------------------------------------------------
577  XRootDStatus Protocol( ResponseHandler *handler,
578  uint16_t timeout = 0 )
579  XRD_WARN_UNUSED_RESULT;
580 
581  //------------------------------------------------------------------------
588  //------------------------------------------------------------------------
589  XRootDStatus Protocol( ProtocolInfo *&response,
590  uint16_t timeout = 0 )
591  XRD_WARN_UNUSED_RESULT;
592 
593  //------------------------------------------------------------------------
604  //------------------------------------------------------------------------
605  XRootDStatus DirList( const std::string &path,
606  DirListFlags::Flags flags,
607  ResponseHandler *handler,
608  uint16_t timeout = 0 )
609  XRD_WARN_UNUSED_RESULT;
610 
611  //------------------------------------------------------------------------
620  //------------------------------------------------------------------------
621  XRootDStatus DirList( const std::string &path,
622  DirListFlags::Flags flags,
623  DirectoryList *&response,
624  uint16_t timeout = 0 )
625  XRD_WARN_UNUSED_RESULT;
626 
627  //------------------------------------------------------------------------
637  //------------------------------------------------------------------------
638  XRootDStatus SendInfo( const std::string &info,
639  ResponseHandler *handler,
640  uint16_t timeout = 0 )
641  XRD_WARN_UNUSED_RESULT;
642 
643  //------------------------------------------------------------------------
651  //------------------------------------------------------------------------
652  XRootDStatus SendInfo( const std::string &info,
653  Buffer *&response,
654  uint16_t timeout = 0 )
655  XRD_WARN_UNUSED_RESULT;
656 
657  //------------------------------------------------------------------------
669  //------------------------------------------------------------------------
670  XRootDStatus Prepare( const std::vector<std::string> &fileList,
671  PrepareFlags::Flags flags,
672  uint8_t priority,
673  ResponseHandler *handler,
674  uint16_t timeout = 0 )
675  XRD_WARN_UNUSED_RESULT;
676 
677  //------------------------------------------------------------------------
687  //------------------------------------------------------------------------
688  XRootDStatus Prepare( const std::vector<std::string> &fileList,
689  PrepareFlags::Flags flags,
690  uint8_t priority,
691  Buffer *&response,
692  uint16_t timeout = 0 )
693  XRD_WARN_UNUSED_RESULT;
694 
695  //------------------------------------------------------------------------
700  //------------------------------------------------------------------------
701  bool SetProperty( const std::string &name, const std::string &value );
702 
703  //------------------------------------------------------------------------
707  //------------------------------------------------------------------------
708  bool GetProperty( const std::string &name, std::string &value ) const;
709 
710  private:
711  FileSystem(const FileSystem &other);
712  FileSystem &operator = (const FileSystem &other);
713 
714  //------------------------------------------------------------------------
715  // Send a message in a locked environment
716  //------------------------------------------------------------------------
717  Status Send( Message *msg,
718  ResponseHandler *handler,
719  MessageSendParams &params );
720 
721  //------------------------------------------------------------------------
722  // Assign a load balancer if it has not already been assigned
723  //------------------------------------------------------------------------
724  void AssignLoadBalancer( const URL &url );
725 
726  //------------------------------------------------------------------------
727  // Lock the internal lock
728  //------------------------------------------------------------------------
729  void Lock()
730  {
731  pMutex.Lock();
732  }
733 
734  //------------------------------------------------------------------------
735  // Unlock the internal lock
736  //------------------------------------------------------------------------
737  void UnLock()
738  {
739  pMutex.UnLock();
740  }
741 
746  FileSystemPlugIn *pPlugIn;
747  };
748 }
749 
750 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:199
Definition: XProtocol.hh:220
bool pFollowRedirects
Definition: XrdClFileSystem.hh:744
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
Open only for appending.
Definition: XrdClFileSystem.hh:95
Definition: XProtocol.hh:195
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:221
Open only for writing.
Definition: XrdClFileSystem.hh:98
Prepare flags.
Definition: XrdClFileSystem.hh:167
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: XrdClFileSystem.hh:85
Definition: XProtocol.hh:215
Access mode.
Definition: XrdClFileSystem.hh:115
Definition: XProtocol.hh:128
Flags
Definition: XrdClFileSystem.hh:169
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Procedure execution status.
Definition: XrdClStatus.hh:106
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:192
Definition: XrdClFileSystem.hh:101
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:205
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:743
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:737
Definition: XProtocol.hh:127
Definition: XrdClFileSystem.hh:83
Definition: XProtocol.hh:129
Flags
Definition: XrdClFileSystem.hh:141
Definition: XrdClFileSystem.hh:99
Definition: XProtocol.hh:223
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:742
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:206
Definition: XProtocol.hh:125
XRootD query request codes.
Definition: XrdClFileSystem.hh:48
Request status.
Definition: XrdClXRootDResponses.hh:212
Definition: XrdClFileSystem.hh:106
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:745
Definition: XrdClFileSystem.hh:103
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
Open only for reading.
Definition: XrdClFileSystem.hh:96
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
Definition: XrdClFileSystem.hh:87
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:186
Definition: XProtocol.hh:204
Nothing.
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:198
Definition: XProtocol.hh:218
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Definition: XrdClFileSystem.hh:81
Definition: XProtocol.hh:207
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:746
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
Definition: XrdClFileSystem.hh:89
Binary blob representation.
Definition: XrdClBuffer.hh:33