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 //------------------------------------------------------------------------ 00219 //------------------------------------------------------------------------ 00220 static XRootDStatus MkdirPath( const std::string &path ); 00221 00222 void SetHostList( const HostList &hostList ) 00223 { 00224 pHostList = hostList; 00225 } 00226 00227 const HostList& GetHostList() 00228 { 00229 return pHostList; 00230 } 00231 00232 //------------------------------------------------------------------------ 00234 //------------------------------------------------------------------------ 00235 XRootDStatus ExecRequest( const URL &url, 00236 Message *msg, 00237 ResponseHandler *handler, 00238 MessageSendParams &sendParams ); 00239 00240 private: 00241 00242 XRootDStatus OpenImpl( const std::string &url, uint16_t flags, 00243 uint16_t mode, AnyObject *&resp ); 00244 00245 //--------------------------------------------------------------------- 00246 // Receives LocalFileTasks to handle them async 00247 //--------------------------------------------------------------------- 00248 JobManager *jmngr; 00249 00250 //--------------------------------------------------------------------- 00251 // Internal filedescriptor, which is used by all operations after open 00252 //--------------------------------------------------------------------- 00253 int fd; 00254 00255 //--------------------------------------------------------------------- 00256 // The file URL 00257 //--------------------------------------------------------------------- 00258 std::string pUrl; 00259 00260 //--------------------------------------------------------------------- 00261 // The host list returned in the user callback 00262 //--------------------------------------------------------------------- 00263 HostList pHostList; 00264 00265 }; 00266 } 00267 #endif