]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 TL |
3 | |
4 | /* | |
5 | * Ceph - scalable distributed file system | |
6 | * | |
7 | * Copyright (C) 2018 Red Hat, Inc. | |
8 | * | |
9 | * This is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License version 2.1, as published by the Free Software | |
12 | * Foundation. See file COPYING. | |
13 | * | |
14 | */ | |
15 | ||
16 | #pragma once | |
17 | ||
18 | #include "include/buffer.h" | |
20effc67 | 19 | #include "rgw_sal.h" |
11fdf7f2 TL |
20 | |
21 | namespace rgw::putobj { | |
22 | ||
11fdf7f2 | 23 | // for composing data processors into a pipeline |
20effc67 TL |
24 | class Pipe : public rgw::sal::DataProcessor { |
25 | rgw::sal::DataProcessor *next; | |
11fdf7f2 | 26 | public: |
20effc67 | 27 | explicit Pipe(rgw::sal::DataProcessor *next) : next(next) {} |
11fdf7f2 | 28 | |
1e59de90 TL |
29 | virtual ~Pipe() override {} |
30 | ||
11fdf7f2 TL |
31 | // passes the data on to the next processor |
32 | int process(bufferlist&& data, uint64_t offset) override { | |
33 | return next->process(std::move(data), offset); | |
34 | } | |
35 | }; | |
36 | ||
37 | // pipe that writes to the next processor in discrete chunks | |
38 | class ChunkProcessor : public Pipe { | |
39 | uint64_t chunk_size; | |
40 | bufferlist chunk; // leftover bytes from the last call to process() | |
41 | public: | |
20effc67 | 42 | ChunkProcessor(rgw::sal::DataProcessor *next, uint64_t chunk_size) |
11fdf7f2 TL |
43 | : Pipe(next), chunk_size(chunk_size) |
44 | {} | |
1e59de90 | 45 | virtual ~ChunkProcessor() override {} |
11fdf7f2 TL |
46 | |
47 | int process(bufferlist&& data, uint64_t offset) override; | |
48 | }; | |
49 | ||
50 | ||
51 | // interface to generate the next stripe description | |
52 | class StripeGenerator { | |
53 | public: | |
54 | virtual ~StripeGenerator() {} | |
55 | ||
56 | virtual int next(uint64_t offset, uint64_t *stripe_size) = 0; | |
57 | }; | |
58 | ||
59 | // pipe that respects stripe boundaries and restarts each stripe at offset 0 | |
60 | class StripeProcessor : public Pipe { | |
61 | StripeGenerator *gen; | |
62 | std::pair<uint64_t, uint64_t> bounds; // bounds of current stripe | |
63 | public: | |
20effc67 | 64 | StripeProcessor(rgw::sal::DataProcessor *next, StripeGenerator *gen, |
11fdf7f2 TL |
65 | uint64_t first_stripe_size) |
66 | : Pipe(next), gen(gen), bounds(0, first_stripe_size) | |
67 | {} | |
1e59de90 | 68 | virtual ~StripeProcessor() override {} |
11fdf7f2 TL |
69 | |
70 | int process(bufferlist&& data, uint64_t data_offset) override; | |
71 | }; | |
72 | ||
73 | } // namespace rgw::putobj |