1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-12 17:21:42 +03:00

Renamed client_context to client_state.

This commit is contained in:
Teemu Ollakka
2018-06-17 10:00:13 +03:00
parent 97ee96987e
commit dd28b173ab
33 changed files with 518 additions and 518 deletions

View File

@ -22,7 +22,7 @@
namespace wsrep
{
class transaction_context;
class client_context;
class client_state;
class client_service
{
public:
@ -60,14 +60,14 @@ namespace wsrep
/**
* Set up a data for replication.
*/
virtual int prepare_data_for_replication(wsrep::client_context&, const wsrep::transaction_context&) = 0;
virtual int prepare_data_for_replication(wsrep::client_state&, const wsrep::transaction_context&) = 0;
//
// Streaming
//
virtual size_t bytes_generated() const = 0;
virtual int prepare_fragment_for_replication(
wsrep::client_context&, const wsrep::transaction_context&, wsrep::mutable_buffer&) = 0;
wsrep::client_state&, const wsrep::transaction_context&, wsrep::mutable_buffer&) = 0;
virtual void remove_fragments(const wsrep::transaction_context&) = 0;
//
@ -77,17 +77,17 @@ namespace wsrep
/**
* Apply a write set.
*/
virtual int apply(wsrep::client_context&, const wsrep::const_buffer&) = 0;
virtual int apply(wsrep::client_state&, const wsrep::const_buffer&) = 0;
/**
* Commit transaction.
*/
virtual int commit(wsrep::client_context&, const wsrep::ws_handle&, const wsrep::ws_meta&) = 0;
virtual int commit(wsrep::client_state&, const wsrep::ws_handle&, const wsrep::ws_meta&) = 0;
/**
* Roll back transaction.
*/
virtual int rollback(wsrep::client_context&) = 0;
virtual int rollback(wsrep::client_state&) = 0;
//
// Interface to global server state
@ -114,13 +114,13 @@ namespace wsrep
/**
* Replay the current transaction. The implementation must put
* the caller Client Context into applying mode and call
* client_context::replay().
* client_state::replay().
*
* @todo This should not be visible to DBMS level, should be
* handled internally by wsrep-lib.
*/
virtual enum wsrep::provider::status replay(
wsrep::client_context&,
wsrep::client_state&,
wsrep::transaction_context&) = 0;
/**
@ -130,7 +130,7 @@ namespace wsrep
* @todo This should not be visible to DBMS level, should be
* handled internally by wsrep-lib.
*/
virtual void wait_for_replayers(wsrep::client_context&, wsrep::unique_lock<wsrep::mutex>&) = 0;
virtual void wait_for_replayers(wsrep::client_state&, wsrep::unique_lock<wsrep::mutex>&) = 0;
// Streaming replication
/**
@ -146,7 +146,7 @@ namespace wsrep
*
* @params sync_point Name of the debug sync point.
*/
virtual void debug_sync(wsrep::client_context&, const char* sync_point) = 0;
virtual void debug_sync(wsrep::client_state&, const char* sync_point) = 0;
/**
* Forcefully kill the process if the crash_point has

View File

@ -2,7 +2,7 @@
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
/** @file client_context.hpp
/** @file client_state.hpp
*
* Client Context
* ==============
@ -80,7 +80,7 @@ namespace wsrep
*
* Client Contex abstract interface.
*/
class client_context
class client_state
{
public:
/**
@ -136,7 +136,7 @@ namespace wsrep
/**
* Destructor.
*/
virtual ~client_context()
virtual ~client_state()
{
assert(transaction_.active() == false);
}
@ -538,7 +538,7 @@ namespace wsrep
* Client context constuctor. This is protected so that it
* can be called from derived class constructors only.
*/
client_context(wsrep::mutex& mutex,
client_state(wsrep::mutex& mutex,
wsrep::server_context& server_context,
wsrep::client_service& client_service,
const client_id& id,
@ -557,10 +557,10 @@ namespace wsrep
{ }
private:
client_context(const client_context&);
client_context& operator=(client_context&);
client_state(const client_state&);
client_state& operator=(client_state&);
friend class client_context_switch;
friend class client_state_switch;
friend class high_priority_context;
friend class client_toi_mode;
friend class transaction_context;
@ -593,84 +593,84 @@ namespace wsrep
};
class client_context_switch
class client_state_switch
{
public:
client_context_switch(wsrep::client_context& orig_context,
wsrep::client_context& current_context)
client_state_switch(wsrep::client_state& orig_context,
wsrep::client_state& current_context)
: orig_context_(orig_context)
, current_context_(current_context)
{
current_context_.client_service_.store_globals();
}
~client_context_switch()
~client_state_switch()
{
orig_context_.client_service_.store_globals();
}
private:
client_context& orig_context_;
client_context& current_context_;
client_state& orig_context_;
client_state& current_context_;
};
class high_priority_context
{
public:
high_priority_context(wsrep::client_context& client)
high_priority_context(wsrep::client_state& client)
: client_(client)
, orig_mode_(client.mode_)
{
client_.mode_ = wsrep::client_context::m_high_priority;
client_.mode_ = wsrep::client_state::m_high_priority;
}
~high_priority_context()
{
client_.mode_ = orig_mode_;
}
private:
wsrep::client_context& client_;
enum wsrep::client_context::mode orig_mode_;
wsrep::client_state& client_;
enum wsrep::client_state::mode orig_mode_;
};
class client_toi_mode
{
public:
client_toi_mode(wsrep::client_context& client)
client_toi_mode(wsrep::client_state& client)
: client_(client)
, orig_mode_(client.mode_)
{
client_.mode_ = wsrep::client_context::m_toi;
client_.mode_ = wsrep::client_state::m_toi;
}
~client_toi_mode()
{
assert(client_.mode() == wsrep::client_context::m_toi);
assert(client_.mode() == wsrep::client_state::m_toi);
client_.mode_ = orig_mode_;
}
private:
wsrep::client_context& client_;
enum wsrep::client_context::mode orig_mode_;
wsrep::client_state& client_;
enum wsrep::client_state::mode orig_mode_;
};
template <class D>
class scoped_client_context
class scoped_client_state
{
public:
scoped_client_context(wsrep::client_context* client_context, D deleter)
: client_context_(client_context)
scoped_client_state(wsrep::client_state* client_state, D deleter)
: client_state_(client_state)
, deleter_(deleter)
{
if (client_context_ == 0)
if (client_state_ == 0)
{
throw wsrep::runtime_error("Null client_context provided");
throw wsrep::runtime_error("Null client_state provided");
}
}
wsrep::client_context& client_context() { return *client_context_; }
~scoped_client_context()
wsrep::client_state& client_state() { return *client_state_; }
~scoped_client_state()
{
deleter_(client_context_);
deleter_(client_state_);
}
private:
scoped_client_context(const scoped_client_context&);
scoped_client_context& operator=(const scoped_client_context&);
wsrep::client_context* client_context_;
scoped_client_state(const scoped_client_state&);
scoped_client_state& operator=(const scoped_client_state&);
wsrep::client_state* client_state_;
D deleter_;
};
}

View File

@ -74,7 +74,7 @@ namespace wsrep
class ws_handle;
class ws_meta;
class provider;
class client_context;
class client_state;
class transaction_id;
class transaction_context;
class id;
@ -199,7 +199,7 @@ namespace wsrep
*
* @return Pointer to Client Context.
*/
virtual client_context* local_client_context() = 0;
virtual client_state* local_client_state() = 0;
/**
* Create applier context for streaming transaction.
@ -208,24 +208,24 @@ namespace wsrep
* @param transaction_id Transaction ID of the SR transaction on the
* origin server.
*/
virtual client_context* streaming_applier_client_context() = 0;
virtual client_state* streaming_applier_client_state() = 0;
virtual void release_client_context(wsrep::client_context*) = 0;
virtual void release_client_state(wsrep::client_state*) = 0;
void start_streaming_applier(
const wsrep::id&,
const wsrep::transaction_id&,
wsrep::client_context* client_context);
wsrep::client_state* client_state);
void stop_streaming_applier(
const wsrep::id&, const wsrep::transaction_id&);
/**
* Return reference to streaming applier.
*/
client_context* find_streaming_applier(const wsrep::id&,
client_state* find_streaming_applier(const wsrep::id&,
const wsrep::transaction_id&) const;
virtual void log_dummy_write_set(wsrep::client_context&,
virtual void log_dummy_write_set(wsrep::client_state&,
const wsrep::ws_meta&) = 0;
/**
* Load WSRep provider.
@ -333,7 +333,7 @@ namespace wsrep
const wsrep::gtid& gtid,
bool bypass) = 0;
virtual void background_rollback(wsrep::client_context&) = 0;
virtual void background_rollback(wsrep::client_state&) = 0;
/**
*
*/
@ -364,13 +364,13 @@ namespace wsrep
*
* @todo Make this private, allow calls for provider implementations
* only.
* @param client_context Applier client context.
* @param client_state Applier client context.
* @param transaction_context Transaction context.
* @param data Write set data
*
* @return Zero on success, non-zero on failure.
*/
int on_apply(wsrep::client_context& client_context,
int on_apply(wsrep::client_state& client_state,
const wsrep::ws_handle& ws_handle,
const wsrep::ws_meta& ws_meta,
const wsrep::const_buffer& data);
@ -384,7 +384,7 @@ namespace wsrep
* replication, false otherwise.
*/
virtual bool statement_allowed_for_streaming(
const wsrep::client_context& client_context,
const wsrep::client_state& client_state,
const wsrep::transaction_context& transaction_context) const;
void debug_log_level(int level) { debug_log_level_ = level; }
@ -435,7 +435,7 @@ namespace wsrep
wsrep::condition_variable& cond_;
enum state state_;
mutable std::vector<int> state_waiters_;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>, wsrep::client_context*> streaming_appliers_map;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>, wsrep::client_state*> streaming_appliers_map;
streaming_appliers_map streaming_appliers_;
wsrep::provider* provider_;
std::string name_;
@ -452,9 +452,9 @@ namespace wsrep
client_deleter(wsrep::server_context& server_context)
: server_context_(server_context)
{ }
void operator()(wsrep::client_context* client_context)
void operator()(wsrep::client_state* client_state)
{
server_context_.release_client_context(client_context);
server_context_.release_client_state(client_state);
}
private:
wsrep::server_context& server_context_;

View File

@ -16,7 +16,7 @@
namespace wsrep
{
class client_context;
class client_state;
class key;
class const_buffer;
@ -43,7 +43,7 @@ namespace wsrep
enum state state() const
{ return state_; }
transaction_context(wsrep::client_context& client_context);
transaction_context(wsrep::client_state& client_state);
~transaction_context();
// Accessors
wsrep::transaction_id id() const
@ -136,7 +136,7 @@ namespace wsrep
void debug_log_state(const char*) const;
wsrep::provider& provider_;
wsrep::client_context& client_context_;
wsrep::client_state& client_state_;
wsrep::transaction_id id_;
enum state state_;
std::vector<enum state> state_hist_;