XRootD
Loading...
Searching...
No Matches
XrdClS3File.hh
Go to the documentation of this file.
1/******************************************************************************/
2/* Copyright (C) 2025, Pelican Project, Morgridge Institute for Research */
3/* */
4/* This file is part of the XrdClS3 client plugin for XRootD. */
5/* */
6/* XRootD is free software: you can redistribute it and/or modify it under */
7/* the terms of the GNU Lesser General Public License as published by the */
8/* Free Software Foundation, either version 3 of the License, or (at your */
9/* option) any later version. */
10/* */
11/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
12/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
13/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
14/* License for more details. */
15/* */
16/* The copyright holder's institutional names and contributor's names may not */
17/* be used to endorse or promote products derived from this software without */
18/* specific prior written permission of the institution or contributor. */
19/******************************************************************************/
20
21#ifndef XRDCLS3_S3FILE_HH
22#define XRDCLS3_S3FILE_HH
23
25
26#include <XrdCl/XrdClFile.hh>
27
28namespace XrdCl {
29
30class Log;
31
32}
33
34namespace XrdClS3 {
35
36class File final : public XrdCl::FilePlugIn {
37public:
38 File(XrdCl::Log *log);
39
40 virtual ~File() noexcept;
41
43 time_t timeout) override;
44
45 virtual bool GetProperty( const std::string &name,
46 std::string &value ) const override;
47
48 virtual bool IsOpen() const override;
49
50 virtual XrdCl::XRootDStatus Open(const std::string &url,
54 time_t timeout) override;
55
56 virtual XrdCl::XRootDStatus PgRead(uint64_t offset,
57 uint32_t size,
58 void *buffer,
60 time_t timeout) override;
61
62 virtual XrdCl::XRootDStatus Read(uint64_t offset,
63 uint32_t size,
64 void *buffer,
66 time_t timeout) override;
67
68 virtual bool SetProperty( const std::string &name,
69 const std::string &value ) override;
70
71 virtual XrdCl::XRootDStatus Stat(bool force,
73 time_t timeout) override;
74
76 void *buffer,
78 time_t timeout ) override;
79
80 virtual XrdCl::XRootDStatus Write(uint64_t offset,
81 uint32_t size,
82 const void *buffer,
84 time_t timeout) override;
85
86 virtual XrdCl::XRootDStatus Write(uint64_t offset,
87 XrdCl::Buffer &&buffer,
89 time_t timeout) override;
90
91private:
92 bool m_is_opened{false};
93
94 // The flags used to open the file
96
97 std::string m_url;
98 XrdCl::Log *m_logger{nullptr};
99 mutable std::mutex m_properties_mutex;
100 std::unordered_map<std::string, std::string> m_properties;
101
102 std::unique_ptr<XrdCl::File> m_wrapped_file;
103
104 // Given a path, provide the corresponding HTTP file handle.
105 std::tuple<XrdCl::XRootDStatus, std::string, XrdCl::File*> GetFileHandle(const std::string &url);
106
107 // Class for setting up the required HTTP headers for S3 requests
108 class S3HeaderCallout : public XrdClHttp::HeaderCallout {
109 public:
110 S3HeaderCallout(File &fs) : m_parent(fs)
111 {}
112
113 virtual ~S3HeaderCallout() noexcept = default;
114
115 virtual std::shared_ptr<HeaderList> GetHeaders(const std::string &verb,
116 const std::string &url,
117 const HeaderList &headers) override;
118
119 private:
120 File &m_parent;
121 };
122
123 S3HeaderCallout m_header_callout{*this};
124};
125
126}
127
128#endif // XRDCLS3_S3FILE_HH
struct stat Stat
Definition XrdCks.cc:49
XrdOucString File
std::vector< std::pair< std::string, std::string > > HeaderList
virtual XrdCl::XRootDStatus Open(const std::string &url, XrdCl::OpenFlags::Flags flags, XrdCl::Access::Mode mode, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual bool SetProperty(const std::string &name, const std::string &value) override
virtual bool IsOpen() const override
virtual XrdCl::XRootDStatus VectorRead(const XrdCl::ChunkList &chunks, void *buffer, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual ~File() noexcept
virtual bool GetProperty(const std::string &name, std::string &value) const override
File(XrdCl::Log *log)
virtual XrdCl::XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Close(XrdCl::ResponseHandler *handler, time_t timeout) override
Binary blob representation.
An interface for file plug-ins.
Handle diagnostics.
Definition XrdClLog.hh:101
Handle an async response.
std::vector< ChunkInfo > ChunkList
List of chunks.
Flags
Open flags, may be or'd when appropriate.