]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include "cls/user/cls_user_types.h" | |
5 | #include "common/Formatter.h" | |
6 | #include "common/ceph_json.h" | |
31f18b77 | 7 | #include "include/utime.h" |
7c673cae FG |
8 | |
9 | void cls_user_gen_test_bucket(cls_user_bucket *bucket, int i) | |
10 | { | |
11 | char buf[16]; | |
12 | snprintf(buf, sizeof(buf), ".%d", i); | |
13 | ||
14 | bucket->name = string("buck") + buf; | |
15 | bucket->marker = string("mark") + buf; | |
16 | bucket->bucket_id = string("bucket.id") + buf; | |
17 | } | |
18 | ||
19 | void cls_user_bucket::dump(Formatter *f) const | |
20 | { | |
21 | encode_json("name", name, f); | |
22 | encode_json("marker", marker,f); | |
23 | encode_json("bucket_id", bucket_id,f); | |
24 | } | |
25 | ||
26 | void cls_user_bucket::generate_test_instances(list<cls_user_bucket*>& ls) | |
27 | { | |
28 | ls.push_back(new cls_user_bucket); | |
29 | cls_user_bucket *b = new cls_user_bucket; | |
30 | cls_user_gen_test_bucket(b, 0); | |
31 | ls.push_back(b); | |
32 | } | |
33 | ||
34 | void cls_user_bucket_entry::dump(Formatter *f) const | |
35 | { | |
36 | encode_json("bucket", bucket, f); | |
37 | encode_json("size", size, f); | |
38 | encode_json("size_rounded", size_rounded, f); | |
39 | encode_json("creation_time", utime_t(creation_time), f); | |
40 | encode_json("count", count, f); | |
41 | encode_json("user_stats_sync", user_stats_sync, f); | |
42 | } | |
43 | ||
44 | void cls_user_gen_test_bucket_entry(cls_user_bucket_entry *entry, int i) | |
45 | { | |
46 | cls_user_gen_test_bucket(&entry->bucket, i); | |
47 | entry->size = i + 1; | |
48 | entry->size_rounded = i + 2; | |
49 | entry->creation_time = real_clock::from_time_t(i + 3); | |
50 | entry->count = i + 4; | |
51 | entry->user_stats_sync = true; | |
52 | } | |
53 | ||
54 | void cls_user_bucket_entry::generate_test_instances(list<cls_user_bucket_entry*>& ls) | |
55 | { | |
56 | ls.push_back(new cls_user_bucket_entry); | |
57 | cls_user_bucket_entry *entry = new cls_user_bucket_entry; | |
58 | cls_user_gen_test_bucket_entry(entry, 0); | |
59 | ls.push_back(entry); | |
60 | } | |
61 | ||
62 | void cls_user_gen_test_stats(cls_user_stats *s) | |
63 | { | |
64 | s->total_entries = 1; | |
65 | s->total_bytes = 2; | |
66 | s->total_bytes_rounded = 3; | |
67 | } | |
68 | ||
69 | void cls_user_stats::dump(Formatter *f) const | |
70 | { | |
71 | f->dump_int("total_entries", total_entries); | |
72 | f->dump_int("total_bytes", total_bytes); | |
73 | f->dump_int("total_bytes_rounded", total_bytes_rounded); | |
74 | } | |
75 | ||
76 | void cls_user_stats::generate_test_instances(list<cls_user_stats*>& ls) | |
77 | { | |
78 | ls.push_back(new cls_user_stats); | |
79 | cls_user_stats *s = new cls_user_stats; | |
80 | cls_user_gen_test_stats(s); | |
81 | ls.push_back(s); | |
82 | } | |
83 | ||
84 | void cls_user_gen_test_header(cls_user_header *h) | |
85 | { | |
86 | cls_user_gen_test_stats(&h->stats); | |
87 | h->last_stats_sync = utime_t(1, 0).to_real_time(); | |
88 | h->last_stats_update = utime_t(2, 0).to_real_time(); | |
89 | } | |
90 | ||
91 | void cls_user_header::dump(Formatter *f) const | |
92 | { | |
93 | encode_json("stats", stats, f); | |
94 | encode_json("last_stats_sync", utime_t(last_stats_sync), f); | |
95 | encode_json("last_stats_update", utime_t(last_stats_update), f); | |
96 | } | |
97 | ||
98 | void cls_user_header::generate_test_instances(list<cls_user_header*>& ls) | |
99 | { | |
100 | ls.push_back(new cls_user_header); | |
101 | cls_user_header *h = new cls_user_header; | |
102 | cls_user_gen_test_header(h); | |
103 | ls.push_back(h); | |
104 | } |