]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/migration/HttpStream.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / migration / HttpStream.h
CommitLineData
f67539c2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_LIBRBD_MIGRATION_HTTP_STREAM_H
5#define CEPH_LIBRBD_MIGRATION_HTTP_STREAM_H
6
7#include "include/int_types.h"
8#include "librbd/migration/StreamInterface.h"
9#include <boost/beast/http/message.hpp>
10#include <boost/beast/http/string_body.hpp>
11#include <json_spirit/json_spirit.h>
12#include <memory>
13#include <string>
14
15struct Context;
16
17namespace librbd {
18
19struct AsioEngine;
20struct ImageCtx;
21
22namespace migration {
23
24template <typename> class HttpClient;
25
26template <typename ImageCtxT>
27class HttpStream : public StreamInterface {
28public:
29 static HttpStream* create(ImageCtxT* image_ctx,
30 const json_spirit::mObject& json_object) {
31 return new HttpStream(image_ctx, json_object);
32 }
33
34 HttpStream(ImageCtxT* image_ctx, const json_spirit::mObject& json_object);
35 ~HttpStream() override;
36
37 HttpStream(const HttpStream&) = delete;
38 HttpStream& operator=(const HttpStream&) = delete;
39
40 void open(Context* on_finish) override;
41 void close(Context* on_finish) override;
42
43 void get_size(uint64_t* size, Context* on_finish) override;
44
45 void read(io::Extents&& byte_extents, bufferlist* data,
46 Context* on_finish) override;
47
48private:
49 using HttpResponse = boost::beast::http::response<
50 boost::beast::http::string_body>;
51
52 ImageCtxT* m_image_ctx;
53 CephContext* m_cct;
54 std::shared_ptr<AsioEngine> m_asio_engine;
55 json_spirit::mObject m_json_object;
56
57 std::string m_url;
58
59 std::unique_ptr<HttpClient<ImageCtxT>> m_http_client;
60
61};
62
63} // namespace migration
64} // namespace librbd
65
66extern template class librbd::migration::HttpStream<librbd::ImageCtx>;
67
68#endif // CEPH_LIBRBD_MIGRATION_HTTP_STREAM_H