]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 | 3 | |
7c673cae FG |
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); | |
11fdf7f2 TL |
25 | encode(state, bl); |
26 | encode(num_shards, bl); | |
27 | encode(period, bl); | |
28 | encode(realm_epoch, bl); | |
7c673cae FG |
29 | ENCODE_FINISH(bl); |
30 | } | |
31 | ||
11fdf7f2 | 32 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 33 | DECODE_START(1, bl); |
11fdf7f2 TL |
34 | decode(state, bl); |
35 | decode(num_shards, bl); | |
7c673cae | 36 | if (struct_v >= 2) { |
11fdf7f2 TL |
37 | decode(period, bl); |
38 | decode(realm_epoch, bl); | |
7c673cae FG |
39 | } |
40 | DECODE_FINISH(bl); | |
41 | } | |
42 | ||
43 | void decode_json(JSONObj *obj); | |
44 | void dump(Formatter *f) const; | |
b32b8144 | 45 | static void generate_test_instances(std::list<rgw_meta_sync_info*>& ls); |
7c673cae FG |
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; | |
20effc67 TL |
57 | std::string marker; |
58 | std::string next_step_marker; | |
7c673cae FG |
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); | |
11fdf7f2 TL |
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); | |
7c673cae FG |
75 | ENCODE_FINISH(bl); |
76 | } | |
77 | ||
11fdf7f2 | 78 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 79 | DECODE_START(2, bl); |
11fdf7f2 TL |
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); | |
7c673cae | 86 | if (struct_v >= 2) { |
11fdf7f2 | 87 | decode(realm_epoch, bl); |
7c673cae FG |
88 | } |
89 | DECODE_FINISH(bl); | |
90 | } | |
91 | ||
92 | void decode_json(JSONObj *obj); | |
93 | void dump(Formatter *f) const; | |
b32b8144 | 94 | static void generate_test_instances(std::list<rgw_meta_sync_marker*>& ls); |
7c673cae FG |
95 | }; |
96 | WRITE_CLASS_ENCODER(rgw_meta_sync_marker) | |
97 | ||
98 | struct rgw_meta_sync_status { | |
99 | rgw_meta_sync_info sync_info; | |
20effc67 | 100 | std::map<uint32_t, rgw_meta_sync_marker> sync_markers; |
7c673cae FG |
101 | |
102 | rgw_meta_sync_status() {} | |
103 | ||
104 | void encode(bufferlist& bl) const { | |
105 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
106 | encode(sync_info, bl); |
107 | encode(sync_markers, bl); | |
7c673cae FG |
108 | ENCODE_FINISH(bl); |
109 | } | |
110 | ||
11fdf7f2 | 111 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 112 | DECODE_START(1, bl); |
11fdf7f2 TL |
113 | decode(sync_info, bl); |
114 | decode(sync_markers, bl); | |
7c673cae FG |
115 | DECODE_FINISH(bl); |
116 | } | |
117 | ||
118 | void dump(Formatter *f) const; | |
119 | void decode_json(JSONObj *obj); | |
b32b8144 | 120 | static void generate_test_instances(std::list<rgw_meta_sync_status*>& ls); |
7c673cae FG |
121 | }; |
122 | WRITE_CLASS_ENCODER(rgw_meta_sync_status) | |
123 | ||
124 | #endif |