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