]>
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_LOG_OPS_H | |
5 | #define CEPH_CLS_LOG_OPS_H | |
6 | ||
7c673cae FG |
7 | #include "cls_log_types.h" |
8 | ||
9 | struct cls_log_add_op { | |
10 | list<cls_log_entry> entries; | |
11 | bool monotonic_inc; | |
12 | ||
13 | cls_log_add_op() : monotonic_inc(true) {} | |
14 | ||
15 | void encode(bufferlist& bl) const { | |
16 | ENCODE_START(2, 1, bl); | |
11fdf7f2 TL |
17 | encode(entries, bl); |
18 | encode(monotonic_inc, bl); | |
7c673cae FG |
19 | ENCODE_FINISH(bl); |
20 | } | |
21 | ||
11fdf7f2 | 22 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 23 | DECODE_START(2, bl); |
11fdf7f2 | 24 | decode(entries, bl); |
7c673cae | 25 | if (struct_v >= 2) { |
11fdf7f2 | 26 | decode(monotonic_inc, bl); |
7c673cae FG |
27 | } |
28 | DECODE_FINISH(bl); | |
29 | } | |
30 | }; | |
31 | WRITE_CLASS_ENCODER(cls_log_add_op) | |
32 | ||
33 | struct cls_log_list_op { | |
34 | utime_t from_time; | |
35 | string marker; /* if not empty, overrides from_time */ | |
36 | utime_t to_time; /* not inclusive */ | |
37 | int max_entries; /* upperbound to returned num of entries | |
38 | might return less than that and still be truncated */ | |
39 | ||
40 | cls_log_list_op() : max_entries(0) {} | |
41 | ||
42 | void encode(bufferlist& bl) const { | |
43 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
44 | encode(from_time, bl); |
45 | encode(marker, bl); | |
46 | encode(to_time, bl); | |
47 | encode(max_entries, bl); | |
7c673cae FG |
48 | ENCODE_FINISH(bl); |
49 | } | |
50 | ||
11fdf7f2 | 51 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 52 | DECODE_START(1, bl); |
11fdf7f2 TL |
53 | decode(from_time, bl); |
54 | decode(marker, bl); | |
55 | decode(to_time, bl); | |
56 | decode(max_entries, bl); | |
7c673cae FG |
57 | DECODE_FINISH(bl); |
58 | } | |
59 | }; | |
60 | WRITE_CLASS_ENCODER(cls_log_list_op) | |
61 | ||
62 | struct cls_log_list_ret { | |
63 | list<cls_log_entry> entries; | |
64 | string marker; | |
65 | bool truncated; | |
66 | ||
67 | cls_log_list_ret() : truncated(false) {} | |
68 | ||
69 | void encode(bufferlist& bl) const { | |
70 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
71 | encode(entries, bl); |
72 | encode(marker, bl); | |
73 | encode(truncated, bl); | |
7c673cae FG |
74 | ENCODE_FINISH(bl); |
75 | } | |
76 | ||
11fdf7f2 | 77 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 78 | DECODE_START(1, bl); |
11fdf7f2 TL |
79 | decode(entries, bl); |
80 | decode(marker, bl); | |
81 | decode(truncated, bl); | |
7c673cae FG |
82 | DECODE_FINISH(bl); |
83 | } | |
84 | }; | |
85 | WRITE_CLASS_ENCODER(cls_log_list_ret) | |
86 | ||
87 | ||
88 | /* | |
89 | * operation will return 0 when successfully removed but not done. Will return | |
90 | * -ENODATA when done, so caller needs to repeat sending request until that. | |
91 | */ | |
92 | struct cls_log_trim_op { | |
93 | utime_t from_time; | |
94 | utime_t to_time; /* inclusive */ | |
95 | string from_marker; | |
96 | string to_marker; | |
97 | ||
98 | cls_log_trim_op() {} | |
99 | ||
100 | void encode(bufferlist& bl) const { | |
101 | ENCODE_START(2, 1, bl); | |
11fdf7f2 TL |
102 | encode(from_time, bl); |
103 | encode(to_time, bl); | |
104 | encode(from_marker, bl); | |
105 | encode(to_marker, bl); | |
7c673cae FG |
106 | ENCODE_FINISH(bl); |
107 | } | |
108 | ||
11fdf7f2 | 109 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 110 | DECODE_START(2, bl); |
11fdf7f2 TL |
111 | decode(from_time, bl); |
112 | decode(to_time, bl); | |
7c673cae | 113 | if (struct_v >= 2) { |
11fdf7f2 TL |
114 | decode(from_marker, bl); |
115 | decode(to_marker, bl); | |
7c673cae FG |
116 | } |
117 | DECODE_FINISH(bl); | |
118 | } | |
119 | }; | |
120 | WRITE_CLASS_ENCODER(cls_log_trim_op) | |
121 | ||
122 | struct cls_log_info_op { | |
123 | cls_log_info_op() {} | |
124 | ||
125 | void encode(bufferlist& bl) const { | |
126 | ENCODE_START(1, 1, bl); | |
127 | // currently empty request | |
128 | ENCODE_FINISH(bl); | |
129 | } | |
130 | ||
11fdf7f2 | 131 | void decode(bufferlist::const_iterator& bl) { |
7c673cae FG |
132 | DECODE_START(1, bl); |
133 | // currently empty request | |
134 | DECODE_FINISH(bl); | |
135 | } | |
136 | }; | |
137 | WRITE_CLASS_ENCODER(cls_log_info_op) | |
138 | ||
139 | struct cls_log_info_ret { | |
140 | cls_log_header header; | |
141 | ||
142 | void encode(bufferlist& bl) const { | |
143 | ENCODE_START(1, 1, bl); | |
11fdf7f2 | 144 | encode(header, bl); |
7c673cae FG |
145 | ENCODE_FINISH(bl); |
146 | } | |
147 | ||
11fdf7f2 | 148 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 149 | DECODE_START(1, bl); |
11fdf7f2 | 150 | decode(header, bl); |
7c673cae FG |
151 | DECODE_FINISH(bl); |
152 | } | |
153 | }; | |
154 | WRITE_CLASS_ENCODER(cls_log_info_ret) | |
155 | ||
156 | #endif |