1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

* Fixes to SST time server state management

* Logging tweaks
* Boolean to tune behavior on exception
This commit is contained in:
Teemu Ollakka
2018-06-22 13:03:12 +03:00
parent 8f0e112c47
commit 1f6a6db1e9
12 changed files with 187 additions and 40 deletions

View File

@ -10,13 +10,18 @@
namespace wsrep
{
extern bool abort_on_exception;
class runtime_error : public std::runtime_error
{
public:
runtime_error(const std::string& msg)
: std::runtime_error(msg)
{
// ::abort();
if (abort_on_exception)
{
::abort();
}
}
};

View File

@ -16,14 +16,33 @@ namespace wsrep
class log
{
public:
log(const std::string& prefix = "INFO")
: prefix_(prefix)
enum level
{
debug,
info,
warning,
error
};
static const char* to_c_string(enum level level)
{
switch (level)
{
case debug: return "debug";
case info: return "info";
case warning: return "warning";
case error: return "error";
};
return "unknown";
}
log(enum wsrep::log::level level, const char* prefix = "")
: level_(level)
, prefix_(prefix)
, oss_()
{ }
~log()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
os_ << prefix_ << ": " << oss_.str() << "\n";
os_ << prefix_ << ": " << oss_.str() << std::endl;
}
template <typename T>
std::ostream& operator<<(const T& val)
@ -31,7 +50,10 @@ namespace wsrep
return (oss_ << val);
}
private:
const std::string prefix_;
log(const log&);
log& operator=(const log&);
enum level level_;
const char* prefix_;
std::ostringstream oss_;
static wsrep::mutex& mutex_;
static std::ostream& os_;
@ -41,28 +63,28 @@ namespace wsrep
{
public:
log_error()
: log("ERROR") { }
: log(error) { }
};
class log_warning : public log
{
public:
log_warning()
: log("WARNING") { }
: log(warning) { }
};
class log_info : public log
{
public:
log_info()
: log("INFO") { }
: log(info) { }
};
class log_debug : public log
{
public:
log_debug()
: log("DEBUG") { }
: log(debug) { }
};
}

View File

@ -13,6 +13,8 @@
#ifndef WSREP_SERVER_SERVICE_HPP
#define WSREP_SERVER_SERVICE_HPP
#include "logger.hpp"
#include <string>
namespace wsrep
@ -53,6 +55,14 @@ namespace wsrep
*/
virtual void background_rollback(wsrep::client_state&) = 0;
/**
* Log message
*
* @param level Requested logging level
* @param message Message
*/
virtual void log_message(enum wsrep::log::level level,
const char* message) = 0;
/**
* Log a dummy write set. A dummy write set is usually either
* a remotely generated write set which failed certification in

View File

@ -73,7 +73,6 @@
#include "id.hpp"
#include "transaction_id.hpp"
#include "provider.hpp"
// #include "gtid.hpp"
#include <vector>
#include <string>
@ -312,6 +311,26 @@ namespace wsrep
*/
enum wsrep::provider::status causal_read(int timeout) const;
/**
* Prepares server state for SST.
*
* @return String containing a SST request
*/
std::string prepare_for_sst();
/**
* Start a state snapshot transfer.
*
* @param sst_requets SST request string
* @param gtid Current GTID
* @param bypass Bypass flag
*
* @return Zero in case of success, non-zero otherwise
*/
int start_sst(const std::string& sst_request,
const wsrep::gtid& gtid,
bool bypass);
/**
*
*/
@ -353,7 +372,11 @@ namespace wsrep
const wsrep::ws_meta& ws_meta,
const wsrep::const_buffer& data);
enum state state() const { return state_; }
enum state state() const
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
return state_;
}
/**
* Set server wide wsrep debug logging level.
*