diff --git a/include/wsrep/client_context.hpp b/include/wsrep/client_context.hpp index c757adc..8bcac59 100644 --- a/include/wsrep/client_context.hpp +++ b/include/wsrep/client_context.hpp @@ -39,6 +39,7 @@ #define WSREP_CLIENT_CONTEXT_HPP #include "server_context.hpp" +#include "provider.hpp" #include "transaction_context.hpp" #include "client_id.hpp" #include "mutex.hpp" @@ -46,6 +47,7 @@ #include "data.hpp" #include "thread.hpp" + namespace wsrep { class server_context; diff --git a/include/wsrep/exception.hpp b/include/wsrep/exception.hpp index 1f1f589..aaf90c0 100644 --- a/include/wsrep/exception.hpp +++ b/include/wsrep/exception.hpp @@ -16,7 +16,7 @@ namespace wsrep runtime_error(const std::string& msg) : std::runtime_error(msg) { - ::abort(); + // ::abort(); } }; diff --git a/include/wsrep/provider.hpp b/include/wsrep/provider.hpp index 7bc035a..15ce517 100644 --- a/include/wsrep/provider.hpp +++ b/include/wsrep/provider.hpp @@ -5,8 +5,7 @@ #ifndef WSREP_PROVIDER_HPP #define WSREP_PROVIDER_HPP -#include "id.hpp" -#include "seqno.hpp" +#include "gtid.hpp" #include "key.hpp" #include "data.hpp" #include "client_id.hpp" @@ -24,25 +23,6 @@ namespace wsrep { class server_context; - class gtid - { - public: - gtid() - : id_() - , seqno_() - { } - gtid(const wsrep::id& id, wsrep::seqno seqno) - : id_(id) - , seqno_(seqno) - { } - const wsrep::id& id() const { return id_; } - wsrep::seqno seqno() const { return seqno_ ; } - private: - wsrep::id id_; - wsrep::seqno seqno_; - }; - - class stid { public: diff --git a/include/wsrep/server_context.hpp b/include/wsrep/server_context.hpp index 1605dc1..0438b4d 100644 --- a/include/wsrep/server_context.hpp +++ b/include/wsrep/server_context.hpp @@ -61,20 +61,21 @@ #ifndef WSREP_SERVER_CONTEXT_HPP #define WSREP_SERVER_CONTEXT_HPP -#include "exception.hpp" #include "mutex.hpp" #include "condition_variable.hpp" -#include "provider.hpp" -#include #include +#include namespace wsrep { // Forward declarations - // class provider; + class ws_handle; + class ws_meta; + class provider; class client_context; class transaction_context; + class gtid; class view; class data; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5207ae9..290b2e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(wsrep-lib wsrep_api_v26 pthread dl) add_executable(wsrep-lib_test mock_client_context.cpp test_utils.cpp + id_test.cpp server_context_test.cpp transaction_context_test.cpp wsrep-lib_test.cpp diff --git a/src/id_test.cpp b/src/id_test.cpp new file mode 100644 index 0000000..7417b4e --- /dev/null +++ b/src/id_test.cpp @@ -0,0 +1,38 @@ +// +// Copyright (C) 2018 Codership Oy +// + +#include "wsrep/id.hpp" +#include + +#include + +namespace +{ + bool exception_check(const wsrep::runtime_error&) { return true; } +} + +BOOST_AUTO_TEST_CASE(id_test_uuid) +{ + std::string uuid_str("6a20d44a-6e17-11e8-b1e2-9061aec0cdad"); + wsrep::id id(uuid_str); + std::ostringstream os; + os << id; + BOOST_REQUIRE(uuid_str == os.str()); +} + +BOOST_AUTO_TEST_CASE(id_test_string) +{ + std::string id_str("1234567890123456"); + wsrep::id id(id_str); + std::ostringstream os; + os << id; + BOOST_REQUIRE(id_str == os.str()); +} + +BOOST_AUTO_TEST_CASE(id_test_string_too_long) +{ + std::string id_str("12345678901234567"); + BOOST_REQUIRE_EXCEPTION(wsrep::id id(id_str), wsrep::runtime_error, + exception_check); +} diff --git a/src/mock_provider.hpp b/src/mock_provider.hpp index 6782e8a..7817cd6 100644 --- a/src/mock_provider.hpp +++ b/src/mock_provider.hpp @@ -127,7 +127,7 @@ namespace wsrep wsrep::transaction_id trx_id, wsrep::seqno& victim_seqno) { - std::cerr << "bf_abort: " << trx_id << "\n"; + // std::cerr << "bf_abort: " << trx_id << "\n"; bf_abort_map_.insert(std::make_pair(trx_id, bf_seqno)); if (bf_seqno.nil() == false) { diff --git a/src/server_context_test.cpp b/src/server_context_test.cpp index 96dffb0..7cf2bdf 100644 --- a/src/server_context_test.cpp +++ b/src/server_context_test.cpp @@ -37,7 +37,6 @@ namespace BOOST_FIXTURE_TEST_CASE(server_context_applying_1pc, applying_server_fixture) { - cc.debug_log_level(1); char buf[1] = { 1 }; BOOST_REQUIRE(sc.on_apply(cc, ws_handle, ws_meta, wsrep::data(buf, 1)) == 0); diff --git a/src/transaction_context.cpp b/src/transaction_context.cpp index d70eb11..6f329fe 100644 --- a/src/transaction_context.cpp +++ b/src/transaction_context.cpp @@ -512,18 +512,24 @@ bool wsrep::transaction_context::bf_abort( switch (status) { case wsrep::provider::success: - wsrep::log() << "Seqno " << bf_seqno - << " succesfully BF aborted " << id_.get() - << " victim_seqno " << victim_seqno; + if (client_context_.debug_log_level() >= 1) + { + wsrep::log_debug() << "Seqno " << bf_seqno + << " succesfully BF aborted " << id_.get() + << " victim_seqno " << victim_seqno; + } bf_abort_state_ = state(); state(lock, s_must_abort); ret = true; break; default: - wsrep::log() << "Seqno " << bf_seqno - << " failed to BF abort " << id_.get() - << " with status " << status - << " victim_seqno " << victim_seqno; + if (client_context_.debug_log_level() >= 1) + { + wsrep::log_debug() << "Seqno " << bf_seqno + << " failed to BF abort " << id_.get() + << " with status " << status + << " victim_seqno " << victim_seqno; + } break; } break;