mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-08-09 13:22:47 +03:00
The write set handle and meta data are needed for SR transactions where the commit context is not known when the transaction starts. The passed handle and meta data can be set through client_state prepare_for_ordering() call before performing commit.
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
//
|
|
// Copyright (C) 2018 Codership Oy <info@codership.com>
|
|
//
|
|
|
|
#include "mock_storage_service.hpp"
|
|
#include "mock_server_state.hpp"
|
|
|
|
#include "wsrep/client_state.hpp"
|
|
|
|
wsrep::mock_storage_service::mock_storage_service(
|
|
wsrep::mock_server_state& server_state,
|
|
wsrep::client_id client_id)
|
|
: server_state_(server_state)
|
|
, client_service_(client_state_)
|
|
, client_state_(server_state, client_service_, client_id,
|
|
wsrep::client_state::m_high_priority)
|
|
{
|
|
client_state_.open(client_id);
|
|
client_state_.before_command();
|
|
}
|
|
|
|
|
|
wsrep::mock_storage_service::~mock_storage_service()
|
|
{
|
|
client_state_.after_command_before_result();
|
|
client_state_.after_command_after_result();
|
|
client_state_.close();
|
|
client_state_.cleanup();
|
|
}
|
|
|
|
int wsrep::mock_storage_service::start_transaction(const wsrep::ws_handle& ws_handle)
|
|
{
|
|
return client_state_.start_transaction(ws_handle.transaction_id());
|
|
}
|
|
|
|
int wsrep::mock_storage_service::commit(const wsrep::ws_handle& ws_handle,
|
|
const wsrep::ws_meta& ws_meta)
|
|
{
|
|
int ret(client_state_.prepare_for_ordering(
|
|
ws_handle, ws_meta, true) ||
|
|
client_state_.before_commit() ||
|
|
client_state_.ordered_commit() ||
|
|
client_state_.after_commit());
|
|
client_state_.after_applying();
|
|
return ret;
|
|
}
|
|
|
|
int wsrep::mock_storage_service::rollback(const wsrep::ws_handle& ws_handle,
|
|
const wsrep::ws_meta& ws_meta)
|
|
{
|
|
int ret(client_state_.prepare_for_ordering(
|
|
ws_handle, ws_meta, false) ||
|
|
client_state_.before_rollback() ||
|
|
client_state_.after_rollback());
|
|
client_state_.after_applying();
|
|
return ret;
|
|
}
|