1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-30 07:23:07 +03:00

Added TOI client mode, replced string with const char* in debug calls.

This commit is contained in:
Teemu Ollakka
2018-05-21 16:42:40 +03:00
parent 90f6eb1ecf
commit 646a2b328e
8 changed files with 76 additions and 32 deletions

View File

@ -99,7 +99,9 @@ namespace trrep
/*! Generates write sets for replication by the provider. */ /*! Generates write sets for replication by the provider. */
m_replicating, m_replicating,
/*! Applies write sets from the provider. */ /*! Applies write sets from the provider. */
m_applier m_applier,
/*! Client is in total order isolation mode */
m_toi
}; };
/*! /*!
@ -345,6 +347,7 @@ namespace trrep
const trrep::data&); const trrep::data&);
friend class client_context_switch; friend class client_context_switch;
friend class client_applier_mode; friend class client_applier_mode;
friend class client_toi_mode;
friend class transaction_context; friend class transaction_context;
/*! /*!
@ -450,12 +453,12 @@ namespace trrep
/*! /*!
* Enter debug synchronization point. * Enter debug synchronization point.
*/ */
virtual void debug_sync(const std::string&) = 0; virtual void debug_sync(const char*) = 0;
/*! /*!
* *
*/ */
virtual void debug_suicide(const std::string&) = 0; virtual void debug_suicide(const char*) = 0;
/*! /*!
* Notify the implementation about an error. * Notify the implementation about an error.
@ -526,6 +529,27 @@ namespace trrep
trrep::client_context& client_; trrep::client_context& client_;
enum trrep::client_context::mode orig_mode_; enum trrep::client_context::mode orig_mode_;
}; };
class client_toi_mode
{
public:
client_toi_mode(trrep::client_context& client)
: client_(client)
, orig_mode_(client.mode_)
{
client_.mode_ = trrep::client_context::m_toi;
}
~client_toi_mode()
{
assert(client_.mode == trrep::client_context::m_toi);
client_.mode_ = orig_mode_;
}
private:
trrep::client_context& client_;
enum trrep::client_context::mode orig_mode_;
};
} }
#endif // TRREP_CLIENT_CONTEXT_HPP #endif // TRREP_CLIENT_CONTEXT_HPP

View File

@ -225,34 +225,31 @@ namespace trrep
bool bootstrap); bool bootstrap);
int disconnect(); int disconnect();
/*!
* Virtual method which will be called when the server
* has been joined to the cluster. Must be provided by
* the implementation.
*
* \todo Document overriding.
*/
virtual void on_connect();
/*! /*!
* Virtual method which will be called when a view * A method which will be called when the server
* has been joined to the cluster
*/
void on_connect();
/*!
* A method which will be called when a view
* notification event has been delivered by the * notification event has been delivered by the
* provider. * provider.
* *
* \todo Document overriding.
*
* \params view trrep::view object which holds the new view * \params view trrep::view object which holds the new view
* information. * information.
*/ */
virtual void on_view(const trrep::view& view); void on_view(const trrep::view& view);
/*! /*!
* Virtual method which will be called when the server * A method which will be called when the server
* has been synchronized with the cluster. * has been synchronized with the cluster.
* *
* \todo Document overriding. * This will have a side effect of changing the Server Context
* state to s_synced.
*/ */
virtual void on_sync(); void on_sync();
/*! /*!
* Wait until server reaches given state. * Wait until server reaches given state.
@ -312,6 +309,13 @@ namespace trrep
*/ */
void sst_received(const wsrep_gtid_t& gtid, int error); void sst_received(const wsrep_gtid_t& gtid, int error);
/*!
* This method must be called after the server initialization
* has been completed. The call has a side effect of changing
* the Server Context state to s_initialized.
*/
void initialized();
/*! /*!
* *
*/ */

View File

@ -150,7 +150,7 @@ namespace trrep
void remove_fragments(); void remove_fragments();
void clear_fragments(); void clear_fragments();
void cleanup(); void cleanup();
void debug_log_state(const std::string&) const; void debug_log_state(const char*) const;
trrep::provider& provider_; trrep::provider& provider_;
trrep::client_context& client_context_; trrep::client_context& client_context_;

View File

@ -17,11 +17,11 @@ function run_benchmark()
} }
# for servers in 1 2 4 8 16 for servers in 1 2 4 8 16
for servers in 16 # for servers in 16
do do
# for clients in 1 2 4 8 16 32 for clients in 1 2 4 8 16 32
for clients in 4 8 16 32 # for clients in 4 8 16 32
do do
run_benchmark $servers $clients run_benchmark $servers $clients
done done

View File

