1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "cls/timeindex/cls_timeindex_ops.h"
7 #include "cls/timeindex/cls_timeindex_client.h"
8 #include "include/compat.h"
10 void cls_timeindex_add(
11 librados::ObjectWriteOperation
& op
,
12 std::list
<cls_timeindex_entry
>& entries
)
14 librados::bufferlist in
;
15 cls_timeindex_add_op call
;
16 call
.entries
= entries
;
19 op
.exec("timeindex", "add", in
);
22 void cls_timeindex_add(
23 librados::ObjectWriteOperation
& op
,
24 cls_timeindex_entry
& entry
)
26 librados::bufferlist in
;
27 cls_timeindex_add_op call
;
28 call
.entries
.push_back(entry
);
31 op
.exec("timeindex", "add", in
);
34 void cls_timeindex_add_prepare_entry(
35 cls_timeindex_entry
& entry
,
36 const utime_t
& key_timestamp
,
37 const std::string
& key_ext
,
38 const librados::bufferlist
& bl
)
40 entry
.key_ts
= key_timestamp
;
41 entry
.key_ext
= key_ext
;
45 void cls_timeindex_add(
46 librados::ObjectWriteOperation
& op
,
47 const utime_t
& key_timestamp
,
48 const std::string
& key_ext
,
49 const librados::bufferlist
& bl
)
51 cls_timeindex_entry entry
;
52 cls_timeindex_add_prepare_entry(entry
, key_timestamp
, key_ext
, bl
);
53 cls_timeindex_add(op
, entry
);
56 void cls_timeindex_trim(
57 librados::ObjectWriteOperation
& op
,
58 const utime_t
& from_time
,
59 const utime_t
& to_time
,
60 const std::string
& from_marker
,
61 const std::string
& to_marker
)
63 librados::bufferlist in
;
64 cls_timeindex_trim_op call
;
65 call
.from_time
= from_time
;
66 call
.to_time
= to_time
;
67 call
.from_marker
= from_marker
;
68 call
.to_marker
= to_marker
;
72 op
.exec("timeindex", "trim", in
);
75 int cls_timeindex_trim(
76 librados::IoCtx
& io_ctx
,
77 const std::string
& oid
,
78 const utime_t
& from_time
,
79 const utime_t
& to_time
,
80 const std::string
& from_marker
,
81 const std::string
& to_marker
)
86 librados::ObjectWriteOperation op
;
87 cls_timeindex_trim(op
, from_time
, to_time
, from_marker
, to_marker
);
88 int r
= io_ctx
.operate(oid
, &op
);
99 void cls_timeindex_list(
100 librados::ObjectReadOperation
& op
,
103 const std::string
& in_marker
,
104 const int max_entries
,
105 std::list
<cls_timeindex_entry
>& entries
,
106 std::string
*out_marker
,
109 librados::bufferlist in
;
110 cls_timeindex_list_op call
;
111 call
.from_time
= from
;
113 call
.marker
= in_marker
;
114 call
.max_entries
= max_entries
;
118 op
.exec("timeindex", "list", in
,
119 new TimeindexListCtx(&entries
, out_marker
, truncated
));