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"
35#include <string>
36#include <vector>
37
38namespace 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,
87 New = kXR_new,
99 POSC = kXR_posc,
110 };
111 };
113
114 //----------------------------------------------------------------------------
116 //----------------------------------------------------------------------------
117 struct Access
118 {
119 //--------------------------------------------------------------------------
121 //--------------------------------------------------------------------------
122 enum Mode
123 {
124 None = 0,
125 UR = kXR_ur,
126 UW = kXR_uw,
127 UX = kXR_ux,
128 GR = kXR_gr,
129 GW = kXR_gw,
130 GX = kXR_gx,
131 OR = kXR_or,
132 OW = kXR_ow,
133 OX = kXR_ox
134 };
135 };
137
138 //----------------------------------------------------------------------------
140 //----------------------------------------------------------------------------
142 {
143 enum Flags
144 {
145 None = 0,
146 MakePath = 1
147 };
148 };
150
151 //----------------------------------------------------------------------------
153 //----------------------------------------------------------------------------
155 {
156 enum Flags
157 {
158 None = 0,
159 Stat = 1,
160 Locate = 2,
162 Recursive = 4,
163 Merge = 8,
164 Chunked = 16,
165 Zip = 32
166 };
167 };
169
170 //----------------------------------------------------------------------------
172 //----------------------------------------------------------------------------
174 {
175 enum Flags
176 {
177 None = 0,
178 Colocate = kXR_coloc,
179 Fresh = kXR_fresh,
181 Stage = kXR_stage,
183 WriteMode = kXR_wmode,
185 Cancel = kXR_cancel,
186 Evict = kXR_evict << 8
190 };
191 };
193
194 //----------------------------------------------------------------------------
196 //----------------------------------------------------------------------------
198 {
199 friend class AssignLBHandler;
200 friend class ForkHandler;
201
202 public:
203 typedef std::vector<LocationInfo> LocationList;
204
205 //------------------------------------------------------------------------
210 //------------------------------------------------------------------------
211 FileSystem( const URL &url, bool enablePlugIns = true );
212
213 //------------------------------------------------------------------------
215 //------------------------------------------------------------------------
217
218 //------------------------------------------------------------------------
229 //------------------------------------------------------------------------
230 XRootDStatus Locate( const std::string &path,
231 OpenFlags::Flags flags,
232 ResponseHandler *handler,
233 uint16_t timeout = 0 )
235
236 //------------------------------------------------------------------------
245 //------------------------------------------------------------------------
246 XRootDStatus Locate( const std::string &path,
247 OpenFlags::Flags flags,
248 LocationInfo *&response,
249 uint16_t timeout = 0 )
251
252 //------------------------------------------------------------------------
263 //------------------------------------------------------------------------
264 XRootDStatus DeepLocate( const std::string &path,
265 OpenFlags::Flags flags,
266 ResponseHandler *handler,
267 uint16_t timeout = 0 )
269
270 //------------------------------------------------------------------------
279 //------------------------------------------------------------------------
280 XRootDStatus DeepLocate( const std::string &path,
281 OpenFlags::Flags flags,
282 LocationInfo *&response,
283 uint16_t timeout = 0 )
285
286 //------------------------------------------------------------------------
295 //------------------------------------------------------------------------
296 XRootDStatus Mv( const std::string &source,
297 const std::string &dest,
298 ResponseHandler *handler,
299 uint16_t timeout = 0 )
301
302 //------------------------------------------------------------------------
310 //------------------------------------------------------------------------
311 XRootDStatus Mv( const std::string &source,
312 const std::string &dest,
313 uint16_t timeout = 0 )
315
316 //------------------------------------------------------------------------
327 //------------------------------------------------------------------------
328 XRootDStatus Query( QueryCode::Code queryCode,
329 const Buffer &arg,
330 ResponseHandler *handler,
331 uint16_t timeout = 0 )
333
334 //------------------------------------------------------------------------
343 //------------------------------------------------------------------------
344 XRootDStatus Query( QueryCode::Code queryCode,
345 const Buffer &arg,
346 Buffer *&response,
347 uint16_t timeout = 0 )
349
350 //------------------------------------------------------------------------
359 //------------------------------------------------------------------------
360 XRootDStatus Truncate( const std::string &path,
361 uint64_t size,
362 ResponseHandler *handler,
363 uint16_t timeout = 0 )
365
366 //------------------------------------------------------------------------
374 //------------------------------------------------------------------------
375 XRootDStatus Truncate( const std::string &path,
376 uint64_t size,
377 uint16_t timeout = 0 )
379
380 //------------------------------------------------------------------------
388 //------------------------------------------------------------------------
389 XRootDStatus Rm( const std::string &path,
390 ResponseHandler *handler,
391 uint16_t timeout = 0 )
393
394 //------------------------------------------------------------------------
401 //------------------------------------------------------------------------
402 XRootDStatus Rm( const std::string &path,
403 uint16_t timeout = 0 )
405
406 //------------------------------------------------------------------------
416 //------------------------------------------------------------------------
417 XRootDStatus MkDir( const std::string &path,
418 MkDirFlags::Flags flags,
419 Access::Mode mode,
420 ResponseHandler *handler,
421 uint16_t timeout = 0 )
423
424 //------------------------------------------------------------------------
433 //------------------------------------------------------------------------
434 XRootDStatus MkDir( const std::string &path,
435 MkDirFlags::Flags flags,
436 Access::Mode mode,
437 uint16_t timeout = 0 )
439
440 //------------------------------------------------------------------------
448 //------------------------------------------------------------------------
449 XRootDStatus RmDir( const std::string &path,
450 ResponseHandler *handler,
451 uint16_t timeout = 0 )
453
454 //------------------------------------------------------------------------
461 //------------------------------------------------------------------------
462 XRootDStatus RmDir( const std::string &path,
463 uint16_t timeout = 0 )
465
466 //------------------------------------------------------------------------
475 //------------------------------------------------------------------------
476 XRootDStatus ChMod( const std::string &path,
477 Access::Mode mode,
478 ResponseHandler *handler,
479 uint16_t timeout = 0 )
481
482 //------------------------------------------------------------------------
490 //------------------------------------------------------------------------
491 XRootDStatus ChMod( const std::string &path,
492 Access::Mode mode,
493 uint16_t timeout = 0 )
495
496 //------------------------------------------------------------------------
503 //------------------------------------------------------------------------
505 uint16_t timeout = 0 )
507
508 //------------------------------------------------------------------------
514 //------------------------------------------------------------------------
515 XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
516
517 //------------------------------------------------------------------------
527 //------------------------------------------------------------------------
528 XRootDStatus Stat( const std::string &path,
529 ResponseHandler *handler,
530 uint16_t timeout = 0 )
532
533 //------------------------------------------------------------------------
542 //------------------------------------------------------------------------
543 XRootDStatus Stat( const std::string &path,
544 StatInfo *&response,
545 uint16_t timeout = 0 )
547
548 //------------------------------------------------------------------------
558 //------------------------------------------------------------------------
559 XRootDStatus StatVFS( const std::string &path,
560 ResponseHandler *handler,
561 uint16_t timeout = 0 )
563
564 //------------------------------------------------------------------------
572 //------------------------------------------------------------------------
573 XRootDStatus StatVFS( const std::string &path,
574 StatInfoVFS *&response,
575 uint16_t timeout = 0 )
577
578 //------------------------------------------------------------------------
587 //------------------------------------------------------------------------
589 uint16_t timeout = 0 )
591
592 //------------------------------------------------------------------------
599 //------------------------------------------------------------------------
601 uint16_t timeout = 0 )
603
604 //------------------------------------------------------------------------
615 //------------------------------------------------------------------------
616 XRootDStatus DirList( const std::string &path,
617 DirListFlags::Flags flags,
618 ResponseHandler *handler,
619 uint16_t timeout = 0 )
621
622 //------------------------------------------------------------------------
631 //------------------------------------------------------------------------
632 XRootDStatus DirList( const std::string &path,
633 DirListFlags::Flags flags,
634 DirectoryList *&response,
635 uint16_t timeout = 0 )
637
638 //------------------------------------------------------------------------
648 //------------------------------------------------------------------------
649 XRootDStatus SendInfo( const std::string &info,
650 ResponseHandler *handler,
651 uint16_t timeout = 0 )
653
654 //------------------------------------------------------------------------
662 //------------------------------------------------------------------------
663 XRootDStatus SendInfo( const std::string &info,
664 Buffer *&response,
665 uint16_t timeout = 0 )
667
668 //------------------------------------------------------------------------
680 //------------------------------------------------------------------------
681 XRootDStatus Prepare( const std::vector<std::string> &fileList,
682 PrepareFlags::Flags flags,
683 uint8_t priority,
684 ResponseHandler *handler,
685 uint16_t timeout = 0 )
687
688 //------------------------------------------------------------------------
698 //------------------------------------------------------------------------
699 XRootDStatus Prepare( const std::vector<std::string> &fileList,
700 PrepareFlags::Flags flags,
701 uint8_t priority,
702 Buffer *&response,
703 uint16_t timeout = 0 )
705
706 //------------------------------------------------------------------------
711 //------------------------------------------------------------------------
712 bool SetProperty( const std::string &name, const std::string &value );
713
714 //------------------------------------------------------------------------
718 //------------------------------------------------------------------------
719 bool GetProperty( const std::string &name, std::string &value ) const;
720
721 private:
722 FileSystem(const FileSystem &other);
723 FileSystem &operator = (const FileSystem &other);
724
725 //------------------------------------------------------------------------
726 // Send a message in a locked environment
727 //------------------------------------------------------------------------
728 Status Send( Message *msg,
729 ResponseHandler *handler,
730 MessageSendParams &params );
731
732 //------------------------------------------------------------------------
733 // Assign a load balancer if it has not already been assigned
734 //------------------------------------------------------------------------
735 void AssignLoadBalancer( const URL &url );
736
737 //------------------------------------------------------------------------
738 // Lock the internal lock
739 //------------------------------------------------------------------------
740 void Lock()
741 {
742 pMutex.Lock();
743 }
744
745 //------------------------------------------------------------------------
746 // Unlock the internal lock
747 //------------------------------------------------------------------------
748 void UnLock()
749 {
750 pMutex.UnLock();
751 }
752
758 };
759}
760
761#endif // __XRD_CL_FILE_SYSTEM_HH__
@ kXR_open_wrto
Definition: XProtocol.hh:233
@ kXR_compress
Definition: XProtocol.hh:216
@ kXR_delete
Definition: XProtocol.hh:217
@ kXR_prefname
Definition: XProtocol.hh:225
@ kXR_nowait
Definition: XProtocol.hh:231
@ kXR_open_read
Definition: XProtocol.hh:220
@ kXR_open_updt
Definition: XProtocol.hh:221
@ kXR_mkpath
Definition: XProtocol.hh:224
@ kXR_seqio
Definition: XProtocol.hh:232
@ kXR_replica
Definition: XProtocol.hh:229
@ kXR_posc
Definition: XProtocol.hh:230
@ kXR_refresh
Definition: XProtocol.hh:223
@ kXR_new
Definition: XProtocol.hh:219
@ kXR_force
Definition: XProtocol.hh:218
@ kXR_4dirlist
Definition: XProtocol.hh:228
@ kXR_open_apnd
Definition: XProtocol.hh:226
@ kXR_wmode
Definition: XProtocol.hh:269
@ kXR_evict
Definition: XProtocol.hh:274
@ kXR_cancel
Definition: XProtocol.hh:265
@ kXR_fresh
Definition: XProtocol.hh:271
@ kXR_coloc
Definition: XProtocol.hh:270
@ kXR_stage
Definition: XProtocol.hh:268
@ kXR_gw
Definition: XProtocol.hh:153
@ kXR_ur
Definition: XProtocol.hh:149
@ kXR_uw
Definition: XProtocol.hh:150
@ kXR_gr
Definition: XProtocol.hh:152
@ kXR_ow
Definition: XProtocol.hh:156
@ kXR_gx
Definition: XProtocol.hh:154
@ kXR_or
Definition: XProtocol.hh:155
@ kXR_ox
Definition: XProtocol.hh:157
@ kXR_ux
Definition: XProtocol.hh:151
@ kXR_QPrep
Definition: XProtocol.hh:242
@ kXR_Qconfig
Definition: XProtocol.hh:247
@ kXR_Qopaquf
Definition: XProtocol.hh:250
@ kXR_Qckscan
Definition: XProtocol.hh:246
@ kXR_Qxattr
Definition: XProtocol.hh:244
@ kXR_Qspace
Definition: XProtocol.hh:245
@ kXR_Qvisa
Definition: XProtocol.hh:248
@ kXR_QStats
Definition: XProtocol.hh:241
@ kXR_Qcksum
Definition: XProtocol.hh:243
@ kXR_Qopaque
Definition: XProtocol.hh:249
#define XRD_WARN_UNUSED_RESULT
Definition: XrdOucCompiler.hh:31
#define XRDOUC_ENUM_OPERATORS(T)
Definition: XrdOucEnum.hh:22
Binary blob representation.
Definition: XrdClBuffer.hh:34
ChMod operation (.
Definition: XrdClFileSystemOperations.hh:566
DeepLocate operation (.
Definition: XrdClFileSystemOperations.hh:162
DirList operation (.
Definition: XrdClFileSystemOperations.hh:819
Directory list.
Definition: XrdClXRootDResponses.hh:511
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:191
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:198
bool pLoadBalancerLookupDone
Definition: XrdClFileSystem.hh:754
XRootDStatus Locate(const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
FileSystemPlugIn * pPlugIn
Definition: XrdClFileSystem.hh:757
FileSystem(const URL &url, bool enablePlugIns=true)
XrdSysMutex pMutex
Definition: XrdClFileSystem.hh:753
bool pFollowRedirects
Definition: XrdClFileSystem.hh:755
URL * pUrl
Definition: XrdClFileSystem.hh:756
void UnLock()
Definition: XrdClFileSystem.hh:748
~FileSystem()
Destructor.
std::vector< LocationInfo > LocationList
Location list.
Definition: XrdClFileSystem.hh:203
Definition: XrdClForkHandler.hh:36
Locate operation (.
Definition: XrdClFileSystemOperations.hh:105
Path location info.
Definition: XrdClXRootDResponses.hh:38
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
MkDir operation (.
Definition: XrdClFileSystemOperations.hh:453
Mv operation (.
Definition: XrdClFileSystemOperations.hh:219
Ping operation (.
Definition: XrdClFileSystemOperations.hh:622
Prepare operation (.
Definition: XrdClFileSystemOperations.hh:932
Protocol operation (.
Definition: XrdClFileSystemOperations.hh:781
Protocol response.
Definition: XrdClXRootDResponses.hh:280
Query operation (.
Definition: XrdClFileSystemOperations.hh:276
Read operation (.
Definition: XrdClFileOperations.hh:252
Handle an async response.
Definition: XrdClXRootDResponses.hh:855
RmDir operation (.
Definition: XrdClFileSystemOperations.hh:511
Rm operation (.
Definition: XrdClFileSystemOperations.hh:398
SendInfo operation (.
Definition: XrdClFileSystemOperations.hh:876
VFS stat info.
Definition: XrdClXRootDResponses.hh:434
Object stat info.
Definition: XrdClXRootDResponses.hh:333
StatVS operation (.
Definition: XrdClFileSystemOperations.hh:725
URL representation.
Definition: XrdClURL.hh:31
Visa operation (.
Definition: XrdClFileOperations.hh:807
Write operation (.
Definition: XrdClFileOperations.hh:418
Request status.
Definition: XrdClXRootDResponses.hh:213
Definition: XrdSysPthread.hh:166
Definition: XrdClAnyObject.hh:26
StatImpl< false > Stat(File *file, Arg< bool > force)
Definition: XrdClFileOperations.hh:398
TruncateImpl< false > Truncate(File *file, Arg< uint64_t > size)
Definition: XrdClFileOperations.hh:564
Access mode.
Definition: XrdClFileSystem.hh:118
Mode
Access mode.
Definition: XrdClFileSystem.hh:123
DirList flags.
Definition: XrdClFileSystem.hh:155
Flags
Definition: XrdClFileSystem.hh:157
Definition: XrdClMessageUtils.hh:129
MkDir flags.
Definition: XrdClFileSystem.hh:142
Flags
Definition: XrdClFileSystem.hh:144
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:72
Flags
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:77
@ Compress
Definition: XrdClFileSystem.hh:79
@ Delete
Definition: XrdClFileSystem.hh:81
@ Force
Definition: XrdClFileSystem.hh:83
@ New
Definition: XrdClFileSystem.hh:87
@ PrefName
Definition: XrdClFileSystem.hh:106
@ Replica
Definition: XrdClFileSystem.hh:103
@ MakePath
Definition: XrdClFileSystem.hh:85
@ None
Nothing.
Definition: XrdClFileSystem.hh:78
@ POSC
Definition: XrdClFileSystem.hh:99
@ Refresh
Definition: XrdClFileSystem.hh:101
@ SeqIO
File will be read or written sequentially.
Definition: XrdClFileSystem.hh:105
@ Update
Open for reading and writing.
Definition: XrdClFileSystem.hh:97
@ IntentDirList
Definition: XrdClFileSystem.hh:108
@ NoWait
Definition: XrdClFileSystem.hh:89
@ Append
Open only for appending.
Definition: XrdClFileSystem.hh:95
Prepare flags.
Definition: XrdClFileSystem.hh:174
Flags
Definition: XrdClFileSystem.hh:176
XRootD query request codes.
Definition: XrdClFileSystem.hh:49
Code
XRootD query request codes.
Definition: XrdClFileSystem.hh:54
@ OpaqueFile
Implementation dependent.
Definition: XrdClFileSystem.hh:59
@ XAttr
Query file extended attributes.
Definition: XrdClFileSystem.hh:64
@ Opaque
Implementation dependent.
Definition: XrdClFileSystem.hh:58
@ Config
Query server configuration.
Definition: XrdClFileSystem.hh:55
@ Stats
Query server stats.
Definition: XrdClFileSystem.hh:62
@ ChecksumCancel
Query file checksum cancellation.
Definition: XrdClFileSystem.hh:56
@ Checksum
Query file checksum.
Definition: XrdClFileSystem.hh:57
@ Space
Query logical space stats.
Definition: XrdClFileSystem.hh:61
Procedure execution status.
Definition: XrdClStatus.hh:110