mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-25 21:41:56 +03:00
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
//
|
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
|
//
|
|
|
|
#include "wsrep/transaction.hpp"
|
|
#include "mock_client_state.hpp"
|
|
|
|
|
|
int wsrep::mock_client_service::apply_write_set(
|
|
const wsrep::const_buffer&)
|
|
|
|
{
|
|
assert(client_state_.toi_meta().seqno().is_undefined());
|
|
assert(client_state_.transaction().state() == wsrep::transaction::s_executing ||
|
|
client_state_.transaction().state() == wsrep::transaction::s_replaying);
|
|
return (fail_next_applying_ ? 1 : 0);
|
|
}
|
|
|
|
int wsrep::mock_client_service::apply_toi(const wsrep::const_buffer&)
|
|
{
|
|
assert(client_state_.transaction().active() == false);
|
|
assert(client_state_.toi_meta().seqno().is_undefined() == false);
|
|
return (fail_next_toi_ ? 1 : 0);
|
|
}
|
|
|
|
int wsrep::mock_client_service::commit(
|
|
const wsrep::ws_handle&, const wsrep::ws_meta&)
|
|
{
|
|
int ret(0);
|
|
if (do_2pc())
|
|
{
|
|
if (client_state_.before_prepare())
|
|
{
|
|
ret = 1;
|
|
}
|
|
else if (client_state_.after_prepare())
|
|
{
|
|
ret = 1;
|
|
}
|
|
}
|
|
if (ret == 0 &&
|
|
(client_state_.before_commit() ||
|
|
client_state_.ordered_commit() ||
|
|
client_state_.after_commit()))
|
|
{
|
|
ret = 1;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int wsrep::mock_client_service::rollback()
|
|
{
|
|
int ret(0);
|
|
if (client_state_.before_rollback())
|
|
{
|
|
ret = 1;
|
|
}
|
|
else if (client_state_.after_rollback())
|
|
{
|
|
ret = 1;
|
|
}
|
|
return ret;
|
|
}
|