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  Recursive = 4,
161  Merge = 8
162  };
163  };
165 
166  //----------------------------------------------------------------------------
168  //----------------------------------------------------------------------------
170  {
171  enum Flags
172  {
173  None = 0,
174  Colocate = kXR_coloc,
175  Fresh = kXR_fresh,
176  Stage = kXR_stage,
178  WriteMode = kXR_wmode
180  };
182  };
184 
185  //----------------------------------------------------------------------------
187  //----------------------------------------------------------------------------
189  {
190  friend class AssignLBHandler;
191  friend class ForkHandler;
192 
193  public:
194  typedef std::vector<LocationInfo> LocationList;
195 
196  //------------------------------------------------------------------------
201  //------------------------------------------------------------------------
202  FileSystem( const URL &url, bool enablePlugIns = true );
203 
204  //------------------------------------------------------------------------
206  //------------------------------------------------------------------------
207  ~FileSystem();
208 
209  //------------------------------------------------------------------------
220  //------------------------------------------------------------------------
221  XRootDStatus Locate( const std::string &path,
222  OpenFlags::Flags flags,
223  ResponseHandler *handler,
224  uint16_t timeout = 0 )
225  XRD_WARN_UNUSED_RESULT;
226 
227  //------------------------------------------------------------------------
236  //------------------------------------------------------------------------
237  XRootDStatus Locate( const std::string &path,
238  OpenFlags::Flags flags,
239  LocationInfo *&response,
240  uint16_t timeout = 0 )
241  XRD_WARN_UNUSED_RESULT;
242 
243  //------------------------------------------------------------------------
254  //------------------------------------------------------------------------
255  XRootDStatus DeepLocate( const std::string &path,
256  OpenFlags::Flags flags,
257  ResponseHandler *handler,
258  uint16_t timeout = 0 )
259  XRD_WARN_UNUSED_RESULT;
260 
261  //------------------------------------------------------------------------
270  //------------------------------------------------------------------------
271  XRootDStatus DeepLocate( const std::string &path,
272  OpenFlags::Flags flags,
273  LocationInfo *&response,
274  uint16_t timeout = 0 )
275  XRD_WARN_UNUSED_RESULT;
276 
277  //------------------------------------------------------------------------
286  //------------------------------------------------------------------------
287  XRootDStatus Mv( const std::string &source,
288  const std::string &dest,
289  ResponseHandler *handler,
290  uint16_t timeout = 0 )
291  XRD_WARN_UNUSED_RESULT;
292 
293  //------------------------------------------------------------------------
301  //------------------------------------------------------------------------
302  XRootDStatus Mv( const std::string &source,
303  const std::string &dest,
304  uint16_t timeout = 0 )
305  XRD_WARN_UNUSED_RESULT;
306 
307  //------------------------------------------------------------------------
318  //------------------------------------------------------------------------
319  XRootDStatus Query( QueryCode::Code queryCode,
320  const Buffer &arg,
321  ResponseHandler *handler,
322  uint16_t timeout = 0 )
323  XRD_WARN_UNUSED_RESULT;
324 
325  //------------------------------------------------------------------------
334  //------------------------------------------------------------------------
335  XRootDStatus Query( QueryCode::Code queryCode,
336  const Buffer &arg,
337  Buffer *&response,
338  uint16_t timeout = 0 )
339  XRD_WARN_UNUSED_RESULT;
340 
341  //------------------------------------------------------------------------
350  //------------------------------------------------------------------------
351  XRootDStatus Truncate( const std::string &path,
352  uint64_t size,
353  ResponseHandler *handler,
354  uint16_t timeout = 0 )
355  XRD_WARN_UNUSED_RESULT;
356 
357  //------------------------------------------------------------------------
365  //------------------------------------------------------------------------
366  XRootDStatus Truncate( const std::string &path,
367  uint64_t size,
368  uint16_t timeout = 0 )
369  XRD_WARN_UNUSED_RESULT;
370 
371  //------------------------------------------------------------------------
379  //------------------------------------------------------------------------
380  XRootDStatus Rm( const std::string &path,
381  ResponseHandler *handler,
382  uint16_t timeout = 0 )
383  XRD_WARN_UNUSED_RESULT;
384 
385  //------------------------------------------------------------------------
392  //------------------------------------------------------------------------
393  XRootDStatus Rm( const std::string &path,
394  uint16_t timeout = 0 )
395  XRD_WARN_UNUSED_RESULT;
396 
397  //------------------------------------------------------------------------
407  //------------------------------------------------------------------------
408  XRootDStatus MkDir( const std::string &path,
409  MkDirFlags::Flags flags,
410  Access::Mode mode,
411  ResponseHandler *handler,
412  uint16_t timeout = 0 )
413  XRD_WARN_UNUSED_RESULT;
414 
415  //------------------------------------------------------------------------
424  //------------------------------------------------------------------------
425  XRootDStatus MkDir( const std::string &path,
426  MkDirFlags::Flags flags,
427  Access::Mode mode,
428  uint16_t timeout = 0 )
429  XRD_WARN_UNUSED_RESULT;
430 
431  //------------------------------------------------------------------------
439  //------------------------------------------------------------------------
440  XRootDStatus RmDir( const std::string &path,
441  ResponseHandler *handler,
442  uint16_t timeout = 0 )
443  XRD_WARN_UNUSED_RESULT;
444 
445  //------------------------------------------------------------------------
452  //------------------------------------------------------------------------
453  XRootDStatus RmDir( const std::string &path,
454  uint16_t timeout = 0 )
455  XRD_WARN_UNUSED_RESULT;
456 
457  //------------------------------------------------------------------------
466  //------------------------------------------------------------------------
467  XRootDStatus ChMod( const std::string &path,
468  Access::Mode mode,
469  ResponseHandler *handler,
470  uint16_t timeout = 0 )
471  XRD_WARN_UNUSED_RESULT;
472 
473  //------------------------------------------------------------------------
481  //------------------------------------------------------------------------
482  XRootDStatus ChMod( const std::string &path,
483  Access::Mode mode,
484  uint16_t timeout = 0 )
485  XRD_WARN_UNUSED_RESULT;
486 
487  //------------------------------------------------------------------------
494  //------------------------------------------------------------------------
495  XRootDStatus Ping( ResponseHandler *handler,
496  uint16_t timeout = 0 )
497  XRD_WARN_UNUSED_RESULT;
498 
499  //------------------------------------------------------------------------
505  //------------------------------------------------------------------------
506  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
507 
508  //------------------------------------------------------------------------
518  //------------------------------------------------------------------------
519  XRootDStatus Stat( const std::string &path,
520  ResponseHandler *handler,
521  uint16_t timeout = 0 )
522  XRD_WARN_UNUSED_RESULT;
523 
524  //------------------------------------------------------------------------
533  //------------------------------------------------------------------------
534  XRootDStatus Stat( const std::string &path,
535  StatInfo *&response,
536  uint16_t timeout = 0 )
537  XRD_WARN_UNUSED_RESULT;
538 
539  //------------------------------------------------------------------------
549  //------------------------------------------------------------------------
550  XRootDStatus StatVFS( const std::string &path,
551  ResponseHandler *handler,
552  uint16_t timeout = 0 )
553  XRD_WARN_UNUSED_RESULT;
554 
555  //------------------------------------------------------------------------
563  //------------------------------------------------------------------------
564  XRootDStatus StatVFS( const std::string &path,
565  StatInfoVFS *&response,
566  uint16_t timeout = 0 )
567  XRD_WARN_UNUSED_RESULT;
568 
569  //------------------------------------------------------------------------
578  //------------------------------------------------------------------------
579  XRootDStatus Protocol( ResponseHandler *handler,
580  uint16_t timeout = 0 )
581  XRD_WARN_UNUSED_RESULT;
582 
583  //------------------------------------------------------------------------
590  //------------------------------------------------------------------------
591  XRootDStatus Protocol( ProtocolInfo *&response,
592  uint16_t timeout = 0 )
593  XRD_WARN_UNUSED_RESULT;
594 
595  //------------------------------------------------------------------------
606  //------------------------------------------------------------------------
607  XRootDStatus DirList( const std::string &path,
608  DirListFlags::Flags flags,
609  ResponseHandler *handler,
610  uint16_t timeout = 0 )
611  XRD_WARN_UNUSED_RESULT;
612 
613  //------------------------------------------------------------------------
622  //------------------------------------------------------------------------
623  XRootDStatus DirList( const std::string &path,
624  DirListFlags::Flags flags,
625  DirectoryList *&response,
626  uint16_t timeout = 0 )
627  XRD_WARN_UNUSED_RESULT;
628 
629  //------------------------------------------------------------------------
639  //------------------------------------------------------------------------
640  XRootDStatus SendInfo( const std::string &info,
641  ResponseHandler *handler,
642  uint16_t timeout = 0 )
643  XRD_WARN_UNUSED_RESULT;
644 
645  //------------------------------------------------------------------------
653  //------------------------------------------------------------------------
654  XRootDStatus SendInfo( const std::string &info,
655  Buffer *&response,
656  uint16_t timeout = 0 )
657  XRD_WARN_UNUSED_RESULT;
658 
659  //------------------------------------------------------------------------
671  //------------------------------------------------------------------------
672  XRootDStatus Prepare( const std::vector<std::string> &fileList,
673  PrepareFlags::Flags flags,
674  uint8_t priority,
675  ResponseHandler *handler,
676  uint16_t timeout = 0 )
677  XRD_WARN_UNUSED_RESULT;
678 
679  //------------------------------------------------------------------------
689  //------------------------------------------------------------------------
690  XRootDStatus Prepare( const std::vector<std::string> &fileList,
691  PrepareFlags::Flags flags,
692  uint8_t priority,
693  Buffer *&response,
694  uint16_t timeout = 0 )
695  XRD_WARN_UNUSED_RESULT;
696 
697  //------------------------------------------------------------------------
702  //------------------------------------------------------------------------
703  bool SetProperty( const std::string &name, const std::string &value );
704 
705  //------------------------------------------------------------------------
709  //------------------------------------------------------------------------
710  bool GetProperty( const std::string &name, std::string &value ) const;
711 
712  private:
713  FileSystem(const FileSystem &other);
714  FileSystem &operator = (const FileSystem &other);
715 
716  //------------------------------------------------------------------------
717  // Send a message in a locked environment
718  //------------------------------------------------------------------------
719  Status Send( Message *msg,
720  ResponseHandler *handler,
721  MessageSendParams &params );
722 
723  //------------------------------------------------------------------------
724  // Assign a load balancer if it has not already been assigned
725  //------------------------------------------------------------------------
726  void AssignLoadBalancer( const URL &url );
727 
728  //------------------------------------------------------------------------
729  // Lock the internal lock
730  //------------------------------------------------------------------------
731  void Lock()
732  {
733  pMutex.Lock();
734  }
735 
736  //------------------------------------------------------------------------
737  // Unlock the internal lock
738  //------------------------------------------------------------------------
739  void UnLock()
740  {
741  pMutex.UnLock();
742  }
743 
748  FileSystemPlugIn *pPlugIn;
749  };
750 }
751 
752 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:199
Definition: XProtocol.hh:220
bool pFollowRedirects
Definition: XrdClFileSystem.hh:746
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:169
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:171
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Procedure execution status.
Definition: XrdClStatus.hh:107
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:194
Definition: XrdClFileSystem.hh:101
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:205
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:745
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:739
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:744
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:747
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:188
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:748
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