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"
32 #include "XrdSys/XrdSysPthread.hh"
33 #include "XProtocol/XProtocol.hh"
34 #include <string>
35 #include <vector>
36 
37 namespace XrdCl
38 {
39  class PostMaster;
40  class Message;
41  class FileSystemPlugIn;
42  struct MessageSendParams;
43 
44  //----------------------------------------------------------------------------
46  //----------------------------------------------------------------------------
47  struct QueryCode
48  {
49  //--------------------------------------------------------------------------
51  //--------------------------------------------------------------------------
52  enum Code
53  {
64  };
65  };
66 
67  //----------------------------------------------------------------------------
69  //----------------------------------------------------------------------------
70  struct OpenFlags
71  {
72  //--------------------------------------------------------------------------
74  //--------------------------------------------------------------------------
75  enum Flags
76  {
77  None = 0,
79  Force = kXR_force,
83  New = kXR_new,
85  NoWait = kXR_nowait,
101  SeqIO = kXR_seqio,
104  };
106  };
108 
109  //----------------------------------------------------------------------------
111  //----------------------------------------------------------------------------
112  struct Access
113  {
114  //--------------------------------------------------------------------------
116  //--------------------------------------------------------------------------
117  enum Mode
118  {
119  None = 0,
120  UR = kXR_ur,
121  UW = kXR_uw,
122  UX = kXR_ux,
123  GR = kXR_gr,
124  GW = kXR_gw,
125  GX = kXR_gx,
126  OR = kXR_or,
127  OW = kXR_ow,
128  OX = kXR_ox
129  };
130  };
132 
133  //----------------------------------------------------------------------------
135  //----------------------------------------------------------------------------
136  struct MkDirFlags
137  {
138  enum Flags
139  {
140  None = 0,
141  MakePath = 1
142  };
143  };
145 
146  //----------------------------------------------------------------------------
148  //----------------------------------------------------------------------------
150  {
151  enum Flags
152  {
153  None = 0,
154  Stat = 1,
155  Locate = 2
156  };
158  };
160 
161  //----------------------------------------------------------------------------
163  //----------------------------------------------------------------------------
165  {
166  enum Flags
167  {
168  None = 0,
169  Colocate = kXR_coloc,
170  Fresh = kXR_fresh,
171  Stage = kXR_stage,
173  WriteMode = kXR_wmode
175  };
177  };
179 
180  //----------------------------------------------------------------------------
182  //----------------------------------------------------------------------------
184  {
185  friend class AssignLBHandler;
186  friend class ForkHandler;
187 
188  public:
189  typedef std::vector<LocationInfo> LocationList;
190 
191  //------------------------------------------------------------------------
196  //------------------------------------------------------------------------
197  FileSystem( const URL &url, bool enablePlugIns = true );
198 
199  //------------------------------------------------------------------------
201  //------------------------------------------------------------------------
202  ~FileSystem();
203 
204  //------------------------------------------------------------------------
215  //------------------------------------------------------------------------
216  XRootDStatus Locate( const std::string &path,
217  OpenFlags::Flags flags,
218  ResponseHandler *handler,
219  uint16_t timeout = 0 );
220 
221  //------------------------------------------------------------------------
230  //------------------------------------------------------------------------
231  XRootDStatus Locate( const std::string &path,
232  OpenFlags::Flags flags,
233  LocationInfo *&response,
234  uint16_t timeout = 0 );
235 
236  //------------------------------------------------------------------------
247  //------------------------------------------------------------------------
248  XRootDStatus DeepLocate( const std::string &path,
249  OpenFlags::Flags flags,
250  ResponseHandler *handler,
251  uint16_t timeout = 0 );
252 
253  //------------------------------------------------------------------------
262  //------------------------------------------------------------------------
263  XRootDStatus DeepLocate( const std::string &path,
264  OpenFlags::Flags flags,
265  LocationInfo *&response,
266  uint16_t timeout = 0 );
267 
268  //------------------------------------------------------------------------
277  //------------------------------------------------------------------------
278  XRootDStatus Mv( const std::string &source,
279  const std::string &dest,
280  ResponseHandler *handler,
281  uint16_t timeout = 0 );
282 
283  //------------------------------------------------------------------------
291  //------------------------------------------------------------------------
292  XRootDStatus Mv( const std::string &source,
293  const std::string &dest,
294  uint16_t timeout = 0 );
295 
296  //------------------------------------------------------------------------
307  //------------------------------------------------------------------------
308  XRootDStatus Query( QueryCode::Code queryCode,
309  const Buffer &arg,
310  ResponseHandler *handler,
311  uint16_t timeout = 0 );
312 
313  //------------------------------------------------------------------------
322  //------------------------------------------------------------------------
323  XRootDStatus Query( QueryCode::Code queryCode,
324  const Buffer &arg,
325  Buffer *&response,
326  uint16_t timeout = 0 );
327 
328  //------------------------------------------------------------------------
337  //------------------------------------------------------------------------
338  XRootDStatus Truncate( const std::string &path,
339  uint64_t size,
340  ResponseHandler *handler,
341  uint16_t timeout = 0 );
342 
343  //------------------------------------------------------------------------
351  //------------------------------------------------------------------------
352  XRootDStatus Truncate( const std::string &path,
353  uint64_t size,
354  uint16_t timeout = 0 );
355 
356  //------------------------------------------------------------------------
364  //------------------------------------------------------------------------
365  XRootDStatus Rm( const std::string &path,
366  ResponseHandler *handler,
367  uint16_t timeout = 0 );
368 
369  //------------------------------------------------------------------------
376  //------------------------------------------------------------------------
377  XRootDStatus Rm( const std::string &path,
378  uint16_t timeout = 0 );
379 
380  //------------------------------------------------------------------------
390  //------------------------------------------------------------------------
391  XRootDStatus MkDir( const std::string &path,
392  MkDirFlags::Flags flags,
393  Access::Mode mode,
394  ResponseHandler *handler,
395  uint16_t timeout = 0 );
396 
397  //------------------------------------------------------------------------
406  //------------------------------------------------------------------------
407  XRootDStatus MkDir( const std::string &path,
408  MkDirFlags::Flags flags,
409  Access::Mode mode,
410  uint16_t timeout = 0 );
411 
412  //------------------------------------------------------------------------
420  //------------------------------------------------------------------------
421  XRootDStatus RmDir( const std::string &path,
422  ResponseHandler *handler,
423  uint16_t timeout = 0 );
424 
425  //------------------------------------------------------------------------
432  //------------------------------------------------------------------------
433  XRootDStatus RmDir( const std::string &path,
434  uint16_t timeout = 0 );
435 
436  //------------------------------------------------------------------------
445  //------------------------------------------------------------------------
446  XRootDStatus ChMod( const std::string &path,
447  Access::Mode mode,
448  ResponseHandler *handler,
449  uint16_t timeout = 0 );
450 
451  //------------------------------------------------------------------------
459  //------------------------------------------------------------------------
460  XRootDStatus ChMod( const std::string &path,
461  Access::Mode mode,
462  uint16_t timeout = 0 );
463 
464  //------------------------------------------------------------------------
471  //------------------------------------------------------------------------
472  XRootDStatus Ping( ResponseHandler *handler,
473  uint16_t timeout = 0 );
474 
475  //------------------------------------------------------------------------
481  //------------------------------------------------------------------------
482  XRootDStatus Ping( uint16_t timeout = 0 );
483 
484  //------------------------------------------------------------------------
494  //------------------------------------------------------------------------
495  XRootDStatus Stat( const std::string &path,
496  ResponseHandler *handler,
497  uint16_t timeout = 0 );
498 
499  //------------------------------------------------------------------------
507  //------------------------------------------------------------------------
508  XRootDStatus Stat( const std::string &path,
509  StatInfo *&response,
510  uint16_t timeout = 0 );
511 
512  //------------------------------------------------------------------------
522  //------------------------------------------------------------------------
523  XRootDStatus StatVFS( const std::string &path,
524  ResponseHandler *handler,
525  uint16_t timeout = 0 );
526 
527  //------------------------------------------------------------------------
535  //------------------------------------------------------------------------
536  XRootDStatus StatVFS( const std::string &path,
537  StatInfoVFS *&response,
538  uint16_t timeout = 0 );
539 
540  //------------------------------------------------------------------------
549  //------------------------------------------------------------------------
550  XRootDStatus Protocol( ResponseHandler *handler,
551  uint16_t timeout = 0 );
552 
553  //------------------------------------------------------------------------
560  //------------------------------------------------------------------------
561  XRootDStatus Protocol( ProtocolInfo *&response,
562  uint16_t timeout = 0 );
563 
564  //------------------------------------------------------------------------
575  //------------------------------------------------------------------------
576  XRootDStatus DirList( const std::string &path,
577  DirListFlags::Flags flags,
578  ResponseHandler *handler,
579  uint16_t timeout = 0 );
580 
581  //------------------------------------------------------------------------
590  //------------------------------------------------------------------------
591  XRootDStatus DirList( const std::string &path,
592  DirListFlags::Flags flags,
593  DirectoryList *&response,
594  uint16_t timeout = 0 );
595 
596  //------------------------------------------------------------------------
606  //------------------------------------------------------------------------
607  XRootDStatus SendInfo( const std::string &info,
608  ResponseHandler *handler,
609  uint16_t timeout = 0 );
610 
611  //------------------------------------------------------------------------
619  //------------------------------------------------------------------------
620  XRootDStatus SendInfo( const std::string &info,
621  Buffer *&response,
622  uint16_t timeout = 0 );
623 
624  //------------------------------------------------------------------------
636  //------------------------------------------------------------------------
637  XRootDStatus Prepare( const std::vector<std::string> &fileList,
638  PrepareFlags::Flags flags,
639  uint8_t priority,
640  ResponseHandler *handler,
641  uint16_t timeout = 0 );
642 
643  //------------------------------------------------------------------------
653  //------------------------------------------------------------------------
654  XRootDStatus Prepare( const std::vector<std::string> &fileList,
655  PrepareFlags::Flags flags,
656  uint8_t priority,
657  Buffer *&response,
658  uint16_t timeout = 0 );
659 
660  //------------------------------------------------------------------------
665  //------------------------------------------------------------------------
666  bool SetProperty( const std::string &name, const std::string &value );
667 
668  //------------------------------------------------------------------------
672  //------------------------------------------------------------------------
673  bool GetProperty( const std::string &name, std::string &value ) const;
674 
675  private:
676 
677  //------------------------------------------------------------------------
678  // Send a message in a locked environment
679  //------------------------------------------------------------------------
680  Status Send( Message *msg,
681  ResponseHandler *handler,
682  MessageSendParams &params );
683 
684  //------------------------------------------------------------------------
685  // Assign a load balancer if it has not already been assigned
686  //------------------------------------------------------------------------
687  void AssignLoadBalancer( const URL &url );
688 
689  //------------------------------------------------------------------------
690  // Lock the internal lock
691  //------------------------------------------------------------------------
692  void Lock()
693  {
694  pMutex.Lock();
695  }
696 
697  //------------------------------------------------------------------------
698  // Unlock the internal lock
699  //------------------------------------------------------------------------
700  void UnLock()
701  {
702  pMutex.UnLock();
703  }
704 
709  FileSystemPlugIn *pPlugIn;
710  };
711 }
712 
713 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:191
Definition: XProtocol.hh:208
bool pFollowRedirects
Definition: XrdClFileSystem.hh:707
Definition: XProtocol.hh:233
Implementation dependent.
Definition: XrdClFileSystem.hh:58
Definition: XProtocol.hh:231
Definition: XProtocol.hh:188
Definition: XProtocol.hh:127
Definition: XProtocol.hh:125
Directory list.
Definition: XrdClXRootDResponses.hh:504
Open only for appending.
Definition: XrdClFileSystem.hh:92
Definition: XProtocol.hh:187
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Object stat info.
Definition: XrdClXRootDResponses.hh:332
Definition: XProtocol.hh:209
Open only for writing.
Definition: XrdClFileSystem.hh:95
Prepare flags.
Definition: XrdClFileSystem.hh:164
Definition: XProtocol.hh:126
Query file visa attributes.
Definition: XrdClFileSystem.hh:62
Query file checksum.
Definition: XrdClFileSystem.hh:56
Definition: XProtocol.hh:210
Query prepare status.
Definition: XrdClFileSystem.hh:59
Path location info.
Definition: XrdClXRootDResponses.hh:37
Definition: XProtocol.hh:232
Definition: XrdClFileSystem.hh:82
Definition: XProtocol.hh:203
Access mode.
Definition: XrdClFileSystem.hh:112
Definition: XProtocol.hh:123
Flags
Definition: XrdClFileSystem.hh:166
Implementation dependent.
Definition: XrdClFileSystem.hh:57
Procedure execution status.
Definition: XrdClStatus.hh:106
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:189
Definition: XrdClFileSystem.hh:98
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:55
Definition: XProtocol.hh:197
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:706
DirList flags.
Definition: XrdClFileSystem.hh:149
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:70
Protocol response.
Definition: XrdClXRootDResponses.hh:279
Definition: XrdSysPthread.hh:140
void UnLock()
Definition: XrdClFileSystem.hh:700
Definition: XProtocol.hh:122
Definition: XrdClFileSystem.hh:80
Definition: XProtocol.hh:124
Flags
Definition: XrdClFileSystem.hh:138
Definition: XrdClFileSystem.hh:96
void Lock()
Definition: XrdClFileSystem.hh:692
Definition: XProtocol.hh:211
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:705
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:102
MkDir flags.
Definition: XrdClFileSystem.hh:136
Query file extended attributes.
Definition: XrdClFileSystem.hh:63
Open for reading and writing.
Definition: XrdClFileSystem.hh:94
Definition: XProtocol.hh:198
Definition: XProtocol.hh:120
XRootD query request codes.
Definition: XrdClFileSystem.hh:47
Request status.
Definition: XrdClXRootDResponses.hh:212
Definition: XrdClFileSystem.hh:103
Definition: XProtocol.hh:212
Definition: XProtocol.hh:207
VFS stat info.
Definition: XrdClXRootDResponses.hh:427
Definition: XProtocol.hh:186
Definition: XProtocol.hh:121
Definition: XProtocol.hh:128
URL * pUrl
Definition: XrdClFileSystem.hh:708
Definition: XrdClFileSystem.hh:100
Definition: XProtocol.hh:184
Handle an async response.
Definition: XrdClXRootDResponses.hh:832
Definition: XProtocol.hh:204
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:52
Open only for reading.
Definition: XrdClFileSystem.hh:93
URL representation.
Definition: XrdClURL.hh:30
Flags
Definition: XrdClFileSystem.hh:151
Definition: XProtocol.hh:234
Definition: XProtocol.hh:195
Query server stats.
Definition: XrdClFileSystem.hh:61
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Mode
Access mode.
Definition: XrdClFileSystem.hh:117
Definition: XrdClFileSystem.hh:84
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:183
Definition: XProtocol.hh:196
Nothing.
Definition: XrdClFileSystem.hh:77
Definition: XProtocol.hh:190
Definition: XProtocol.hh:206
Query logical space stats.
Definition: XrdClFileSystem.hh:60
Definition: XrdClFileSystem.hh:78
Definition: XProtocol.hh:199
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:709
Definition: XProtocol.hh:192
Query server configuration.
Definition: XrdClFileSystem.hh:54
Flags
Open flags, may be or&#39;d when appropriate.
Definition: XrdClFileSystem.hh:75
Definition: XProtocol.hh:193
Definition: XProtocol.hh:205
Definition: XProtocol.hh:185
Definition: XrdClFileSystem.hh:86
Binary blob representation.
Definition: XrdClBuffer.hh:33