mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-06-13 04:01:32 +03:00
Added topology argument to dbsim to allow testing master/slave
This commit is contained in:
@ -6,6 +6,28 @@
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace
|
||||
{
|
||||
void validate_params(const db::params& params)
|
||||
{
|
||||
std::ostringstream os;
|
||||
if (params.n_servers != params.topology.size())
|
||||
{
|
||||
if (params.topology.size() > 0)
|
||||
{
|
||||
os << "Error: --topology=" << params.topology << " does not "
|
||||
<< "match the number of server --servers="
|
||||
<< params.n_servers << "\n";
|
||||
}
|
||||
}
|
||||
if (os.str().size())
|
||||
{
|
||||
throw std::invalid_argument(os.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db::params db::parse_args(int argc, char** argv)
|
||||
{
|
||||
@ -22,8 +44,10 @@ db::params db::parse_args(int argc, char** argv)
|
||||
"wsrep provider options")
|
||||
("servers", po::value<size_t>(¶ms.n_servers)->required(),
|
||||
"number of servers to start")
|
||||
("topology", po::value<std::string>(¶ms.topology),
|
||||
"replication topology (e.g. mm for multi master, ms for master/slave")
|
||||
("clients", po::value<size_t>(¶ms.n_clients)->required(),
|
||||
"number of clients to start per server")
|
||||
"number of clients to start per master")
|
||||
("transactions", po::value<size_t>(¶ms.n_transactions),
|
||||
"number of transactions run by a client")
|
||||
("rows", po::value<size_t>(¶ms.n_rows),
|
||||
@ -42,5 +66,7 @@ db::params db::parse_args(int argc, char** argv)
|
||||
std::cerr << desc << "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
validate_params(params);
|
||||
return params;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace db
|
||||
size_t n_transactions;
|
||||
size_t n_rows;
|
||||
size_t alg_freq;
|
||||
std::string topology;
|
||||
std::string wsrep_provider;
|
||||
std::string wsrep_provider_options;
|
||||
int debug_log_level;
|
||||
@ -27,6 +28,7 @@ namespace db
|
||||
, n_transactions(0)
|
||||
, n_rows(1000)
|
||||
, alg_freq(0)
|
||||
, topology()
|
||||
, wsrep_provider()
|
||||
, wsrep_provider_options()
|
||||
, debug_log_level(0)
|
||||
|
@ -39,10 +39,9 @@ void db::simulator::sst(db::server& server,
|
||||
|
||||
std::string db::simulator::stats() const
|
||||
{
|
||||
size_t transactions(params_.n_servers * params_.n_clients
|
||||
* params_.n_transactions);
|
||||
auto duration(std::chrono::duration<double>(
|
||||
clients_stop_ - clients_start_).count());
|
||||
long long transactions(stats_.commits + stats_.rollbacks);
|
||||
long long bf_aborts(0);
|
||||
for (const auto& s : servers_)
|
||||
{
|
||||
@ -121,10 +120,15 @@ void db::simulator::start()
|
||||
// Start client threads
|
||||
wsrep::log() << "####################### Starting client load";
|
||||
clients_start_ = std::chrono::steady_clock::now();
|
||||
size_t index(0);
|
||||
for (auto& i : servers_)
|
||||
{
|
||||
if (params_.topology.size() == 0 || params_.topology[index] == 'm')
|
||||
{
|
||||
i.second->start_clients();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
void db::simulator::stop()
|
||||
|
@ -7,6 +7,14 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
db::simulator(db::parse_args(argc, argv)).run();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user