1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-06 20:56:43 +03:00

Implemented thread service support.

Added a wsrep::thread_service interface to allow application to
inject instrumented thread, mutex and condition variable implementation
for provider.

The interface is defined in include/wsrep/thread_service.hpp.
Sample implementation is provided in dbsim/db_threads.[h|c]pp.

This patch will also clean up some remaining dependencies to
wsrep-API compilation units so that the dependency to wsrep-API
is header only. This will extending the provider support to
later wsrep-API versions.
This commit is contained in:
Teemu Ollakka
2019-02-16 17:09:18 +02:00
parent 477a71dd46
commit eb4cf86c1e
33 changed files with 1821 additions and 58 deletions

View File

@ -19,12 +19,15 @@
#include "db_simulator.hpp"
#include "db_client.hpp"
#include "db_threads.hpp"
#include "wsrep/logger.hpp"
#include <boost/filesystem.hpp>
#include <sstream>
static db::ti thread_instrumentation;
void db::simulator::run()
{
start();
@ -32,6 +35,7 @@ void db::simulator::run()
std::flush(std::cerr);
std::cout << "Results:\n";
std::cout << stats() << std::endl;
std::cout << db::ti::stats() << std::endl;
}
void db::simulator::sst(db::server& server,
@ -108,6 +112,8 @@ std::string db::simulator::stats() const
void db::simulator::start()
{
thread_instrumentation.level(params_.thread_instrumentation);
thread_instrumentation.cond_checks(params_.cond_checks);
wsrep::log_info() << "Provider: " << params_.wsrep_provider;
std::string cluster_address(build_cluster_address());
@ -139,13 +145,17 @@ void db::simulator::start()
server.server_state().debug_log_level(params_.debug_log_level);
std::string server_options(params_.wsrep_provider_options);
if (server.server_state().load_provider(
params_.wsrep_provider, server_options))
wsrep::provider::services services;
services.thread_service = params_.thread_instrumentation
? &thread_instrumentation
: nullptr;
if (server.server_state().load_provider(params_.wsrep_provider,
server_options, services))
{
throw wsrep::runtime_error("Failed to load provider");
}
if (server.server_state().connect("sim_cluster", cluster_address, "",
i == 0))
i == 0))
{
throw wsrep::runtime_error("Failed to connect");
}
@ -185,6 +195,7 @@ void db::simulator::stop()
clients_stop_ = std::chrono::steady_clock::now();
wsrep::log_info() << "######## Stats ############";
wsrep::log_info() << stats();
std::cout << db::ti::stats() << std::endl;
wsrep::log_info() << "######## Stats ############";
if (params_.fast_exit)
{