]>
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 | ||
5 | #pragma once | |
6 | ||
7 | ||
8 | #include <string.h> | |
9 | ||
10 | #include <chrono> | |
11 | #include <vector> | |
12 | #include <sstream> | |
13 | #include <iomanip> | |
14 | ||
15 | #include "ConfUtils.h" | |
16 | ||
17 | ||
18 | namespace crimson { | |
19 | namespace qos_simulation { | |
20 | ||
21 | struct cli_group_t { | |
22 | uint client_count; | |
23 | std::chrono::seconds client_wait; | |
24 | uint client_total_ops; | |
25 | uint client_server_select_range; | |
26 | uint client_iops_goal; | |
27 | uint client_outstanding_ops; | |
28 | double client_reservation; | |
29 | double client_limit; | |
30 | double client_weight; | |
31 | ||
32 | cli_group_t(uint _client_count = 100, | |
33 | uint _client_wait = 0, | |
34 | uint _client_total_ops = 1000, | |
35 | uint _client_server_select_range = 10, | |
36 | uint _client_iops_goal = 50, | |
37 | uint _client_outstanding_ops = 100, | |
38 | double _client_reservation = 20.0, | |
39 | double _client_limit = 60.0, | |
40 | double _client_weight = 1.0) : | |
41 | client_count(_client_count), | |
42 | client_wait(std::chrono::seconds(_client_wait)), | |
43 | client_total_ops(_client_total_ops), | |
44 | client_server_select_range(_client_server_select_range), | |
45 | client_iops_goal(_client_iops_goal), | |
46 | client_outstanding_ops(_client_outstanding_ops), | |
47 | client_reservation(_client_reservation), | |
48 | client_limit(_client_limit), | |
49 | client_weight(_client_weight) | |
50 | { | |
51 | // empty | |
52 | } | |
53 | ||
54 | friend std::ostream& operator<<(std::ostream& out, | |
55 | const cli_group_t& cli_group) { | |
56 | out << | |
57 | "client_count = " << cli_group.client_count << "\n" << | |
58 | "client_wait = " << cli_group.client_wait.count() << "\n" << | |
59 | "client_total_ops = " << cli_group.client_total_ops << "\n" << | |
60 | "client_server_select_range = " << cli_group.client_server_select_range << "\n" << | |
61 | "client_iops_goal = " << cli_group.client_iops_goal << "\n" << | |
62 | "client_outstanding_ops = " << cli_group.client_outstanding_ops << "\n" << | |
63 | std::fixed << std::setprecision(1) << | |
64 | "client_reservation = " << cli_group.client_reservation << "\n" << | |
65 | "client_limit = " << cli_group.client_limit << "\n" << | |
66 | "client_weight = " << cli_group.client_weight; | |
67 | return out; | |
68 | } | |
69 | }; // class cli_group_t | |
70 | ||
71 | ||
72 | struct srv_group_t { | |
73 | uint server_count; | |
74 | uint server_iops; | |
75 | uint server_threads; | |
76 | ||
77 | srv_group_t(uint _server_count = 100, | |
78 | uint _server_iops = 40, | |
79 | uint _server_threads = 1) : | |
80 | server_count(_server_count), | |
81 | server_iops(_server_iops), | |
82 | server_threads(_server_threads) | |
83 | { | |
84 | // empty | |
85 | } | |
86 | ||
87 | friend std::ostream& operator<<(std::ostream& out, | |
88 | const srv_group_t& srv_group) { | |
89 | out << | |
90 | "server_count = " << srv_group.server_count << "\n" << | |
91 | "server_iops = " << srv_group.server_iops << "\n" << | |
92 | "server_threads = " << srv_group.server_threads; | |
93 | return out; | |
94 | } | |
95 | }; // class srv_group_t | |
96 | ||
97 | ||
98 | struct sim_config_t { | |
99 | uint server_groups; | |
100 | uint client_groups; | |
101 | bool server_random_selection; | |
102 | bool server_soft_limit; | |
103 | ||
104 | std::vector<cli_group_t> cli_group; | |
105 | std::vector<srv_group_t> srv_group; | |
106 | ||
107 | sim_config_t(uint _server_groups = 1, | |
108 | uint _client_groups = 1, | |
109 | bool _server_random_selection = false, | |
110 | bool _server_soft_limit = true) : | |
111 | server_groups(_server_groups), | |
112 | client_groups(_client_groups), | |
113 | server_random_selection(_server_random_selection), | |
114 | server_soft_limit(_server_soft_limit) | |
115 | { | |
116 | srv_group.reserve(server_groups); | |
117 | cli_group.reserve(client_groups); | |
118 | } | |
119 | ||
120 | friend std::ostream& operator<<(std::ostream& out, | |
121 | const sim_config_t& sim_config) { | |
122 | out << | |
123 | "server_groups = " << sim_config.server_groups << "\n" << | |
124 | "client_groups = " << sim_config.client_groups << "\n" << | |
125 | "server_random_selection = " << sim_config.server_random_selection << "\n" << | |
126 | "server_soft_limit = " << sim_config.server_soft_limit; | |
127 | return out; | |
128 | } | |
129 | }; // class sim_config_t | |
130 | ||
131 | ||
132 | bool ceph_argparse_witharg(std::vector<const char*> &args, | |
133 | std::vector<const char*>::iterator &i, std::string *ret, ...); | |
134 | void ceph_argparse_early_args(std::vector<const char*>& args, std::string *conf_file_list); | |
135 | int parse_config_file(const std::string &fname, sim_config_t &g_conf); | |
136 | ||
137 | }; // namespace qos_simulation | |
138 | }; // namespace crimson |