]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Ceph - scalable distributed file system | |
3 | * | |
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. | |
8 | * | |
9 | */ | |
10 | ||
11 | #include "cls_replica_log_types.h" | |
12 | ||
13 | #include "common/Formatter.h" | |
14 | #include "common/ceph_json.h" | |
15 | ||
16 | void cls_replica_log_item_marker::dump(Formatter *f) const | |
17 | { | |
18 | f->dump_string("name", item_name); | |
19 | f->dump_stream("timestamp") << item_timestamp; | |
20 | } | |
21 | ||
22 | void cls_replica_log_item_marker::decode_json(JSONObj *obj) | |
23 | { | |
24 | JSONDecoder::decode_json("name", item_name, obj); | |
25 | JSONDecoder::decode_json("timestamp", item_timestamp, obj); | |
26 | } | |
27 | ||
28 | void cls_replica_log_item_marker:: | |
29 | generate_test_instances(std::list<cls_replica_log_item_marker*>& ls) | |
30 | { | |
31 | ls.push_back(new cls_replica_log_item_marker); | |
32 | ls.back()->item_name = "test_item_1"; | |
33 | ls.back()->item_timestamp.set_from_double(0); | |
34 | ls.push_back(new cls_replica_log_item_marker); | |
35 | ls.back()->item_name = "test_item_2"; | |
36 | ls.back()->item_timestamp.set_from_double(20); | |
37 | } | |
38 | ||
39 | void cls_replica_log_progress_marker::dump(Formatter *f) const | |
40 | { | |
41 | encode_json("entity", entity_id, f); | |
42 | encode_json("position_marker", position_marker, f); | |
43 | encode_json("position_time", position_time, f); | |
44 | encode_json("items_in_progress", items, f); | |
45 | } | |
46 | ||
47 | void cls_replica_log_progress_marker::decode_json(JSONObj *obj) | |
48 | { | |
49 | JSONDecoder::decode_json("entity", entity_id, obj); | |
50 | JSONDecoder::decode_json("position_marker", position_marker, obj); | |
51 | JSONDecoder::decode_json("position_time", position_time, obj); | |
52 | JSONDecoder::decode_json("items_in_progress", items, obj); | |
53 | } | |
54 | ||
55 | void cls_replica_log_progress_marker:: | |
56 | generate_test_instances(std::list<cls_replica_log_progress_marker*>& ls) | |
57 | { | |
58 | ls.push_back(new cls_replica_log_progress_marker); | |
59 | ls.push_back(new cls_replica_log_progress_marker); | |
60 | ls.back()->entity_id = "entity1"; | |
61 | ls.back()->position_marker = "pos1"; | |
62 | ls.back()->position_time.set_from_double(20); | |
63 | ||
64 | std::list<cls_replica_log_item_marker*> test_items; | |
65 | cls_replica_log_item_marker::generate_test_instances(test_items); | |
66 | std::list<cls_replica_log_item_marker*>::iterator i = test_items.begin(); | |
67 | for ( ; i != test_items.end(); ++i) { | |
68 | ls.back()->items.push_back(*(*i)); | |
69 | } | |
70 | } | |
71 | ||
72 | void cls_replica_log_bound::dump(Formatter *f) const | |
73 | { | |
74 | encode_json("position_marker", position_marker, f); | |
75 | encode_json("position_time", position_time, f); | |
76 | encode_json("marker_exists", marker_exists, f); | |
77 | if (marker_exists) { | |
78 | encode_json("marker", marker, f); //progress marker | |
79 | } | |
80 | } | |
81 | ||
82 | void cls_replica_log_bound::decode_json(JSONObj *obj) | |
83 | { | |
84 | JSONDecoder::decode_json("position_marker", position_marker, obj); | |
85 | JSONDecoder::decode_json("position_time", position_time, obj); | |
86 | JSONDecoder::decode_json("marker_exists", marker_exists, obj); | |
87 | if (marker_exists) { | |
88 | JSONDecoder::decode_json("marker", marker, obj); //progress marker | |
89 | } | |
90 | } | |
91 | ||
92 | void cls_replica_log_bound:: | |
93 | generate_test_instances(std::list<cls_replica_log_bound*>& ls) | |
94 | { | |
95 | ls.push_back(new cls_replica_log_bound); | |
96 | std::list<cls_replica_log_progress_marker*> marker_objects; | |
97 | cls_replica_log_progress_marker::generate_test_instances(marker_objects); | |
98 | std::list<cls_replica_log_progress_marker*>::iterator i = | |
99 | marker_objects.begin(); | |
100 | ls.back()->update_marker(*(*i)); | |
101 | ls.push_back(new cls_replica_log_bound); | |
102 | ++i; | |
103 | ls.back()->update_marker(*(*i)); | |
104 | } |