1 /* 2 * This File is part of Davix, The IO library for HTTP based protocols 3 * Copyright (C) CERN 2013 4 * Author: Adrien Devresse <adrien.devresse@cern.ch> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 */ 21 22 #ifndef METALINKOPS_HPP 23 #define METALINKOPS_HPP 24 25 26 #include <davixcontext.hpp> 27 #include <params/davixrequestparams.hpp> 28 #include <file/davfile.hpp> 29 #include <fileops/httpiochain.hpp> 30 31 namespace Davix{ 32 33 /// 34 /// \brief The MetalinkOps class 35 /// 36 /// Metalink chain element 37 /// 38 /// the metalink chain element handle the recovery using metalink for any "reading" operation of the I/O chain 39 /// 40 class MetalinkOps: public HttpIOChain{ 41 public: 42 MetalinkOps(); 43 virtual ~MetalinkOps(); 44 45 virtual StatInfo & statInfo(IOChainContext &iocontext, StatInfo &st_info); 46 47 virtual dav_ssize_t read(IOChainContext & iocontext, void *buf, dav_size_t count); 48 49 virtual dav_ssize_t pread(IOChainContext & iocontext, void* buf, dav_size_t count, dav_off_t offset); 50 51 virtual dav_ssize_t preadVec(IOChainContext & iocontext, const DavIOVecInput * input_vec, 52 DavIOVecOuput * output_vec, 53 const dav_size_t count_vec); 54 55 // read to fd 56 virtual dav_ssize_t readToFd(IOChainContext & iocontext, int fd, dav_size_t size); 57 58 // calc replica 59 virtual std::vector<File> & getReplicas(IOChainContext & iocontext, std::vector<File> & vec); 60 61 62 }; 63 64 65 66 /// \brief The AutoRetry class 67 /// 68 /// AutoRetry chain element 69 /// 70 /// the Retry chain element handle the recovery using auto-retry for any "reading" operation of the I/O chain 71 /// 72 class AutoRetryOps: public HttpIOChain{ 73 public: 74 AutoRetryOps(); 75 virtual ~AutoRetryOps(); 76 77 virtual StatInfo & statInfo(IOChainContext &iocontext, StatInfo &st_info); 78 79 virtual dav_ssize_t read(IOChainContext & iocontext, void *buf, dav_size_t count); 80 81 virtual dav_ssize_t pread(IOChainContext & iocontext, void* buf, dav_size_t count, dav_off_t offset); 82 83 virtual dav_ssize_t preadVec(IOChainContext & iocontext, const DavIOVecInput * input_vec, 84 DavIOVecOuput * output_vec, 85 const dav_size_t count_vec); 86 87 // read to fd 88 virtual dav_ssize_t readToFd(IOChainContext & iocontext, int fd, dav_size_t size); 89 90 }; 91 92 93 // utilities 94 int davix_metalink_header_parser(const std::string & header_key, const std::string & header_value, 95 const Uri & u_original, 96 Uri & metalink); 97 98 99 } 100 101 #endif // METALINKOPS_HPP 102