1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
12 #ifndef RGW_REPLICA_LOG_H_
13 #define RGW_REPLICA_LOG_H_
16 #include "cls/replica_log/cls_replica_log_types.h"
17 #include "include/types.h"
18 #include "include/utime.h"
19 #include "include/rados/librados.hpp"
20 #include "rgw_common.h"
25 #define META_REPLICA_LOG_OBJ_PREFIX "meta.replicalog."
26 #define DATA_REPLICA_LOG_OBJ_PREFIX "data.replicalog."
28 typedef cls_replica_log_item_marker RGWReplicaItemMarker;
29 typedef cls_replica_log_progress_marker RGWReplicaProgressMarker;
31 struct RGWReplicaBounds {
34 list<RGWReplicaProgressMarker> markers;
36 void dump(Formatter *f) const;
37 void decode_json(JSONObj *obj);
40 class RGWReplicaLogger {
44 int open_ioctx(librados::IoCtx& ctx, const rgw_pool& pool);
46 explicit RGWReplicaLogger(RGWRados *_store);
48 int update_bound(const string& oid, const rgw_pool& pool,
49 const string& daemon_id, const string& marker,
51 const list<RGWReplicaItemMarker> *entries,
53 int write_bounds(const string& oid, const rgw_pool& pool,
54 RGWReplicaBounds& bounds);
55 int delete_bound(const string& oid, const rgw_pool& pool,
56 const string& daemon_id, bool purge_all,
58 int get_bounds(const string& oid, const rgw_pool& pool,
59 RGWReplicaBounds& bounds);
62 class RGWReplicaObjectLogger : private RGWReplicaLogger {
66 void get_shard_oid(int id, string& oid) {
68 snprintf(buf, sizeof(buf), "%d", id);
73 RGWReplicaObjectLogger(RGWRados *_store,
74 const rgw_pool& _pool,
75 const string& _prefix);
77 int create_log_objects(int shards);
78 int update_bound(int shard, const string& daemon_id, const string& marker,
80 const list<RGWReplicaItemMarker> *entries) {
82 get_shard_oid(shard, oid);
83 return RGWReplicaLogger::update_bound(oid, pool,
84 daemon_id, marker, time, entries, false);
86 int delete_bound(int shard, const string& daemon_id, bool purge_all) {
88 get_shard_oid(shard, oid);
89 return RGWReplicaLogger::delete_bound(oid, pool,
90 daemon_id, purge_all, false);
92 int get_bounds(int shard, RGWReplicaBounds& bounds) {
94 get_shard_oid(shard, oid);
95 return RGWReplicaLogger::get_bounds(oid, pool, bounds);
99 class RGWReplicaBucketLogger : private RGWReplicaLogger {
103 string obj_name(const rgw_bucket& bucket, int shard_id, bool index_by_instance);
106 explicit RGWReplicaBucketLogger(RGWRados *_store);
107 int update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
108 const string& marker, const utime_t& time,
109 const list<RGWReplicaItemMarker> *entries);
110 int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool purge_all);
111 int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds);
112 int convert_old_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds);
115 #endif /* RGW_REPLICA_LOG_H_ */