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  //------------------------------------------------------------------------
530  //------------------------------------------------------------------------
531  XRootDStatus Stat( const std::string &path,
532  StatInfo *&response,
533  uint16_t timeout = 0 )
534  XRD_WARN_UNUSED_RESULT;
535 
536  //------------------------------------------------------------------------
546  //------------------------------------------------------------------------
547  XRootDStatus StatVFS( const std::string &path,
548  ResponseHandler *handler,
549  uint16_t timeout = 0 )
550  XRD_WARN_UNUSED_RESULT;
551 
552  //------------------------------------------------------------------------
560  //------------------------------------------------------------------------
561  XRootDStatus StatVFS( const std::string &path,
562  StatInfoVFS *&response,
563  uint16_t timeout = 0 )
564  XRD_WARN_UNUSED_RESULT;
565 
566  //------------------------------------------------------------------------
575  //------------------------------------------------------------------------
576  XRootDStatus Protocol( ResponseHandler *handler,
577  uint16_t timeout = 0 )
578  XRD_WARN_UNUSED_RESULT;
579 
580  //------------------------------------------------------------------------
587  //------------------------------------------------------------------------
588  XRootDStatus Protocol( ProtocolInfo *&response,
589  uint16_t timeout = 0 )
590  XRD_WARN_UNUSED_RESULT;
591 
592  //------------------------------------------------------------------------
603  //------------------------------------------------------------------------
604  XRootDStatus DirList( const std::string &path,
605  DirListFlags::Flags flags,
606  ResponseHandler *handler,
607  uint16_t timeout = 0 )
608  XRD_WARN_UNUSED_RESULT;
609 
610  //------------------------------------------------------------------------
619  //------------------------------------------------------------------------
620  XRootDStatus DirList( const std::string &path,
621  DirListFlags::Flags flags,
622  DirectoryList *&response,
623  uint16_t timeout = 0 )
624  XRD_WARN_UNUSED_RESULT;
625 
626  //------------------------------------------------------------------------
636  //------------------------------------------------------------------------
637  XRootDStatus SendInfo( const std::string &info,
638  ResponseHandler *handler,
639  uint16_t timeout = 0 )
640  XRD_WARN_UNUSED_RESULT;
641 
642  //------------------------------------------------------------------------
650  //------------------------------------------------------------------------
651  XRootDStatus SendInfo( const std::string &info,
652  Buffer *&response,
653  uint16_t timeout = 0 )
654  XRD_WARN_UNUSED_RESULT;
655 
656  //------------------------------------------------------------------------
668  //------------------------------------------------------------------------
669  XRootDStatus Prepare( const std::vector<std::string> &fileList,
670  PrepareFlags::Flags flags,
671  uint8_t priority,
672  ResponseHandler *handler,
673  uint16_t timeout = 0 )
674  XRD_WARN_UNUSED_RESULT;
675 
676  //------------------------------------------------------------------------
686  //------------------------------------------------------------------------
687  XRootDStatus Prepare( const std::vector<std::string> &fileList,
688  PrepareFlags::Flags flags,
689  uint8_t priority,
690  Buffer *&response,
691  uint16_t timeout = 0 )
692  XRD_WARN_UNUSED_RESULT;
693 
694  //------------------------------------------------------------------------
699  //------------------------------------------------------------------------
700  bool SetProperty( const std::string &name, const std::string &value );
701 
702  //------------------------------------------------------------------------
706  //------------------------------------------------------------------------
707  bool GetProperty( const std::string &name, std::string &value ) const;
708 
709  private:
710  FileSystem(const FileSystem &other);
711  FileSystem &operator = (const FileSystem &other);
712 
713  //------------------------------------------------------------------------
714  // Send a message in a locked environment
715  //------------------------------------------------------------------------
716  Status Send( Message *msg,
717  ResponseHandler *handler,
718  MessageSendParams &params );
719 
720  //------------------------------------------------------------------------
721  // Assign a load balancer if it has not already been assigned
722  //------------------------------------------------------------------------
723  void AssignLoadBalancer( const URL &url );
724 
725  //------------------------------------------------------------------------
726  // Lock the internal lock
727  //------------------------------------------------------------------------
728  void Lock()
729  {
730  pMutex.Lock();
731  }
732 
733  //------------------------------------------------------------------------
734  // Unlock the internal lock
735  //------------------------------------------------------------------------
736  void UnLock()
737  {
738  pMutex.UnLock();
739  }
740 
745  FileSystemPlugIn *pPlugIn;
746  };
747 }
748 
749 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:193
Definition: XProtocol.hh:210
bool pFollowRedirects
Definition: XrdClFileSystem.hh:743
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:95
Definition: XProtocol.hh:189
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:211
Open only for writing.
Definition: XrdClFileSystem.hh:98
Prepare flags.
Definition: XrdClFileSystem.hh:167
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:85
Definition: XProtocol.hh:205
Access mode.
Definition: XrdClFileSystem.hh:115
Definition: XProtocol.hh:123
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:199
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:742
DirList flags.
Definition: XrdClFileSystem.hh:152
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:736
Definition: XProtocol.hh:122
Definition: XrdClFileSystem.hh:83
Definition: XProtocol.hh:124
Flags
Definition: XrdClFileSystem.hh:141
Definition: XrdClFileSystem.hh:99
Definition: XProtocol.hh:213
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:741
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: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:106
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:744
Definition: XrdClFileSystem.hh:103
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:96
URL representation.
Definition: XrdClURL.hh:30
Definition: XProtocol.hh:185
Flags
Definition: XrdClFileSystem.hh:154
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:120
Definition: XrdClFileSystem.hh:87
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:186
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:81
Definition: XProtocol.hh:201
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:745
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:89
Binary blob representation.
Definition: XrdClBuffer.hh:33