1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "include/types.h"
7 #include "cls/timeindex/cls_timeindex_ops.h"
8 #include "cls/timeindex/cls_timeindex_client.h"
9 #include "include/rados/librados.hpp"
10 #include "include/compat.h"
12 void cls_timeindex_add(
13 librados::ObjectWriteOperation
& op
,
14 std::list
<cls_timeindex_entry
>& entries
)
16 librados::bufferlist in
;
17 cls_timeindex_add_op call
;
18 call
.entries
= entries
;
21 op
.exec("timeindex", "add", in
);
24 void cls_timeindex_add(
25 librados::ObjectWriteOperation
& op
,
26 cls_timeindex_entry
& entry
)
28 librados::bufferlist in
;
29 cls_timeindex_add_op call
;
30 call
.entries
.push_back(entry
);
33 op
.exec("timeindex", "add", in
);
36 void cls_timeindex_add_prepare_entry(
37 cls_timeindex_entry
& entry
,
38 const utime_t
& key_timestamp
,
39 const std::string
& key_ext
,
40 const librados::bufferlist
& bl
)
42 entry
.key_ts
= key_timestamp
;
43 entry
.key_ext
= key_ext
;
47 void cls_timeindex_add(
48 librados::ObjectWriteOperation
& op
,
49 const utime_t
& key_timestamp
,
50 const std::string
& key_ext
,
51 const librados::bufferlist
& bl
)
53 cls_timeindex_entry entry
;
54 cls_timeindex_add_prepare_entry(entry
, key_timestamp
, key_ext
, bl
);
55 cls_timeindex_add(op
, entry
);
58 void cls_timeindex_trim(
59 librados::ObjectWriteOperation
& op
,
60 const utime_t
& from_time
,
61 const utime_t
& to_time
,
62 const std::string
& from_marker
,
63 const std::string
& to_marker
)
65 librados::bufferlist in
;
66 cls_timeindex_trim_op call
;
67 call
.from_time
= from_time
;
68 call
.to_time
= to_time
;
69 call
.from_marker
= from_marker
;
70 call
.to_marker
= to_marker
;
74 op
.exec("timeindex", "trim", in
);
77 int cls_timeindex_trim(
78 librados::IoCtx
& io_ctx
,
79 const std::string
& oid
,
80 const utime_t
& from_time
,
81 const utime_t
& to_time
,
82 const std::string
& from_marker
,
83 const std::string
& to_marker
)
88 librados::ObjectWriteOperation op
;
89 cls_timeindex_trim(op
, from_time
, to_time
, from_marker
, to_marker
);
90 int r
= io_ctx
.operate(oid
, &op
);
101 void cls_timeindex_list(
102 librados::ObjectReadOperation
& op
,
105 const std::string
& in_marker
,
106 const int max_entries
,
107 std::list
<cls_timeindex_entry
>& entries
,
108 std::string
*out_marker
,
111 librados::bufferlist in
;
112 cls_timeindex_list_op call
;
113 call
.from_time
= from
;
115 call
.marker
= in_marker
;
116 call
.max_entries
= max_entries
;
120 op
.exec("timeindex", "list", in
,
121 new TimeindexListCtx(&entries
, out_marker
, truncated
));