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,
82  New = kXR_new,
84  NoWait = kXR_nowait,
100  SeqIO = kXR_seqio,
103  };
105  };
107 
108  //----------------------------------------------------------------------------
110  //----------------------------------------------------------------------------
111  struct Access
112  {
113  //--------------------------------------------------------------------------
115  //--------------------------------------------------------------------------
116  enum Mode
117  {
118  None = 0,
119  UR = kXR_ur,
120  UW = kXR_uw,
121  UX = kXR_ux,
122  GR = kXR_gr,
123  GW = kXR_gw,
124  GX = kXR_gx,
125  OR = kXR_or,
126  OW = kXR_ow,
127  OX = kXR_ox
128  };
129  };
131 
132  //----------------------------------------------------------------------------
134  //----------------------------------------------------------------------------
135  struct MkDirFlags
136  {
137  enum Flags
138  {
139  None = 0,
140  MakePath = 1
141  };
142  };
144 
145  //----------------------------------------------------------------------------
147  //----------------------------------------------------------------------------
149  {
150  enum Flags
151  {
152  None = 0,
153  Stat = 1,
154  Locate = 2
155  };
157  };
159 
160  //----------------------------------------------------------------------------
162  //----------------------------------------------------------------------------
164  {
165  enum Flags
166  {
167  None = 0,
168  Colocate = kXR_coloc,
169  Fresh = kXR_fresh,
170  Stage = kXR_stage,
172  WriteMode = kXR_wmode
174  };
176  };
178 
179  //----------------------------------------------------------------------------
181  //----------------------------------------------------------------------------
183  {
184  friend class AssignLBHandler;
185  friend class ForkHandler;
186 
187  public:
188  typedef std::vector<LocationInfo> LocationList;
189 
190  //------------------------------------------------------------------------
195  //------------------------------------------------------------------------
196  FileSystem( const URL &url, bool enablePlugIns = true );
197 
198  //------------------------------------------------------------------------
200  //------------------------------------------------------------------------
201  ~FileSystem();
202 
203  //------------------------------------------------------------------------
214  //------------------------------------------------------------------------
215  XRootDStatus Locate( const std::string &path,
216  OpenFlags::Flags flags,
217  ResponseHandler *handler,
218  uint16_t timeout = 0 );
219 
220  //------------------------------------------------------------------------
229  //------------------------------------------------------------------------
230  XRootDStatus Locate( const std::string &path,
231  OpenFlags::Flags flags,
232  LocationInfo *&response,
233  uint16_t timeout = 0 );
234 
235  //------------------------------------------------------------------------
246  //------------------------------------------------------------------------
247  XRootDStatus DeepLocate( const std::string &path,
248  OpenFlags::Flags flags,
249  ResponseHandler *handler,
250  uint16_t timeout = 0 );
251 
252  //------------------------------------------------------------------------
261  //------------------------------------------------------------------------
262  XRootDStatus DeepLocate( const std::string &path,
263  OpenFlags::Flags flags,
264  LocationInfo *&response,
265  uint16_t timeout = 0 );
266 
267  //------------------------------------------------------------------------
276  //------------------------------------------------------------------------
277  XRootDStatus Mv( const std::string &source,
278  const std::string &dest,
279  ResponseHandler *handler,
280  uint16_t timeout = 0 );
281 
282  //------------------------------------------------------------------------
290  //------------------------------------------------------------------------
291  XRootDStatus Mv( const std::string &source,
292  const std::string &dest,
293  uint16_t timeout = 0 );
294 
295  //------------------------------------------------------------------------
306  //------------------------------------------------------------------------
307  XRootDStatus Query( QueryCode::Code queryCode,
308  const Buffer &arg,
309  ResponseHandler *handler,
310  uint16_t timeout = 0 );
311 
312  //------------------------------------------------------------------------
321  //------------------------------------------------------------------------
322  XRootDStatus Query( QueryCode::Code queryCode,
323  const Buffer &arg,
324  Buffer *&response,
325  uint16_t timeout = 0 );
326 
327  //------------------------------------------------------------------------
336  //------------------------------------------------------------------------
337  XRootDStatus Truncate( const std::string &path,
338  uint64_t size,
339  ResponseHandler *handler,
340  uint16_t timeout = 0 );
341 
342  //------------------------------------------------------------------------
350  //------------------------------------------------------------------------
351  XRootDStatus Truncate( const std::string &path,
352  uint64_t size,
353  uint16_t timeout = 0 );
354 
355  //------------------------------------------------------------------------
363  //------------------------------------------------------------------------
364  XRootDStatus Rm( const std::string &path,
365  ResponseHandler *handler,
366  uint16_t timeout = 0 );
367 
368  //------------------------------------------------------------------------
375  //------------------------------------------------------------------------
376  XRootDStatus Rm( const std::string &path,
377  uint16_t timeout = 0 );
378 
379  //------------------------------------------------------------------------
389  //------------------------------------------------------------------------
390  XRootDStatus MkDir( const std::string &path,
391  MkDirFlags::Flags flags,
392  Access::Mode mode,
393  ResponseHandler *handler,
394  uint16_t timeout = 0 );
395 
396  //------------------------------------------------------------------------
405  //------------------------------------------------------------------------
406  XRootDStatus MkDir( const std::string &path,
407  MkDirFlags::Flags flags,
408  Access::Mode mode,
409  uint16_t timeout = 0 );
410 
411  //------------------------------------------------------------------------
419  //------------------------------------------------------------------------
420  XRootDStatus RmDir( const std::string &path,
421  ResponseHandler *handler,
422  uint16_t timeout = 0 );
423 
424  //------------------------------------------------------------------------
431  //------------------------------------------------------------------------
432  XRootDStatus RmDir( const std::string &path,
433  uint16_t timeout = 0 );
434 
435  //------------------------------------------------------------------------
444  //------------------------------------------------------------------------
445  XRootDStatus ChMod( const std::string &path,
446  Access::Mode mode,
447  ResponseHandler *handler,
448  uint16_t timeout = 0 );
449 
450  //------------------------------------------------------------------------
458  //------------------------------------------------------------------------
459  XRootDStatus ChMod( const std::string &path,
460  Access::Mode mode,
461  uint16_t timeout = 0 );
462 
463  //------------------------------------------------------------------------
470  //------------------------------------------------------------------------
471  XRootDStatus Ping( ResponseHandler *handler,
472  uint16_t timeout = 0 );
473 
474  //------------------------------------------------------------------------
480  //------------------------------------------------------------------------
481  XRootDStatus Ping( uint16_t timeout = 0 );
482 
483  //------------------------------------------------------------------------
493  //------------------------------------------------------------------------
494  XRootDStatus Stat( const std::string &path,
495  ResponseHandler *handler,
496  uint16_t timeout = 0 );
497 
498  //------------------------------------------------------------------------
506  //------------------------------------------------------------------------
507  XRootDStatus Stat( const std::string &path,
508  StatInfo *&response,
509  uint16_t timeout = 0 );
510 
511  //------------------------------------------------------------------------
521  //------------------------------------------------------------------------
522  XRootDStatus StatVFS( const std::string &path,
523  ResponseHandler *handler,
524  uint16_t timeout = 0 );
525 
526  //------------------------------------------------------------------------
534  //------------------------------------------------------------------------
535  XRootDStatus StatVFS( const std::string &path,
536  StatInfoVFS *&response,
537  uint16_t timeout = 0 );
538 
539  //------------------------------------------------------------------------
548  //------------------------------------------------------------------------
549  XRootDStatus Protocol( ResponseHandler *handler,
550  uint16_t timeout = 0 );
551 
552  //------------------------------------------------------------------------
559  //------------------------------------------------------------------------
560  XRootDStatus Protocol( ProtocolInfo *&response,
561  uint16_t timeout = 0 );
562 
563  //------------------------------------------------------------------------
574  //------------------------------------------------------------------------
575  XRootDStatus DirList( const std::string &path,
576  DirListFlags::Flags flags,
577  ResponseHandler *handler,
578  uint16_t timeout = 0 );
579 
580  //------------------------------------------------------------------------
589  //------------------------------------------------------------------------
590  XRootDStatus DirList( const std::string &path,
591  DirListFlags::Flags flags,
592  DirectoryList *&response,
593  uint16_t timeout = 0 );
594 
595  //------------------------------------------------------------------------
605  //------------------------------------------------------------------------
606  XRootDStatus SendInfo( const std::string &info,
607  ResponseHandler *handler,
608  uint16_t timeout = 0 );
609 
610  //------------------------------------------------------------------------
618  //------------------------------------------------------------------------
619  XRootDStatus SendInfo( const std::string &info,
620  Buffer *&response,
621  uint16_t timeout = 0 );
622 
623  //------------------------------------------------------------------------
635  //------------------------------------------------------------------------
636  XRootDStatus Prepare( const std::vector<std::string> &fileList,
637  PrepareFlags::Flags flags,
638  uint8_t priority,
639  ResponseHandler *handler,
640  uint16_t timeout = 0 );
641 
642  //------------------------------------------------------------------------
652  //------------------------------------------------------------------------
653  XRootDStatus Prepare( const std::vector<std::string> &fileList,
654  PrepareFlags::Flags flags,
655  uint8_t priority,
656  Buffer *&response,
657  uint16_t timeout = 0 );
658 
659  //------------------------------------------------------------------------
664  //------------------------------------------------------------------------
665  bool SetProperty( const std::string &name, const std::string &value );
666 
667  //------------------------------------------------------------------------
671  //------------------------------------------------------------------------
672  bool GetProperty( const std::string &name, std::string &value ) const;
673 
674  private:
675 
676  //------------------------------------------------------------------------
677  // Send a message in a locked environment
678  //------------------------------------------------------------------------
679  Status Send( Message *msg,
680  ResponseHandler *handler,
681  MessageSendParams &params );
682 
683  //------------------------------------------------------------------------
684  // Assign a load balancer if it has not already been assigned
685  //------------------------------------------------------------------------
686  void AssignLoadBalancer( const URL &url );
687 
688  //------------------------------------------------------------------------
689  // Lock the internal lock
690  //------------------------------------------------------------------------
691  void Lock()
692  {
693  pMutex.Lock();
694  }
695 
696  //------------------------------------------------------------------------
697  // Unlock the internal lock
698  //------------------------------------------------------------------------
699  void UnLock()
700  {
701  pMutex.UnLock();
702  }
703 
708  FileSystemPlugIn *pPlugIn;
709  };
710 }
711 
712 #endif // __XRD_CL_FILE_SYSTEM_HH__
Definition: XProtocol.hh:191
Definition: XProtocol.hh:208
bool pFollowRedirects
Definition: XrdClFileSystem.hh:706
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:91
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:94
Prepare flags.
Definition: XrdClFileSystem.hh:163
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:81
Definition: XProtocol.hh:203
Access mode.
Definition: XrdClFileSystem.hh:111
Definition: XProtocol.hh:123
Flags
Definition: XrdClFileSystem.hh:165
Implementation dependent.
Definition: XrdClFileSystem.hh:57
Procedure execution status.
Definition: XrdClStatus.hh:106
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:188
Definition: XrdClFileSystem.hh:97
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:55
Definition: XProtocol.hh:197
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:705
DirList flags.
Definition: XrdClFileSystem.hh:148
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:699
Definition: XProtocol.hh:122
Ignore file usage rules.
Definition: XrdClFileSystem.hh:80
Definition: XProtocol.hh:124
Flags
Definition: XrdClFileSystem.hh:137
Definition: XrdClFileSystem.hh:95
void Lock()
Definition: XrdClFileSystem.hh:691
Definition: XProtocol.hh:211
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:704
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:101
MkDir flags.
Definition: XrdClFileSystem.hh:135
Query file extended attributes.
Definition: XrdClFileSystem.hh:63
Open for reading and writing.
Definition: XrdClFileSystem.hh:93
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:102
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:707
Definition: XrdClFileSystem.hh:99
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:92
URL representation.
Definition: XrdClURL.hh:30
Flags
Definition: XrdClFileSystem.hh:150
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:116
Definition: XrdClFileSystem.hh:83
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:182
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:708
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:85
Binary blob representation.
Definition: XrdClBuffer.hh:33