]>
Commit | Line | Data |
---|---|---|
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 | ||
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); | |
17 | ::encode(entries, bl); | |
18 | ::encode(monotonic_inc, bl); | |
19 | ENCODE_FINISH(bl); | |
20 | } | |
21 | ||
22 | void decode(bufferlist::iterator& bl) { | |
23 | DECODE_START(2, bl); | |
24 | ::decode(entries, bl); | |
25 | if (struct_v >= 2) { | |
26 | ::decode(monotonic_inc, bl); | |
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); | |
44 | ::encode(from_time, bl); | |
45 | ::encode(marker, bl); | |
46 | ::encode(to_time, bl); | |
47 | ::encode(max_entries, bl); | |
48 | ENCODE_FINISH(bl); | |
49 | } | |
50 | ||
51 | void decode(bufferlist::iterator& bl) { | |
52 | DECODE_START(1, bl); | |
53 | ::decode(from_time, bl); | |
54 | ::decode(marker, bl); | |
55 | ::decode(to_time, bl); | |
56 | ::decode(max_entries, bl); | |
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); | |
71 | ::encode(entries, bl); | |
72 | ::encode(marker, bl); | |
73 | ::encode(truncated, bl); | |
74 | ENCODE_FINISH(bl); | |
75 | } | |
76 | ||
77 | void decode(bufferlist::iterator& bl) { | |
78 | DECODE_START(1, bl); | |
79 | ::decode(entries, bl); | |
80 | ::decode(marker, bl); | |
81 | ::decode(truncated, bl); | |
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); | |
102 | ::encode(from_time, bl); | |
103 | ::encode(to_time, bl); | |
104 | ::encode(from_marker, bl); | |
105 | ::encode(to_marker, bl); | |
106 | ENCODE_FINISH(bl); | |
107 | } | |
108 | ||
109 | void decode(bufferlist::iterator& bl) { | |
110 | DECODE_START(2, bl); | |
111 | ::decode(from_time, bl); | |
112 | ::decode(to_time, bl); | |
113 | if (struct_v >= 2) { | |
114 | ::decode(from_marker, bl); | |
115 | ::decode(to_marker, bl); | |
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 | ||
131 | void decode(bufferlist::iterator& bl) { | |
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); | |
144 | ::encode(header, bl); | |
145 | ENCODE_FINISH(bl); | |
146 | } | |
147 | ||
148 | void decode(bufferlist::iterator& bl) { | |
149 | DECODE_START(1, bl); | |
150 | ::decode(header, bl); | |
151 | DECODE_FINISH(bl); | |
152 | } | |
153 | }; | |
154 | WRITE_CLASS_ENCODER(cls_log_info_ret) | |
155 | ||
156 | #endif |