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  Cancel = kXR_cancel
182  };
183  };
185 
186  //----------------------------------------------------------------------------
188  //----------------------------------------------------------------------------
190  {
191  friend class AssignLBHandler;
192  friend class ForkHandler;
193 
194  public:
195  typedef std::vector<LocationInfo> LocationList;
196 
197  //------------------------------------------------------------------------
202  //------------------------------------------------------------------------
203  FileSystem( const URL &url, bool enablePlugIns = true );
204 
205  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  ~FileSystem();
209 
210  //------------------------------------------------------------------------
221  //------------------------------------------------------------------------
222  XRootDStatus Locate( const std::string &path,
223  OpenFlags::Flags flags,
224  ResponseHandler *handler,
225  uint16_t timeout = 0 )
226  XRD_WARN_UNUSED_RESULT;
227 
228  //------------------------------------------------------------------------
237  //------------------------------------------------------------------------
238  XRootDStatus Locate( const std::string &path,
239  OpenFlags::Flags flags,
240  LocationInfo *&response,
241  uint16_t timeout = 0 )
242  XRD_WARN_UNUSED_RESULT;
243 
244  //------------------------------------------------------------------------
255  //------------------------------------------------------------------------
256  XRootDStatus DeepLocate( const std::string &path,
257  OpenFlags::Flags flags,
258  ResponseHandler *handler,
259  uint16_t timeout = 0 )
260  XRD_WARN_UNUSED_RESULT;
261 
262  //------------------------------------------------------------------------
271  //------------------------------------------------------------------------
272  XRootDStatus DeepLocate( const std::string &path,
273  OpenFlags::Flags flags,
274  LocationInfo *&response,
275  uint16_t timeout = 0 )
276  XRD_WARN_UNUSED_RESULT;
277 
278  //------------------------------------------------------------------------
287  //------------------------------------------------------------------------
288  XRootDStatus Mv( const std::string &source,
289  const std::string &dest,
290  ResponseHandler *handler,
291  uint16_t timeout = 0 )
292  XRD_WARN_UNUSED_RESULT;
293 
294  //------------------------------------------------------------------------
302  //------------------------------------------------------------------------
303  XRootDStatus Mv( const std::string &source,
304  const std::string &dest,
305  uint16_t timeout = 0 )
306  XRD_WARN_UNUSED_RESULT;
307 
308  //------------------------------------------------------------------------
319  //------------------------------------------------------------------------
320  XRootDStatus Query( QueryCode::Code queryCode,
321  const Buffer &arg,
322  ResponseHandler *handler,
323  uint16_t timeout = 0 )
324  XRD_WARN_UNUSED_RESULT;
325 
326  //------------------------------------------------------------------------
335  //------------------------------------------------------------------------
336  XRootDStatus Query( QueryCode::Code queryCode,
337  const Buffer &arg,
338  Buffer *&response,
339  uint16_t timeout = 0 )
340  XRD_WARN_UNUSED_RESULT;
341 
342  //------------------------------------------------------------------------
351  //------------------------------------------------------------------------
352  XRootDStatus Truncate( const std::string &path,
353  uint64_t size,
354  ResponseHandler *handler,
355  uint16_t timeout = 0 )
356  XRD_WARN_UNUSED_RESULT;
357 
358  //------------------------------------------------------------------------
366  //------------------------------------------------------------------------
367  XRootDStatus Truncate( const std::string &path,
368  uint64_t size,
369  uint16_t timeout = 0 )
370  XRD_WARN_UNUSED_RESULT;
371 
372  //------------------------------------------------------------------------
380  //------------------------------------------------------------------------
381  XRootDStatus Rm( const std::string &path,
382  ResponseHandler *handler,
383  uint16_t timeout = 0 )
384  XRD_WARN_UNUSED_RESULT;
385 
386  //------------------------------------------------------------------------
393  //------------------------------------------------------------------------
394  XRootDStatus Rm( const std::string &path,
395  uint16_t timeout = 0 )
396  XRD_WARN_UNUSED_RESULT;
397 
398  //------------------------------------------------------------------------
408  //------------------------------------------------------------------------
409  XRootDStatus MkDir( const std::string &path,
410  MkDirFlags::Flags flags,
411  Access::Mode mode,
412  ResponseHandler *handler,
413  uint16_t timeout = 0 )
414  XRD_WARN_UNUSED_RESULT;
415 
416  //------------------------------------------------------------------------
425  //------------------------------------------------------------------------
426  XRootDStatus MkDir( const std::string &path,
427  MkDirFlags::Flags flags,
428  Access::Mode mode,
429  uint16_t timeout = 0 )
430  XRD_WARN_UNUSED_RESULT;
431 
432  //------------------------------------------------------------------------
440  //------------------------------------------------------------------------
441  XRootDStatus RmDir( const std::string &path,
442  ResponseHandler *handler,
443  uint16_t timeout = 0 )
444  XRD_WARN_UNUSED_RESULT;
445 
446  //------------------------------------------------------------------------
453  //------------------------------------------------------------------------
454  XRootDStatus RmDir( const std::string &path,
455  uint16_t timeout = 0 )
456  XRD_WARN_UNUSED_RESULT;
457 
458  //------------------------------------------------------------------------
467  //------------------------------------------------------------------------
468  XRootDStatus ChMod( const std::string &path,
469  Access::Mode mode,
470  ResponseHandler *handler,
471  uint16_t timeout = 0 )
472  XRD_WARN_UNUSED_RESULT;
473 
474  //------------------------------------------------------------------------
482  //------------------------------------------------------------------------
483  XRootDStatus ChMod( const std::string &path,
484  Access::Mode mode,
485  uint16_t timeout = 0 )
486  XRD_WARN_UNUSED_RESULT;
487 
488  //------------------------------------------------------------------------
495  //------------------------------------------------------------------------
496  XRootDStatus Ping( ResponseHandler *handler,
497  uint16_t timeout = 0 )
498  XRD_WARN_UNUSED_RESULT;
499 
500  //------------------------------------------------------------------------
506  //------------------------------------------------------------------------
507  XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
508 
509  //------------------------------------------------------------------------
519  //------------------------------------------------------------------------
520  XRootDStatus Stat( const std::string &path,
521  ResponseHandler *handler,
522  uint16_t timeout = 0 )
523  XRD_WARN_UNUSED_RESULT;
524 
525  //------------------------------------------------------------------------
534  //------------------------------------------------------------------------
535  XRootDStatus Stat( const std::string &path,
536  StatInfo *&response,
537  uint16_t timeout = 0 )
538  XRD_WARN_UNUSED_RESULT;
539 
540  //------------------------------------------------------------------------
550  //------------------------------------------------------------------------
551  XRootDStatus StatVFS( const std::string &path,
552  ResponseHandler *handler,
553  uint16_t timeout = 0 )
554  XRD_WARN_UNUSED_RESULT;
555 
556  //------------------------------------------------------------------------
564  //------------------------------------------------------------------------
565  XRootDStatus StatVFS( const std::string &path,
566  StatInfoVFS *&response,
567  uint16_t timeout = 0 )
568  XRD_WARN_UNUSED_RESULT;
569 
570  //------------------------------------------------------------------------
579  //------------------------------------------------------------------------
580  XRootDStatus Protocol( ResponseHandler *handler,
581  uint16_t timeout = 0 )
582  XRD_WARN_UNUSED_RESULT;
583 
584  //------------------------------------------------------------------------
591  //------------------------------------------------------------------------
592  XRootDStatus Protocol( ProtocolInfo *&response,
593  uint16_t timeout = 0 )
594  XRD_WARN_UNUSED_RESULT;
595 
596  //------------------------------------------------------------------------
607  //------------------------------------------------------------------------
608  XRootDStatus DirList( const std::string &path,
609  DirListFlags::Flags flags,
610  ResponseHandler *handler,
611  uint16_t timeout = 0 )
612  XRD_WARN_UNUSED_RESULT;
613 
614  //------------------------------------------------------------------------
623  //------------------------------------------------------------------------
624  XRootDStatus DirList( const std::string &path,
625  DirListFlags::Flags flags,
626  DirectoryList *&response,
627  uint16_t timeout = 0 )
628  XRD_WARN_UNUSED_RESULT;
629 
630  //------------------------------------------------------------------------
640  //------------------------------------------------------------------------
641  XRootDStatus SendInfo( const std::string &info,
642  ResponseHandler *handler,
643  uint16_t timeout = 0 )
644  XRD_WARN_UNUSED_RESULT;
645 
646  //------------------------------------------------------------------------
654  //------------------------------------------------------------------------
655  XRootDStatus SendInfo( const std::string &info,
656  Buffer *&response,
657  uint16_t timeout = 0 )
658  XRD_WARN_UNUSED_RESULT;
659 
660  //------------------------------------------------------------------------
672  //------------------------------------------------------------------------
673  XRootDStatus Prepare( const std::vector<std::string> &fileList,
674  PrepareFlags::Flags flags,
675  uint8_t priority,
676  ResponseHandler *handler,
677  uint16_t timeout = 0 )
678  XRD_WARN_UNUSED_RESULT;
679 
680  //------------------------------------------------------------------------
690  //------------------------------------------------------------------------
691  XRootDStatus Prepare( const std::vector<std::string> &fileList,
692  PrepareFlags::Flags flags,
693  uint8_t priority,
694  Buffer *&response,
695  uint16_t timeout = 0 )
696  XRD_WARN_UNUSED_RESULT;
697 
698  //------------------------------------------------------------------------
703  //------------------------------------------------------------------------
704  bool SetProperty( const std::string &name, const std::string &value );
705 
706  //------------------------------------------------------------------------
710  //------------------------------------------------------------------------
711  bool GetProperty( const std::string &name, std::string &value ) const;
712 
713  private:
714  FileSystem(const FileSystem &other);
715  FileSystem &operator = (const FileSystem &other);
716 
717  //------------------------------------------------------------------------
718  // Send a message in a locked environment
719  //------------------------------------------------------------------------
720  Status Send( Message *msg,
721  ResponseHandler *handler,
722  MessageSendParams &params );
723 
724  //------------------------------------------------------------------------
725  // Assign a load balancer if it has not already been assigned
726  //------------------------------------------------------------------------
727  void AssignLoadBalancer( const URL &url );
728 
729  //------------------------------------------------------------------------
730  // Lock the internal lock
731  //------------------------------------------------------------------------
732  void Lock()
733  {
734  pMutex.Lock();
735  }
736 
737  //------------------------------------------------------------------------
738  // Unlock the internal lock
739  //------------------------------------------------------------------------
740  void UnLock()
741  {
742  pMutex.UnLock();
743  }
744 
749  FileSystemPlugIn *pPlugIn;
750  };
751 }
752 
753 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:199
Definition: XProtocol.hh:220
bool pFollowRedirects
Definition: XrdClFileSystem.hh:747
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:195
Definition: XrdClFileSystem.hh:101
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:205
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:746
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:740
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:745
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:748
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:240
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:189
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:749
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