mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-06-14 15:02:27 +03:00
Changed project name to wsrep-lib.
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
project (trrep)
|
project (wsrep-lib)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
12
README.md
12
README.md
@ -1,6 +1,6 @@
|
|||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
Project name: Trrep - Transaction Replication
|
Project name: wsrep-lib - Library for WSREP
|
||||||
|
|
||||||
The purpose of this project is to implement C++ wrapper
|
The purpose of this project is to implement C++ wrapper
|
||||||
for wsrep API with additional convenience for transaction
|
for wsrep API with additional convenience for transaction
|
||||||
@ -202,7 +202,7 @@ Methods:
|
|||||||
# Example usage
|
# Example usage
|
||||||
|
|
||||||
```
|
```
|
||||||
class dbms_server : public trrep::server_context
|
class dbms_server : public wsrep::server_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Implementation
|
// Implementation
|
||||||
@ -212,7 +212,7 @@ class dbms_server : public trrep::server_context
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class dbms_client : public trrep::client_context
|
class dbms_client : public wsrep::client_context
|
||||||
{
|
{
|
||||||
// Implementation
|
// Implementation
|
||||||
};
|
};
|
||||||
@ -224,18 +224,18 @@ int main()
|
|||||||
if (server.sst_before_init())
|
if (server.sst_before_init())
|
||||||
{
|
{
|
||||||
server.start();
|
server.start();
|
||||||
server.wait_until_state(trrep::server_context::s_joined);
|
server.wait_until_state(wsrep::server_context::s_joined);
|
||||||
|
|
||||||
}
|
}
|
||||||
// Initialize dbms code here
|
// Initialize dbms code here
|
||||||
if (server.sst_before_init() == false)
|
if (server.sst_before_init() == false)
|
||||||
{
|
{
|
||||||
server.start();
|
server.start();
|
||||||
server.wait_until_state(trrep::server_context::s_joined);
|
server.wait_until_state(wsrep::server_context::s_joined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start accepting client connections
|
// Start accepting client connections
|
||||||
server.wait_until_state(trrep::server_context::s_synced);
|
server.wait_until_state(wsrep::server_context::s_synced);
|
||||||
|
|
||||||
// Clients can read and write here
|
// Clients can read and write here
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
|
|||||||
# title of most generated pages and in a few other places.
|
# title of most generated pages and in a few other places.
|
||||||
# The default value is: My Project.
|
# The default value is: My Project.
|
||||||
|
|
||||||
PROJECT_NAME = "TRREP"
|
PROJECT_NAME = "wsrep-lib"
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
@ -773,7 +773,7 @@ WARN_LOGFILE =
|
|||||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = ../include/trrep
|
INPUT = ../include/wsrep
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
* drives the transaction.
|
* drives the transaction.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TRREP_CLIENT_CONTEXT_HPP
|
#ifndef WSREP_CLIENT_CONTEXT_HPP
|
||||||
#define TRREP_CLIENT_CONTEXT_HPP
|
#define WSREP_CLIENT_CONTEXT_HPP
|
||||||
|
|
||||||
#include "server_context.hpp"
|
#include "server_context.hpp"
|
||||||
#include "transaction_context.hpp"
|
#include "transaction_context.hpp"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
#include "lock.hpp"
|
#include "lock.hpp"
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class server_context;
|
class server_context;
|
||||||
class provider;
|
class provider;
|
||||||
@ -206,7 +206,7 @@ namespace trrep
|
|||||||
assert(state_ == s_exec);
|
assert(state_ == s_exec);
|
||||||
return transaction_.start_transaction();
|
return transaction_.start_transaction();
|
||||||
}
|
}
|
||||||
int start_transaction(const trrep::transaction_id& id)
|
int start_transaction(const wsrep::transaction_id& id)
|
||||||
{
|
{
|
||||||
assert(state_ == s_exec);
|
assert(state_ == s_exec);
|
||||||
return transaction_.start_transaction(id);
|
return transaction_.start_transaction(id);
|
||||||
@ -220,13 +220,13 @@ namespace trrep
|
|||||||
return transaction_.start_transaction(wsh, meta, flags);
|
return transaction_.start_transaction(wsh, meta, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int append_key(const trrep::key& key)
|
int append_key(const wsrep::key& key)
|
||||||
{
|
{
|
||||||
assert(state_ == s_exec);
|
assert(state_ == s_exec);
|
||||||
return transaction_.append_key(key);
|
return transaction_.append_key(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int append_data(const trrep::data& data)
|
int append_data(const wsrep::data& data)
|
||||||
{
|
{
|
||||||
assert(state_ == s_exec);
|
assert(state_ == s_exec);
|
||||||
return transaction_.append_data(data);
|
return transaction_.append_data(data);
|
||||||
@ -271,7 +271,7 @@ namespace trrep
|
|||||||
return transaction_.after_rollback();
|
return transaction_.after_rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
int bf_abort(trrep::unique_lock<trrep::mutex>& lock,
|
int bf_abort(wsrep::unique_lock<wsrep::mutex>& lock,
|
||||||
wsrep_seqno_t bf_seqno)
|
wsrep_seqno_t bf_seqno)
|
||||||
{
|
{
|
||||||
return transaction_.bf_abort(lock, bf_seqno);
|
return transaction_.bf_abort(lock, bf_seqno);
|
||||||
@ -281,14 +281,14 @@ namespace trrep
|
|||||||
*
|
*
|
||||||
* \return Reference to the client mutex.
|
* \return Reference to the client mutex.
|
||||||
*/
|
*/
|
||||||
trrep::mutex& mutex() { return mutex_; }
|
wsrep::mutex& mutex() { return mutex_; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get server context associated the the client session.
|
* Get server context associated the the client session.
|
||||||
*
|
*
|
||||||
* \return Reference to server context.
|
* \return Reference to server context.
|
||||||
*/
|
*/
|
||||||
trrep::server_context& server_context() const
|
wsrep::server_context& server_context() const
|
||||||
{ return server_context_; }
|
{ return server_context_; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -296,10 +296,10 @@ namespace trrep
|
|||||||
* with the client context.
|
* with the client context.
|
||||||
*
|
*
|
||||||
* \return Reference to the provider.
|
* \return Reference to the provider.
|
||||||
* \throw trrep::runtime_error if no providers are associated
|
* \throw wsrep::runtime_error if no providers are associated
|
||||||
* with the client context.
|
* with the client context.
|
||||||
*/
|
*/
|
||||||
trrep::provider& provider() const;
|
wsrep::provider& provider() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get Client identifier.
|
* Get Client identifier.
|
||||||
@ -317,7 +317,7 @@ namespace trrep
|
|||||||
*/
|
*/
|
||||||
enum mode mode() const { return mode_; }
|
enum mode mode() const { return mode_; }
|
||||||
|
|
||||||
const trrep::transaction_context& transaction() const
|
const wsrep::transaction_context& transaction() const
|
||||||
{
|
{
|
||||||
return transaction_;
|
return transaction_;
|
||||||
}
|
}
|
||||||
@ -331,10 +331,10 @@ namespace trrep
|
|||||||
|
|
||||||
void reset_error()
|
void reset_error()
|
||||||
{
|
{
|
||||||
current_error_ = trrep::e_success;
|
current_error_ = wsrep::e_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum trrep::client_error current_error() const
|
enum wsrep::client_error current_error() const
|
||||||
{
|
{
|
||||||
return current_error_;
|
return current_error_;
|
||||||
}
|
}
|
||||||
@ -343,8 +343,8 @@ namespace trrep
|
|||||||
* Client context constuctor. This is protected so that it
|
* Client context constuctor. This is protected so that it
|
||||||
* can be called from derived class constructors only.
|
* can be called from derived class constructors only.
|
||||||
*/
|
*/
|
||||||
client_context(trrep::mutex& mutex,
|
client_context(wsrep::mutex& mutex,
|
||||||
trrep::server_context& server_context,
|
wsrep::server_context& server_context,
|
||||||
const client_id& id,
|
const client_id& id,
|
||||||
enum mode mode)
|
enum mode mode)
|
||||||
: mutex_(mutex)
|
: mutex_(mutex)
|
||||||
@ -355,7 +355,7 @@ namespace trrep
|
|||||||
, transaction_(*this)
|
, transaction_(*this)
|
||||||
, allow_dirty_reads_()
|
, allow_dirty_reads_()
|
||||||
, debug_log_level_(0)
|
, debug_log_level_(0)
|
||||||
, current_error_(trrep::e_success)
|
, current_error_(wsrep::e_success)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -366,7 +366,7 @@ namespace trrep
|
|||||||
* Friend declarations
|
* Friend declarations
|
||||||
*/
|
*/
|
||||||
friend int server_context::on_apply(client_context&,
|
friend int server_context::on_apply(client_context&,
|
||||||
const trrep::data&);
|
const wsrep::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 client_toi_mode;
|
||||||
@ -384,7 +384,7 @@ namespace trrep
|
|||||||
/*!
|
/*!
|
||||||
* Set client state.
|
* Set client state.
|
||||||
*/
|
*/
|
||||||
void state(trrep::unique_lock<trrep::mutex>& lock, enum state state);
|
void state(wsrep::unique_lock<wsrep::mutex>& lock, enum state state);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Virtual method to return true if the client operates
|
* Virtual method to return true if the client operates
|
||||||
@ -398,8 +398,8 @@ namespace trrep
|
|||||||
/*!
|
/*!
|
||||||
* Append SR fragment to the transaction.
|
* Append SR fragment to the transaction.
|
||||||
*/
|
*/
|
||||||
virtual int append_fragment(trrep::transaction_context&,
|
virtual int append_fragment(wsrep::transaction_context&,
|
||||||
uint32_t, const trrep::data&)
|
uint32_t, const wsrep::data&)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ namespace trrep
|
|||||||
*
|
*
|
||||||
* \return Zero on success, non-zero on applying failure.
|
* \return Zero on success, non-zero on applying failure.
|
||||||
*/
|
*/
|
||||||
virtual int apply(const trrep::data& data) = 0;
|
virtual int apply(const wsrep::data& data) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Virtual method which will be called
|
* Virtual method which will be called
|
||||||
@ -433,21 +433,21 @@ namespace trrep
|
|||||||
* Notify a implementation that the client is about
|
* Notify a implementation that the client is about
|
||||||
* to replay the transaction.
|
* to replay the transaction.
|
||||||
*/
|
*/
|
||||||
virtual void will_replay(trrep::transaction_context&) = 0;
|
virtual void will_replay(wsrep::transaction_context&) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Replay the transaction.
|
* Replay the transaction.
|
||||||
*/
|
*/
|
||||||
virtual int replay(trrep::transaction_context& tc) = 0;
|
virtual int replay(wsrep::transaction_context& tc) = 0;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Wait until all of the replaying transactions have been committed.
|
* Wait until all of the replaying transactions have been committed.
|
||||||
*/
|
*/
|
||||||
virtual void wait_for_replayers(trrep::unique_lock<trrep::mutex>&) const = 0;
|
virtual void wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&) const = 0;
|
||||||
|
|
||||||
virtual int prepare_data_for_replication(
|
virtual int prepare_data_for_replication(
|
||||||
const trrep::transaction_context&, trrep::data& data)
|
const wsrep::transaction_context&, wsrep::data& data)
|
||||||
{
|
{
|
||||||
static const char buf[1] = { 1 };
|
static const char buf[1] = { 1 };
|
||||||
data.assign(buf, 1);
|
data.assign(buf, 1);
|
||||||
@ -484,27 +484,27 @@ namespace trrep
|
|||||||
/*!
|
/*!
|
||||||
* Notify the implementation about an error.
|
* Notify the implementation about an error.
|
||||||
*/
|
*/
|
||||||
virtual void on_error(enum trrep::client_error error) = 0;
|
virtual void on_error(enum wsrep::client_error error) = 0;
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void override_error(enum trrep::client_error error)
|
void override_error(enum wsrep::client_error error)
|
||||||
{
|
{
|
||||||
if (current_error_ != trrep::e_success &&
|
if (current_error_ != wsrep::e_success &&
|
||||||
error == trrep::e_success)
|
error == wsrep::e_success)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Overriding error with success");
|
throw wsrep::runtime_error("Overriding error with success");
|
||||||
}
|
}
|
||||||
current_error_ = error;
|
current_error_ = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::mutex& mutex_;
|
wsrep::mutex& mutex_;
|
||||||
trrep::server_context& server_context_;
|
wsrep::server_context& server_context_;
|
||||||
client_id id_;
|
client_id id_;
|
||||||
enum mode mode_;
|
enum mode mode_;
|
||||||
enum state state_;
|
enum state state_;
|
||||||
protected:
|
protected:
|
||||||
trrep::transaction_context transaction_;
|
wsrep::transaction_context transaction_;
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
* \todo This boolean should be converted to better read isolation
|
* \todo This boolean should be converted to better read isolation
|
||||||
@ -512,15 +512,15 @@ namespace trrep
|
|||||||
*/
|
*/
|
||||||
bool allow_dirty_reads_;
|
bool allow_dirty_reads_;
|
||||||
int debug_log_level_;
|
int debug_log_level_;
|
||||||
trrep::client_error current_error_;
|
wsrep::client_error current_error_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class client_context_switch
|
class client_context_switch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_context_switch(trrep::client_context& orig_context,
|
client_context_switch(wsrep::client_context& orig_context,
|
||||||
trrep::client_context& current_context)
|
wsrep::client_context& current_context)
|
||||||
: orig_context_(orig_context)
|
: orig_context_(orig_context)
|
||||||
, current_context_(current_context)
|
, current_context_(current_context)
|
||||||
{
|
{
|
||||||
@ -538,41 +538,41 @@ namespace trrep
|
|||||||
class client_applier_mode
|
class client_applier_mode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_applier_mode(trrep::client_context& client)
|
client_applier_mode(wsrep::client_context& client)
|
||||||
: client_(client)
|
: client_(client)
|
||||||
, orig_mode_(client.mode_)
|
, orig_mode_(client.mode_)
|
||||||
{
|
{
|
||||||
client_.mode_ = trrep::client_context::m_applier;
|
client_.mode_ = wsrep::client_context::m_applier;
|
||||||
}
|
}
|
||||||
~client_applier_mode()
|
~client_applier_mode()
|
||||||
{
|
{
|
||||||
client_.mode_ = orig_mode_;
|
client_.mode_ = orig_mode_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
trrep::client_context& client_;
|
wsrep::client_context& client_;
|
||||||
enum trrep::client_context::mode orig_mode_;
|
enum wsrep::client_context::mode orig_mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class client_toi_mode
|
class client_toi_mode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_toi_mode(trrep::client_context& client)
|
client_toi_mode(wsrep::client_context& client)
|
||||||
: client_(client)
|
: client_(client)
|
||||||
, orig_mode_(client.mode_)
|
, orig_mode_(client.mode_)
|
||||||
{
|
{
|
||||||
client_.mode_ = trrep::client_context::m_toi;
|
client_.mode_ = wsrep::client_context::m_toi;
|
||||||
}
|
}
|
||||||
~client_toi_mode()
|
~client_toi_mode()
|
||||||
{
|
{
|
||||||
assert(client_.mode() == trrep::client_context::m_toi);
|
assert(client_.mode() == wsrep::client_context::m_toi);
|
||||||
client_.mode_ = orig_mode_;
|
client_.mode_ = orig_mode_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
trrep::client_context& client_;
|
wsrep::client_context& client_;
|
||||||
enum trrep::client_context::mode orig_mode_;
|
enum wsrep::client_context::mode orig_mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_CLIENT_CONTEXT_HPP
|
#endif // WSREP_CLIENT_CONTEXT_HPP
|
@ -8,9 +8,9 @@
|
|||||||
* Compiler specific options.
|
* Compiler specific options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRREP_UNUSED __attribute__((unused))
|
#define WSREP_UNUSED __attribute__((unused))
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
#define TRREP_OVERRIDE override
|
#define WSREP_OVERRIDE override
|
||||||
#else
|
#else
|
||||||
#define TRREP_OVERRIDE
|
#define WSREP_OVERRIDE
|
||||||
#endif // __cplusplus >= 201103L
|
#endif // __cplusplus >= 201103L
|
@ -2,14 +2,14 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_CONDITION_VARIABLE_HPP
|
#ifndef WSREP_CONDITION_VARIABLE_HPP
|
||||||
#define TRREP_CONDITION_VARIABLE_HPP
|
#define WSREP_CONDITION_VARIABLE_HPP
|
||||||
|
|
||||||
#include "lock.hpp"
|
#include "lock.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class condition_variable
|
class condition_variable
|
||||||
{
|
{
|
||||||
@ -18,7 +18,7 @@ namespace trrep
|
|||||||
virtual ~condition_variable() { }
|
virtual ~condition_variable() { }
|
||||||
virtual void notify_one() = 0;
|
virtual void notify_one() = 0;
|
||||||
virtual void notify_all() = 0;
|
virtual void notify_all() = 0;
|
||||||
virtual void wait(trrep::unique_lock<trrep::mutex>& lock) = 0;
|
virtual void wait(wsrep::unique_lock<wsrep::mutex>& lock) = 0;
|
||||||
private:
|
private:
|
||||||
condition_variable(const condition_variable&);
|
condition_variable(const condition_variable&);
|
||||||
condition_variable& operator=(const condition_variable&);
|
condition_variable& operator=(const condition_variable&);
|
||||||
@ -33,7 +33,7 @@ namespace trrep
|
|||||||
{
|
{
|
||||||
if (pthread_cond_init(&cond_, 0))
|
if (pthread_cond_init(&cond_, 0))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to initialized condvar");
|
throw wsrep::runtime_error("Failed to initialized condvar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,13 +54,13 @@ namespace trrep
|
|||||||
(void)pthread_cond_broadcast(&cond_);
|
(void)pthread_cond_broadcast(&cond_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait(trrep::unique_lock<trrep::mutex>& lock)
|
void wait(wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
{
|
{
|
||||||
if (pthread_cond_wait(
|
if (pthread_cond_wait(
|
||||||
&cond_,
|
&cond_,
|
||||||
reinterpret_cast<pthread_mutex_t*>(lock.mutex().native())))
|
reinterpret_cast<pthread_mutex_t*>(lock.mutex().native())))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Cond wait failed");
|
throw wsrep::runtime_error("Cond wait failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,4 +70,4 @@ namespace trrep
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_CONDITION_VARIABLE_HPP
|
#endif // WSREP_CONDITION_VARIABLE_HPP
|
@ -2,10 +2,10 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_DATA_HPP
|
#ifndef WSREP_DATA_HPP
|
||||||
#define TRREP_DATA_HPP
|
#define WSREP_DATA_HPP
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class data
|
class data
|
||||||
{
|
{
|
||||||
@ -33,4 +33,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_DATA_HPP
|
#endif // WSREP_DATA_HPP
|
@ -2,13 +2,13 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_EXCEPTION_HPP
|
#ifndef WSREP_EXCEPTION_HPP
|
||||||
#define TRREP_EXCEPTION_HPP
|
#define WSREP_EXCEPTION_HPP
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class runtime_error : public std::runtime_error
|
class runtime_error : public std::runtime_error
|
||||||
{
|
{
|
||||||
@ -33,4 +33,4 @@ namespace trrep
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // TRREP_EXCEPTION_HPP
|
#endif // WSREP_EXCEPTION_HPP
|
@ -2,12 +2,12 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_KEY_HPP
|
#ifndef WSREP_KEY_HPP
|
||||||
#define TRREP_KEY_HPP
|
#define WSREP_KEY_HPP
|
||||||
|
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class key
|
class key
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ namespace trrep
|
|||||||
{
|
{
|
||||||
if (key_.key_parts_num == 3)
|
if (key_.key_parts_num == 3)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("key parts exceed maximum of 3");
|
throw wsrep::runtime_error("key parts exceed maximum of 3");
|
||||||
}
|
}
|
||||||
key_parts_[key_.key_parts_num].ptr = ptr;
|
key_parts_[key_.key_parts_num].ptr = ptr;
|
||||||
key_parts_[key_.key_parts_num].len = len;
|
key_parts_[key_.key_parts_num].len = len;
|
||||||
@ -38,4 +38,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_KEY_HPP
|
#endif // WSREP_KEY_HPP
|
@ -2,14 +2,14 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_LOCK_HPP
|
#ifndef WSREP_LOCK_HPP
|
||||||
#define TRREP_LOCK_HPP
|
#define WSREP_LOCK_HPP
|
||||||
|
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
template <class M>
|
template <class M>
|
||||||
class unique_lock
|
class unique_lock
|
||||||
@ -58,4 +58,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_LOCK_HPP
|
#endif // WSREP_LOCK_HPP
|
@ -2,8 +2,8 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_LOGGER_HPP
|
#ifndef WSREP_LOGGER_HPP
|
||||||
#define TRREP_LOGGER_HPP
|
#define WSREP_LOGGER_HPP
|
||||||
|
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include "lock.hpp"
|
#include "lock.hpp"
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class log
|
class log
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ namespace trrep
|
|||||||
{ }
|
{ }
|
||||||
~log()
|
~log()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
os_ << prefix_ << ": " << oss_.str() << "\n";
|
os_ << prefix_ << ": " << oss_.str() << "\n";
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -33,7 +33,7 @@ namespace trrep
|
|||||||
private:
|
private:
|
||||||
const std::string prefix_;
|
const std::string prefix_;
|
||||||
std::ostringstream oss_;
|
std::ostringstream oss_;
|
||||||
static trrep::mutex& mutex_;
|
static wsrep::mutex& mutex_;
|
||||||
static std::ostream& os_;
|
static std::ostream& os_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,4 +46,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_LOGGER_HPP
|
#endif // WSREP_LOGGER_HPP
|
@ -2,14 +2,14 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_MUTEX_HPP
|
#ifndef WSREP_MUTEX_HPP
|
||||||
#define TRREP_MUTEX_HPP
|
#define WSREP_MUTEX_HPP
|
||||||
|
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
@ -29,23 +29,23 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Default pthread implementation
|
// Default pthread implementation
|
||||||
class default_mutex : public trrep::mutex
|
class default_mutex : public wsrep::mutex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
default_mutex()
|
default_mutex()
|
||||||
: trrep::mutex(),
|
: wsrep::mutex(),
|
||||||
mutex_()
|
mutex_()
|
||||||
{
|
{
|
||||||
if (pthread_mutex_init(&mutex_, 0))
|
if (pthread_mutex_init(&mutex_, 0))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("mutex init failed");
|
throw wsrep::runtime_error("mutex init failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~default_mutex()
|
~default_mutex()
|
||||||
{
|
{
|
||||||
if (pthread_mutex_destroy(&mutex_))
|
if (pthread_mutex_destroy(&mutex_))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("mutex destroy failed");
|
throw wsrep::runtime_error("mutex destroy failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace trrep
|
|||||||
{
|
{
|
||||||
if (pthread_mutex_lock(&mutex_))
|
if (pthread_mutex_lock(&mutex_))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("mutex lock failed");
|
throw wsrep::runtime_error("mutex lock failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace trrep
|
|||||||
{
|
{
|
||||||
if (pthread_mutex_unlock(&mutex_))
|
if (pthread_mutex_unlock(&mutex_))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("mutex unlock failed");
|
throw wsrep::runtime_error("mutex unlock failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,4 +74,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_MUTEX_HPP
|
#endif // WSREP_MUTEX_HPP
|
@ -2,8 +2,8 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_PROVIDER_HPP
|
#ifndef WSREP_PROVIDER_HPP
|
||||||
#define TRREP_PROVIDER_HPP
|
#define WSREP_PROVIDER_HPP
|
||||||
|
|
||||||
// #include "provider_impl.hpp"
|
// #include "provider_impl.hpp"
|
||||||
|
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
// Abstract interface for provider implementations
|
// Abstract interface for provider implementations
|
||||||
class provider
|
class provider
|
||||||
@ -96,4 +96,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_PROVIDER_HPP
|
#endif // WSREP_PROVIDER_HPP
|
@ -7,7 +7,7 @@
|
|||||||
* Server Context Abstraction
|
* Server Context Abstraction
|
||||||
* ==========================
|
* ==========================
|
||||||
*
|
*
|
||||||
* This file defines an interface for TRRep Server Context.
|
* This file defines an interface for WSREP Server Context.
|
||||||
* The Server Context will encapsulate server identification,
|
* The Server Context will encapsulate server identification,
|
||||||
* server state and server capabilities. The class also
|
* server state and server capabilities. The class also
|
||||||
* defines an interface for manipulating server state, applying
|
* defines an interface for manipulating server state, applying
|
||||||
@ -58,8 +58,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TRREP_SERVER_CONTEXT_HPP
|
#ifndef WSREP_SERVER_CONTEXT_HPP
|
||||||
#define TRREP_SERVER_CONTEXT_HPP
|
#define WSREP_SERVER_CONTEXT_HPP
|
||||||
|
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
@ -69,7 +69,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
class provider;
|
class provider;
|
||||||
@ -208,13 +208,13 @@ namespace trrep
|
|||||||
*
|
*
|
||||||
* \return Reference to provider
|
* \return Reference to provider
|
||||||
*
|
*
|
||||||
* \throw trrep::runtime_error if provider has not been loaded
|
* \throw wsrep::runtime_error if provider has not been loaded
|
||||||
*/
|
*/
|
||||||
virtual trrep::provider& provider() const
|
virtual wsrep::provider& provider() const
|
||||||
{
|
{
|
||||||
if (provider_ == 0)
|
if (provider_ == 0)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("provider not loaded");
|
throw wsrep::runtime_error("provider not loaded");
|
||||||
}
|
}
|
||||||
return *provider_;
|
return *provider_;
|
||||||
}
|
}
|
||||||
@ -237,10 +237,10 @@ namespace trrep
|
|||||||
* notification event has been delivered by the
|
* notification event has been delivered by the
|
||||||
* provider.
|
* provider.
|
||||||
*
|
*
|
||||||
* \params view trrep::view object which holds the new view
|
* \params view wsrep::view object which holds the new view
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
void on_view(const trrep::view& view);
|
void on_view(const wsrep::view& view);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* A method which will be called when the server
|
* A method which will be called when the server
|
||||||
@ -254,7 +254,7 @@ namespace trrep
|
|||||||
/*!
|
/*!
|
||||||
* Wait until server reaches given state.
|
* Wait until server reaches given state.
|
||||||
*/
|
*/
|
||||||
void wait_until_state(trrep::server_context::state) const;
|
void wait_until_state(wsrep::server_context::state) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Virtual method to return true if the configured SST
|
* Virtual method to return true if the configured SST
|
||||||
@ -275,7 +275,7 @@ namespace trrep
|
|||||||
* Virtual method which will be called on *donor* when the
|
* Virtual method which will be called on *donor* when the
|
||||||
* SST request has been delivered by the provider.
|
* SST request has been delivered by the provider.
|
||||||
* This method should initiate SST transfer or throw
|
* This method should initiate SST transfer or throw
|
||||||
* a trrep::runtime_error
|
* a wsrep::runtime_error
|
||||||
* if the SST transfer cannot be initiated. If the SST request
|
* if the SST transfer cannot be initiated. If the SST request
|
||||||
* initiation is succesful, the server remains in s_donor
|
* initiation is succesful, the server remains in s_donor
|
||||||
* state until the SST is over or fails. The \param bypass
|
* state until the SST is over or fails. The \param bypass
|
||||||
@ -332,8 +332,8 @@ namespace trrep
|
|||||||
*
|
*
|
||||||
* \return Zero on success, non-zero on failure.
|
* \return Zero on success, non-zero on failure.
|
||||||
*/
|
*/
|
||||||
int on_apply(trrep::client_context& client_context,
|
int on_apply(wsrep::client_context& client_context,
|
||||||
const trrep::data& data);
|
const wsrep::data& data);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This virtual method should be implemented by the DBMS
|
* This virtual method should be implemented by the DBMS
|
||||||
@ -344,8 +344,8 @@ namespace trrep
|
|||||||
* replication, false otherwise.
|
* replication, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool statement_allowed_for_streaming(
|
virtual bool statement_allowed_for_streaming(
|
||||||
const trrep::client_context& client_context,
|
const wsrep::client_context& client_context,
|
||||||
const trrep::transaction_context& transaction_context) const;
|
const wsrep::transaction_context& transaction_context) const;
|
||||||
|
|
||||||
void debug_log_level(int level) { debug_log_level_ = level; }
|
void debug_log_level(int level) { debug_log_level_ = level; }
|
||||||
int debug_log_level() const { return debug_log_level_; }
|
int debug_log_level() const { return debug_log_level_; }
|
||||||
@ -363,8 +363,8 @@ namespace trrep
|
|||||||
* data files.
|
* data files.
|
||||||
* \param rollback_mode Rollback mode which server operates on.
|
* \param rollback_mode Rollback mode which server operates on.
|
||||||
*/
|
*/
|
||||||
server_context(trrep::mutex& mutex,
|
server_context(wsrep::mutex& mutex,
|
||||||
trrep::condition_variable& cond,
|
wsrep::condition_variable& cond,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
const std::string& address,
|
const std::string& address,
|
||||||
@ -388,13 +388,13 @@ namespace trrep
|
|||||||
server_context(const server_context&);
|
server_context(const server_context&);
|
||||||
server_context& operator=(const server_context&);
|
server_context& operator=(const server_context&);
|
||||||
|
|
||||||
void state(trrep::unique_lock<trrep::mutex>&, enum state);
|
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);
|
||||||
|
|
||||||
trrep::mutex& mutex_;
|
wsrep::mutex& mutex_;
|
||||||
trrep::condition_variable& cond_;
|
wsrep::condition_variable& cond_;
|
||||||
enum state state_;
|
enum state state_;
|
||||||
mutable std::vector<int> state_waiters_;
|
mutable std::vector<int> state_waiters_;
|
||||||
trrep::provider* provider_;
|
wsrep::provider* provider_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string id_;
|
std::string id_;
|
||||||
std::string address_;
|
std::string address_;
|
||||||
@ -403,23 +403,23 @@ namespace trrep
|
|||||||
int debug_log_level_;
|
int debug_log_level_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline std::string to_string(enum trrep::server_context::state state)
|
static inline std::string to_string(enum wsrep::server_context::state state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case trrep::server_context::s_disconnected: return "disconnected";
|
case wsrep::server_context::s_disconnected: return "disconnected";
|
||||||
case trrep::server_context::s_initializing: return "initilizing";
|
case wsrep::server_context::s_initializing: return "initilizing";
|
||||||
case trrep::server_context::s_initialized: return "initilized";
|
case wsrep::server_context::s_initialized: return "initilized";
|
||||||
case trrep::server_context::s_connected: return "connected";
|
case wsrep::server_context::s_connected: return "connected";
|
||||||
case trrep::server_context::s_joiner: return "joiner";
|
case wsrep::server_context::s_joiner: return "joiner";
|
||||||
case trrep::server_context::s_joined: return "joined";
|
case wsrep::server_context::s_joined: return "joined";
|
||||||
case trrep::server_context::s_donor: return "donor";
|
case wsrep::server_context::s_donor: return "donor";
|
||||||
case trrep::server_context::s_synced: return "synced";
|
case wsrep::server_context::s_synced: return "synced";
|
||||||
case trrep::server_context::s_disconnecting: return "disconnecting";
|
case wsrep::server_context::s_disconnecting: return "disconnecting";
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_SERVER_CONTEXT_HPP
|
#endif // WSREP_SERVER_CONTEXT_HPP
|
@ -2,8 +2,8 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_TRANSACTION_CONTEXT_HPP
|
#ifndef WSREP_TRANSACTION_CONTEXT_HPP
|
||||||
#define TRREP_TRANSACTION_CONTEXT_HPP
|
#define WSREP_TRANSACTION_CONTEXT_HPP
|
||||||
|
|
||||||
#include "provider.hpp"
|
#include "provider.hpp"
|
||||||
#include "server_context.hpp"
|
#include "server_context.hpp"
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class client_context;
|
class client_context;
|
||||||
class key;
|
class key;
|
||||||
@ -59,17 +59,17 @@ namespace trrep
|
|||||||
enum state state() const
|
enum state state() const
|
||||||
{ return state_; }
|
{ return state_; }
|
||||||
|
|
||||||
transaction_context(trrep::client_context& client_context);
|
transaction_context(wsrep::client_context& client_context);
|
||||||
~transaction_context();
|
~transaction_context();
|
||||||
// Accessors
|
// Accessors
|
||||||
trrep::transaction_id id() const
|
wsrep::transaction_id id() const
|
||||||
{ return id_; }
|
{ return id_; }
|
||||||
|
|
||||||
bool active() const
|
bool active() const
|
||||||
{ return (id_ != trrep::transaction_id::invalid()); }
|
{ return (id_ != wsrep::transaction_id::invalid()); }
|
||||||
|
|
||||||
|
|
||||||
void state(trrep::unique_lock<trrep::mutex>&, enum state);
|
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);
|
||||||
|
|
||||||
// Return true if the certification of the last
|
// Return true if the certification of the last
|
||||||
// fragment succeeded
|
// fragment succeeded
|
||||||
@ -99,15 +99,15 @@ namespace trrep
|
|||||||
return start_transaction(trx_meta_.stid.trx);
|
return start_transaction(trx_meta_.stid.trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int start_transaction(const trrep::transaction_id& id);
|
int start_transaction(const wsrep::transaction_id& id);
|
||||||
|
|
||||||
int start_transaction(const wsrep_ws_handle_t& ws_handle,
|
int start_transaction(const wsrep_ws_handle_t& ws_handle,
|
||||||
const wsrep_trx_meta_t& trx_meta,
|
const wsrep_trx_meta_t& trx_meta,
|
||||||
uint32_t flags);
|
uint32_t flags);
|
||||||
|
|
||||||
int append_key(const trrep::key&);
|
int append_key(const wsrep::key&);
|
||||||
|
|
||||||
int append_data(const trrep::data&);
|
int append_data(const wsrep::data&);
|
||||||
|
|
||||||
int after_row();
|
int after_row();
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ namespace trrep
|
|||||||
|
|
||||||
int after_statement();
|
int after_statement();
|
||||||
|
|
||||||
bool bf_abort(trrep::unique_lock<trrep::mutex>& lock,
|
bool bf_abort(wsrep::unique_lock<wsrep::mutex>& lock,
|
||||||
wsrep_seqno_t bf_seqno);
|
wsrep_seqno_t bf_seqno);
|
||||||
|
|
||||||
uint32_t flags() const
|
uint32_t flags() const
|
||||||
@ -137,7 +137,7 @@ namespace trrep
|
|||||||
return flags_;
|
return flags_;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::mutex& mutex();
|
wsrep::mutex& mutex();
|
||||||
|
|
||||||
wsrep_ws_handle_t& ws_handle() { return ws_handle_; }
|
wsrep_ws_handle_t& ws_handle() { return ws_handle_; }
|
||||||
private:
|
private:
|
||||||
@ -145,16 +145,16 @@ namespace trrep
|
|||||||
transaction_context operator=(const transaction_context&);
|
transaction_context operator=(const transaction_context&);
|
||||||
|
|
||||||
void flags(uint32_t flags) { flags_ = flags; }
|
void flags(uint32_t flags) { flags_ = flags; }
|
||||||
int certify_fragment(trrep::unique_lock<trrep::mutex>&);
|
int certify_fragment(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
int certify_commit(trrep::unique_lock<trrep::mutex>&);
|
int certify_commit(wsrep::unique_lock<wsrep::mutex>&);
|
||||||
void remove_fragments();
|
void remove_fragments();
|
||||||
void clear_fragments();
|
void clear_fragments();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void debug_log_state(const char*) const;
|
void debug_log_state(const char*) const;
|
||||||
|
|
||||||
trrep::provider& provider_;
|
wsrep::provider& provider_;
|
||||||
trrep::client_context& client_context_;
|
wsrep::client_context& client_context_;
|
||||||
trrep::transaction_id id_;
|
wsrep::transaction_id id_;
|
||||||
enum state state_;
|
enum state state_;
|
||||||
std::vector<enum state> state_hist_;
|
std::vector<enum state> state_hist_;
|
||||||
enum state bf_abort_state_;
|
enum state bf_abort_state_;
|
||||||
@ -166,29 +166,29 @@ namespace trrep
|
|||||||
bool certified_;
|
bool certified_;
|
||||||
|
|
||||||
std::vector<wsrep_gtid_t> fragments_;
|
std::vector<wsrep_gtid_t> fragments_;
|
||||||
trrep::transaction_id rollback_replicated_for_;
|
wsrep::transaction_id rollback_replicated_for_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline std::string to_string(enum trrep::transaction_context::state state)
|
static inline std::string to_string(enum wsrep::transaction_context::state state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case trrep::transaction_context::s_executing: return "executing";
|
case wsrep::transaction_context::s_executing: return "executing";
|
||||||
case trrep::transaction_context::s_preparing: return "preparing";
|
case wsrep::transaction_context::s_preparing: return "preparing";
|
||||||
case trrep::transaction_context::s_certifying: return "certifying";
|
case wsrep::transaction_context::s_certifying: return "certifying";
|
||||||
case trrep::transaction_context::s_committing: return "committing";
|
case wsrep::transaction_context::s_committing: return "committing";
|
||||||
case trrep::transaction_context::s_ordered_commit: return "ordered_commit";
|
case wsrep::transaction_context::s_ordered_commit: return "ordered_commit";
|
||||||
case trrep::transaction_context::s_committed: return "committed";
|
case wsrep::transaction_context::s_committed: return "committed";
|
||||||
case trrep::transaction_context::s_cert_failed: return "cert_failed";
|
case wsrep::transaction_context::s_cert_failed: return "cert_failed";
|
||||||
case trrep::transaction_context::s_must_abort: return "must_abort";
|
case wsrep::transaction_context::s_must_abort: return "must_abort";
|
||||||
case trrep::transaction_context::s_aborting: return "aborting";
|
case wsrep::transaction_context::s_aborting: return "aborting";
|
||||||
case trrep::transaction_context::s_aborted: return "aborted";
|
case wsrep::transaction_context::s_aborted: return "aborted";
|
||||||
case trrep::transaction_context::s_must_replay: return "must_replay";
|
case wsrep::transaction_context::s_must_replay: return "must_replay";
|
||||||
case trrep::transaction_context::s_replaying: return "replaying";
|
case wsrep::transaction_context::s_replaying: return "replaying";
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_TRANSACTION_CONTEXT_HPP
|
#endif // WSREP_TRANSACTION_CONTEXT_HPP
|
@ -2,14 +2,14 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_VIEW_HPP
|
#ifndef WSREP_VIEW_HPP
|
||||||
#define TRREP_VIEW_HPP
|
#define WSREP_VIEW_HPP
|
||||||
|
|
||||||
#include <wsrep_api.h>
|
#include <wsrep_api.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class view
|
class view
|
||||||
{
|
{
|
||||||
@ -87,4 +87,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_VIEW
|
#endif // WSREP_VIEW
|
@ -4,30 +4,30 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_library(trrep
|
add_library(wsrep-lib
|
||||||
logger.cpp
|
logger.cpp
|
||||||
provider.cpp
|
provider.cpp
|
||||||
client_context.cpp
|
client_context.cpp
|
||||||
server_context.cpp
|
server_context.cpp
|
||||||
transaction_context.cpp
|
transaction_context.cpp
|
||||||
wsrep_provider_v26.cpp)
|
wsrep_provider_v26.cpp)
|
||||||
target_link_libraries(trrep wsrep pthread dl)
|
target_link_libraries(wsrep-lib wsrep pthread dl)
|
||||||
|
|
||||||
add_executable(trrep_test
|
add_executable(wsrep-lib_test
|
||||||
mock_client_context.cpp
|
mock_client_context.cpp
|
||||||
mock_utils.cpp
|
mock_utils.cpp
|
||||||
client_context_test.cpp
|
client_context_test.cpp
|
||||||
server_context_test.cpp
|
server_context_test.cpp
|
||||||
transaction_context_test.cpp
|
transaction_context_test.cpp
|
||||||
trrep_test.cpp
|
wsrep-lib_test.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(trrep_test trrep)
|
target_link_libraries(wsrep-lib_test wsrep-lib)
|
||||||
add_test(NAME trrep_test
|
add_test(NAME wsrep-lib_test
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/trrep_test
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/wsrep-lib_test
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(dbms_simulator
|
add_executable(dbms_simulator
|
||||||
dbms_simulator.cpp)
|
dbms_simulator.cpp)
|
||||||
target_link_libraries(dbms_simulator trrep ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
|
target_link_libraries(dbms_simulator wsrep-lib ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
|
||||||
set_property(TARGET dbms_simulator PROPERTY CXX_STANDARD 14)
|
set_property(TARGET dbms_simulator PROPERTY CXX_STANDARD 14)
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_APPLIER_HPP
|
#ifndef WSREP_APPLIER_HPP
|
||||||
#define TRREP_APPLIER_HPP
|
#define WSREP_APPLIER_HPP
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class applier
|
class applier
|
||||||
{
|
{
|
||||||
@ -13,4 +13,4 @@ namespace trrep
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_APPLIER_HPP
|
#endif // WSREP_APPLIER_HPP
|
||||||
|
@ -2,68 +2,68 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "trrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
trrep::provider& trrep::client_context::provider() const
|
wsrep::provider& wsrep::client_context::provider() const
|
||||||
{
|
{
|
||||||
return server_context_.provider();
|
return server_context_.provider();
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::client_context::before_command()
|
int wsrep::client_context::before_command()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
assert(state_ == s_idle);
|
assert(state_ == s_idle);
|
||||||
if (server_context_.rollback_mode() == trrep::server_context::rm_sync)
|
if (server_context_.rollback_mode() == wsrep::server_context::rm_sync)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \todo Wait until the possible synchronous rollback
|
* \todo Wait until the possible synchronous rollback
|
||||||
* has been finished.
|
* has been finished.
|
||||||
*/
|
*/
|
||||||
while (transaction_.state() == trrep::transaction_context::s_aborting)
|
while (transaction_.state() == wsrep::transaction_context::s_aborting)
|
||||||
{
|
{
|
||||||
// cond_.wait(lock);
|
// cond_.wait(lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state(lock, s_exec);
|
state(lock, s_exec);
|
||||||
if (transaction_.active() &&
|
if (transaction_.active() &&
|
||||||
(transaction_.state() == trrep::transaction_context::s_must_abort ||
|
(transaction_.state() == wsrep::transaction_context::s_must_abort ||
|
||||||
transaction_.state() == trrep::transaction_context::s_aborted))
|
transaction_.state() == wsrep::transaction_context::s_aborted))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::client_context::after_command_before_result()
|
void wsrep::client_context::after_command_before_result()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
assert(state() == s_exec);
|
assert(state() == s_exec);
|
||||||
if (transaction_.active() &&
|
if (transaction_.active() &&
|
||||||
transaction_.state() == trrep::transaction_context::s_must_abort)
|
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||||
{
|
{
|
||||||
override_error(trrep::e_deadlock_error);
|
override_error(wsrep::e_deadlock_error);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
rollback();
|
rollback();
|
||||||
transaction_.after_statement();
|
transaction_.after_statement();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
assert(transaction_.state() == trrep::transaction_context::s_aborted);
|
assert(transaction_.state() == wsrep::transaction_context::s_aborted);
|
||||||
assert(current_error() != trrep::e_success);
|
assert(current_error() != wsrep::e_success);
|
||||||
}
|
}
|
||||||
state(lock, s_result);
|
state(lock, s_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::client_context::after_command_after_result()
|
void wsrep::client_context::after_command_after_result()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
assert(state() == s_result);
|
assert(state() == s_result);
|
||||||
if (transaction_.active() &&
|
if (transaction_.active() &&
|
||||||
transaction_.state() == trrep::transaction_context::s_must_abort)
|
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||||
{
|
{
|
||||||
// Note: Error is not overridden here as the result has already
|
// Note: Error is not overridden here as the result has already
|
||||||
// been sent to client. The error should be set in before_command()
|
// been sent to client. The error should be set in before_command()
|
||||||
@ -72,31 +72,31 @@ void trrep::client_context::after_command_after_result()
|
|||||||
rollback();
|
rollback();
|
||||||
transaction_.after_statement();
|
transaction_.after_statement();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
assert(transaction_.state() == trrep::transaction_context::s_aborted);
|
assert(transaction_.state() == wsrep::transaction_context::s_aborted);
|
||||||
assert(current_error() != trrep::e_success);
|
assert(current_error() != wsrep::e_success);
|
||||||
}
|
}
|
||||||
state(lock, s_idle);
|
state(lock, s_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::client_context::before_statement()
|
int wsrep::client_context::before_statement()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
#if 0
|
#if 0
|
||||||
/*!
|
/*!
|
||||||
* \todo It might be beneficial to implement timed wait for
|
* \todo It might be beneficial to implement timed wait for
|
||||||
* server synced state.
|
* server synced state.
|
||||||
*/
|
*/
|
||||||
if (allow_dirty_reads_ == false &&
|
if (allow_dirty_reads_ == false &&
|
||||||
server_context_.state() != trrep::server_context::s_synced)
|
server_context_.state() != wsrep::server_context::s_synced)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
if (transaction_.active() &&
|
if (transaction_.active() &&
|
||||||
transaction_.state() == trrep::transaction_context::s_must_abort)
|
transaction_.state() == wsrep::transaction_context::s_must_abort)
|
||||||
{
|
{
|
||||||
override_error(trrep::e_deadlock_error);
|
override_error(wsrep::e_deadlock_error);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
rollback();
|
rollback();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
@ -105,7 +105,7 @@ int trrep::client_context::before_statement()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::client_context::after_statement()
|
void wsrep::client_context::after_statement()
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
/*!
|
/*!
|
||||||
@ -117,9 +117,9 @@ void trrep::client_context::after_statement()
|
|||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
void trrep::client_context::state(
|
void wsrep::client_context::state(
|
||||||
trrep::unique_lock<trrep::mutex>& lock TRREP_UNUSED,
|
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
|
||||||
enum trrep::client_context::state state)
|
enum wsrep::client_context::state state)
|
||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
static const char allowed[state_max_][state_max_] =
|
static const char allowed[state_max_][state_max_] =
|
||||||
@ -139,6 +139,6 @@ void trrep::client_context::state(
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "client_context: Unallowed state transition: "
|
os << "client_context: Unallowed state transition: "
|
||||||
<< state_ << " -> " << state << "\n";
|
<< state_ << " -> " << state << "\n";
|
||||||
throw trrep::runtime_error(os.str());
|
throw wsrep::runtime_error(os.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,18 @@
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(client_context_test_error_codes)
|
BOOST_AUTO_TEST_CASE(client_context_test_error_codes)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1", trrep::server_context::rm_async);
|
wsrep::mock_server_context sc("s1", "s1", wsrep::server_context::rm_async);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier,
|
wsrep::client_context::m_applier,
|
||||||
false);
|
false);
|
||||||
const trrep::transaction_context& txc(cc.transaction());
|
const wsrep::transaction_context& txc(cc.transaction());
|
||||||
cc.before_command();
|
cc.before_command();
|
||||||
cc.before_statement();
|
cc.before_statement();
|
||||||
|
|
||||||
BOOST_REQUIRE(txc.active() == false);
|
BOOST_REQUIRE(txc.active() == false);
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
trrep_mock::bf_abort_unordered(cc);
|
wsrep_mock::bf_abort_unordered(cc);
|
||||||
|
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
cc.after_command_before_result();
|
cc.after_command_before_result();
|
||||||
|
@ -5,19 +5,19 @@
|
|||||||
//
|
//
|
||||||
// This file implementes a simple DBMS simulator which
|
// This file implementes a simple DBMS simulator which
|
||||||
// will launch one or server threads and replicates transactions
|
// will launch one or server threads and replicates transactions
|
||||||
// through trrep interface.
|
// through wsrep interface.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "trrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "trrep/key.hpp"
|
#include "wsrep/key.hpp"
|
||||||
#include "trrep/data.hpp"
|
#include "wsrep/data.hpp"
|
||||||
#include "trrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
#include "trrep/condition_variable.hpp"
|
#include "wsrep/condition_variable.hpp"
|
||||||
#include "trrep/view.hpp"
|
#include "wsrep/view.hpp"
|
||||||
#include "trrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
@ -76,9 +76,9 @@ public:
|
|||||||
|
|
||||||
bool active() const { return cc_ != nullptr; }
|
bool active() const { return cc_ != nullptr; }
|
||||||
|
|
||||||
void start(trrep::client_context* cc)
|
void start(wsrep::client_context* cc)
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(se_.mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(se_.mutex_);
|
||||||
if (se_.transactions_.insert(cc).second == false)
|
if (se_.transactions_.insert(cc).second == false)
|
||||||
{
|
{
|
||||||
::abort();
|
::abort();
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (cc_)
|
if (cc_)
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(se_.mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(se_.mutex_);
|
||||||
se_.transactions_.erase(cc_);
|
se_.transactions_.erase(cc_);
|
||||||
}
|
}
|
||||||
cc_ = nullptr;
|
cc_ = nullptr;
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (cc_)
|
if (cc_)
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(se_.mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(se_.mutex_);
|
||||||
se_.transactions_.erase(cc_);
|
se_.transactions_.erase(cc_);
|
||||||
}
|
}
|
||||||
cc_ = nullptr;
|
cc_ = nullptr;
|
||||||
@ -117,23 +117,23 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
dbms_storage_engine& se_;
|
dbms_storage_engine& se_;
|
||||||
trrep::client_context* cc_;
|
wsrep::client_context* cc_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void bf_abort_some(const trrep::transaction_context& txc)
|
void bf_abort_some(const wsrep::transaction_context& txc)
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
if (alg_freq_ && (std::rand() % alg_freq_) == 0)
|
if (alg_freq_ && (std::rand() % alg_freq_) == 0)
|
||||||
{
|
{
|
||||||
if (transactions_.empty() == false)
|
if (transactions_.empty() == false)
|
||||||
{
|
{
|
||||||
auto* victim_txc(*transactions_.begin());
|
auto* victim_txc(*transactions_.begin());
|
||||||
trrep::unique_lock<trrep::mutex> victim_txc_lock(
|
wsrep::unique_lock<wsrep::mutex> victim_txc_lock(
|
||||||
victim_txc->mutex());
|
victim_txc->mutex());
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
if (victim_txc->bf_abort(victim_txc_lock, txc.seqno()))
|
if (victim_txc->bf_abort(victim_txc_lock, txc.seqno()))
|
||||||
{
|
{
|
||||||
trrep::log() << "BF aborted " << victim_txc->id().get();
|
wsrep::log() << "BF aborted " << victim_txc->id().get();
|
||||||
++bf_aborts_;
|
++bf_aborts_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,8 +145,8 @@ public:
|
|||||||
return bf_aborts_;
|
return bf_aborts_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
std::unordered_set<trrep::client_context*> transactions_;
|
std::unordered_set<wsrep::client_context*> transactions_;
|
||||||
size_t alg_freq_;
|
size_t alg_freq_;
|
||||||
std::atomic<long long> bf_aborts_;
|
std::atomic<long long> bf_aborts_;
|
||||||
};
|
};
|
||||||
@ -181,7 +181,7 @@ private:
|
|||||||
}
|
}
|
||||||
std::string build_cluster_address() const;
|
std::string build_cluster_address() const;
|
||||||
|
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
const dbms_simulator_params& params_;
|
const dbms_simulator_params& params_;
|
||||||
std::map<size_t, std::unique_ptr<dbms_server>> servers_;
|
std::map<size_t, std::unique_ptr<dbms_server>> servers_;
|
||||||
std::chrono::time_point<std::chrono::steady_clock> clients_start_;
|
std::chrono::time_point<std::chrono::steady_clock> clients_start_;
|
||||||
@ -202,17 +202,17 @@ public:
|
|||||||
|
|
||||||
class dbms_client;
|
class dbms_client;
|
||||||
|
|
||||||
class dbms_server : public trrep::server_context
|
class dbms_server : public wsrep::server_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dbms_server(dbms_simulator& simulator,
|
dbms_server(dbms_simulator& simulator,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
const std::string& address)
|
const std::string& address)
|
||||||
: trrep::server_context(mutex_,
|
: wsrep::server_context(mutex_,
|
||||||
cond_,
|
cond_,
|
||||||
name, id, address, name + "_data",
|
name, id, address, name + "_data",
|
||||||
trrep::server_context::rm_async)
|
wsrep::server_context::rm_async)
|
||||||
, simulator_(simulator)
|
, simulator_(simulator)
|
||||||
, storage_engine_(simulator_.params())
|
, storage_engine_(simulator_.params())
|
||||||
, mutex_()
|
, mutex_()
|
||||||
@ -230,13 +230,13 @@ public:
|
|||||||
|
|
||||||
void start_applier()
|
void start_applier()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
appliers_.push_back(boost::thread(&dbms_server::applier_thread, this));
|
appliers_.push_back(boost::thread(&dbms_server::applier_thread, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_applier()
|
void stop_applier()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
appliers_.front().join();
|
appliers_.front().join();
|
||||||
appliers_.erase(appliers_.begin());
|
appliers_.erase(appliers_.begin());
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Client context management
|
// Client context management
|
||||||
trrep::client_context* local_client_context();
|
wsrep::client_context* local_client_context();
|
||||||
|
|
||||||
size_t next_transaction_id()
|
size_t next_transaction_id()
|
||||||
{
|
{
|
||||||
@ -265,8 +265,8 @@ public:
|
|||||||
|
|
||||||
dbms_storage_engine& storage_engine() { return storage_engine_; }
|
dbms_storage_engine& storage_engine() { return storage_engine_; }
|
||||||
|
|
||||||
int apply_to_storage_engine(const trrep::transaction_context& txc,
|
int apply_to_storage_engine(const wsrep::transaction_context& txc,
|
||||||
const trrep::data&)
|
const wsrep::data&)
|
||||||
{
|
{
|
||||||
storage_engine_.bf_abort_some(txc);
|
storage_engine_.bf_abort_some(txc);
|
||||||
return 0;
|
return 0;
|
||||||
@ -281,8 +281,8 @@ private:
|
|||||||
|
|
||||||
dbms_simulator& simulator_;
|
dbms_simulator& simulator_;
|
||||||
dbms_storage_engine storage_engine_;
|
dbms_storage_engine storage_engine_;
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
trrep::default_condition_variable cond_;
|
wsrep::default_condition_variable cond_;
|
||||||
std::atomic<size_t> last_client_id_;
|
std::atomic<size_t> last_client_id_;
|
||||||
std::atomic<size_t> last_transaction_id_;
|
std::atomic<size_t> last_transaction_id_;
|
||||||
std::vector<boost::thread> appliers_;
|
std::vector<boost::thread> appliers_;
|
||||||
@ -290,14 +290,14 @@ private:
|
|||||||
std::vector<boost::thread> client_threads_;
|
std::vector<boost::thread> client_threads_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class dbms_client : public trrep::client_context
|
class dbms_client : public wsrep::client_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dbms_client(dbms_server& server,
|
dbms_client(dbms_server& server,
|
||||||
const trrep::client_id& id,
|
const wsrep::client_id& id,
|
||||||
enum trrep::client_context::mode mode,
|
enum wsrep::client_context::mode mode,
|
||||||
size_t n_transactions)
|
size_t n_transactions)
|
||||||
: trrep::client_context(mutex_, server, id, mode)
|
: wsrep::client_context(mutex_, server, id, mode)
|
||||||
, mutex_()
|
, mutex_()
|
||||||
, server_(server)
|
, server_(server)
|
||||||
, se_trx_(server_.storage_engine())
|
, se_trx_(server_.storage_engine())
|
||||||
@ -307,7 +307,7 @@ public:
|
|||||||
|
|
||||||
~dbms_client()
|
~dbms_client()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void start()
|
void start()
|
||||||
@ -337,13 +337,13 @@ public:
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool do_2pc() const override { return false; }
|
bool do_2pc() const override { return false; }
|
||||||
int apply(const trrep::data& data) override
|
int apply(const wsrep::data& data) override
|
||||||
{
|
{
|
||||||
return server_.apply_to_storage_engine(transaction(), data);
|
return server_.apply_to_storage_engine(transaction(), data);
|
||||||
}
|
}
|
||||||
int commit() override
|
int commit() override
|
||||||
{
|
{
|
||||||
assert(mode() == trrep::client_context::m_applier);
|
assert(mode() == wsrep::client_context::m_applier);
|
||||||
int ret(0);
|
int ret(0);
|
||||||
ret = before_commit();
|
ret = before_commit();
|
||||||
se_trx_.commit();
|
se_trx_.commit();
|
||||||
@ -353,31 +353,31 @@ private:
|
|||||||
}
|
}
|
||||||
int rollback() override
|
int rollback() override
|
||||||
{
|
{
|
||||||
trrep::log() << "rollback: " << transaction().id().get()
|
wsrep::log() << "rollback: " << transaction().id().get()
|
||||||
<< "state: "
|
<< "state: "
|
||||||
<< trrep::to_string(transaction().state());
|
<< wsrep::to_string(transaction().state());
|
||||||
before_rollback();
|
before_rollback();
|
||||||
se_trx_.abort();
|
se_trx_.abort();
|
||||||
after_rollback();
|
after_rollback();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void will_replay(trrep::transaction_context&) override { }
|
void will_replay(wsrep::transaction_context&) override { }
|
||||||
int replay(trrep::transaction_context& txc) override
|
int replay(wsrep::transaction_context& txc) override
|
||||||
{
|
{
|
||||||
trrep::log() << "replay: " << txc.id().get();
|
wsrep::log() << "replay: " << txc.id().get();
|
||||||
trrep::client_applier_mode applier_mode(*this);
|
wsrep::client_applier_mode applier_mode(*this);
|
||||||
++stats_.replays;
|
++stats_.replays;
|
||||||
return provider().replay(&txc.ws_handle(), this);
|
return provider().replay(&txc.ws_handle(), this);
|
||||||
}
|
}
|
||||||
void wait_for_replayers(trrep::unique_lock<trrep::mutex>&) const override
|
void wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&) const override
|
||||||
{ }
|
{ }
|
||||||
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 char*) override { }
|
void debug_sync(const char*) override { }
|
||||||
void debug_suicide(const char*) override { }
|
void debug_suicide(const char*) override { }
|
||||||
void on_error(enum trrep::client_error) override { }
|
void on_error(enum wsrep::client_error) override { }
|
||||||
|
|
||||||
template <class Func>
|
template <class Func>
|
||||||
int client_command(Func f)
|
int client_command(Func f)
|
||||||
@ -417,13 +417,13 @@ private:
|
|||||||
int data(std::rand() % 10000000);
|
int data(std::rand() % 10000000);
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << data;
|
os << data;
|
||||||
trrep::key key;
|
wsrep::key key;
|
||||||
key.append_key_part("dbms", 4);
|
key.append_key_part("dbms", 4);
|
||||||
wsrep_conn_id_t client_id(id().get());
|
wsrep_conn_id_t client_id(id().get());
|
||||||
key.append_key_part(&client_id, sizeof(client_id));
|
key.append_key_part(&client_id, sizeof(client_id));
|
||||||
key.append_key_part(&data, sizeof(data));
|
key.append_key_part(&data, sizeof(data));
|
||||||
err = append_key(key);
|
err = append_key(key);
|
||||||
err = err || append_data(trrep::data(os.str().c_str(),
|
err = err || append_data(wsrep::data(os.str().c_str(),
|
||||||
os.str().size()));
|
os.str().size()));
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
@ -445,16 +445,16 @@ private:
|
|||||||
});
|
});
|
||||||
|
|
||||||
assert((current_error() &&
|
assert((current_error() &&
|
||||||
transaction().state() == trrep::transaction_context::s_aborted) ||
|
transaction().state() == wsrep::transaction_context::s_aborted) ||
|
||||||
transaction().state() == trrep::transaction_context::s_committed);
|
transaction().state() == wsrep::transaction_context::s_committed);
|
||||||
assert(se_trx_.active() == false);
|
assert(se_trx_.active() == false);
|
||||||
assert(transaction().active() == false);
|
assert(transaction().active() == false);
|
||||||
switch (transaction().state())
|
switch (transaction().state())
|
||||||
{
|
{
|
||||||
case trrep::transaction_context::s_committed:
|
case wsrep::transaction_context::s_committed:
|
||||||
++stats_.commits;
|
++stats_.commits;
|
||||||
break;
|
break;
|
||||||
case trrep::transaction_context::s_aborted:
|
case wsrep::transaction_context::s_aborted:
|
||||||
++stats_.aborts;
|
++stats_.aborts;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -466,12 +466,12 @@ private:
|
|||||||
{
|
{
|
||||||
if ((i % 1000) == 0)
|
if ((i % 1000) == 0)
|
||||||
{
|
{
|
||||||
trrep::log() << "client: " << id().get()
|
wsrep::log() << "client: " << id().get()
|
||||||
<< " transactions: " << i
|
<< " transactions: " << i
|
||||||
<< " " << 100*double(i)/n_transactions_ << "%";
|
<< " " << 100*double(i)/n_transactions_ << "%";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
dbms_server& server_;
|
dbms_server& server_;
|
||||||
dbms_storage_engine::transaction se_trx_;
|
dbms_storage_engine::transaction se_trx_;
|
||||||
const size_t n_transactions_;
|
const size_t n_transactions_;
|
||||||
@ -482,18 +482,18 @@ private:
|
|||||||
// Server methods
|
// Server methods
|
||||||
void dbms_server::applier_thread()
|
void dbms_server::applier_thread()
|
||||||
{
|
{
|
||||||
trrep::client_id client_id(last_client_id_.fetch_add(1) + 1);
|
wsrep::client_id client_id(last_client_id_.fetch_add(1) + 1);
|
||||||
dbms_client applier(*this, client_id,
|
dbms_client applier(*this, client_id,
|
||||||
trrep::client_context::m_applier, 0);
|
wsrep::client_context::m_applier, 0);
|
||||||
wsrep_status_t ret(provider().run_applier(&applier));
|
wsrep_status_t ret(provider().run_applier(&applier));
|
||||||
trrep::log() << "Applier thread exited with error code " << ret;
|
wsrep::log() << "Applier thread exited with error code " << ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::client_context* dbms_server::local_client_context()
|
wsrep::client_context* dbms_server::local_client_context()
|
||||||
{
|
{
|
||||||
std::ostringstream id_os;
|
std::ostringstream id_os;
|
||||||
size_t client_id(++last_client_id_);
|
size_t client_id(++last_client_id_);
|
||||||
return new dbms_client(*this, client_id, trrep::client_context::m_replicating, 0);
|
return new dbms_client(*this, client_id, wsrep::client_context::m_replicating, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbms_server::start_clients()
|
void dbms_server::start_clients()
|
||||||
@ -529,7 +529,7 @@ void dbms_server::start_client(size_t id)
|
|||||||
{
|
{
|
||||||
auto client(std::make_shared<dbms_client>(
|
auto client(std::make_shared<dbms_client>(
|
||||||
*this, id,
|
*this, id,
|
||||||
trrep::client_context::m_replicating,
|
wsrep::client_context::m_replicating,
|
||||||
simulator_.params().n_transactions));
|
simulator_.params().n_transactions));
|
||||||
clients_.push_back(client);
|
clients_.push_back(client);
|
||||||
client_threads_.push_back(
|
client_threads_.push_back(
|
||||||
@ -540,10 +540,10 @@ void dbms_server::start_client(size_t id)
|
|||||||
|
|
||||||
void dbms_simulator::start()
|
void dbms_simulator::start()
|
||||||
{
|
{
|
||||||
trrep::log() << "Provider: " << params_.wsrep_provider;
|
wsrep::log() << "Provider: " << params_.wsrep_provider;
|
||||||
|
|
||||||
std::string cluster_address(build_cluster_address());
|
std::string cluster_address(build_cluster_address());
|
||||||
trrep::log() << "Cluster address: " << cluster_address;
|
wsrep::log() << "Cluster address: " << cluster_address;
|
||||||
for (size_t i(0); i < params_.n_servers; ++i)
|
for (size_t i(0); i < params_.n_servers; ++i)
|
||||||
{
|
{
|
||||||
std::ostringstream name_os;
|
std::ostringstream name_os;
|
||||||
@ -562,7 +562,7 @@ void dbms_simulator::start()
|
|||||||
address_os.str()))));
|
address_os.str()))));
|
||||||
if (it.second == false)
|
if (it.second == false)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to add server");
|
throw wsrep::runtime_error("Failed to add server");
|
||||||
}
|
}
|
||||||
boost::filesystem::path dir(std::string("./") + id_os.str() + "_data");
|
boost::filesystem::path dir(std::string("./") + id_os.str() + "_data");
|
||||||
boost::filesystem::create_directory(dir);
|
boost::filesystem::create_directory(dir);
|
||||||
@ -573,19 +573,19 @@ void dbms_simulator::start()
|
|||||||
|
|
||||||
if (server.load_provider(params_.wsrep_provider, server_options))
|
if (server.load_provider(params_.wsrep_provider, server_options))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to load provider");
|
throw wsrep::runtime_error("Failed to load provider");
|
||||||
}
|
}
|
||||||
if (server.connect("sim_cluster", cluster_address, "",
|
if (server.connect("sim_cluster", cluster_address, "",
|
||||||
i == 0))
|
i == 0))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to connect");
|
throw wsrep::runtime_error("Failed to connect");
|
||||||
}
|
}
|
||||||
server.start_applier();
|
server.start_applier();
|
||||||
server.wait_until_state(trrep::server_context::s_synced);
|
server.wait_until_state(wsrep::server_context::s_synced);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start client threads
|
// Start client threads
|
||||||
trrep::log() << "####################### Starting client load";
|
wsrep::log() << "####################### Starting client load";
|
||||||
clients_start_ = std::chrono::steady_clock::now();
|
clients_start_ = std::chrono::steady_clock::now();
|
||||||
for (auto& i : servers_)
|
for (auto& i : servers_)
|
||||||
{
|
{
|
||||||
@ -602,9 +602,9 @@ void dbms_simulator::stop()
|
|||||||
server.stop_clients();
|
server.stop_clients();
|
||||||
}
|
}
|
||||||
clients_stop_ = std::chrono::steady_clock::now();
|
clients_stop_ = std::chrono::steady_clock::now();
|
||||||
trrep::log() << "######## Stats ############";
|
wsrep::log() << "######## Stats ############";
|
||||||
trrep::log() << stats();
|
wsrep::log() << stats();
|
||||||
trrep::log() << "######## Stats ############";
|
wsrep::log() << "######## Stats ############";
|
||||||
if (params_.fast_exit)
|
if (params_.fast_exit)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -612,16 +612,16 @@ void dbms_simulator::stop()
|
|||||||
for (auto& i : servers_)
|
for (auto& i : servers_)
|
||||||
{
|
{
|
||||||
dbms_server& server(*i.second);
|
dbms_server& server(*i.second);
|
||||||
trrep::log() << "Status for server: " << server.id();
|
wsrep::log() << "Status for server: " << server.id();
|
||||||
auto status(server.provider().status());
|
auto status(server.provider().status());
|
||||||
for_each(status.begin(), status.end(),
|
for_each(status.begin(), status.end(),
|
||||||
[](const trrep::provider::status_variable& sv)
|
[](const wsrep::provider::status_variable& sv)
|
||||||
{
|
{
|
||||||
trrep::log() << sv.name() << " = " << sv.value();
|
wsrep::log() << sv.name() << " = " << sv.value();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.disconnect();
|
server.disconnect();
|
||||||
server.wait_until_state(trrep::server_context::s_disconnected);
|
server.wait_until_state(wsrep::server_context::s_disconnected);
|
||||||
server.stop_applier();
|
server.stop_applier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -663,15 +663,15 @@ void dbms_simulator::donate_sst(dbms_server& server,
|
|||||||
size_t id;
|
size_t id;
|
||||||
std::istringstream is(req);
|
std::istringstream is(req);
|
||||||
is >> id;
|
is >> id;
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
auto i(servers_.find(id));
|
auto i(servers_.find(id));
|
||||||
if (i == servers_.end())
|
if (i == servers_.end())
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Server " + req + " not found");
|
throw wsrep::runtime_error("Server " + req + " not found");
|
||||||
}
|
}
|
||||||
if (bypass == false)
|
if (bypass == false)
|
||||||
{
|
{
|
||||||
trrep::log() << "SST " << server.id() << " -> " << id;
|
wsrep::log() << "SST " << server.id() << " -> " << id;
|
||||||
}
|
}
|
||||||
i->second->sst_received(gtid, 0);
|
i->second->sst_received(gtid, 0);
|
||||||
server.sst_sent(gtid, 0);
|
server.sst_sent(gtid, 0);
|
||||||
@ -742,17 +742,17 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
trrep::log() << "Caught exception: " << e.what();
|
wsrep::log() << "Caught exception: " << e.what();
|
||||||
}
|
}
|
||||||
stats = sim.stats();
|
stats = sim.stats();
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
trrep::log() << e.what();
|
wsrep::log() << e.what();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::log() << "Stats:\n" << stats << "\n";
|
wsrep::log() << "Stats:\n" << stats << "\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#include "trrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
std::ostream& trrep::log::os_ = std::cout;
|
std::ostream& wsrep::log::os_ = std::cout;
|
||||||
static trrep::default_mutex log_mutex_;
|
static wsrep::default_mutex log_mutex_;
|
||||||
trrep::mutex& trrep::log::mutex_ = log_mutex_;
|
wsrep::mutex& wsrep::log::mutex_ = log_mutex_;
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "mock_client_context.hpp"
|
#include "mock_client_context.hpp"
|
||||||
|
|
||||||
|
|
||||||
int trrep::mock_client_context::apply(
|
int wsrep::mock_client_context::apply(
|
||||||
const trrep::data& data __attribute__((unused)))
|
const wsrep::data& data __attribute__((unused)))
|
||||||
|
|
||||||
{
|
{
|
||||||
assert(transaction_.state() == trrep::transaction_context::s_executing);
|
assert(transaction_.state() == wsrep::transaction_context::s_executing);
|
||||||
return (fail_next_applying_ ? 1 : 0);
|
return (fail_next_applying_ ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::mock_client_context::commit()
|
int wsrep::mock_client_context::commit()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
if (do_2pc())
|
if (do_2pc())
|
||||||
@ -38,7 +38,7 @@ int trrep::mock_client_context::commit()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::mock_client_context::rollback()
|
int wsrep::mock_client_context::rollback()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
if (transaction_.before_rollback())
|
if (transaction_.before_rollback())
|
||||||
|
@ -2,23 +2,23 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_MOCK_CLIENT_CONTEXT_HPP
|
#ifndef WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||||
#define TRREP_MOCK_CLIENT_CONTEXT_HPP
|
#define WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||||
|
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "trrep/mutex.hpp"
|
#include "wsrep/mutex.hpp"
|
||||||
#include "trrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class mock_client_context : public trrep::client_context
|
class mock_client_context : public wsrep::client_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mock_client_context(trrep::server_context& server_context,
|
mock_client_context(wsrep::server_context& server_context,
|
||||||
const trrep::client_id& id,
|
const wsrep::client_id& id,
|
||||||
enum trrep::client_context::mode mode,
|
enum wsrep::client_context::mode mode,
|
||||||
bool do_2pc = false)
|
bool do_2pc = false)
|
||||||
: trrep::client_context(mutex_, server_context, id, mode)
|
: wsrep::client_context(mutex_, server_context, id, mode)
|
||||||
// Note: Mutex is initialized only after passed
|
// Note: Mutex is initialized only after passed
|
||||||
// to client_context constructor.
|
// to client_context constructor.
|
||||||
, mutex_()
|
, mutex_()
|
||||||
@ -32,38 +32,38 @@ namespace trrep
|
|||||||
(void)rollback();
|
(void)rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int apply(const trrep::data&);
|
int apply(const wsrep::data&);
|
||||||
int commit();
|
int commit();
|
||||||
int rollback();
|
int rollback();
|
||||||
bool do_2pc() const { return do_2pc_; }
|
bool do_2pc() const { return do_2pc_; }
|
||||||
void will_replay(trrep::transaction_context&) TRREP_OVERRIDE { }
|
void will_replay(wsrep::transaction_context&) WSREP_OVERRIDE { }
|
||||||
int replay(trrep::transaction_context& tc) TRREP_OVERRIDE
|
int replay(wsrep::transaction_context& tc) WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
tc.state(lock, trrep::transaction_context::s_committing);
|
tc.state(lock, wsrep::transaction_context::s_committing);
|
||||||
tc.state(lock, trrep::transaction_context::s_ordered_commit);
|
tc.state(lock, wsrep::transaction_context::s_ordered_commit);
|
||||||
tc.state(lock, trrep::transaction_context::s_committed);
|
tc.state(lock, wsrep::transaction_context::s_committed);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void wait_for_replayers(trrep::unique_lock<trrep::mutex>&) const
|
void wait_for_replayers(wsrep::unique_lock<wsrep::mutex>&) const
|
||||||
TRREP_OVERRIDE { }
|
WSREP_OVERRIDE { }
|
||||||
bool killed() const TRREP_OVERRIDE { return false; }
|
bool killed() const WSREP_OVERRIDE { return false; }
|
||||||
void abort() const TRREP_OVERRIDE { }
|
void abort() const WSREP_OVERRIDE { }
|
||||||
void store_globals() TRREP_OVERRIDE { }
|
void store_globals() WSREP_OVERRIDE { }
|
||||||
void debug_sync(const char*) TRREP_OVERRIDE { }
|
void debug_sync(const char*) WSREP_OVERRIDE { }
|
||||||
void debug_suicide(const char*) TRREP_OVERRIDE
|
void debug_suicide(const char*) WSREP_OVERRIDE
|
||||||
{
|
{
|
||||||
::abort();
|
::abort();
|
||||||
}
|
}
|
||||||
void on_error(enum trrep::client_error) { }
|
void on_error(enum wsrep::client_error) { }
|
||||||
// Mock state modifiers
|
// Mock state modifiers
|
||||||
void fail_next_applying(bool fail_next_applying)
|
void fail_next_applying(bool fail_next_applying)
|
||||||
{ fail_next_applying_ = fail_next_applying; }
|
{ fail_next_applying_ = fail_next_applying; }
|
||||||
private:
|
private:
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
bool do_2pc_;
|
bool do_2pc_;
|
||||||
bool fail_next_applying_;
|
bool fail_next_applying_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_MOCK_CLIENT_CONTEXT_HPP
|
#endif // WSREP_MOCK_CLIENT_CONTEXT_HPP
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_MOCK_PROVIDER_HPP
|
#ifndef WSREP_MOCK_PROVIDER_HPP
|
||||||
#define TRREP_MOCK_PROVIDER_HPP
|
#define WSREP_MOCK_PROVIDER_HPP
|
||||||
|
|
||||||
#include "trrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iostream> // todo: proper logging
|
#include <iostream> // todo: proper logging
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class mock_provider : public trrep::provider
|
class mock_provider : public wsrep::provider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<wsrep_trx_id_t, wsrep_seqno_t > bf_abort_map;
|
typedef std::map<wsrep_trx_id_t, wsrep_seqno_t > bf_abort_map;
|
||||||
@ -150,4 +150,4 @@ namespace trrep
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // TRREP_MOCK_PROVIDER_HPP
|
#endif // WSREP_MOCK_PROVIDER_HPP
|
||||||
|
@ -2,57 +2,57 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_MOCK_SERVER_CONTEXT_HPP
|
#ifndef WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||||
#define TRREP_MOCK_SERVER_CONTEXT_HPP
|
#define WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||||
|
|
||||||
#include "trrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "mock_client_context.hpp"
|
#include "mock_client_context.hpp"
|
||||||
#include "mock_provider.hpp"
|
#include "mock_provider.hpp"
|
||||||
|
|
||||||
#include "trrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class mock_server_context : public trrep::server_context
|
class mock_server_context : public wsrep::server_context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mock_server_context(const std::string& name,
|
mock_server_context(const std::string& name,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
enum trrep::server_context::rollback_mode rollback_mode)
|
enum wsrep::server_context::rollback_mode rollback_mode)
|
||||||
: trrep::server_context(mutex_, cond_,
|
: wsrep::server_context(mutex_, cond_,
|
||||||
name, id, "", "./", rollback_mode)
|
name, id, "", "./", rollback_mode)
|
||||||
, mutex_()
|
, mutex_()
|
||||||
, cond_()
|
, cond_()
|
||||||
, provider_()
|
, provider_()
|
||||||
, last_client_id_(0)
|
, last_client_id_(0)
|
||||||
{ }
|
{ }
|
||||||
trrep::mock_provider& provider() const
|
wsrep::mock_provider& provider() const
|
||||||
{ return provider_; }
|
{ return provider_; }
|
||||||
trrep::client_context* local_client_context()
|
wsrep::client_context* local_client_context()
|
||||||
{
|
{
|
||||||
return new trrep::mock_client_context(*this, ++last_client_id_,
|
return new wsrep::mock_client_context(*this, ++last_client_id_,
|
||||||
trrep::client_context::m_local);
|
wsrep::client_context::m_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_connect() TRREP_OVERRIDE { }
|
void on_connect() WSREP_OVERRIDE { }
|
||||||
void wait_until_connected() TRREP_OVERRIDE { }
|
void wait_until_connected() WSREP_OVERRIDE { }
|
||||||
void on_view(const trrep::view&) TRREP_OVERRIDE { }
|
void on_view(const wsrep::view&) WSREP_OVERRIDE { }
|
||||||
void on_sync() TRREP_OVERRIDE { }
|
void on_sync() WSREP_OVERRIDE { }
|
||||||
bool sst_before_init() const TRREP_OVERRIDE { return false; }
|
bool sst_before_init() const WSREP_OVERRIDE { return false; }
|
||||||
std::string on_sst_required() TRREP_OVERRIDE { return ""; }
|
std::string on_sst_required() WSREP_OVERRIDE { return ""; }
|
||||||
void on_sst_request(const std::string&,
|
void on_sst_request(const std::string&,
|
||||||
const wsrep_gtid_t&,
|
const wsrep_gtid_t&,
|
||||||
bool) TRREP_OVERRIDE { }
|
bool) WSREP_OVERRIDE { }
|
||||||
// void sst_received(const wsrep_gtid_t&, int) TRREP_OVERRIDE { }
|
// void sst_received(const wsrep_gtid_t&, int) WSREP_OVERRIDE { }
|
||||||
// void on_apply(trrep::transaction_context&) { }
|
// void on_apply(wsrep::transaction_context&) { }
|
||||||
// void on_commit(trrep::transaction_context&) { }
|
// void on_commit(wsrep::transaction_context&) { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
trrep::default_mutex mutex_;
|
wsrep::default_mutex mutex_;
|
||||||
trrep::default_condition_variable cond_;
|
wsrep::default_condition_variable cond_;
|
||||||
mutable trrep::mock_provider provider_;
|
mutable wsrep::mock_provider provider_;
|
||||||
unsigned long long last_client_id_;
|
unsigned long long last_client_id_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRREP_MOCK_SERVER_CONTEXT_HPP
|
#endif // WSREP_MOCK_SERVER_CONTEXT_HPP
|
||||||
|
@ -3,21 +3,21 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "mock_utils.hpp"
|
#include "mock_utils.hpp"
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "mock_server_context.hpp"
|
#include "mock_server_context.hpp"
|
||||||
|
|
||||||
|
|
||||||
// Simple BF abort method to BF abort unordered transasctions
|
// Simple BF abort method to BF abort unordered transasctions
|
||||||
void trrep_mock::bf_abort_unordered(trrep::client_context& cc)
|
void wsrep_mock::bf_abort_unordered(wsrep::client_context& cc)
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(cc.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(cc.mutex());
|
||||||
assert(cc.transaction().seqno() <= 0);
|
assert(cc.transaction().seqno() <= 0);
|
||||||
cc.bf_abort(lock, 1);
|
cc.bf_abort(lock, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BF abort method to abort transactions via provider
|
// BF abort method to abort transactions via provider
|
||||||
void trrep_mock::bf_abort_provider(trrep::mock_server_context& sc,
|
void wsrep_mock::bf_abort_provider(wsrep::mock_server_context& sc,
|
||||||
const trrep::transaction_context& tc,
|
const wsrep::transaction_context& tc,
|
||||||
wsrep_seqno_t bf_seqno)
|
wsrep_seqno_t bf_seqno)
|
||||||
{
|
{
|
||||||
wsrep_seqno_t victim_seqno;
|
wsrep_seqno_t victim_seqno;
|
||||||
@ -25,9 +25,9 @@ void trrep_mock::bf_abort_provider(trrep::mock_server_context& sc,
|
|||||||
(void)victim_seqno;
|
(void)victim_seqno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep_mock::start_applying_transaction(
|
void wsrep_mock::start_applying_transaction(
|
||||||
trrep::client_context& cc,
|
wsrep::client_context& cc,
|
||||||
const trrep::transaction_id& id,
|
const wsrep::transaction_id& id,
|
||||||
wsrep_seqno_t seqno,
|
wsrep_seqno_t seqno,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
@ -40,6 +40,6 @@ void trrep_mock::start_applying_transaction(
|
|||||||
int ret(cc.start_transaction(ws_handle, meta, flags));
|
int ret(cc.start_transaction(ws_handle, meta, flags));
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("failed to start applying transaction");
|
throw wsrep::runtime_error("failed to start applying transaction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,31 +5,31 @@
|
|||||||
#include <wsrep_api.h> // Wsrep typedefs
|
#include <wsrep_api.h> // Wsrep typedefs
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class client_context;
|
class client_context;
|
||||||
class mock_server_context;
|
class mock_server_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Utility functions
|
// Utility functions
|
||||||
//
|
//
|
||||||
namespace trrep_mock
|
namespace wsrep_mock
|
||||||
{
|
{
|
||||||
|
|
||||||
// Simple BF abort method to BF abort unordered transasctions
|
// Simple BF abort method to BF abort unordered transasctions
|
||||||
void bf_abort_unordered(trrep::client_context& cc);
|
void bf_abort_unordered(wsrep::client_context& cc);
|
||||||
|
|
||||||
// BF abort method to abort transactions via provider
|
// BF abort method to abort transactions via provider
|
||||||
void bf_abort_provider(trrep::mock_server_context& sc,
|
void bf_abort_provider(wsrep::mock_server_context& sc,
|
||||||
const trrep::transaction_context& tc,
|
const wsrep::transaction_context& tc,
|
||||||
wsrep_seqno_t bf_seqno);
|
wsrep_seqno_t bf_seqno);
|
||||||
|
|
||||||
void start_applying_transaction(
|
void start_applying_transaction(
|
||||||
trrep::client_context& cc,
|
wsrep::client_context& cc,
|
||||||
const trrep::transaction_id& id,
|
const wsrep::transaction_id& id,
|
||||||
wsrep_seqno_t seqno,
|
wsrep_seqno_t seqno,
|
||||||
uint32_t flags);
|
uint32_t flags);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
|
|
||||||
#include "provider_impl.hpp"
|
#include "provider_impl.hpp"
|
||||||
|
|
||||||
trrep::provider* trrep::provider::make_provider(
|
wsrep::provider* wsrep::provider::make_provider(
|
||||||
const std::string&)
|
const std::string&)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_PROVIDER_IMPL_HPP
|
#ifndef WSREP_PROVIDER_IMPL_HPP
|
||||||
#define TRREP_PROVIDER_IMPL_HPP
|
#define WSREP_PROVIDER_IMPL_HPP
|
||||||
|
|
||||||
#include <wsrep_api.h>
|
#include <wsrep_api.h>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
// Abstract interface for provider implementations
|
// Abstract interface for provider implementations
|
||||||
class provider_impl
|
class provider_impl
|
||||||
@ -28,4 +28,4 @@ namespace trrep
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // TRREP_PROVIDER_IMPL_HPP
|
#endif // WSREP_PROVIDER_IMPL_HPP
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "trrep/view.hpp"
|
#include "wsrep/view.hpp"
|
||||||
#include "trrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
#include "trrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
// Todo: refactor into provider factory
|
// Todo: refactor into provider factory
|
||||||
#include "mock_provider.hpp"
|
#include "mock_provider.hpp"
|
||||||
@ -41,8 +41,8 @@ namespace
|
|||||||
const wsrep_view_info_t* view __attribute((unused)))
|
const wsrep_view_info_t* view __attribute((unused)))
|
||||||
{
|
{
|
||||||
assert(app_ctx);
|
assert(app_ctx);
|
||||||
trrep::server_context& server_context(
|
wsrep::server_context& server_context(
|
||||||
*reinterpret_cast<trrep::server_context*>(app_ctx));
|
*reinterpret_cast<wsrep::server_context*>(app_ctx));
|
||||||
//
|
//
|
||||||
// TODO: Fetch server id and group id from view infor
|
// TODO: Fetch server id and group id from view infor
|
||||||
//
|
//
|
||||||
@ -51,7 +51,7 @@ namespace
|
|||||||
server_context.on_connect();
|
server_context.on_connect();
|
||||||
return WSREP_CB_SUCCESS;
|
return WSREP_CB_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const trrep::runtime_error& e)
|
catch (const wsrep::runtime_error& e)
|
||||||
{
|
{
|
||||||
std::cerr << "Exception: " << e.what();
|
std::cerr << "Exception: " << e.what();
|
||||||
return WSREP_CB_FAILURE;
|
return WSREP_CB_FAILURE;
|
||||||
@ -66,15 +66,15 @@ namespace
|
|||||||
{
|
{
|
||||||
assert(app_ctx);
|
assert(app_ctx);
|
||||||
assert(view_info);
|
assert(view_info);
|
||||||
trrep::server_context& server_context(
|
wsrep::server_context& server_context(
|
||||||
*reinterpret_cast<trrep::server_context*>(app_ctx));
|
*reinterpret_cast<wsrep::server_context*>(app_ctx));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
trrep::view view(*view_info);
|
wsrep::view view(*view_info);
|
||||||
server_context.on_view(view);
|
server_context.on_view(view);
|
||||||
return WSREP_CB_SUCCESS;
|
return WSREP_CB_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const trrep::runtime_error& e)
|
catch (const wsrep::runtime_error& e)
|
||||||
{
|
{
|
||||||
std::cerr << "Exception: " << e.what();
|
std::cerr << "Exception: " << e.what();
|
||||||
return WSREP_CB_FAILURE;
|
return WSREP_CB_FAILURE;
|
||||||
@ -85,8 +85,8 @@ namespace
|
|||||||
void **sst_req, size_t* sst_req_len)
|
void **sst_req, size_t* sst_req_len)
|
||||||
{
|
{
|
||||||
assert(app_ctx);
|
assert(app_ctx);
|
||||||
trrep::server_context& server_context(
|
wsrep::server_context& server_context(
|
||||||
*reinterpret_cast<trrep::server_context*>(app_ctx));
|
*reinterpret_cast<wsrep::server_context*>(app_ctx));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ namespace
|
|||||||
*sst_req_len = strlen(req.c_str());
|
*sst_req_len = strlen(req.c_str());
|
||||||
return WSREP_CB_SUCCESS;
|
return WSREP_CB_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const trrep::runtime_error& e)
|
catch (const wsrep::runtime_error& e)
|
||||||
{
|
{
|
||||||
return WSREP_CB_FAILURE;
|
return WSREP_CB_FAILURE;
|
||||||
}
|
}
|
||||||
@ -110,13 +110,13 @@ namespace
|
|||||||
{
|
{
|
||||||
wsrep_cb_status_t ret(WSREP_CB_SUCCESS);
|
wsrep_cb_status_t ret(WSREP_CB_SUCCESS);
|
||||||
|
|
||||||
trrep::client_context* client_context(
|
wsrep::client_context* client_context(
|
||||||
reinterpret_cast<trrep::client_context*>(ctx));
|
reinterpret_cast<wsrep::client_context*>(ctx));
|
||||||
assert(client_context);
|
assert(client_context);
|
||||||
assert(client_context->mode() == trrep::client_context::m_applier);
|
assert(client_context->mode() == wsrep::client_context::m_applier);
|
||||||
|
|
||||||
trrep::data data(buf->ptr, buf->len);
|
wsrep::data data(buf->ptr, buf->len);
|
||||||
if (client_context->transaction().state() != trrep::transaction_context::s_replaying && client_context->start_transaction(*wsh, *meta, flags))
|
if (client_context->transaction().state() != wsrep::transaction_context::s_replaying && client_context->start_transaction(*wsh, *meta, flags))
|
||||||
{
|
{
|
||||||
ret = WSREP_CB_FAILURE;
|
ret = WSREP_CB_FAILURE;
|
||||||
}
|
}
|
||||||
@ -132,14 +132,14 @@ namespace
|
|||||||
wsrep_cb_status_t synced_cb(void* app_ctx)
|
wsrep_cb_status_t synced_cb(void* app_ctx)
|
||||||
{
|
{
|
||||||
assert(app_ctx);
|
assert(app_ctx);
|
||||||
trrep::server_context& server_context(
|
wsrep::server_context& server_context(
|
||||||
*reinterpret_cast<trrep::server_context*>(app_ctx));
|
*reinterpret_cast<wsrep::server_context*>(app_ctx));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
server_context.on_sync();
|
server_context.on_sync();
|
||||||
return WSREP_CB_SUCCESS;
|
return WSREP_CB_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const trrep::runtime_error& e)
|
catch (const wsrep::runtime_error& e)
|
||||||
{
|
{
|
||||||
std::cerr << "On sync failed: " << e.what() << "\n";
|
std::cerr << "On sync failed: " << e.what() << "\n";
|
||||||
return WSREP_CB_FAILURE;
|
return WSREP_CB_FAILURE;
|
||||||
@ -155,8 +155,8 @@ namespace
|
|||||||
bool bypass)
|
bool bypass)
|
||||||
{
|
{
|
||||||
assert(app_ctx);
|
assert(app_ctx);
|
||||||
trrep::server_context& server_context(
|
wsrep::server_context& server_context(
|
||||||
*reinterpret_cast<trrep::server_context*>(app_ctx));
|
*reinterpret_cast<wsrep::server_context*>(app_ctx));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string req(reinterpret_cast<const char*>(req_buf->ptr),
|
std::string req(reinterpret_cast<const char*>(req_buf->ptr),
|
||||||
@ -164,20 +164,20 @@ namespace
|
|||||||
server_context.on_sst_request(req, *gtid, bypass);
|
server_context.on_sst_request(req, *gtid, bypass);
|
||||||
return WSREP_CB_SUCCESS;
|
return WSREP_CB_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const trrep::runtime_error& e)
|
catch (const wsrep::runtime_error& e)
|
||||||
{
|
{
|
||||||
return WSREP_CB_FAILURE;
|
return WSREP_CB_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::server_context::load_provider(const std::string& provider_spec,
|
int wsrep::server_context::load_provider(const std::string& provider_spec,
|
||||||
const std::string& provider_options)
|
const std::string& provider_options)
|
||||||
{
|
{
|
||||||
trrep::log() << "Loading provider " << provider_spec;
|
wsrep::log() << "Loading provider " << provider_spec;
|
||||||
if (provider_spec == "mock")
|
if (provider_spec == "mock")
|
||||||
{
|
{
|
||||||
provider_ = new trrep::mock_provider;
|
provider_ = new wsrep::mock_provider;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -203,13 +203,13 @@ int trrep::server_context::load_provider(const std::string& provider_spec,
|
|||||||
init_args.synced_cb = &synced_cb;
|
init_args.synced_cb = &synced_cb;
|
||||||
|
|
||||||
std::cerr << init_args.options << "\n";
|
std::cerr << init_args.options << "\n";
|
||||||
provider_ = new trrep::wsrep_provider_v26(provider_spec.c_str(),
|
provider_ = new wsrep::wsrep_provider_v26(provider_spec.c_str(),
|
||||||
&init_args);
|
&init_args);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::server_context::connect(const std::string& cluster_name,
|
int wsrep::server_context::connect(const std::string& cluster_name,
|
||||||
const std::string& cluster_address,
|
const std::string& cluster_address,
|
||||||
const std::string& state_donor,
|
const std::string& state_donor,
|
||||||
bool bootstrap)
|
bool bootstrap)
|
||||||
@ -218,33 +218,33 @@ int trrep::server_context::connect(const std::string& cluster_name,
|
|||||||
bootstrap);
|
bootstrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::server_context::disconnect()
|
int wsrep::server_context::disconnect()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
state(lock, s_disconnecting);
|
state(lock, s_disconnecting);
|
||||||
}
|
}
|
||||||
return provider().disconnect();
|
return provider().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::server_context::~server_context()
|
wsrep::server_context::~server_context()
|
||||||
{
|
{
|
||||||
delete provider_;
|
delete provider_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::server_context::sst_sent(const wsrep_gtid_t& gtid, int error)
|
void wsrep::server_context::sst_sent(const wsrep_gtid_t& gtid, int error)
|
||||||
{
|
{
|
||||||
provider_->sst_sent(gtid, error);
|
provider_->sst_sent(gtid, error);
|
||||||
}
|
}
|
||||||
void trrep::server_context::sst_received(const wsrep_gtid_t& gtid, int error)
|
void wsrep::server_context::sst_received(const wsrep_gtid_t& gtid, int error)
|
||||||
{
|
{
|
||||||
provider_->sst_received(gtid, error);
|
provider_->sst_received(gtid, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::server_context::wait_until_state(
|
void wsrep::server_context::wait_until_state(
|
||||||
enum trrep::server_context::state state) const
|
enum wsrep::server_context::state state) const
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
++state_waiters_[state];
|
++state_waiters_[state];
|
||||||
while (state_ != state)
|
while (state_ != state)
|
||||||
{
|
{
|
||||||
@ -254,57 +254,57 @@ void trrep::server_context::wait_until_state(
|
|||||||
cond_.notify_all();
|
cond_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::server_context::on_connect()
|
void wsrep::server_context::on_connect()
|
||||||
{
|
{
|
||||||
trrep::log() << "Server " << name_ << " connected to cluster";
|
wsrep::log() << "Server " << name_ << " connected to cluster";
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
state(lock, s_connected);
|
state(lock, s_connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::server_context::on_view(const trrep::view& view)
|
void wsrep::server_context::on_view(const wsrep::view& view)
|
||||||
{
|
{
|
||||||
trrep::log() << "================================================\nView:\n"
|
wsrep::log() << "================================================\nView:\n"
|
||||||
<< "id: " << view.id() << "\n"
|
<< "id: " << view.id() << "\n"
|
||||||
<< "status: " << view.status() << "\n"
|
<< "status: " << view.status() << "\n"
|
||||||
<< "own_index: " << view.own_index() << "\n"
|
<< "own_index: " << view.own_index() << "\n"
|
||||||
<< "final: " << view.final() << "\n"
|
<< "final: " << view.final() << "\n"
|
||||||
<< "members";
|
<< "members";
|
||||||
const std::vector<trrep::view::member>& members(view.members());
|
const std::vector<wsrep::view::member>& members(view.members());
|
||||||
for (std::vector<trrep::view::member>::const_iterator i(members.begin());
|
for (std::vector<wsrep::view::member>::const_iterator i(members.begin());
|
||||||
i != members.end(); ++i)
|
i != members.end(); ++i)
|
||||||
{
|
{
|
||||||
trrep::log() << "id: " << i->id() << " "
|
wsrep::log() << "id: " << i->id() << " "
|
||||||
<< "name: " << i->name();
|
<< "name: " << i->name();
|
||||||
}
|
}
|
||||||
trrep::log() << "=================================================";
|
wsrep::log() << "=================================================";
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
if (view.final())
|
if (view.final())
|
||||||
{
|
{
|
||||||
state(lock, s_disconnected);
|
state(lock, s_disconnected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::server_context::on_sync()
|
void wsrep::server_context::on_sync()
|
||||||
{
|
{
|
||||||
trrep::log() << "Server " << name_ << " synced with group";
|
wsrep::log() << "Server " << name_ << " synced with group";
|
||||||
trrep::unique_lock<trrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
if (state_ != s_synced)
|
if (state_ != s_synced)
|
||||||
{
|
{
|
||||||
state(lock, s_synced);
|
state(lock, s_synced);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::server_context::on_apply(
|
int wsrep::server_context::on_apply(
|
||||||
trrep::client_context& client_context,
|
wsrep::client_context& client_context,
|
||||||
const trrep::data& data)
|
const wsrep::data& data)
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
const trrep::transaction_context& txc(client_context.transaction());
|
const wsrep::transaction_context& txc(client_context.transaction());
|
||||||
if (starts_transaction(txc.flags()) &&
|
if (starts_transaction(txc.flags()) &&
|
||||||
commits_transaction(txc.flags()))
|
commits_transaction(txc.flags()))
|
||||||
{
|
{
|
||||||
bool not_replaying(txc.state() !=
|
bool not_replaying(txc.state() !=
|
||||||
trrep::transaction_context::s_replaying);
|
wsrep::transaction_context::s_replaying);
|
||||||
if (not_replaying)
|
if (not_replaying)
|
||||||
{
|
{
|
||||||
client_context.before_command();
|
client_context.before_command();
|
||||||
@ -327,7 +327,7 @@ int trrep::server_context::on_apply(
|
|||||||
client_context.after_command_after_result();
|
client_context.after_command_after_result();
|
||||||
}
|
}
|
||||||
assert(ret ||
|
assert(ret ||
|
||||||
txc.state() == trrep::transaction_context::s_committed);
|
txc.state() == wsrep::transaction_context::s_committed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -345,9 +345,9 @@ int trrep::server_context::on_apply(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool trrep::server_context::statement_allowed_for_streaming(
|
bool wsrep::server_context::statement_allowed_for_streaming(
|
||||||
const trrep::client_context&,
|
const wsrep::client_context&,
|
||||||
const trrep::transaction_context&) const
|
const wsrep::transaction_context&) const
|
||||||
{
|
{
|
||||||
/* Streaming not implemented yet. */
|
/* Streaming not implemented yet. */
|
||||||
return false;
|
return false;
|
||||||
@ -355,9 +355,9 @@ bool trrep::server_context::statement_allowed_for_streaming(
|
|||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
void trrep::server_context::state(
|
void wsrep::server_context::state(
|
||||||
trrep::unique_lock<trrep::mutex>& lock TRREP_UNUSED,
|
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
|
||||||
enum trrep::server_context::state state)
|
enum wsrep::server_context::state state)
|
||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
static const char allowed[n_states_][n_states_] =
|
static const char allowed[n_states_][n_states_] =
|
||||||
@ -376,7 +376,7 @@ void trrep::server_context::state(
|
|||||||
|
|
||||||
if (allowed[state_][state])
|
if (allowed[state_][state])
|
||||||
{
|
{
|
||||||
trrep::log() << "server " << name_ << " state change: "
|
wsrep::log() << "server " << name_ << " state change: "
|
||||||
<< state_ << " -> " << state;
|
<< state_ << " -> " << state;
|
||||||
state_ = state;
|
state_ = state;
|
||||||
cond_.notify_all();
|
cond_.notify_all();
|
||||||
@ -389,9 +389,9 @@ void trrep::server_context::state(
|
|||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "server: " << name_ << " unallowed state transition: "
|
os << "server: " << name_ << " unallowed state transition: "
|
||||||
<< trrep::to_string(state_) << " -> " << trrep::to_string(state);
|
<< wsrep::to_string(state_) << " -> " << wsrep::to_string(state);
|
||||||
std::cerr << os.str() << "\n";
|
std::cerr << os.str() << "\n";
|
||||||
::abort();
|
::abort();
|
||||||
// throw trrep::runtime_error(os.str());
|
// throw wsrep::runtime_error(os.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,76 +10,76 @@
|
|||||||
// Test on_apply() method for 1pc
|
// Test on_apply() method for 1pc
|
||||||
BOOST_AUTO_TEST_CASE(server_context_applying_1pc)
|
BOOST_AUTO_TEST_CASE(server_context_applying_1pc)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
trrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier,
|
wsrep::client_context::m_applier,
|
||||||
false);
|
false);
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
char buf[1] = { 1 };
|
char buf[1] = { 1 };
|
||||||
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 0);
|
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 0);
|
||||||
const trrep::transaction_context& txc(cc.transaction());
|
const wsrep::transaction_context& txc(cc.transaction());
|
||||||
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_committed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test on_apply() method for 2pc
|
// Test on_apply() method for 2pc
|
||||||
BOOST_AUTO_TEST_CASE(server_context_applying_2pc)
|
BOOST_AUTO_TEST_CASE(server_context_applying_2pc)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
trrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier,
|
wsrep::client_context::m_applier,
|
||||||
true);
|
true);
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
char buf[1] = { 1 };
|
char buf[1] = { 1 };
|
||||||
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 0);
|
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 0);
|
||||||
const trrep::transaction_context& txc(cc.transaction());
|
const wsrep::transaction_context& txc(cc.transaction());
|
||||||
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_committed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test on_apply() method for 1pc transaction which
|
// Test on_apply() method for 1pc transaction which
|
||||||
// fails applying and rolls back
|
// fails applying and rolls back
|
||||||
BOOST_AUTO_TEST_CASE(server_context_applying_1pc_rollback)
|
BOOST_AUTO_TEST_CASE(server_context_applying_1pc_rollback)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
trrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier,
|
wsrep::client_context::m_applier,
|
||||||
false);
|
false);
|
||||||
cc.fail_next_applying(true);
|
cc.fail_next_applying(true);
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
char buf[1] = { 1 };
|
char buf[1] = { 1 };
|
||||||
|
|
||||||
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 1);
|
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 1);
|
||||||
const trrep::transaction_context& txc(cc.transaction());
|
const wsrep::transaction_context& txc(cc.transaction());
|
||||||
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_aborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test on_apply() method for 2pc transaction which
|
// Test on_apply() method for 2pc transaction which
|
||||||
// fails applying and rolls back
|
// fails applying and rolls back
|
||||||
BOOST_AUTO_TEST_CASE(server_context_applying_2pc_rollback)
|
BOOST_AUTO_TEST_CASE(server_context_applying_2pc_rollback)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
trrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier,
|
wsrep::client_context::m_applier,
|
||||||
true);
|
true);
|
||||||
cc.fail_next_applying(true);
|
cc.fail_next_applying(true);
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
char buf[1] = { 1 };
|
char buf[1] = { 1 };
|
||||||
BOOST_REQUIRE(sc.on_apply(cc, trrep::data(buf, 1)) == 1);
|
BOOST_REQUIRE(sc.on_apply(cc, wsrep::data(buf, 1)) == 1);
|
||||||
const trrep::transaction_context& txc(cc.transaction());
|
const wsrep::transaction_context& txc(cc.transaction());
|
||||||
BOOST_REQUIRE(txc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(txc.state() == wsrep::transaction_context::s_aborted);
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,21 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "trrep/client_context.hpp"
|
#include "wsrep/client_context.hpp"
|
||||||
#include "trrep/server_context.hpp"
|
#include "wsrep/server_context.hpp"
|
||||||
#include "trrep/key.hpp"
|
#include "wsrep/key.hpp"
|
||||||
#include "trrep/data.hpp"
|
#include "wsrep/data.hpp"
|
||||||
#include "trrep/logger.hpp"
|
#include "wsrep/logger.hpp"
|
||||||
#include "trrep/compiler.hpp"
|
#include "wsrep/compiler.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
trrep::transaction_context::transaction_context(
|
wsrep::transaction_context::transaction_context(
|
||||||
trrep::client_context& client_context)
|
wsrep::client_context& client_context)
|
||||||
: provider_(client_context.provider())
|
: provider_(client_context.provider())
|
||||||
, client_context_(client_context)
|
, client_context_(client_context)
|
||||||
, id_(transaction_id::invalid())
|
, id_(transaction_id::invalid())
|
||||||
@ -34,12 +34,12 @@ trrep::transaction_context::transaction_context(
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
trrep::transaction_context::~transaction_context()
|
wsrep::transaction_context::~transaction_context()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::start_transaction(
|
int wsrep::transaction_context::start_transaction(
|
||||||
const trrep::transaction_id& id)
|
const wsrep::transaction_id& id)
|
||||||
{
|
{
|
||||||
assert(active() == false);
|
assert(active() == false);
|
||||||
id_ = id;
|
id_ = id;
|
||||||
@ -49,10 +49,10 @@ int trrep::transaction_context::start_transaction(
|
|||||||
flags_ |= WSREP_FLAG_TRX_START;
|
flags_ |= WSREP_FLAG_TRX_START;
|
||||||
switch (client_context_.mode())
|
switch (client_context_.mode())
|
||||||
{
|
{
|
||||||
case trrep::client_context::m_local:
|
case wsrep::client_context::m_local:
|
||||||
case trrep::client_context::m_applier:
|
case wsrep::client_context::m_applier:
|
||||||
return 0;
|
return 0;
|
||||||
case trrep::client_context::m_replicating:
|
case wsrep::client_context::m_replicating:
|
||||||
return provider_.start_transaction(&ws_handle_);
|
return provider_.start_transaction(&ws_handle_);
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -60,13 +60,13 @@ int trrep::transaction_context::start_transaction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::start_transaction(
|
int wsrep::transaction_context::start_transaction(
|
||||||
const wsrep_ws_handle_t& ws_handle,
|
const wsrep_ws_handle_t& ws_handle,
|
||||||
const wsrep_trx_meta_t& trx_meta,
|
const wsrep_trx_meta_t& trx_meta,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
assert(active() == false);
|
assert(active() == false);
|
||||||
assert(client_context_.mode() == trrep::client_context::m_applier);
|
assert(client_context_.mode() == wsrep::client_context::m_applier);
|
||||||
state_ = s_executing;
|
state_ = s_executing;
|
||||||
ws_handle_ = ws_handle;
|
ws_handle_ = ws_handle;
|
||||||
trx_meta_ = trx_meta;
|
trx_meta_ = trx_meta;
|
||||||
@ -76,30 +76,30 @@ int trrep::transaction_context::start_transaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int trrep::transaction_context::append_key(const trrep::key& key)
|
int wsrep::transaction_context::append_key(const wsrep::key& key)
|
||||||
{
|
{
|
||||||
|
|
||||||
return provider_.append_key(&ws_handle_, &key.get());
|
return provider_.append_key(&ws_handle_, &key.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::append_data(const trrep::data& data)
|
int wsrep::transaction_context::append_data(const wsrep::data& data)
|
||||||
{
|
{
|
||||||
|
|
||||||
return provider_.append_data(&ws_handle_, &data.get());
|
return provider_.append_data(&ws_handle_, &data.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::before_prepare()
|
int wsrep::transaction_context::before_prepare()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
|
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("before_prepare_enter");
|
debug_log_state("before_prepare_enter");
|
||||||
assert(state() == s_executing || state() == s_must_abort);
|
assert(state() == s_executing || state() == s_must_abort);
|
||||||
|
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
assert(client_context_.mode() == trrep::client_context::m_replicating);
|
assert(client_context_.mode() == wsrep::client_context::m_replicating);
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ int trrep::transaction_context::before_prepare()
|
|||||||
|
|
||||||
switch (client_context_.mode())
|
switch (client_context_.mode())
|
||||||
{
|
{
|
||||||
case trrep::client_context::m_replicating:
|
case wsrep::client_context::m_replicating:
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
client_context_.debug_suicide(
|
client_context_.debug_suicide(
|
||||||
@ -116,7 +116,7 @@ int trrep::transaction_context::before_prepare()
|
|||||||
if (client_context_.server_context().statement_allowed_for_streaming(
|
if (client_context_.server_context().statement_allowed_for_streaming(
|
||||||
client_context_, *this))
|
client_context_, *this))
|
||||||
{
|
{
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -128,8 +128,8 @@ int trrep::transaction_context::before_prepare()
|
|||||||
"crash_last_fragment_commit_after_fragment_removal");
|
"crash_last_fragment_commit_after_fragment_removal");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_local:
|
case wsrep::client_context::m_local:
|
||||||
case trrep::client_context::m_applier:
|
case wsrep::client_context::m_applier:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -141,22 +141,22 @@ int trrep::transaction_context::before_prepare()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::after_prepare()
|
int wsrep::transaction_context::after_prepare()
|
||||||
{
|
{
|
||||||
int ret(1);
|
int ret(1);
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("after_prepare_enter");
|
debug_log_state("after_prepare_enter");
|
||||||
assert(state() == s_preparing || state() == s_must_abort);
|
assert(state() == s_preparing || state() == s_must_abort);
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
assert(client_context_.mode() == trrep::client_context::m_replicating);
|
assert(client_context_.mode() == wsrep::client_context::m_replicating);
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (client_context_.mode())
|
switch (client_context_.mode())
|
||||||
{
|
{
|
||||||
case trrep::client_context::m_replicating:
|
case wsrep::client_context::m_replicating:
|
||||||
if (state() == s_preparing)
|
if (state() == s_preparing)
|
||||||
{
|
{
|
||||||
ret = certify_commit(lock);
|
ret = certify_commit(lock);
|
||||||
@ -168,11 +168,11 @@ int trrep::transaction_context::after_prepare()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(state() == s_must_abort);
|
assert(state() == s_must_abort);
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_local:
|
case wsrep::client_context::m_local:
|
||||||
case trrep::client_context::m_applier:
|
case wsrep::client_context::m_applier:
|
||||||
state(lock, s_certifying);
|
state(lock, s_certifying);
|
||||||
state(lock, s_committing);
|
state(lock, s_committing);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -185,13 +185,13 @@ int trrep::transaction_context::after_prepare()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::before_commit()
|
int wsrep::transaction_context::before_commit()
|
||||||
{
|
{
|
||||||
int ret(1);
|
int ret(1);
|
||||||
|
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("before_commit_enter");
|
debug_log_state("before_commit_enter");
|
||||||
assert(client_context_.mode() != trrep::client_context::m_toi);
|
assert(client_context_.mode() != wsrep::client_context::m_toi);
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_committing ||
|
state() == s_committing ||
|
||||||
state() == s_must_abort ||
|
state() == s_must_abort ||
|
||||||
@ -200,13 +200,13 @@ int trrep::transaction_context::before_commit()
|
|||||||
|
|
||||||
switch (client_context_.mode())
|
switch (client_context_.mode())
|
||||||
{
|
{
|
||||||
case trrep::client_context::m_local:
|
case wsrep::client_context::m_local:
|
||||||
if (ordered())
|
if (ordered())
|
||||||
{
|
{
|
||||||
ret = provider_.commit_order_enter(&ws_handle_, &trx_meta_);
|
ret = provider_.commit_order_enter(&ws_handle_, &trx_meta_);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_replicating:
|
case wsrep::client_context::m_replicating:
|
||||||
|
|
||||||
// Commit is one phase - before/after prepare was not called
|
// Commit is one phase - before/after prepare was not called
|
||||||
if (state() == s_executing)
|
if (state() == s_executing)
|
||||||
@ -221,7 +221,7 @@ int trrep::transaction_context::before_commit()
|
|||||||
else if (state() != s_committing)
|
else if (state() != s_committing)
|
||||||
{
|
{
|
||||||
assert(state() == s_must_abort);
|
assert(state() == s_must_abort);
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -252,7 +252,7 @@ int trrep::transaction_context::before_commit()
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_applier:
|
case wsrep::client_context::m_applier:
|
||||||
assert(ordered());
|
assert(ordered());
|
||||||
ret = provider_.commit_order_enter(&ws_handle_, &trx_meta_);
|
ret = provider_.commit_order_enter(&ws_handle_, &trx_meta_);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -281,11 +281,11 @@ int trrep::transaction_context::before_commit()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::ordered_commit()
|
int wsrep::transaction_context::ordered_commit()
|
||||||
{
|
{
|
||||||
int ret(1);
|
int ret(1);
|
||||||
|
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("ordered_commit_enter");
|
debug_log_state("ordered_commit_enter");
|
||||||
assert(state() == s_committing);
|
assert(state() == s_committing);
|
||||||
assert(ordered());
|
assert(ordered());
|
||||||
@ -297,27 +297,27 @@ int trrep::transaction_context::ordered_commit()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::after_commit()
|
int wsrep::transaction_context::after_commit()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
|
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("after_commit_enter");
|
debug_log_state("after_commit_enter");
|
||||||
assert(state() == s_ordered_commit);
|
assert(state() == s_ordered_commit);
|
||||||
|
|
||||||
switch (client_context_.mode())
|
switch (client_context_.mode())
|
||||||
{
|
{
|
||||||
case trrep::client_context::m_local:
|
case wsrep::client_context::m_local:
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_replicating:
|
case wsrep::client_context::m_replicating:
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
clear_fragments();
|
clear_fragments();
|
||||||
}
|
}
|
||||||
ret = provider_.release(&ws_handle_);
|
ret = provider_.release(&ws_handle_);
|
||||||
break;
|
break;
|
||||||
case trrep::client_context::m_applier:
|
case wsrep::client_context::m_applier:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -329,9 +329,9 @@ int trrep::transaction_context::after_commit()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::before_rollback()
|
int wsrep::transaction_context::before_rollback()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("before_rollback_enter");
|
debug_log_state("before_rollback_enter");
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_must_abort ||
|
state() == s_must_abort ||
|
||||||
@ -382,9 +382,9 @@ int trrep::transaction_context::before_rollback()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::after_rollback()
|
int wsrep::transaction_context::after_rollback()
|
||||||
{
|
{
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("after_rollback_enter");
|
debug_log_state("after_rollback_enter");
|
||||||
assert(state() == s_aborting ||
|
assert(state() == s_aborting ||
|
||||||
state() == s_must_replay);
|
state() == s_must_replay);
|
||||||
@ -404,10 +404,10 @@ int trrep::transaction_context::after_rollback()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::transaction_context::after_statement()
|
int wsrep::transaction_context::after_statement()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
trrep::unique_lock<trrep::mutex> lock(client_context_.mutex());
|
wsrep::unique_lock<wsrep::mutex> lock(client_context_.mutex());
|
||||||
debug_log_state("after_statement_enter");
|
debug_log_state("after_statement_enter");
|
||||||
assert(state() == s_executing ||
|
assert(state() == s_executing ||
|
||||||
state() == s_committed ||
|
state() == s_committed ||
|
||||||
@ -429,7 +429,7 @@ int trrep::transaction_context::after_statement()
|
|||||||
break;
|
break;
|
||||||
case s_must_abort:
|
case s_must_abort:
|
||||||
case s_cert_failed:
|
case s_cert_failed:
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
ret = client_context_.rollback();
|
ret = client_context_.rollback();
|
||||||
lock.lock();
|
lock.lock();
|
||||||
@ -478,8 +478,8 @@ int trrep::transaction_context::after_statement()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool trrep::transaction_context::bf_abort(
|
bool wsrep::transaction_context::bf_abort(
|
||||||
trrep::unique_lock<trrep::mutex>& lock TRREP_UNUSED,
|
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED,
|
||||||
wsrep_seqno_t bf_seqno)
|
wsrep_seqno_t bf_seqno)
|
||||||
{
|
{
|
||||||
bool ret(false);
|
bool ret(false);
|
||||||
@ -488,11 +488,11 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
|
|
||||||
if (active() == false)
|
if (active() == false)
|
||||||
{
|
{
|
||||||
trrep::log() << "Transaction not active, skipping bf abort";
|
wsrep::log() << "Transaction not active, skipping bf abort";
|
||||||
}
|
}
|
||||||
else if (ordered() && seqno() < bf_seqno)
|
else if (ordered() && seqno() < bf_seqno)
|
||||||
{
|
{
|
||||||
trrep::log() << "Not allowed to BF abort transaction ordered before "
|
wsrep::log() << "Not allowed to BF abort transaction ordered before "
|
||||||
<< "aborter: " << seqno() << " < " << bf_seqno;
|
<< "aborter: " << seqno() << " < " << bf_seqno;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -510,7 +510,7 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case WSREP_OK:
|
case WSREP_OK:
|
||||||
trrep::log() << "Seqno " << bf_seqno
|
wsrep::log() << "Seqno " << bf_seqno
|
||||||
<< " succesfully BF aborted " << id_.get()
|
<< " succesfully BF aborted " << id_.get()
|
||||||
<< " victim_seqno " << victim_seqno;
|
<< " victim_seqno " << victim_seqno;
|
||||||
bf_abort_state_ = state();
|
bf_abort_state_ = state();
|
||||||
@ -518,7 +518,7 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trrep::log() << "Seqno " << bf_seqno
|
wsrep::log() << "Seqno " << bf_seqno
|
||||||
<< " failed to BF abort " << id_.get()
|
<< " failed to BF abort " << id_.get()
|
||||||
<< " with status " << status
|
<< " with status " << status
|
||||||
<< " victim_seqno " << victim_seqno;
|
<< " victim_seqno " << victim_seqno;
|
||||||
@ -527,8 +527,8 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
trrep::log() << "BF abort not allowed in state "
|
wsrep::log() << "BF abort not allowed in state "
|
||||||
<< trrep::to_string(state());
|
<< wsrep::to_string(state());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,7 +537,7 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
{
|
{
|
||||||
bf_abort_client_state_ = client_context_.state();
|
bf_abort_client_state_ = client_context_.state();
|
||||||
if (client_context_.server_context().rollback_mode() ==
|
if (client_context_.server_context().rollback_mode() ==
|
||||||
trrep::server_context::rm_sync)
|
wsrep::server_context::rm_sync)
|
||||||
{
|
{
|
||||||
//! \todo Launch background rollbacker.
|
//! \todo Launch background rollbacker.
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -546,15 +546,15 @@ bool trrep::transaction_context::bf_abort(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::mutex& trrep::transaction_context::mutex()
|
wsrep::mutex& wsrep::transaction_context::mutex()
|
||||||
{
|
{
|
||||||
return client_context_.mutex();
|
return client_context_.mutex();
|
||||||
}
|
}
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
void trrep::transaction_context::state(
|
void wsrep::transaction_context::state(
|
||||||
trrep::unique_lock<trrep::mutex>& lock __attribute__((unused)),
|
wsrep::unique_lock<wsrep::mutex>& lock __attribute__((unused)),
|
||||||
enum trrep::transaction_context::state next_state)
|
enum wsrep::transaction_context::state next_state)
|
||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
static const char allowed[n_states][n_states] =
|
static const char allowed[n_states][n_states] =
|
||||||
@ -581,28 +581,28 @@ void trrep::transaction_context::state(
|
|||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "unallowed state transition for transaction "
|
os << "unallowed state transition for transaction "
|
||||||
<< id_.get() << ": " << trrep::to_string(state_)
|
<< id_.get() << ": " << wsrep::to_string(state_)
|
||||||
<< " -> " << trrep::to_string(next_state);
|
<< " -> " << wsrep::to_string(next_state);
|
||||||
trrep::log() << os.str();
|
wsrep::log() << os.str();
|
||||||
throw trrep::runtime_error(os.str());
|
throw wsrep::runtime_error(os.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int trrep::transaction_context::certify_fragment(
|
int wsrep::transaction_context::certify_fragment(
|
||||||
trrep::unique_lock<trrep::mutex>& lock)
|
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
{
|
{
|
||||||
// This method is not fully implemented and tested yet.
|
// This method is not fully implemented and tested yet.
|
||||||
throw trrep::not_implemented_error();
|
throw wsrep::not_implemented_error();
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
|
|
||||||
assert(client_context_.mode() == trrep::client_context::m_replicating);
|
assert(client_context_.mode() == wsrep::client_context::m_replicating);
|
||||||
assert(rollback_replicated_for_ != id_);
|
assert(rollback_replicated_for_ != id_);
|
||||||
|
|
||||||
client_context_.wait_for_replayers(lock);
|
client_context_.wait_for_replayers(lock);
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +616,7 @@ int trrep::transaction_context::certify_fragment(
|
|||||||
flags |= WSREP_FLAG_TRX_START;
|
flags |= WSREP_FLAG_TRX_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::data data;
|
wsrep::data data;
|
||||||
if (client_context_.prepare_data_for_replication(*this, data))
|
if (client_context_.prepare_data_for_replication(*this, data))
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
@ -627,17 +627,17 @@ int trrep::transaction_context::certify_fragment(
|
|||||||
// Client context to store fragment in separate transaction
|
// Client context to store fragment in separate transaction
|
||||||
// Switch temporarily to sr_transaction_context, switch back
|
// Switch temporarily to sr_transaction_context, switch back
|
||||||
// to original when this goes out of scope
|
// to original when this goes out of scope
|
||||||
std::auto_ptr<trrep::client_context> sr_client_context(
|
std::auto_ptr<wsrep::client_context> sr_client_context(
|
||||||
client_context_.server_context().local_client_context());
|
client_context_.server_context().local_client_context());
|
||||||
trrep::client_context_switch client_context_switch(
|
wsrep::client_context_switch client_context_switch(
|
||||||
client_context_,
|
client_context_,
|
||||||
*sr_client_context);
|
*sr_client_context);
|
||||||
trrep::transaction_context sr_transaction_context(*sr_client_context);
|
wsrep::transaction_context sr_transaction_context(*sr_client_context);
|
||||||
if (sr_client_context->append_fragment(sr_transaction_context, flags, data))
|
if (sr_client_context->append_fragment(sr_transaction_context, flags, data))
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(trrep::e_append_fragment_error);
|
client_context_.override_error(wsrep::e_append_fragment_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,11 +661,11 @@ int trrep::transaction_context::certify_fragment(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int trrep::transaction_context::certify_commit(
|
int wsrep::transaction_context::certify_commit(
|
||||||
trrep::unique_lock<trrep::mutex>& lock)
|
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
{
|
{
|
||||||
assert(lock.owns_lock());
|
assert(lock.owns_lock());
|
||||||
assert(id_ != trrep::transaction_id::invalid());
|
assert(id_ != wsrep::transaction_id::invalid());
|
||||||
|
|
||||||
client_context_.wait_for_replayers(lock);
|
client_context_.wait_for_replayers(lock);
|
||||||
|
|
||||||
@ -673,7 +673,7 @@ int trrep::transaction_context::certify_commit(
|
|||||||
|
|
||||||
if (state() == s_must_abort)
|
if (state() == s_must_abort)
|
||||||
{
|
{
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +682,7 @@ int trrep::transaction_context::certify_commit(
|
|||||||
flags(flags() | WSREP_FLAG_TRX_END);
|
flags(flags() | WSREP_FLAG_TRX_END);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
trrep::data data;
|
wsrep::data data;
|
||||||
if (client_context_.prepare_data_for_replication(*this, data))
|
if (client_context_.prepare_data_for_replication(*this, data))
|
||||||
{
|
{
|
||||||
// Note: Error must be set by prepare_data_for_replication()
|
// Note: Error must be set by prepare_data_for_replication()
|
||||||
@ -694,7 +694,7 @@ int trrep::transaction_context::certify_commit(
|
|||||||
if (client_context_.killed())
|
if (client_context_.killed())
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -737,13 +737,13 @@ int trrep::transaction_context::certify_commit(
|
|||||||
case WSREP_WARNING:
|
case WSREP_WARNING:
|
||||||
assert(ordered() == false);
|
assert(ordered() == false);
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case WSREP_TRX_MISSING:
|
case WSREP_TRX_MISSING:
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
// The execution should never reach this point if the
|
// The execution should never reach this point if the
|
||||||
// transaction has not generated any keys or data.
|
// transaction has not generated any keys or data.
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
case WSREP_BF_ABORT:
|
case WSREP_BF_ABORT:
|
||||||
@ -762,11 +762,11 @@ int trrep::transaction_context::certify_commit(
|
|||||||
break;
|
break;
|
||||||
case WSREP_TRX_FAIL:
|
case WSREP_TRX_FAIL:
|
||||||
state(lock, s_cert_failed);
|
state(lock, s_cert_failed);
|
||||||
client_context_.override_error(trrep::e_deadlock_error);
|
client_context_.override_error(wsrep::e_deadlock_error);
|
||||||
break;
|
break;
|
||||||
case WSREP_SIZE_EXCEEDED:
|
case WSREP_SIZE_EXCEEDED:
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case WSREP_CONN_FAIL:
|
case WSREP_CONN_FAIL:
|
||||||
case WSREP_NODE_FAIL:
|
case WSREP_NODE_FAIL:
|
||||||
@ -776,39 +776,39 @@ int trrep::transaction_context::certify_commit(
|
|||||||
{
|
{
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
}
|
}
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
case WSREP_FATAL:
|
case WSREP_FATAL:
|
||||||
client_context_.abort();
|
client_context_.abort();
|
||||||
break;
|
break;
|
||||||
case WSREP_NOT_IMPLEMENTED:
|
case WSREP_NOT_IMPLEMENTED:
|
||||||
case WSREP_NOT_ALLOWED:
|
case WSREP_NOT_ALLOWED:
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
client_context_.override_error(trrep::e_error_during_commit);
|
client_context_.override_error(wsrep::e_error_during_commit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::transaction_context::remove_fragments()
|
void wsrep::transaction_context::remove_fragments()
|
||||||
{
|
{
|
||||||
throw trrep::not_implemented_error();
|
throw wsrep::not_implemented_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::transaction_context::clear_fragments()
|
void wsrep::transaction_context::clear_fragments()
|
||||||
{
|
{
|
||||||
throw trrep::not_implemented_error();
|
throw wsrep::not_implemented_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::transaction_context::cleanup()
|
void wsrep::transaction_context::cleanup()
|
||||||
{
|
{
|
||||||
debug_log_state("cleanup_enter");
|
debug_log_state("cleanup_enter");
|
||||||
id_ = trrep::transaction_id::invalid();
|
id_ = wsrep::transaction_id::invalid();
|
||||||
ws_handle_.trx_id = -1;
|
ws_handle_.trx_id = -1;
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
{
|
{
|
||||||
@ -818,24 +818,24 @@ void trrep::transaction_context::cleanup()
|
|||||||
// state_hist_.clear();
|
// state_hist_.clear();
|
||||||
trx_meta_.gtid = WSREP_GTID_UNDEFINED;
|
trx_meta_.gtid = WSREP_GTID_UNDEFINED;
|
||||||
trx_meta_.stid.node = WSREP_UUID_UNDEFINED;
|
trx_meta_.stid.node = WSREP_UUID_UNDEFINED;
|
||||||
trx_meta_.stid.trx = trrep::transaction_id::invalid();
|
trx_meta_.stid.trx = wsrep::transaction_id::invalid();
|
||||||
trx_meta_.stid.conn = trrep::client_id::invalid();
|
trx_meta_.stid.conn = wsrep::client_id::invalid();
|
||||||
certified_ = false;
|
certified_ = false;
|
||||||
pa_unsafe_ = false;
|
pa_unsafe_ = false;
|
||||||
debug_log_state("cleanup_leave");
|
debug_log_state("cleanup_leave");
|
||||||
}
|
}
|
||||||
|
|
||||||
void trrep::transaction_context::debug_log_state(
|
void wsrep::transaction_context::debug_log_state(
|
||||||
const char* context) const
|
const char* context) const
|
||||||
{
|
{
|
||||||
if (client_context_.debug_log_level() >= 1)
|
if (client_context_.debug_log_level() >= 1)
|
||||||
{
|
{
|
||||||
trrep::log_debug() << context
|
wsrep::log_debug() << context
|
||||||
<< ": server: " << client_context_.server_context().name()
|
<< ": server: " << client_context_.server_context().name()
|
||||||
<< ": client: " << client_context_.id().get()
|
<< ": client: " << client_context_.id().get()
|
||||||
<< " trx: " << int64_t(id_.get())
|
<< " trx: " << int64_t(id_.get())
|
||||||
<< " state: " << trrep::to_string(state_)
|
<< " state: " << wsrep::to_string(state_)
|
||||||
<< " error: "
|
<< " error: "
|
||||||
<< trrep::to_string(client_context_.current_error());
|
<< wsrep::to_string(client_context_.current_error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "trrep/transaction_context.hpp"
|
#include "wsrep/transaction_context.hpp"
|
||||||
#include "trrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
|
|
||||||
#include "mock_client_context.hpp"
|
#include "mock_client_context.hpp"
|
||||||
#include "mock_server_context.hpp"
|
#include "mock_server_context.hpp"
|
||||||
@ -17,35 +17,35 @@ namespace
|
|||||||
struct replicating_client_fixture
|
struct replicating_client_fixture
|
||||||
{
|
{
|
||||||
replicating_client_fixture()
|
replicating_client_fixture()
|
||||||
: sc("s1", "s1", trrep::server_context::rm_async)
|
: sc("s1", "s1", wsrep::server_context::rm_async)
|
||||||
, cc(sc, trrep::client_id(1),
|
, cc(sc, wsrep::client_id(1),
|
||||||
trrep::client_context::m_replicating)
|
wsrep::client_context::m_replicating)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
// Verify initial state
|
// Verify initial state
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
}
|
}
|
||||||
trrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
trrep::mock_client_context cc;
|
wsrep::mock_client_context cc;
|
||||||
const trrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct applying_client_fixture
|
struct applying_client_fixture
|
||||||
{
|
{
|
||||||
applying_client_fixture()
|
applying_client_fixture()
|
||||||
: sc("s1", "s1",
|
: sc("s1", "s1",
|
||||||
trrep::server_context::rm_async)
|
wsrep::server_context::rm_async)
|
||||||
, cc(sc,
|
, cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier)
|
wsrep::client_context::m_applier)
|
||||||
, tc(cc.transaction())
|
, tc(cc.transaction())
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
@ -54,9 +54,9 @@ namespace
|
|||||||
BOOST_REQUIRE(tc.certified() == true);
|
BOOST_REQUIRE(tc.certified() == true);
|
||||||
BOOST_REQUIRE(tc.ordered() == true);
|
BOOST_REQUIRE(tc.ordered() == true);
|
||||||
}
|
}
|
||||||
trrep::mock_server_context sc;
|
wsrep::mock_server_context sc;
|
||||||
trrep::mock_client_context cc;
|
wsrep::mock_client_context cc;
|
||||||
const trrep::transaction_context& tc;
|
const wsrep::transaction_context& tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -71,27 +71,27 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_1pc, replicating_client_fixture)
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
|
|
||||||
// Run ordered commit
|
// Run ordered commit
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_ordered_commit);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
|
|
||||||
// Run after commit
|
// Run after commit
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -102,35 +102,35 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc, replicating_client_fixture)
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
// Run before prepare
|
// Run before prepare
|
||||||
BOOST_REQUIRE(cc.before_prepare() == 0);
|
BOOST_REQUIRE(cc.before_prepare() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_preparing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_preparing);
|
||||||
|
|
||||||
// Run after prepare
|
// Run after prepare
|
||||||
BOOST_REQUIRE(cc.after_prepare() == 0);
|
BOOST_REQUIRE(cc.after_prepare() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
|
|
||||||
// Run ordered commit
|
// Run ordered commit
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_ordered_commit);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
|
|
||||||
// Run after commit
|
// Run after commit
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -141,23 +141,23 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_rollback, replicating_client_fixture
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
|
|
||||||
// Run after commit
|
// Run after commit
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -169,22 +169,22 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_1pc_bf_before_before_commit,
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_unordered(cc);
|
wsrep_mock::bf_abort_unordered(cc);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_commit());
|
BOOST_REQUIRE(cc.before_commit());
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_abort);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
|
|
||||||
// Rollback sequence
|
// Rollback sequence
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
@ -203,22 +203,22 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc_bf_before_before_prepare,
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_unordered(cc);
|
wsrep_mock::bf_abort_unordered(cc);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_prepare());
|
BOOST_REQUIRE(cc.before_prepare());
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_abort);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
|
|
||||||
// Rollback sequence
|
// Rollback sequence
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
@ -237,26 +237,26 @@ BOOST_FIXTURE_TEST_CASE(transaction_context_2pc_bf_before_after_prepare,
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
// Run before prepare
|
// Run before prepare
|
||||||
BOOST_REQUIRE(cc.before_prepare() == 0);
|
BOOST_REQUIRE(cc.before_prepare() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_preparing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_preparing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_unordered(cc);
|
wsrep_mock::bf_abort_unordered(cc);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.after_prepare());
|
BOOST_REQUIRE(cc.after_prepare());
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_abort);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_abort);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
|
|
||||||
// Rollback sequence
|
// Rollback sequence
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
@ -277,22 +277,22 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_provider(sc, tc, WSREP_SEQNO_UNDEFINED);
|
wsrep_mock::bf_abort_provider(sc, tc, WSREP_SEQNO_UNDEFINED);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_commit());
|
BOOST_REQUIRE(cc.before_commit());
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_cert_failed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_cert_failed);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
|
|
||||||
// Rollback sequence
|
// Rollback sequence
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
@ -312,10 +312,10 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_unordered(cc);
|
wsrep_mock::bf_abort_unordered(cc);
|
||||||
|
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
@ -335,61 +335,61 @@ BOOST_FIXTURE_TEST_CASE(
|
|||||||
// Start a new transaction with ID 1
|
// Start a new transaction with ID 1
|
||||||
cc.start_transaction(1);
|
cc.start_transaction(1);
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
BOOST_REQUIRE(tc.id() == trrep::transaction_id(1));
|
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_executing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_executing);
|
||||||
|
|
||||||
trrep_mock::bf_abort_provider(sc, tc, 1);
|
wsrep_mock::bf_abort_provider(sc, tc, 1);
|
||||||
|
|
||||||
// Run before commit
|
// Run before commit
|
||||||
BOOST_REQUIRE(cc.before_commit());
|
BOOST_REQUIRE(cc.before_commit());
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_replay);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == true);
|
BOOST_REQUIRE(tc.ordered() == true);
|
||||||
|
|
||||||
// Rollback sequence
|
// Rollback sequence
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_replay);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_must_replay);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_must_replay);
|
||||||
|
|
||||||
// Cleanup after statement
|
// Cleanup after statement
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(tc.ordered() == false);
|
BOOST_REQUIRE(tc.ordered() == false);
|
||||||
BOOST_REQUIRE(tc.certified() == false);
|
BOOST_REQUIRE(tc.certified() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(transaction_context_1pc_applying,
|
BOOST_FIXTURE_TEST_CASE(transaction_context_1pc_applying,
|
||||||
applying_client_fixture)
|
applying_client_fixture)
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_ordered_commit);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(transaction_context_2pc_applying)
|
BOOST_AUTO_TEST_CASE(transaction_context_2pc_applying)
|
||||||
{
|
{
|
||||||
trrep::mock_server_context sc("s1", "s1",
|
wsrep::mock_server_context sc("s1", "s1",
|
||||||
trrep::server_context::rm_sync);
|
wsrep::server_context::rm_sync);
|
||||||
trrep::mock_client_context cc(sc,
|
wsrep::mock_client_context cc(sc,
|
||||||
trrep::client_id(1),
|
wsrep::client_id(1),
|
||||||
trrep::client_context::m_applier);
|
wsrep::client_context::m_applier);
|
||||||
|
|
||||||
BOOST_REQUIRE(cc.before_command() == 0);
|
BOOST_REQUIRE(cc.before_command() == 0);
|
||||||
BOOST_REQUIRE(cc.before_statement() == 0);
|
BOOST_REQUIRE(cc.before_statement() == 0);
|
||||||
|
|
||||||
trrep_mock::start_applying_transaction(
|
wsrep_mock::start_applying_transaction(
|
||||||
cc, 1, 1,
|
cc, 1, 1,
|
||||||
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
WSREP_FLAG_TRX_START | WSREP_FLAG_TRX_END);
|
||||||
const trrep::transaction_context& tc(cc.transaction());
|
const wsrep::transaction_context& tc(cc.transaction());
|
||||||
|
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(cc.start_transaction() == 0);
|
BOOST_REQUIRE(cc.start_transaction() == 0);
|
||||||
@ -398,30 +398,30 @@ BOOST_AUTO_TEST_CASE(transaction_context_2pc_applying)
|
|||||||
BOOST_REQUIRE(tc.ordered() == true);
|
BOOST_REQUIRE(tc.ordered() == true);
|
||||||
|
|
||||||
BOOST_REQUIRE(cc.before_prepare() == 0);
|
BOOST_REQUIRE(cc.before_prepare() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_preparing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_preparing);
|
||||||
BOOST_REQUIRE(cc.after_prepare() == 0);
|
BOOST_REQUIRE(cc.after_prepare() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committing);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committing);
|
||||||
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
BOOST_REQUIRE(cc.ordered_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_ordered_commit);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_ordered_commit);
|
||||||
BOOST_REQUIRE(cc.after_commit() == 0);
|
BOOST_REQUIRE(cc.after_commit() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_committed);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_committed);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(transaction_context_applying_rollback,
|
BOOST_FIXTURE_TEST_CASE(transaction_context_applying_rollback,
|
||||||
applying_client_fixture)
|
applying_client_fixture)
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(cc.before_rollback() == 0);
|
BOOST_REQUIRE(cc.before_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborting);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborting);
|
||||||
BOOST_REQUIRE(cc.after_rollback() == 0);
|
BOOST_REQUIRE(cc.after_rollback() == 0);
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
cc.after_statement();
|
cc.after_statement();
|
||||||
BOOST_REQUIRE(tc.state() == trrep::transaction_context::s_aborted);
|
BOOST_REQUIRE(tc.state() == wsrep::transaction_context::s_aborted);
|
||||||
BOOST_REQUIRE(tc.active() == false);
|
BOOST_REQUIRE(tc.active() == false);
|
||||||
BOOST_REQUIRE(cc.current_error() == trrep::e_success);
|
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE trrep_test
|
#define BOOST_TEST_MODULE wsrep_test
|
||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "wsrep_provider_v26.hpp"
|
#include "wsrep_provider_v26.hpp"
|
||||||
#include "trrep/exception.hpp"
|
#include "wsrep/exception.hpp"
|
||||||
|
|
||||||
#include <wsrep_api.h>
|
#include <wsrep_api.h>
|
||||||
|
|
||||||
@ -12,27 +12,27 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
trrep::wsrep_provider_v26::wsrep_provider_v26(
|
wsrep::wsrep_provider_v26::wsrep_provider_v26(
|
||||||
const char* path,
|
const char* path,
|
||||||
struct wsrep_init_args* args)
|
wsrep_init_args* args)
|
||||||
: wsrep_()
|
: wsrep_()
|
||||||
{
|
{
|
||||||
if (wsrep_load(path, &wsrep_, 0))
|
if (wsrep_load(path, &wsrep_, 0))
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to load wsrep library");
|
throw wsrep::runtime_error("Failed to load wsrep library");
|
||||||
}
|
}
|
||||||
if (wsrep_->init(wsrep_, args) != WSREP_OK)
|
if (wsrep_->init(wsrep_, args) != WSREP_OK)
|
||||||
{
|
{
|
||||||
throw trrep::runtime_error("Failed to initialize wsrep provider");
|
throw wsrep::runtime_error("Failed to initialize wsrep provider");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trrep::wsrep_provider_v26::~wsrep_provider_v26()
|
wsrep::wsrep_provider_v26::~wsrep_provider_v26()
|
||||||
{
|
{
|
||||||
wsrep_unload(wsrep_);
|
wsrep_unload(wsrep_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::connect(
|
int wsrep::wsrep_provider_v26::connect(
|
||||||
const std::string& cluster_name,
|
const std::string& cluster_name,
|
||||||
const std::string& cluster_url,
|
const std::string& cluster_url,
|
||||||
const std::string& state_donor,
|
const std::string& state_donor,
|
||||||
@ -53,7 +53,7 @@ int trrep::wsrep_provider_v26::connect(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::disconnect()
|
int wsrep::wsrep_provider_v26::disconnect()
|
||||||
{
|
{
|
||||||
int ret(0);
|
int ret(0);
|
||||||
wsrep_status_t wret;
|
wsrep_status_t wret;
|
||||||
@ -66,26 +66,26 @@ int trrep::wsrep_provider_v26::disconnect()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsrep_status_t trrep::wsrep_provider_v26::run_applier(void *applier_ctx)
|
wsrep_status_t wsrep::wsrep_provider_v26::run_applier(void *applier_ctx)
|
||||||
{
|
{
|
||||||
return wsrep_->recv(wsrep_, applier_ctx);
|
return wsrep_->recv(wsrep_, applier_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::append_key(wsrep_ws_handle_t* wsh,
|
int wsrep::wsrep_provider_v26::append_key(wsrep_ws_handle_t* wsh,
|
||||||
const wsrep_key_t* key)
|
const wsrep_key_t* key)
|
||||||
{
|
{
|
||||||
return (wsrep_->append_key(wsrep_, wsh, key, 1, WSREP_KEY_EXCLUSIVE, true)
|
return (wsrep_->append_key(wsrep_, wsh, key, 1, WSREP_KEY_EXCLUSIVE, true)
|
||||||
!= WSREP_OK);
|
!= WSREP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::append_data(wsrep_ws_handle_t* wsh,
|
int wsrep::wsrep_provider_v26::append_data(wsrep_ws_handle_t* wsh,
|
||||||
const wsrep_buf_t* data)
|
const wsrep_buf_t* data)
|
||||||
{
|
{
|
||||||
return (wsrep_->append_data(wsrep_, wsh, data, 1, WSREP_DATA_ORDERED, true)
|
return (wsrep_->append_data(wsrep_, wsh, data, 1, WSREP_DATA_ORDERED, true)
|
||||||
!= WSREP_OK);
|
!= WSREP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
wsrep_status_t trrep::wsrep_provider_v26::certify(wsrep_conn_id_t conn_id,
|
wsrep_status_t wsrep::wsrep_provider_v26::certify(wsrep_conn_id_t conn_id,
|
||||||
wsrep_ws_handle_t* wsh,
|
wsrep_ws_handle_t* wsh,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
wsrep_trx_meta_t* meta)
|
wsrep_trx_meta_t* meta)
|
||||||
@ -93,7 +93,7 @@ wsrep_status_t trrep::wsrep_provider_v26::certify(wsrep_conn_id_t conn_id,
|
|||||||
return wsrep_->certify(wsrep_, conn_id, wsh, flags, meta);
|
return wsrep_->certify(wsrep_, conn_id, wsh, flags, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
wsrep_status_t trrep::wsrep_provider_v26::bf_abort(
|
wsrep_status_t wsrep::wsrep_provider_v26::bf_abort(
|
||||||
wsrep_seqno_t bf_seqno,
|
wsrep_seqno_t bf_seqno,
|
||||||
wsrep_trx_id_t victim_id,
|
wsrep_trx_id_t victim_id,
|
||||||
wsrep_seqno_t *victim_seqno)
|
wsrep_seqno_t *victim_seqno)
|
||||||
@ -102,32 +102,32 @@ wsrep_status_t trrep::wsrep_provider_v26::bf_abort(
|
|||||||
wsrep_, bf_seqno, victim_id, victim_seqno);
|
wsrep_, bf_seqno, victim_id, victim_seqno);
|
||||||
}
|
}
|
||||||
|
|
||||||
wsrep_status_t trrep::wsrep_provider_v26::commit_order_enter(
|
wsrep_status_t wsrep::wsrep_provider_v26::commit_order_enter(
|
||||||
const wsrep_ws_handle_t* wsh,
|
const wsrep_ws_handle_t* wsh,
|
||||||
const wsrep_trx_meta_t* meta)
|
const wsrep_trx_meta_t* meta)
|
||||||
{
|
{
|
||||||
return wsrep_->commit_order_enter(wsrep_, wsh, meta);
|
return wsrep_->commit_order_enter(wsrep_, wsh, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::commit_order_leave(
|
int wsrep::wsrep_provider_v26::commit_order_leave(
|
||||||
const wsrep_ws_handle_t* wsh,
|
const wsrep_ws_handle_t* wsh,
|
||||||
const wsrep_trx_meta_t* meta)
|
const wsrep_trx_meta_t* meta)
|
||||||
{
|
{
|
||||||
return (wsrep_->commit_order_leave(wsrep_, wsh, meta, 0) != WSREP_OK);
|
return (wsrep_->commit_order_leave(wsrep_, wsh, meta, 0) != WSREP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::release(wsrep_ws_handle_t* wsh)
|
int wsrep::wsrep_provider_v26::release(wsrep_ws_handle_t* wsh)
|
||||||
{
|
{
|
||||||
return (wsrep_->release(wsrep_, wsh) != WSREP_OK);
|
return (wsrep_->release(wsrep_, wsh) != WSREP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::replay(wsrep_ws_handle_t* wsh,
|
int wsrep::wsrep_provider_v26::replay(wsrep_ws_handle_t* wsh,
|
||||||
void* applier_ctx)
|
void* applier_ctx)
|
||||||
{
|
{
|
||||||
return (wsrep_->replay_trx(wsrep_, wsh, applier_ctx) != WSREP_OK);
|
return (wsrep_->replay_trx(wsrep_, wsh, applier_ctx) != WSREP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::sst_sent(const wsrep_gtid_t& gtid, int err)
|
int wsrep::wsrep_provider_v26::sst_sent(const wsrep_gtid_t& gtid, int err)
|
||||||
{
|
{
|
||||||
if (wsrep_->sst_sent(wsrep_, >id, err) != WSREP_OK)
|
if (wsrep_->sst_sent(wsrep_, >id, err) != WSREP_OK)
|
||||||
{
|
{
|
||||||
@ -136,7 +136,7 @@ int trrep::wsrep_provider_v26::sst_sent(const wsrep_gtid_t& gtid, int err)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trrep::wsrep_provider_v26::sst_received(const wsrep_gtid_t& gtid, int err)
|
int wsrep::wsrep_provider_v26::sst_received(const wsrep_gtid_t& gtid, int err)
|
||||||
{
|
{
|
||||||
if (wsrep_->sst_received(wsrep_, >id, 0, err) != WSREP_OK)
|
if (wsrep_->sst_received(wsrep_, >id, 0, err) != WSREP_OK)
|
||||||
{
|
{
|
||||||
@ -145,12 +145,12 @@ int trrep::wsrep_provider_v26::sst_received(const wsrep_gtid_t& gtid, int err)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<trrep::provider::status_variable>
|
std::vector<wsrep::provider::status_variable>
|
||||||
trrep::wsrep_provider_v26::status() const
|
wsrep::wsrep_provider_v26::status() const
|
||||||
{
|
{
|
||||||
std::vector<status_variable> ret;
|
std::vector<status_variable> ret;
|
||||||
struct wsrep_stats_var* const stats(wsrep_->stats_get(wsrep_));
|
wsrep_stats_var* const stats(wsrep_->stats_get(wsrep_));
|
||||||
struct wsrep_stats_var* i(stats);
|
wsrep_stats_var* i(stats);
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
while (i->name)
|
while (i->name)
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef TRREP_WSREP_PROVIDER_V26_HPP
|
#ifndef WSREP_WSREP_PROVIDER_V26_HPP
|
||||||
#define TRREP_WSREP_PROVIDER_V26_HPP
|
#define WSREP_WSREP_PROVIDER_V26_HPP
|
||||||
|
|
||||||
#include "trrep/provider.hpp"
|
#include "wsrep/provider.hpp"
|
||||||
|
|
||||||
#include <wsrep_api.h>
|
#include <wsrep_api.h>
|
||||||
|
|
||||||
namespace trrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
class wsrep_provider_v26 : public trrep::provider
|
class wsrep_provider_v26 : public wsrep::provider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ namespace trrep
|
|||||||
private:
|
private:
|
||||||
wsrep_provider_v26(const wsrep_provider_v26&);
|
wsrep_provider_v26(const wsrep_provider_v26&);
|
||||||
wsrep_provider_v26& operator=(const wsrep_provider_v26);
|
wsrep_provider_v26& operator=(const wsrep_provider_v26);
|
||||||
struct wsrep* wsrep_;
|
wsrep_t* wsrep_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // TRREP_WSREP_PROVIDER_V26_HPP
|
#endif // WSREP_WSREP_PROVIDER_V26_HPP
|
||||||
|
Reference in New Issue
Block a user