]>
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 | ||
11fdf7f2 TL |
4 | /* |
5 | * Copyright (C) 2016 Red Hat Inc. | |
6 | * | |
7 | * This is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU Lesser General Public License version | |
9 | * 2.1, as published by the Free Software Foundation. See file | |
10 | * COPYING. | |
11 | */ | |
12 | ||
7c673cae FG |
13 | |
14 | #pragma once | |
15 | ||
16 | ||
17 | #include <string.h> | |
18 | ||
19 | #include <chrono> | |
20 | #include <vector> | |
21 | #include <sstream> | |
22 | #include <iomanip> | |
23 | ||
24 | #include "ConfUtils.h" | |
25 | ||
11fdf7f2 TL |
26 | #include "sim_recs.h" |
27 | ||
7c673cae FG |
28 | |
29 | namespace crimson { | |
30 | namespace qos_simulation { | |
31 | ||
32 | struct cli_group_t { | |
9f95a23c | 33 | unsigned client_count; |
7c673cae | 34 | std::chrono::seconds client_wait; |
9f95a23c TL |
35 | unsigned client_total_ops; |
36 | unsigned client_server_select_range; | |
37 | unsigned client_iops_goal; | |
38 | unsigned client_outstanding_ops; | |
7c673cae FG |
39 | double client_reservation; |
40 | double client_limit; | |
41 | double client_weight; | |
11fdf7f2 | 42 | Cost client_req_cost; |
7c673cae | 43 | |
9f95a23c TL |
44 | cli_group_t(unsigned _client_count = 100, |
45 | unsigned _client_wait = 0, | |
46 | unsigned _client_total_ops = 1000, | |
47 | unsigned _client_server_select_range = 10, | |
48 | unsigned _client_iops_goal = 50, | |
49 | unsigned _client_outstanding_ops = 100, | |
7c673cae FG |
50 | double _client_reservation = 20.0, |
51 | double _client_limit = 60.0, | |
11fdf7f2 TL |
52 | double _client_weight = 1.0, |
53 | Cost _client_req_cost = 1u) : | |
7c673cae FG |
54 | client_count(_client_count), |
55 | client_wait(std::chrono::seconds(_client_wait)), | |
56 | client_total_ops(_client_total_ops), | |
57 | client_server_select_range(_client_server_select_range), | |
58 | client_iops_goal(_client_iops_goal), | |
59 | client_outstanding_ops(_client_outstanding_ops), | |
60 | client_reservation(_client_reservation), | |
61 | client_limit(_client_limit), | |
11fdf7f2 TL |
62 | client_weight(_client_weight), |
63 | client_req_cost(_client_req_cost) | |
7c673cae FG |
64 | { |
65 | // empty | |
66 | } | |
67 | ||
68 | friend std::ostream& operator<<(std::ostream& out, | |
69 | const cli_group_t& cli_group) { | |
70 | out << | |
71 | "client_count = " << cli_group.client_count << "\n" << | |
72 | "client_wait = " << cli_group.client_wait.count() << "\n" << | |
73 | "client_total_ops = " << cli_group.client_total_ops << "\n" << | |
74 | "client_server_select_range = " << cli_group.client_server_select_range << "\n" << | |
75 | "client_iops_goal = " << cli_group.client_iops_goal << "\n" << | |
76 | "client_outstanding_ops = " << cli_group.client_outstanding_ops << "\n" << | |
77 | std::fixed << std::setprecision(1) << | |
78 | "client_reservation = " << cli_group.client_reservation << "\n" << | |
79 | "client_limit = " << cli_group.client_limit << "\n" << | |
11fdf7f2 TL |
80 | "client_weight = " << cli_group.client_weight << "\n" << |
81 | "client_req_cost = " << cli_group.client_req_cost; | |
7c673cae FG |
82 | return out; |
83 | } | |
84 | }; // class cli_group_t | |
85 | ||
86 | ||
87 | struct srv_group_t { | |
9f95a23c TL |
88 | unsigned server_count; |
89 | unsigned server_iops; | |
90 | unsigned server_threads; | |
7c673cae | 91 | |
9f95a23c TL |
92 | srv_group_t(unsigned _server_count = 100, |
93 | unsigned _server_iops = 40, | |
94 | unsigned _server_threads = 1) : | |
7c673cae FG |
95 | server_count(_server_count), |
96 | server_iops(_server_iops), | |
97 | server_threads(_server_threads) | |
98 | { | |
99 | // empty | |
100 | } | |
101 | ||
102 | friend std::ostream& operator<<(std::ostream& out, | |
103 | const srv_group_t& srv_group) { | |
104 | out << | |
105 | "server_count = " << srv_group.server_count << "\n" << | |
106 | "server_iops = " << srv_group.server_iops << "\n" << | |
107 | "server_threads = " << srv_group.server_threads; | |
108 | return out; | |
109 | } | |
110 | }; // class srv_group_t | |
111 | ||
112 | ||
113 | struct sim_config_t { | |
9f95a23c TL |
114 | unsigned server_groups; |
115 | unsigned client_groups; | |
7c673cae FG |
116 | bool server_random_selection; |
117 | bool server_soft_limit; | |
11fdf7f2 | 118 | double anticipation_timeout; |
7c673cae FG |
119 | |
120 | std::vector<cli_group_t> cli_group; | |
121 | std::vector<srv_group_t> srv_group; | |
122 | ||
9f95a23c TL |
123 | sim_config_t(unsigned _server_groups = 1, |
124 | unsigned _client_groups = 1, | |
7c673cae | 125 | bool _server_random_selection = false, |
11fdf7f2 TL |
126 | bool _server_soft_limit = true, |
127 | double _anticipation_timeout = 0.0) : | |
7c673cae FG |
128 | server_groups(_server_groups), |
129 | client_groups(_client_groups), | |
130 | server_random_selection(_server_random_selection), | |
11fdf7f2 TL |
131 | server_soft_limit(_server_soft_limit), |
132 | anticipation_timeout(_anticipation_timeout) | |
7c673cae FG |
133 | { |
134 | srv_group.reserve(server_groups); | |
135 | cli_group.reserve(client_groups); | |
136 | } | |
137 | ||
138 | friend std::ostream& operator<<(std::ostream& out, | |
139 | const sim_config_t& sim_config) { | |
140 | out << | |
141 | "server_groups = " << sim_config.server_groups << "\n" << | |
142 | "client_groups = " << sim_config.client_groups << "\n" << | |
143 | "server_random_selection = " << sim_config.server_random_selection << "\n" << | |
11fdf7f2 TL |
144 | "server_soft_limit = " << sim_config.server_soft_limit << "\n" << |
145 | std::fixed << std::setprecision(3) << | |
146 | "anticipation_timeout = " << sim_config.anticipation_timeout; | |
7c673cae FG |
147 | return out; |
148 | } | |
149 | }; // class sim_config_t | |
150 | ||
151 | ||
152 | bool ceph_argparse_witharg(std::vector<const char*> &args, | |
153 | std::vector<const char*>::iterator &i, std::string *ret, ...); | |
154 | void ceph_argparse_early_args(std::vector<const char*>& args, std::string *conf_file_list); | |
155 | int parse_config_file(const std::string &fname, sim_config_t &g_conf); | |
156 | ||
157 | }; // namespace qos_simulation | |
158 | }; // namespace crimson |