]>
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 TL |
28 | |
29 | // passes the data on to the next processor | |
30 | int process(bufferlist&& data, uint64_t offset) override { | |
31 | return next->process(std::move(data), offset); | |
32 | } | |
33 | }; | |
34 | ||
35 | // pipe that writes to the next processor in discrete chunks | |
36 | class ChunkProcessor : public Pipe { | |
37 | uint64_t chunk_size; | |
38 | bufferlist chunk; // leftover bytes from the last call to process() | |
39 | public: | |
20effc67 | 40 | ChunkProcessor(rgw::sal::DataProcessor *next, uint64_t chunk_size) |
11fdf7f2 TL |
41 | : Pipe(next), chunk_size(chunk_size) |
42 | {} | |
43 | ||
44 | int process(bufferlist&& data, uint64_t offset) override; | |
45 | }; | |
46 | ||
47 | ||
48 | // interface to generate the next stripe description | |
49 | class StripeGenerator { | |
50 | public: | |
51 | virtual ~StripeGenerator() {} | |
52 | ||
53 | virtual int next(uint64_t offset, uint64_t *stripe_size) = 0; | |
54 | }; | |
55 | ||
56 | // pipe that respects stripe boundaries and restarts each stripe at offset 0 | |
57 | class StripeProcessor : public Pipe { | |
58 | StripeGenerator *gen; | |
59 | std::pair<uint64_t, uint64_t> bounds; // bounds of current stripe | |
60 | public: | |
20effc67 | 61 | StripeProcessor(rgw::sal::DataProcessor *next, StripeGenerator *gen, |
11fdf7f2 TL |
62 | uint64_t first_stripe_size) |
63 | : Pipe(next), gen(gen), bounds(0, first_stripe_size) | |
64 | {} | |
65 | ||
66 | int process(bufferlist&& data, uint64_t data_offset) override; | |
67 | }; | |
68 | ||
69 | } // namespace rgw::putobj |