xrootd
XrdClLocalFileHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
3 // Author: Paul-Niklas Kramp <p.n.kramp@gsi.de>
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 #ifndef __XRD_CL_LOCAL_FILE_HANDLER_HH__
19 #define __XRD_CL_LOCAL_FILE_HANDLER_HH__
20 #include "XrdCl/XrdClJobManager.hh"
22 #include "XrdCl/XrdClDefaultEnv.hh"
23 #include "XrdCl/XrdClLog.hh"
24 
25 #include <sys/uio.h>
26 
27 namespace XrdCl
28 {
29  class Message;
30  struct MessageSendParams;
31 
33  {
34  public:
35 
37 
39 
40  //------------------------------------------------------------------------
50  //------------------------------------------------------------------------
51  XRootDStatus Open( const std::string &url, uint16_t flags, uint16_t mode,
52  ResponseHandler *handler, uint16_t timeout = 0 );
53 
54  //------------------------------------------------------------------------
56  //------------------------------------------------------------------------
57  XRootDStatus Open( const URL *url, const Message *req, AnyObject *&resp );
58 
59  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
67  XRootDStatus Close( ResponseHandler *handler, uint16_t timeout = 0 );
68 
69  //------------------------------------------------------------------------
78  //------------------------------------------------------------------------
79  XRootDStatus Stat( ResponseHandler *handler, uint16_t timeout = 0 );
80 
81  //------------------------------------------------------------------------
96  //------------------------------------------------------------------------
97  XRootDStatus Read( uint64_t offset, uint32_t size, void *buffer,
98  ResponseHandler *handler, uint16_t timeout = 0 );
99 
100  //------------------------------------------------------------------------
110  //------------------------------------------------------------------------
111  XRootDStatus Write( uint64_t offset, uint32_t size, const void *buffer,
112  ResponseHandler *handler, uint16_t timeout = 0 );
113 
114  //------------------------------------------------------------------------
121  //------------------------------------------------------------------------
122  XRootDStatus Sync( ResponseHandler *handler, uint16_t timeout = 0 );
123 
124  //------------------------------------------------------------------------
132  //------------------------------------------------------------------------
133  XRootDStatus Truncate( uint64_t size, ResponseHandler *handler,
134  uint16_t timeout = 0 );
135 
136  //------------------------------------------------------------------------
145  //------------------------------------------------------------------------
146  XRootDStatus VectorRead( const ChunkList &chunks, void *buffer,
147  ResponseHandler *handler, uint16_t timeout = 0 );
148 
149  //------------------------------------------------------------------------
157  //------------------------------------------------------------------------
159  ResponseHandler *handler, uint16_t timeout = 0 );
160 
161  //------------------------------------------------------------------------
171  //------------------------------------------------------------------------
172  XRootDStatus WriteV( uint64_t offset,
173  ChunkList *chunks,
174  ResponseHandler *handler,
175  uint16_t timeout = 0 );
176 
177  //------------------------------------------------------------------------
184  //------------------------------------------------------------------------
186  ResponseHandler *handler );
187 
188  //------------------------------------------------------------------------
198  //------------------------------------------------------------------------
199  XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler,
200  uint16_t timeout = 0 );
201 
202  //------------------------------------------------------------------------
211  //------------------------------------------------------------------------
212  XRootDStatus Visa( ResponseHandler *handler, uint16_t timeout = 0 );
213 
214 
215  //------------------------------------------------------------------------
226  //------------------------------------------------------------------------
227  XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs,
228  ResponseHandler *handler,
229  uint16_t timeout = 0 );
230 
231  //------------------------------------------------------------------------
242  //------------------------------------------------------------------------
243  XRootDStatus GetXAttr( const std::vector<std::string> &attrs,
244  ResponseHandler *handler,
245  uint16_t timeout = 0 );
246 
247  //------------------------------------------------------------------------
258  //------------------------------------------------------------------------
259  XRootDStatus DelXAttr( const std::vector<std::string> &attrs,
260  ResponseHandler *handler,
261  uint16_t timeout = 0 );
262 
263  //------------------------------------------------------------------------
273  //------------------------------------------------------------------------
275  uint16_t timeout = 0 );
276 
277  //------------------------------------------------------------------------
283  //------------------------------------------------------------------------
284  static XRootDStatus MkdirPath( const std::string &path );
285 
286  void SetHostList( const HostList &hostList )
287  {
288  pHostList = hostList;
289  }
290 
292  {
293  return pHostList;
294  }
295 
296  //------------------------------------------------------------------------
298  //------------------------------------------------------------------------
300  Message *msg,
301  ResponseHandler *handler,
302  MessageSendParams &sendParams );
303 
304  private:
305 
306  XRootDStatus OpenImpl( const std::string &url, uint16_t flags,
307  uint16_t mode, AnyObject *&resp );
308 
309  //------------------------------------------------------------------------
311  //------------------------------------------------------------------------
313  kXR_char numattr,
314  size_t bodylen,
315  char *body,
316  ResponseHandler *handler );
317 
318  //---------------------------------------------------------------------
319  // Receives LocalFileTasks to handle them async
320  //---------------------------------------------------------------------
322 
323  //---------------------------------------------------------------------
324  // Internal filedescriptor, which is used by all operations after open
325  //---------------------------------------------------------------------
326  int fd;
327 
328  //---------------------------------------------------------------------
329  // The file URL
330  //---------------------------------------------------------------------
331  std::string pUrl;
332 
333  //---------------------------------------------------------------------
334  // The host list returned in the user callback
335  //---------------------------------------------------------------------
337 
338  };
339 }
340 #endif
XrdCl::LocalFileHandler::Open
XRootDStatus Open(const std::string &url, uint16_t flags, uint16_t mode, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::MessageSendParams
Definition: XrdClMessageUtils.hh:131
XrdCl::ResponseHandler
Handle an async response.
Definition: XrdClXRootDResponses.hh:975
XrdCl::LocalFileHandler::GetXAttr
XRootDStatus GetXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::MkdirPath
static XRootDStatus MkdirPath(const std::string &path)
XrdCl::LocalFileHandler
Definition: XrdClLocalFileHandler.hh:33
XrdCl::LocalFileHandler::pUrl
std::string pUrl
Definition: XrdClLocalFileHandler.hh:331
XrdCl::LocalFileHandler::LocalFileHandler
LocalFileHandler()
XrdCl::LocalFileHandler::QueueTask
XRootDStatus QueueTask(XRootDStatus *st, AnyObject *obj, ResponseHandler *handler)
XrdCl::LocalFileHandler::pHostList
HostList pHostList
Definition: XrdClLocalFileHandler.hh:336
kXR_char
unsigned char kXR_char
Definition: XPtypes.hh:65
XrdCl::LocalFileHandler::DelXAttr
XRootDStatus DelXAttr(const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::JobManager
A synchronized queue.
Definition: XrdClJobManager.hh:51
XrdCl::LocalFileHandler::Stat
XRootDStatus Stat(ResponseHandler *handler, uint16_t timeout=0)
XrdClLocalFileTask.hh
XrdCl::Message
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
XrdCl::LocalFileHandler::Truncate
XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::Open
XRootDStatus Open(const URL *url, const Message *req, AnyObject *&resp)
Handle local redirect to given URL triggered by the given request.
XrdCl::LocalFileHandler::XAttrImpl
XRootDStatus XAttrImpl(kXR_char code, kXR_char numattr, size_t bodylen, char *body, ResponseHandler *handler)
Parses kXR_fattr request and calls respective XAttr operation.
XrdCl::LocalFileHandler::OpenImpl
XRootDStatus OpenImpl(const std::string &url, uint16_t flags, uint16_t mode, AnyObject *&resp)
XrdClLog.hh
XrdCl::XRootDStatus
Request status.
Definition: XrdClXRootDResponses.hh:215
XrdCl::LocalFileHandler::jmngr
JobManager * jmngr
Definition: XrdClLocalFileHandler.hh:321
XrdCl::ChunkList
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:904
XrdCl::LocalFileHandler::Read
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::~LocalFileHandler
~LocalFileHandler()
XrdCl::LocalFileHandler::Write
XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::Close
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout=0)
XrdClJobManager.hh
XrdCl::LocalFileHandler::ListXAttr
XRootDStatus ListXAttr(ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::SetHostList
void SetHostList(const HostList &hostList)
Definition: XrdClLocalFileHandler.hh:286
XrdCl
Definition: XrdClAnyObject.hh:26
XrdClDefaultEnv.hh
XrdCl::HostList
std::vector< HostInfo > HostList
Definition: XrdClXRootDResponses.hh:969
XrdCl::LocalFileHandler::fd
int fd
Definition: XrdClLocalFileHandler.hh:326
XrdCl::LocalFileHandler::Visa
XRootDStatus Visa(ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::Fcntl
XRootDStatus Fcntl(const Buffer &arg, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::ExecRequest
XRootDStatus ExecRequest(const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams)
Translate an XRootD request into LocalFileHandler call.
XrdCl::LocalFileHandler::GetHostList
const HostList & GetHostList()
Definition: XrdClLocalFileHandler.hh:291
XrdCl::URL
URL representation.
Definition: XrdClURL.hh:31
XrdCl::Buffer
Binary blob representation.
Definition: XrdClBuffer.hh:34
XrdCl::LocalFileHandler::Sync
XRootDStatus Sync(ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::VectorRead
XRootDStatus VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::AnyObject
Definition: XrdClAnyObject.hh:33
XrdCl::LocalFileHandler::VectorWrite
XRootDStatus VectorWrite(const ChunkList &chunks, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::SetXAttr
XRootDStatus SetXAttr(const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0)
XrdCl::LocalFileHandler::WriteV
XRootDStatus WriteV(uint64_t offset, ChunkList *chunks, ResponseHandler *handler, uint16_t timeout=0)