]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_meta_sync_status.h
import quincy 17.2.0
[ceph.git] / ceph / src / rgw / rgw_meta_sync_status.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #ifndef RGW_META_SYNC_STATUS_H
5 #define RGW_META_SYNC_STATUS_H
6
7 #include <string>
8
9 #include "common/ceph_time.h"
10
11 struct rgw_meta_sync_info {
12 enum SyncState {
13 StateInit = 0,
14 StateBuildingFullSyncMaps = 1,
15 StateSync = 2,
16 };
17
18 uint16_t state;
19 uint32_t num_shards;
20 std::string period; //< period id of current metadata log
21 epoch_t realm_epoch = 0; //< realm epoch of period
22
23 void encode(bufferlist& bl) const {
24 ENCODE_START(2, 1, bl);
25 encode(state, bl);
26 encode(num_shards, bl);
27 encode(period, bl);
28 encode(realm_epoch, bl);
29 ENCODE_FINISH(bl);
30 }
31
32 void decode(bufferlist::const_iterator& bl) {
33 DECODE_START(1, bl);
34 decode(state, bl);
35 decode(num_shards, bl);
36 if (struct_v >= 2) {
37 decode(period, bl);
38 decode(realm_epoch, bl);
39 }
40 DECODE_FINISH(bl);
41 }
42
43 void decode_json(JSONObj *obj);
44 void dump(Formatter *f) const;
45 static void generate_test_instances(std::list<rgw_meta_sync_info*>& ls);
46
47 rgw_meta_sync_info() : state((int)StateInit), num_shards(0) {}
48 };
49 WRITE_CLASS_ENCODER(rgw_meta_sync_info)
50
51 struct rgw_meta_sync_marker {
52 enum SyncState {
53 FullSync = 0,
54 IncrementalSync = 1,
55 };
56 uint16_t state;
57 std::string marker;
58 std::string next_step_marker;
59 uint64_t total_entries;
60 uint64_t pos;
61 real_time timestamp;
62 epoch_t realm_epoch{0}; //< realm_epoch of period marker
63
64 rgw_meta_sync_marker() : state(FullSync), total_entries(0), pos(0) {}
65
66 void encode(bufferlist& bl) const {
67 ENCODE_START(2, 1, bl);
68 encode(state, bl);
69 encode(marker, bl);
70 encode(next_step_marker, bl);
71 encode(total_entries, bl);
72 encode(pos, bl);
73 encode(timestamp, bl);
74 encode(realm_epoch, bl);
75 ENCODE_FINISH(bl);
76 }
77
78 void decode(bufferlist::const_iterator& bl) {
79 DECODE_START(2, bl);
80 decode(state, bl);
81 decode(marker, bl);
82 decode(next_step_marker, bl);
83 decode(total_entries, bl);
84 decode(pos, bl);
85 decode(timestamp, bl);
86 if (struct_v >= 2) {
87 decode(realm_epoch, bl);
88 }
89 DECODE_FINISH(bl);
90 }
91
92 void decode_json(JSONObj *obj);
93 void dump(Formatter *f) const;
94 static void generate_test_instances(std::list<rgw_meta_sync_marker*>& ls);
95 };
96 WRITE_CLASS_ENCODER(rgw_meta_sync_marker)
97
98 struct rgw_meta_sync_status {
99 rgw_meta_sync_info sync_info;
100 std::map<uint32_t, rgw_meta_sync_marker> sync_markers;
101
102 rgw_meta_sync_status() {}
103
104 void encode(bufferlist& bl) const {
105 ENCODE_START(1, 1, bl);
106 encode(sync_info, bl);
107 encode(sync_markers, bl);
108 ENCODE_FINISH(bl);
109 }
110
111 void decode(bufferlist::const_iterator& bl) {
112 DECODE_START(1, bl);
113 decode(sync_info, bl);
114 decode(sync_markers, bl);
115 DECODE_FINISH(bl);
116 }
117
118 void dump(Formatter *f) const;
119 void decode_json(JSONObj *obj);
120 static void generate_test_instances(std::list<rgw_meta_sync_status*>& ls);
121 };
122 WRITE_CLASS_ENCODER(rgw_meta_sync_status)
123
124 #endif