]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_CLS_TIMEINDEX_CLIENT_H | |
5 | #define CEPH_CLS_TIMEINDEX_CLIENT_H | |
6 | ||
7c673cae | 7 | #include "include/rados/librados.hpp" |
31f18b77 FG |
8 | |
9 | #include "cls_timeindex_ops.h" | |
10 | ||
7c673cae FG |
11 | /** |
12 | * timeindex objclass | |
13 | */ | |
14 | class TimeindexListCtx : public librados::ObjectOperationCompletion { | |
15 | std::list<cls_timeindex_entry> *entries; | |
16 | std::string *marker; | |
17 | bool *truncated; | |
18 | ||
19 | public: | |
20 | ///* ctor | |
21 | TimeindexListCtx( | |
22 | std::list<cls_timeindex_entry> *_entries, | |
23 | std::string *_marker, | |
24 | bool *_truncated) | |
25 | : entries(_entries), marker(_marker), truncated(_truncated) {} | |
26 | ||
27 | ///* dtor | |
28 | ~TimeindexListCtx() {} | |
29 | ||
30 | void handle_completion(int r, bufferlist& bl) override { | |
31 | if (r >= 0) { | |
32 | cls_timeindex_list_ret ret; | |
33 | try { | |
11fdf7f2 TL |
34 | auto iter = bl.cbegin(); |
35 | decode(ret, iter); | |
7c673cae FG |
36 | if (entries) |
37 | *entries = ret.entries; | |
38 | if (truncated) | |
39 | *truncated = ret.truncated; | |
40 | if (marker) | |
41 | *marker = ret.marker; | |
42 | } catch (buffer::error& err) { | |
43 | // nothing we can do about it atm | |
44 | } | |
45 | } | |
46 | } | |
47 | }; | |
48 | ||
49 | void cls_timeindex_add_prepare_entry( | |
50 | cls_timeindex_entry& entry, | |
51 | const utime_t& key_timestamp, | |
52 | const std::string& key_ext, | |
53 | bufferlist& bl); | |
54 | ||
55 | void cls_timeindex_add( | |
56 | librados::ObjectWriteOperation& op, | |
57 | const std::list<cls_timeindex_entry>& entry); | |
58 | ||
59 | void cls_timeindex_add( | |
60 | librados::ObjectWriteOperation& op, | |
61 | const cls_timeindex_entry& entry); | |
62 | ||
63 | void cls_timeindex_add( | |
64 | librados::ObjectWriteOperation& op, | |
65 | const utime_t& timestamp, | |
66 | const std::string& name, | |
67 | const bufferlist& bl); | |
68 | ||
69 | void cls_timeindex_list( | |
70 | librados::ObjectReadOperation& op, | |
71 | const utime_t& from, | |
72 | const utime_t& to, | |
73 | const std::string& in_marker, | |
74 | const int max_entries, | |
75 | std::list<cls_timeindex_entry>& entries, | |
76 | std::string *out_marker, | |
77 | bool *truncated); | |
78 | ||
79 | void cls_timeindex_trim( | |
80 | librados::ObjectWriteOperation& op, | |
81 | const utime_t& from_time, | |
82 | const utime_t& to_time, | |
83 | const std::string& from_marker = std::string(), | |
84 | const std::string& to_marker = std::string()); | |
85 | ||
86 | int cls_timeindex_trim( | |
87 | librados::IoCtx& io_ctx, | |
88 | const std::string& oid, | |
89 | const utime_t& from_time, | |
90 | const utime_t& to_time, | |
91 | const std::string& from_marker = std::string(), | |
92 | const std::string& to_marker = std::string()); | |
93 | #endif |