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