2 * Ceph - scalable distributed file system
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.
12 #include "cls/replica_log/cls_replica_log_client.h"
13 #include "include/rados/librados.hpp"
15 using namespace librados;
17 void cls_replica_log_prepare_marker(cls_replica_log_progress_marker& progress,
18 const string& entity, const string& marker,
20 const list<pair<string, utime_t> > *entries)
22 progress.entity_id = entity;
23 progress.position_marker = marker;
24 progress.position_time = time;
26 list<pair<string, utime_t> >::const_iterator i;
27 for (i = entries->begin(); i != entries->end(); ++i) {
28 cls_replica_log_item_marker item(i->first, i->second);
29 progress.items.push_back(item);
34 void cls_replica_log_extract_marker(const cls_replica_log_progress_marker& progress,
35 string& entity, string& marker,
37 list<pair<string, utime_t> >& entries)
39 entity = progress.entity_id;
40 marker = progress.position_marker;
41 time = progress.position_time;
42 list<cls_replica_log_item_marker>::const_iterator i;
43 for (i = progress.items.begin(); i != progress.items.end(); ++i) {
44 entries.push_back(make_pair(i->item_name, i->item_timestamp));
48 void cls_replica_log_update_bound(librados::ObjectWriteOperation& o,
49 const cls_replica_log_progress_marker& progress)
51 cls_replica_log_set_marker_op op(progress);
54 o.exec("replica_log", "set", in);
57 void cls_replica_log_delete_bound(librados::ObjectWriteOperation& o,
60 cls_replica_log_delete_marker_op op(entity);
63 o.exec("replica_log", "delete", in);
66 int cls_replica_log_get_bounds(librados::IoCtx& io_ctx, const string& oid,
67 string& position_marker,
69 list<cls_replica_log_progress_marker>& markers)
73 cls_replica_log_get_bounds_op op;
75 int r = io_ctx.exec(oid, "replica_log", "get", in, out);
79 cls_replica_log_get_bounds_ret ret;
81 bufferlist::iterator i = out.begin();
83 } catch (buffer::error& err) {
87 position_marker = ret.position_marker;
88 oldest_time = ret.oldest_time;
89 markers = ret.markers;