2 * Ceph - scalable distributed file system
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.
11 #include "cls_replica_log_types.h"
13 #include "common/Formatter.h"
14 #include "common/ceph_json.h"
16 void cls_replica_log_item_marker::dump(Formatter *f) const
18 f->dump_string("name", item_name);
19 f->dump_stream("timestamp") << item_timestamp;
22 void cls_replica_log_item_marker::decode_json(JSONObj *obj)
24 JSONDecoder::decode_json("name", item_name, obj);
25 JSONDecoder::decode_json("timestamp", item_timestamp, obj);
28 void cls_replica_log_item_marker::
29 generate_test_instances(std::list<cls_replica_log_item_marker*>& ls)
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);
39 void cls_replica_log_progress_marker::dump(Formatter *f) const
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);
47 void cls_replica_log_progress_marker::decode_json(JSONObj *obj)
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);
55 void cls_replica_log_progress_marker::
56 generate_test_instances(std::list<cls_replica_log_progress_marker*>& ls)
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);
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));
72 void cls_replica_log_bound::dump(Formatter *f) const
74 encode_json("position_marker", position_marker, f);
75 encode_json("position_time", position_time, f);
76 encode_json("marker_exists", marker_exists, f);
78 encode_json("marker", marker, f); //progress marker
82 void cls_replica_log_bound::decode_json(JSONObj *obj)
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);
88 JSONDecoder::decode_json("marker", marker, obj); //progress marker
92 void cls_replica_log_bound::
93 generate_test_instances(std::list<cls_replica_log_bound*>& ls)
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);
103 ls.back()->update_marker(*(*i));