mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Pass high_priority_service instead of void ptr for provider methods.
This commit is contained in:
@ -8,7 +8,7 @@ include(CheckIncludeFile)
|
||||
include(CTest)
|
||||
|
||||
# Options
|
||||
option(WITH_AUTO_TEST "Run unit tests automatically after build" OFF)
|
||||
option(WITH_AUTO_TEST "Run unit tests automatically after build" ON)
|
||||
option(WITH_ASAN "Enable address sanitizer" OFF)
|
||||
option(WITH_TSAN "Enable thread sanitizer" OFF)
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
#include "db_server.hpp"
|
||||
#include "db_client.hpp"
|
||||
|
||||
int db::high_priority_service::apply(const wsrep::ws_handle& ws_handle,
|
||||
const wsrep::ws_meta& ws_meta,
|
||||
const wsrep::const_buffer& data)
|
||||
{
|
||||
return server_.server_state().on_apply(*this, ws_handle, ws_meta, data);
|
||||
}
|
||||
db::high_priority_service::high_priority_service(
|
||||
db::server& server, db::client* client)
|
||||
: wsrep::high_priority_service(server_.server_state())
|
||||
, server_(server)
|
||||
, client_(client)
|
||||
{ }
|
||||
|
||||
int db::high_priority_service::start_transaction(
|
||||
const wsrep::ws_handle& ws_handle,
|
||||
|
@ -11,16 +11,10 @@ namespace db
|
||||
{
|
||||
class server;
|
||||
class client;
|
||||
class high_priority_service : wsrep::high_priority_service
|
||||
class high_priority_service : public wsrep::high_priority_service
|
||||
{
|
||||
public:
|
||||
high_priority_service(db::server& server, db::client* client)
|
||||
: server_(server)
|
||||
, client_(client)
|
||||
{ }
|
||||
|
||||
int apply(const wsrep::ws_handle&, const wsrep::ws_meta&,
|
||||
const wsrep::const_buffer&) override;
|
||||
high_priority_service(db::server& server, db::client* client);
|
||||
int start_transaction(const wsrep::ws_handle&,
|
||||
const wsrep::ws_meta&) override;
|
||||
void adopt_transaction(const wsrep::transaction&) override;
|
||||
|
@ -9,6 +9,8 @@
|
||||
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||
#define WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||
|
||||
#include "server_state.hpp"
|
||||
|
||||
namespace wsrep
|
||||
{
|
||||
class ws_handle;
|
||||
@ -18,10 +20,15 @@ namespace wsrep
|
||||
class high_priority_service
|
||||
{
|
||||
public:
|
||||
high_priority_service(wsrep::server_state& server_state)
|
||||
: server_state_(server_state) { }
|
||||
virtual ~high_priority_service() { }
|
||||
|
||||
virtual int apply(const ws_handle&, const ws_meta&,
|
||||
const const_buffer&) = 0;
|
||||
int apply(const ws_handle& ws_handle, const ws_meta& ws_meta,
|
||||
const const_buffer& data)
|
||||
{
|
||||
return server_state_.on_apply(*this, ws_handle, ws_meta, data);
|
||||
}
|
||||
/**
|
||||
* Start a new transaction
|
||||
*/
|
||||
@ -71,7 +78,8 @@ namespace wsrep
|
||||
virtual int log_dummy_write_set(const ws_handle&, const ws_meta&) = 0;
|
||||
|
||||
virtual bool is_replaying() const = 0;
|
||||
private:
|
||||
protected:
|
||||
wsrep::server_state& server_state_;
|
||||
};
|
||||
|
||||
class high_priority_switch
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace wsrep
|
||||
{
|
||||
class server_state;
|
||||
|
||||
class high_priority_service;
|
||||
class stid
|
||||
{
|
||||
public:
|
||||
@ -237,7 +237,8 @@ namespace wsrep
|
||||
virtual int resume() = 0;
|
||||
|
||||
// Applier interface
|
||||
virtual enum status run_applier(void* applier_ctx) = 0;
|
||||
virtual enum status run_applier(wsrep::high_priority_service*
|
||||
applier_ctx) = 0;
|
||||
// Write set replication
|
||||
// TODO: Rename to assing_read_view()
|
||||
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
||||
@ -276,7 +277,8 @@ namespace wsrep
|
||||
* @return Zero in case of success, non-zero on failure.
|
||||
*/
|
||||
virtual enum status replay(
|
||||
const wsrep::ws_handle& ws_handle, void* applier_ctx) = 0;
|
||||
const wsrep::ws_handle& ws_handle,
|
||||
wsrep::high_priority_service* applier_ctx) = 0;
|
||||
|
||||
/**
|
||||
* Enter total order isolation critical section
|
||||
|
@ -554,7 +554,8 @@ int wsrep::wsrep_provider_v26::resume()
|
||||
}
|
||||
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::run_applier(void *applier_ctx)
|
||||
wsrep::wsrep_provider_v26::run_applier(
|
||||
wsrep::high_priority_service *applier_ctx)
|
||||
{
|
||||
return map_return_value(wsrep_->recv(wsrep_, applier_ctx));
|
||||
}
|
||||
@ -649,11 +650,11 @@ int wsrep::wsrep_provider_v26::release(wsrep::ws_handle& ws_handle)
|
||||
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::replay(const wsrep::ws_handle& ws_handle,
|
||||
void* applier_ctx)
|
||||
wsrep::high_priority_service* reply_service)
|
||||
{
|
||||
const_ws_handle mwsh(ws_handle);
|
||||
return map_return_value(
|
||||
wsrep_->replay_trx(wsrep_, mwsh.native(), applier_ctx));
|
||||
wsrep_->replay_trx(wsrep_, mwsh.native(), reply_service));
|
||||
}
|
||||
|
||||
enum wsrep::provider::status
|
||||
|
@ -29,7 +29,7 @@ namespace wsrep
|
||||
wsrep::seqno pause();
|
||||
int resume();
|
||||
|
||||
enum wsrep::provider::status run_applier(void*);
|
||||
enum wsrep::provider::status run_applier(wsrep::high_priority_service*);
|
||||
int start_transaction(wsrep::ws_handle&) { return 0; }
|
||||
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
||||
enum wsrep::provider::status
|
||||
@ -49,7 +49,8 @@ namespace wsrep
|
||||
int commit_order_leave(const wsrep::ws_handle&,
|
||||
const wsrep::ws_meta&);
|
||||
int release(wsrep::ws_handle&);
|
||||
enum wsrep::provider::status replay(const wsrep::ws_handle&, void*);
|
||||
enum wsrep::provider::status replay(const wsrep::ws_handle&,
|
||||
wsrep::high_priority_service*);
|
||||
enum wsrep::provider::status enter_toi(wsrep::client_id,
|
||||
const wsrep::key_array&,
|
||||
const wsrep::const_buffer&,
|
||||
|
@ -17,10 +17,9 @@ namespace wsrep
|
||||
wsrep::server_state& server_state,
|
||||
wsrep::mock_client_state* client_state,
|
||||
bool replaying)
|
||||
: wsrep::high_priority_service()
|
||||
: wsrep::high_priority_service(server_state)
|
||||
, fail_next_applying_()
|
||||
, fail_next_toi_()
|
||||
, server_state_(server_state)
|
||||
, client_state_(client_state)
|
||||
, replaying_(replaying)
|
||||
{ }
|
||||
@ -53,7 +52,6 @@ namespace wsrep
|
||||
private:
|
||||
mock_high_priority_service(const mock_high_priority_service&);
|
||||
mock_high_priority_service& operator=(const mock_high_priority_service&);
|
||||
wsrep::server_state& server_state_;
|
||||
wsrep::mock_client_state* client_state_;
|
||||
bool replaying_;
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ namespace wsrep
|
||||
int resync() { return 0; }
|
||||
wsrep::seqno pause() { return wsrep::seqno(0); }
|
||||
int resume() { return 0; }
|
||||
enum wsrep::provider::status run_applier(void*)
|
||||
enum wsrep::provider::status run_applier(wsrep::high_priority_service*)
|
||||
{
|
||||
return wsrep::provider::success;
|
||||
}
|
||||
@ -160,11 +160,12 @@ namespace wsrep
|
||||
return release_result_;
|
||||
}
|
||||
|
||||
enum wsrep::provider::status replay(const wsrep::ws_handle& ws_handle,
|
||||
void* ctx)
|
||||
enum wsrep::provider::status replay(
|
||||
const wsrep::ws_handle& ws_handle,
|
||||
wsrep::high_priority_service* hps)
|
||||
{
|
||||
wsrep::mock_high_priority_service& high_priority_service(
|
||||
*static_cast<wsrep::mock_high_priority_service*>(ctx));
|
||||
*static_cast<wsrep::mock_high_priority_service*>(hps));
|
||||
wsrep::mock_client_state& cc(
|
||||
*high_priority_service.client_state());
|
||||
wsrep::high_priority_context high_priority_context(cc);
|
||||
|
Reference in New Issue
Block a user