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

Defined log_state_change() interface in server_service.

The interface method can be used to notify the DBMS implementation
about state changes in well defined order. The call will be done
under server_state mutex protection.
This commit is contained in:
Teemu Ollakka
2018-07-05 12:45:22 +03:00
parent fcefe9f03b
commit d80a69fe90
8 changed files with 61 additions and 59 deletions

View File

@ -17,6 +17,7 @@
#define WSREP_CLIENT_STATE_HPP
#include "server_state.hpp"
#include "server_service.hpp"
#include "provider.hpp"
#include "transaction.hpp"
#include "client_id.hpp"
@ -807,6 +808,20 @@ namespace wsrep
enum wsrep::client_state::mode orig_mode_;
};
class client_deleter
{
public:
client_deleter(wsrep::server_service& server_service)
: server_service_(server_service)
{ }
void operator()(wsrep::client_state* client_state)
{
server_service_.release_client_state(client_state);
}
private:
wsrep::server_service& server_service_;
};
template <class D>
class scoped_client_state
{

View File

@ -14,6 +14,7 @@
#define WSREP_SERVER_SERVICE_HPP
#include "logger.hpp"
#include "server_state.hpp"
#include <string>
@ -93,6 +94,20 @@ namespace wsrep
*/
virtual void log_view(const wsrep::view&) = 0;
/**
* Log a state change event.
*
* Note that this method may be called with server_state
* mutex locked, so calling server_state public methods
* should be avoided from within this call.
*
* @param prev_state Previous state server was in
* @param current_state Current state
*/
virtual void log_state_change(
enum wsrep::server_state::state prev_state,
enum wsrep::server_state::state current_state) = 0;
/**
* Determine if the configured SST method requires SST to be
* performed before DBMS storage engine initialization.

View File

@ -69,7 +69,6 @@
#include "mutex.hpp"
#include "condition_variable.hpp"
#include "server_service.hpp"
#include "id.hpp"
#include "view.hpp"
#include "transaction_id.hpp"
@ -87,7 +86,7 @@ namespace wsrep
class client_state;
class transaction;
class const_buffer;
class server_service;
/** @class Server Context
*
*
@ -469,7 +468,9 @@ namespace wsrep
return state_;
}
/**
* Get provider status variables.
*/
std::vector<wsrep::provider::status_variable> status() const;
/**
@ -586,19 +587,6 @@ namespace wsrep
int debug_log_level_;
};
class client_deleter
{
public:
client_deleter(wsrep::server_service& server_service)
: server_service_(server_service)
{ }
void operator()(wsrep::client_state* client_state)
{
server_service_.release_client_state(client_state);
}
private:
wsrep::server_service& server_service_;
};
static inline const char* to_c_string(
enum wsrep::server_state::state state)