@ -38,6 +38,7 @@ struct dbms_simulator_params
size_t n_servers; size_t n_servers;
size_t n_clients; size_t n_clients;
size_t n_transactions; size_t n_transactions;
size_t alg_freq;
std::string wsrep_provider; std::string wsrep_provider;
std::string wsrep_provider_options; std::string wsrep_provider_options;
int debug_log_level; int debug_log_level;
@ -46,6 +47,7 @@ struct dbms_simulator_params
: n_servers(0) : n_servers(0)
, n_clients(0) , n_clients(0)
, n_transactions(0) , n_transactions(0)
, alg_freq(0)
, wsrep_provider() , wsrep_provider()
, wsrep_provider_options() , wsrep_provider_options()
, debug_log_level(0) , debug_log_level(0)
@ -56,10 +58,10 @@ struct dbms_simulator_params
class dbms_storage_engine class dbms_storage_engine
{ {
public: public:
dbms_storage_engine() dbms_storage_engine(const dbms_simulator_params& params)
: mutex_() : mutex_()
, transactions_() , transactions_()
, alg_freq_(0) , alg_freq_(params.alg_freq)
, bf_aborts_() , bf_aborts_()
{ } { }
@ -212,7 +214,7 @@ public:
name, id, address, name + "_data", name, id, address, name + "_data",
trrep::server_context::rm_async) trrep::server_context::rm_async)
, simulator_(simulator) , simulator_(simulator)
, storage_engine_() , storage_engine_(simulator_.params())
, mutex_() , mutex_()
, cond_() , cond_()
, last_client_id_(0) , last_client_id_(0)
@ -372,8 +374,8 @@ private:
bool killed() const override { return false; } bool killed() const override { return false; }
void abort() const override { ::abort(); } void abort() const override { ::abort(); }
void store_globals() override { } void store_globals() override { }
void debug_sync(const std::string&) override { } void debug_sync(const char*) override { }
void debug_suicide(const std::string&) override { } void debug_suicide(const char*) override { }
void on_error(enum trrep::client_error) override { } void on_error(enum trrep::client_error) override { }
template <class Func> template <class Func>
@ -714,6 +716,8 @@ int main(int argc, char** argv)
"number of clients to start per server") "number of clients to start per server")
("transactions", po::value<size_t>(&params.n_transactions), ("transactions", po::value<size_t>(&params.n_transactions),
"number of transactions run by a client") "number of transactions run by a client")
("alg-freq", po::value<size_t>(&params.alg_freq),
"ALG frequency")
("debug-log-level", po::value<int>(&params.debug_log_level), ("debug-log-level", po::value<int>(&params.debug_log_level),
"debug logging level: 0 - none, 1 - verbose") "debug logging level: 0 - none, 1 - verbose")
("fast-exit", po::value<int>(&params.fast_exit), ("fast-exit", po::value<int>(&params.fast_exit),

View File

@ -50,8 +50,8 @@ namespace trrep
bool killed() const TRREP_OVERRIDE { return false; } bool killed() const TRREP_OVERRIDE { return false; }
void abort() const TRREP_OVERRIDE { } void abort() const TRREP_OVERRIDE { }
void store_globals() TRREP_OVERRIDE { } void store_globals() TRREP_OVERRIDE { }
void debug_sync(const std::string&) TRREP_OVERRIDE { } void debug_sync(const char*) TRREP_OVERRIDE { }
void debug_suicide(const std::string&) TRREP_OVERRIDE void debug_suicide(const char*) TRREP_OVERRIDE
{ {
::abort(); ::abort();
} }

View File

@ -131,6 +131,9 @@ int trrep::transaction_context::before_prepare()
case trrep::client_context::m_local: case trrep::client_context::m_local:
case trrep::client_context::m_applier: case trrep::client_context::m_applier:
break; break;
default:
assert(0);
break;
} }
assert(state() == s_preparing); assert(state() == s_preparing);
@ -174,6 +177,9 @@ int trrep::transaction_context::after_prepare()
state(lock, s_committing); state(lock, s_committing);
ret = 0; ret = 0;
break; break;
default:
assert(0);
break;
} }
debug_log_state("after_prepare_leave"); debug_log_state("after_prepare_leave");
return ret; return ret;
@ -267,6 +273,9 @@ int trrep::transaction_context::before_commit()
} }
} }
break; break;
default:
assert(0);
break;
} }
debug_log_state("before_commit_leave"); debug_log_state("before_commit_leave");
return ret; return ret;
@ -310,6 +319,9 @@ int trrep::transaction_context::after_commit()
break; break;
case trrep::client_context::m_applier: case trrep::client_context::m_applier:
break; break;
default:
assert(0);
break;
} }
assert(ret == 0); assert(ret == 0);
state(lock, s_committed); state(lock, s_committed);
@ -806,7 +818,7 @@ void trrep::transaction_context::cleanup()
} }
void trrep::transaction_context::debug_log_state( void trrep::transaction_context::debug_log_state(
const std::string& context TRREP_UNUSED) const const char* context) const
{ {
if (client_context_.debug_log_level() >= 1) if (client_context_.debug_log_level() >= 1)
{ {

2
wsrep

Submodule wsrep updated: 955da1c8c2...e12a9dd89c