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)
|
include(CTest)
|
||||||
|
|
||||||
# Options
|
# 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_ASAN "Enable address sanitizer" OFF)
|
||||||
option(WITH_TSAN "Enable thread sanitizer" OFF)
|
option(WITH_TSAN "Enable thread sanitizer" OFF)
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include "db_server.hpp"
|
#include "db_server.hpp"
|
||||||
#include "db_client.hpp"
|
#include "db_client.hpp"
|
||||||
|
|
||||||
int db::high_priority_service::apply(const wsrep::ws_handle& ws_handle,
|
db::high_priority_service::high_priority_service(
|
||||||
const wsrep::ws_meta& ws_meta,
|
db::server& server, db::client* client)
|
||||||
const wsrep::const_buffer& data)
|
: wsrep::high_priority_service(server_.server_state())
|
||||||
{
|
, server_(server)
|
||||||
return server_.server_state().on_apply(*this, ws_handle, ws_meta, data);
|
, client_(client)
|
||||||
}
|
{ }
|
||||||
|
|
||||||
int db::high_priority_service::start_transaction(
|
int db::high_priority_service::start_transaction(
|
||||||
const wsrep::ws_handle& ws_handle,
|
const wsrep::ws_handle& ws_handle,
|
||||||
|
@ -11,16 +11,10 @@ namespace db
|
|||||||
{
|
{
|
||||||
class server;
|
class server;
|
||||||
class client;
|
class client;
|
||||||
class high_priority_service : wsrep::high_priority_service
|
class high_priority_service : public wsrep::high_priority_service
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
high_priority_service(db::server& server, db::client* client)
|
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;
|
|
||||||
int start_transaction(const wsrep::ws_handle&,
|
int start_transaction(const wsrep::ws_handle&,
|
||||||
const wsrep::ws_meta&) override;
|
const wsrep::ws_meta&) override;
|
||||||
void adopt_transaction(const wsrep::transaction&) override;
|
void adopt_transaction(const wsrep::transaction&) override;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
|
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||||
#define WSREP_HIGH_PRIORITY_SERVICE_HPP
|
#define WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||||
|
|
||||||
|
#include "server_state.hpp"
|
||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class ws_handle;
|
class ws_handle;
|
||||||
@ -18,10 +20,15 @@ namespace wsrep
|
|||||||
class high_priority_service
|
class high_priority_service
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
high_priority_service(wsrep::server_state& server_state)
|
||||||
|
: server_state_(server_state) { }
|
||||||
virtual ~high_priority_service() { }
|
virtual ~high_priority_service() { }
|
||||||
|
|
||||||
virtual int apply(const ws_handle&, const ws_meta&,
|
int apply(const ws_handle& ws_handle, const ws_meta& ws_meta,
|
||||||
const const_buffer&) = 0;
|
const const_buffer& data)
|
||||||
|
{
|
||||||
|
return server_state_.on_apply(*this, ws_handle, ws_meta, data);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Start a new transaction
|
* Start a new transaction
|
||||||
*/
|
*/
|
||||||
@ -71,7 +78,8 @@ namespace wsrep
|
|||||||
virtual int log_dummy_write_set(const ws_handle&, const ws_meta&) = 0;
|
virtual int log_dummy_write_set(const ws_handle&, const ws_meta&) = 0;
|
||||||
|
|
||||||
virtual bool is_replaying() const = 0;
|
virtual bool is_replaying() const = 0;
|
||||||
private:
|
protected:
|
||||||
|
wsrep::server_state& server_state_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class high_priority_switch
|
class high_priority_switch
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class server_state;
|
class server_state;
|
||||||
|
class high_priority_service;
|
||||||
class stid
|
class stid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -237,7 +237,8 @@ namespace wsrep
|
|||||||
virtual int resume() = 0;
|
virtual int resume() = 0;
|
||||||
|
|
||||||
// Applier interface
|
// 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
|
// Write set replication
|
||||||
// TODO: Rename to assing_read_view()
|
// TODO: Rename to assing_read_view()
|
||||||
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
||||||
@ -276,7 +277,8 @@ namespace wsrep
|
|||||||
* @return Zero in case of success, non-zero on failure.
|
* @return Zero in case of success, non-zero on failure.
|
||||||
*/
|
*/
|
||||||
virtual enum status replay(
|
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
|
* Enter total order isolation critical section
|
||||||
|
@ -554,7 +554,8 @@ int wsrep::wsrep_provider_v26::resume()
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum wsrep::provider::status
|
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));
|
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
|
enum wsrep::provider::status
|
||||||
wsrep::wsrep_provider_v26::replay(const wsrep::ws_handle& ws_handle,
|
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);
|
const_ws_handle mwsh(ws_handle);
|
||||||
return map_return_value(
|
return map_return_value(
|
||||||
wsrep_->replay_trx(wsrep_, mwsh.native(), applier_ctx));
|
wsrep_->replay_trx(wsrep_, mwsh.native(), reply_service));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
|
@ -29,7 +29,7 @@ namespace wsrep
|
|||||||
wsrep::seqno pause();
|
wsrep::seqno pause();
|
||||||
int resume();
|
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 start_transaction(wsrep::ws_handle&) { return 0; }
|
||||||
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
||||||
enum wsrep::provider::status
|
enum wsrep::provider::status
|
||||||
@ -49,7 +49,8 @@ namespace wsrep
|
|||||||
int commit_order_leave(const wsrep::ws_handle&,
|
int commit_order_leave(const wsrep::ws_handle&,
|
||||||
const wsrep::ws_meta&);
|
const wsrep::ws_meta&);
|
||||||
int release(wsrep::ws_handle&);
|
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,
|
enum wsrep::provider::status enter_toi(wsrep::client_id,
|
||||||
const wsrep::key_array&,
|
const wsrep::key_array&,
|
||||||
const wsrep::const_buffer&,
|
const wsrep::const_buffer&,
|
||||||
|
@ -17,10 +17,9 @@ namespace wsrep
|
|||||||
wsrep::server_state& server_state,
|
wsrep::server_state& server_state,
|
||||||
wsrep::mock_client_state* client_state,
|
wsrep::mock_client_state* client_state,
|
||||||
bool replaying)
|
bool replaying)
|
||||||
: wsrep::high_priority_service()
|
: wsrep::high_priority_service(server_state)
|
||||||
, fail_next_applying_()
|
, fail_next_applying_()
|
||||||
, fail_next_toi_()
|
, fail_next_toi_()
|
||||||
, server_state_(server_state)
|
|
||||||
, client_state_(client_state)
|
, client_state_(client_state)
|
||||||
, replaying_(replaying)
|
, replaying_(replaying)
|
||||||
{ }
|
{ }
|
||||||
@ -53,7 +52,6 @@ namespace wsrep
|
|||||||
private:
|
private:
|
||||||
mock_high_priority_service(const mock_high_priority_service&);
|
mock_high_priority_service(const mock_high_priority_service&);
|
||||||
mock_high_priority_service& operator=(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_;
|
wsrep::mock_client_state* client_state_;
|
||||||
bool replaying_;
|
bool replaying_;
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@ namespace wsrep
|
|||||||
int resync() { return 0; }
|
int resync() { return 0; }
|
||||||
wsrep::seqno pause() { return wsrep::seqno(0); }
|
wsrep::seqno pause() { return wsrep::seqno(0); }
|
||||||
int resume() { return 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;
|
return wsrep::provider::success;
|
||||||
}
|
}
|
||||||
@ -160,11 +160,12 @@ namespace wsrep
|
|||||||
return release_result_;
|
return release_result_;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum wsrep::provider::status replay(const wsrep::ws_handle& ws_handle,
|
enum wsrep::provider::status replay(
|
||||||
void* ctx)
|
const wsrep::ws_handle& ws_handle,
|
||||||
|
wsrep::high_priority_service* hps)
|
||||||
{
|
{
|
||||||
wsrep::mock_high_priority_service& high_priority_service(
|
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(
|
wsrep::mock_client_state& cc(
|
||||||
*high_priority_service.client_state());
|
*high_priority_service.client_state());
|
||||||
wsrep::high_priority_context high_priority_context(cc);
|
wsrep::high_priority_context high_priority_context(cc);
|
||||||
|
Reference in New Issue
Block a user