xrootd
XrdClFileSystem.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_FILE_SYSTEM_HH__
20 #define __XRD_CL_FILE_SYSTEM_HH__
21 
22 #include "XrdCl/XrdClURL.hh"
23 #include "XrdCl/XrdClStatus.hh"
24 #include "XrdOuc/XrdOucEnum.hh"
26 #include "XrdSys/XrdSysPthread.hh"
27 #include "XProtocol/XProtocol.hh"
28 #include <string>
29 #include <vector>
30 
31 namespace XrdCl
32 {
33  class PostMaster;
34  class Message;
35  struct MessageSendParams;
36 
37  //----------------------------------------------------------------------------
39  //----------------------------------------------------------------------------
40  struct QueryCode
41  {
42  //--------------------------------------------------------------------------
44  //--------------------------------------------------------------------------
45  enum Code
46  {
57  };
58  };
59 
60  //----------------------------------------------------------------------------
62  //----------------------------------------------------------------------------
63  struct OpenFlags
64  {
65  //--------------------------------------------------------------------------
67  //--------------------------------------------------------------------------
68  enum Flags
69  {
70  None = 0,
72  Force = kXR_force,
75  New = kXR_new,
77  NoWait = kXR_nowait,
92  SeqIO = kXR_seqio
94  };
95  };
97 
98  //----------------------------------------------------------------------------
100  //----------------------------------------------------------------------------
101  struct Access
102  {
103  //--------------------------------------------------------------------------
105  //--------------------------------------------------------------------------
106  enum Mode
107  {
108  None = 0,
109  UR = kXR_ur,
110  UW = kXR_uw,
111  UX = kXR_ux,
112  GR = kXR_gr,
113  GW = kXR_gw,
114  GX = kXR_gx,
115  OR = kXR_or,
116  OW = kXR_ow,
117  OX = kXR_ox
118  };
119  };
121 
122  //----------------------------------------------------------------------------
124  //----------------------------------------------------------------------------
125  struct MkDirFlags
126  {
127  enum Flags
128  {
129  None = 0,
130  MakePath = 1
131  };
132  };
134 
135  //----------------------------------------------------------------------------
137  //----------------------------------------------------------------------------
139  {
140  enum Flags
141  {
142  None = 0,
143  Stat = 1,
144  Locate = 2
145  };
147  };
149 
150  //----------------------------------------------------------------------------
152  //----------------------------------------------------------------------------
154  {
155  enum Flags
156  {
157  Colocate = kXR_coloc,
158  Fresh = kXR_fresh,
159  Stage = kXR_stage,
161  WriteMode = kXR_wmode
163  };
165  };
167 
168  //----------------------------------------------------------------------------
170  //----------------------------------------------------------------------------
172  {
173  friend class AssignLBHandler;
174  friend class ForkHandler;
175 
176  public:
177  typedef std::vector<LocationInfo> LocationList;
178 
179  //------------------------------------------------------------------------
183  //------------------------------------------------------------------------
184  FileSystem( const URL &url );
185 
186  //------------------------------------------------------------------------
188  //------------------------------------------------------------------------
189  ~FileSystem();
190 
191  //------------------------------------------------------------------------
202  //------------------------------------------------------------------------
203  XRootDStatus Locate( const std::string &path,
204  OpenFlags::Flags flags,
205  ResponseHandler *handler,
206  uint16_t timeout = 0 );
207 
208  //------------------------------------------------------------------------
217  //------------------------------------------------------------------------
218  XRootDStatus Locate( const std::string &path,
219  OpenFlags::Flags flags,
220  LocationInfo *&response,
221  uint16_t timeout = 0 );
222 
223  //------------------------------------------------------------------------
234  //------------------------------------------------------------------------
235  XRootDStatus DeepLocate( const std::string &path,
236  OpenFlags::Flags flags,
237  ResponseHandler *handler,
238  uint16_t timeout = 0 );
239 
240  //------------------------------------------------------------------------
249  //------------------------------------------------------------------------
250  XRootDStatus DeepLocate( const std::string &path,
251  OpenFlags::Flags flags,
252  LocationInfo *&response,
253  uint16_t timeout = 0 );
254 
255  //------------------------------------------------------------------------
264  //------------------------------------------------------------------------
265  XRootDStatus Mv( const std::string &source,
266  const std::string &dest,
267  ResponseHandler *handler,
268  uint16_t timeout = 0 );
269 
270  //------------------------------------------------------------------------
278  //------------------------------------------------------------------------
279  XRootDStatus Mv( const std::string &source,
280  const std::string &dest,
281  uint16_t timeout = 0 );
282 
283  //------------------------------------------------------------------------
294  //------------------------------------------------------------------------
295  XRootDStatus Query( QueryCode::Code queryCode,
296  const Buffer &arg,
297  ResponseHandler *handler,
298  uint16_t timeout = 0 );
299 
300  //------------------------------------------------------------------------
309  //------------------------------------------------------------------------
310  XRootDStatus Query( QueryCode::Code queryCode,
311  const Buffer &arg,
312  Buffer *&response,
313  uint16_t timeout = 0 );
314 
315  //------------------------------------------------------------------------
324  //------------------------------------------------------------------------
325  XRootDStatus Truncate( const std::string &path,
326  uint64_t size,
327  ResponseHandler *handler,
328  uint16_t timeout = 0 );
329 
330  //------------------------------------------------------------------------
338  //------------------------------------------------------------------------
339  XRootDStatus Truncate( const std::string &path,
340  uint64_t size,
341  uint16_t timeout = 0 );
342 
343  //------------------------------------------------------------------------
351  //------------------------------------------------------------------------
352  XRootDStatus Rm( const std::string &path,
353  ResponseHandler *handler,
354  uint16_t timeout = 0 );
355 
356  //------------------------------------------------------------------------
363  //------------------------------------------------------------------------
364  XRootDStatus Rm( const std::string &path,
365  uint16_t timeout = 0 );
366 
367  //------------------------------------------------------------------------
377  //------------------------------------------------------------------------
378  XRootDStatus MkDir( const std::string &path,
379  MkDirFlags::Flags flags,
380  Access::Mode mode,
381  ResponseHandler *handler,
382  uint16_t timeout = 0 );
383 
384  //------------------------------------------------------------------------
393  //------------------------------------------------------------------------
394  XRootDStatus MkDir( const std::string &path,
395  MkDirFlags::Flags flags,
396  Access::Mode mode,
397  uint16_t timeout = 0 );
398 
399  //------------------------------------------------------------------------
407  //------------------------------------------------------------------------
408  XRootDStatus RmDir( const std::string &path,
409  ResponseHandler *handler,
410  uint16_t timeout = 0 );
411 
412  //------------------------------------------------------------------------
419  //------------------------------------------------------------------------
420  XRootDStatus RmDir( const std::string &path,
421  uint16_t timeout = 0 );
422 
423  //------------------------------------------------------------------------
432  //------------------------------------------------------------------------
433  XRootDStatus ChMod( const std::string &path,
434  Access::Mode mode,
435  ResponseHandler *handler,
436  uint16_t timeout = 0 );
437 
438  //------------------------------------------------------------------------
446  //------------------------------------------------------------------------
447  XRootDStatus ChMod( const std::string &path,
448  Access::Mode mode,
449  uint16_t timeout = 0 );
450 
451  //------------------------------------------------------------------------
458  //------------------------------------------------------------------------
459  XRootDStatus Ping( ResponseHandler *handler,
460  uint16_t timeout = 0 );
461 
462  //------------------------------------------------------------------------
468  //------------------------------------------------------------------------
469  XRootDStatus Ping( uint16_t timeout = 0 );
470 
471  //------------------------------------------------------------------------
481  //------------------------------------------------------------------------
482  XRootDStatus Stat( const std::string &path,
483  ResponseHandler *handler,
484  uint16_t timeout = 0 );
485 
486  //------------------------------------------------------------------------
494  //------------------------------------------------------------------------
495  XRootDStatus Stat( const std::string &path,
496  StatInfo *&response,
497  uint16_t timeout = 0 );
498 
499  //------------------------------------------------------------------------
509  //------------------------------------------------------------------------
510  XRootDStatus StatVFS( const std::string &path,
511  ResponseHandler *handler,
512  uint16_t timeout = 0 );
513 
514  //------------------------------------------------------------------------
522  //------------------------------------------------------------------------
523  XRootDStatus StatVFS( const std::string &path,
524  StatInfoVFS *&response,
525  uint16_t timeout = 0 );
526 
527  //------------------------------------------------------------------------
536  //------------------------------------------------------------------------
537  XRootDStatus Protocol( ResponseHandler *handler,
538  uint16_t timeout = 0 );
539 
540  //------------------------------------------------------------------------
547  //------------------------------------------------------------------------
548  XRootDStatus Protocol( ProtocolInfo *&response,
549  uint16_t timeout = 0 );
550 
551  //------------------------------------------------------------------------
562  //------------------------------------------------------------------------
563  XRootDStatus DirList( const std::string &path,
564  DirListFlags::Flags flags,
565  ResponseHandler *handler,
566  uint16_t timeout = 0 );
567 
568  //------------------------------------------------------------------------
577  //------------------------------------------------------------------------
578  XRootDStatus DirList( const std::string &path,
579  DirListFlags::Flags flags,
580  DirectoryList *&response,
581  uint16_t timeout = 0 );
582 
583  //------------------------------------------------------------------------
593  //------------------------------------------------------------------------
594  XRootDStatus SendInfo( const std::string &info,
595  ResponseHandler *handler,
596  uint16_t timeout = 0 );
597 
598  //------------------------------------------------------------------------
606  //------------------------------------------------------------------------
607  XRootDStatus SendInfo( const std::string &info,
608  Buffer *&response,
609  uint16_t timeout = 0 );
610 
611  //------------------------------------------------------------------------
623  //------------------------------------------------------------------------
624  XRootDStatus Prepare( const std::vector<std::string> &fileList,
625  PrepareFlags::Flags flags,
626  uint8_t priority,
627  ResponseHandler *handler,
628  uint16_t timeout = 0 );
629 
630  //------------------------------------------------------------------------
640  //------------------------------------------------------------------------
641  XRootDStatus Prepare( const std::vector<std::string> &fileList,
642  PrepareFlags::Flags flags,
643  uint8_t priority,
644  Buffer *&response,
645  uint16_t timeout = 0 );
646 
647  private:
648 
649  //------------------------------------------------------------------------
650  // Send a message in a locked environment
651  //------------------------------------------------------------------------
652  Status Send( Message *msg,
653  ResponseHandler *handler,
654  const MessageSendParams &params );
655 
656  //------------------------------------------------------------------------
657  // Assign a load balancer if it has not already been assigned
658  //------------------------------------------------------------------------
659  void AssignLoadBalancer( const URL &url );
660 
661  //------------------------------------------------------------------------
662  // Lock the internal lock
663  //------------------------------------------------------------------------
664  void Lock()
665  {
666  pMutex.Lock();
667  }
668 
669  //------------------------------------------------------------------------
670  // Unlock the internal lock
671  //------------------------------------------------------------------------
672  void UnLock()
673  {
674  pMutex.UnLock();
675  }
676 
680  };
681 }
682 
683 #endif // __XRD_CL_FILE_SYSTEM_HH__