Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / replica_log / cls_replica_log_client.h
1 /*
2  * Ceph - scalable distributed file system
3  *
4  * This is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License version 2.1, as published by the Free Software
7  * Foundation.  See file COPYING.
8  *
9  * Copyright 2013 Inktank
10  */
11
12 #ifndef CLS_REPLICA_LOG_CLIENT_H_
13 #define CLS_REPLICA_LOG_CLIENT_H_
14
15 #include "cls_replica_log_ops.h"
16
17 namespace librados {
18   class ObjectWriteOperation;
19   class IoCtx;
20 }
21
22 /**
23  * Prepare a progress marker object to send out.
24  *
25  * @param progress The marker object to prepare
26  * @param entity The ID of the entity setting the progress
27  * @param marker The marker key the entity has gotten to
28  * @param time The timestamp associated with the marker
29  * param entries A list of in-progress entries prior to the marker
30  */
31 void cls_replica_log_prepare_marker(cls_replica_log_progress_marker& progress,
32                                     const string& entity, const string& marker,
33                                     const utime_t& time,
34                                     const list<pair<string, utime_t> > *entries);
35
36 /**
37  * Extract a progress marker object into its components.
38  *
39  * @param progress The marker object to extract data from
40  * @param entity [out] The ID of the entity the progress is associated with
41  * @param marker [out] The marker key the entity has gotten to
42  * @param time [out] The timestamp associated with the marker
43  * @param entries [out] List of in-progress entries prior to the marker
44  */
45 void cls_replica_log_extract_marker(const cls_replica_log_progress_marker& progress,
46                                     string& entity, string& marker,
47                                     utime_t& time,
48                                     list<pair<string, utime_t> >& entries);
49
50 /**
51  * Add a progress marker update to a write op. The op will return 0 on
52  * success, -EEXIST if the marker conflicts with an existing one, or
53  * -EINVAL if the marker is in conflict (ie, before) the daemon's existing
54  * marker.
55  *
56  * @param op The op to add the update to
57  * @param progress The progress marker to send
58  */
59 void cls_replica_log_update_bound(librados::ObjectWriteOperation& op,
60                                   const cls_replica_log_progress_marker& progress);
61
62 /**
63  * Remove an entity's progress marker from the replica log. The op will return
64  * 0 on success, -ENOENT if the entity does not exist on the replica log, or
65  * -ENOTEMPTY if the items list on the marker is not empty.
66  *
67  * @param op The op to add the delete to
68  * @param entity The entity whose progress should be removed
69  */
70 void cls_replica_log_delete_bound(librados::ObjectWriteOperation& op,
71                                   const string& entity);
72
73 /**
74  * Read the bounds on a replica log.
75  *
76  * @param io_ctx The IoCtx to use for the read
77  * @param oid The oid to direct the read to
78  * @param position_marker [out] The lowest marker key that has been reached
79  * @param oldest_time [out] Timestamp corresponding to the position marker or
80  * oldest in-progress item.
81  * @param markers [out] List of progress markers for individual daemons
82  */
83 int cls_replica_log_get_bounds(librados::IoCtx& io_ctx, const string& oid,
84                                 string& position_marker,
85                                 utime_t& oldest_time,
86                                 list<cls_replica_log_progress_marker>& markers);
87
88 #endif /* CLS_REPLICA_LOG_CLIENT_H_ */