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