00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH 00003 // Author: Paul-Niklas Kramp <p.n.kramp@gsi.de> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 #ifndef __XRD_CL_LOCAL_FILE_HANDLER_HH__ 00019 #define __XRD_CL_LOCAL_FILE_HANDLER_HH__ 00020 #include "XrdCl/XrdClJobManager.hh" 00021 #include "XrdCl/XrdClLocalFileTask.hh" 00022 #include "XrdCl/XrdClDefaultEnv.hh" 00023 #include "XrdCl/XrdClLog.hh" 00024 00025 #include <sys/uio.h> 00026 00027 namespace XrdCl 00028 { 00029 class Message; 00030 struct MessageSendParams; 00031 00032 class LocalFileHandler 00033 { 00034 public: 00035 00036 LocalFileHandler(); 00037 00038 ~LocalFileHandler(); 00039 00040 //------------------------------------------------------------------------ 00050 //------------------------------------------------------------------------ 00051 XRootDStatus Open( const std::string &url, uint16_t flags, uint16_t mode, 00052 ResponseHandler *handler, uint16_t timeout = 0 ); 00053 00054 //------------------------------------------------------------------------ 00056 //------------------------------------------------------------------------ 00057 XRootDStatus Open( const URL *url, const Message *req, AnyObject *&resp ); 00058 00059 //------------------------------------------------------------------------ 00066 //------------------------------------------------------------------------ 00067 XRootDStatus Close( ResponseHandler *handler, uint16_t timeout = 0 ); 00068 00069 //------------------------------------------------------------------------ 00078 //------------------------------------------------------------------------ 00079 XRootDStatus Stat( ResponseHandler *handler, uint16_t timeout = 0 ); 00080 00081 //------------------------------------------------------------------------ 00096 //------------------------------------------------------------------------ 00097 XRootDStatus Read( uint64_t offset, uint32_t size, void *buffer, 00098 ResponseHandler *handler, uint16_t timeout = 0 ); 00099 00100 //------------------------------------------------------------------------ 00110 //------------------------------------------------------------------------ 00111 XRootDStatus Write( uint64_t offset, uint32_t size, const void *buffer, 00112 ResponseHandler *handler, uint16_t timeout = 0 ); 00113 00114 //------------------------------------------------------------------------ 00121 //------------------------------------------------------------------------ 00122 XRootDStatus Sync( ResponseHandler *handler, uint16_t timeout = 0 ); 00123 00124 //------------------------------------------------------------------------ 00132 //------------------------------------------------------------------------ 00133 XRootDStatus Truncate( uint64_t size, ResponseHandler *handler, 00134 uint16_t timeout = 0 ); 00135 00136 //------------------------------------------------------------------------ 00145 //------------------------------------------------------------------------ 00146 XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, 00147 ResponseHandler *handler, uint16_t timeout = 0 ); 00148 00149 //------------------------------------------------------------------------ 00157 //------------------------------------------------------------------------ 00158 XRootDStatus VectorWrite( const ChunkList &chunks, 00159 ResponseHandler *handler, uint16_t timeout = 0 ); 00160 00161 //------------------------------------------------------------------------ 00171 //------------------------------------------------------------------------ 00172 XRootDStatus WriteV( uint64_t offset, 00173 ChunkList *chunks, 00174 ResponseHandler *handler, 00175 uint16_t timeout = 0 ); 00176 00177 //------------------------------------------------------------------------ 00184 //------------------------------------------------------------------------ 00185 XRootDStatus QueueTask( XRootDStatus *st, AnyObject *obj, 00186 ResponseHandler *handler ); 00187 00188 //------------------------------------------------------------------------ 00198 //------------------------------------------------------------------------ 00199 XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler, 00200 uint16_t timeout = 0 ); 00201 00202 //------------------------------------------------------------------------ 00211 //------------------------------------------------------------------------ 00212 XRootDStatus Visa( ResponseHandler *handler, uint16_t timeout = 0 ); 00213 00214 00215 //------------------------------------------------------------------------ 00226 //------------------------------------------------------------------------ 00227 XRootDStatus SetXAttr( const std::vector<xattr_t> &attrs, 00228 ResponseHandler *handler, 00229 uint16_t timeout = 0 ); 00230 00231 //------------------------------------------------------------------------ 00242 //------------------------------------------------------------------------ 00243 XRootDStatus GetXAttr( const std::vector<std::string> &attrs, 00244 ResponseHandler *handler, 00245 uint16_t timeout = 0 ); 00246 00247 //------------------------------------------------------------------------ 00258 //------------------------------------------------------------------------ 00259 XRootDStatus DelXAttr( const std::vector<std::string> &attrs, 00260 ResponseHandler *handler, 00261 uint16_t timeout = 0 ); 00262 00263 //------------------------------------------------------------------------ 00273 //------------------------------------------------------------------------ 00274 XRootDStatus ListXAttr( ResponseHandler *handler, 00275 uint16_t timeout = 0 ); 00276 00277 //------------------------------------------------------------------------ 00283 //------------------------------------------------------------------------ 00284 static XRootDStatus MkdirPath( const std::string &path ); 00285 00286 void SetHostList( const HostList &hostList ) 00287 { 00288 pHostList = hostList; 00289 } 00290 00291 const HostList& GetHostList() 00292 { 00293 return pHostList; 00294 } 00295 00296 //------------------------------------------------------------------------ 00298 //------------------------------------------------------------------------ 00299 XRootDStatus ExecRequest( const URL &url, 00300 Message *msg, 00301 ResponseHandler *handler, 00302 MessageSendParams &sendParams ); 00303 00304 private: 00305 00306 XRootDStatus OpenImpl( const std::string &url, uint16_t flags, 00307 uint16_t mode, AnyObject *&resp ); 00308 00309 //------------------------------------------------------------------------ 00311 //------------------------------------------------------------------------ 00312 XRootDStatus XAttrImpl( kXR_char code, 00313 kXR_char numattr, 00314 size_t bodylen, 00315 char *body, 00316 ResponseHandler *handler ); 00317 00318 //--------------------------------------------------------------------- 00319 // Receives LocalFileTasks to handle them async 00320 //--------------------------------------------------------------------- 00321 JobManager *jmngr; 00322 00323 //--------------------------------------------------------------------- 00324 // Internal filedescriptor, which is used by all operations after open 00325 //--------------------------------------------------------------------- 00326 int fd; 00327 00328 //--------------------------------------------------------------------- 00329 // The file URL 00330 //--------------------------------------------------------------------- 00331 std::string pUrl; 00332 00333 //--------------------------------------------------------------------- 00334 // The host list returned in the user callback 00335 //--------------------------------------------------------------------- 00336 HostList pHostList; 00337 00338 }; 00339 } 00340 #endif