6#ifndef OPENCBDC_TX_SRC_PARSEC_BROKER_INTERFACE_H_
7#define OPENCBDC_TX_SRC_PARSEC_BROKER_INTERFACE_H_
25 unordered_map<key_type, lock_type, hashing::const_sip_hash<key_type>>;
88 = std::variant<ticket_number_type, error_code>;
116 [[nodiscard]]
virtual auto
126 std::variant<error_code, runtime_locking_shard::shard_error>>;
159 std::variant<error_code, runtime_locking_shard::error_code>>;
168 [[nodiscard]]
virtual auto
184 [[nodiscard]]
virtual auto
Buffer to store and retrieve byte data.
virtual auto try_lock(ticket_number_type ticket_number, key_type key, lock_type locktype, try_lock_callback_type result_callback) -> bool=0
Attempts to acquire the given lock on the appropriate shard.
interface(const interface &)=delete
std::function< void(recover_return_type)> recover_callback_type
Callback function type for a recovery operation.
virtual auto recover(recover_callback_type result_callback) -> bool=0
Retrieves tickets associated with this broker from all shards and completes partially committed ticke...
auto operator=(const interface &) -> interface &=delete
virtual auto rollback(ticket_number_type ticket_number, rollback_callback_type result_callback) -> bool=0
Rollback a ticket on all shards involved in the ticket.
std::function< void(rollback_return_type)> rollback_callback_type
Callback function type for a rollback operation.
virtual auto finish(ticket_number_type ticket_number, finish_callback_type result_callback) -> bool=0
Finishes a ticket on all shards involved in the ticket.
std::function< void(ticketnum_or_errcode_type)> begin_callback_type
Callback function type for a begin operation.
virtual ~interface()=default
std::variant< value_type, error_code, runtime_locking_shard::shard_error > try_lock_return_type
Return type from a try lock operation.
std::optional< std::variant< error_code, runtime_locking_shard::shard_error > > commit_return_type
Return type from a commit operation.
interface(interface &&)=delete
std::optional< error_code > finish_return_type
Return type from a finish operation.
virtual auto begin(begin_callback_type result_callback) -> bool=0
Acquires a new ticket number to begin a transaction.
error_code
Error codes returned by broker operations.
@ rollback_error
Shard error during rollback.
@ commit_error
Shard error during commit.
@ directory_unreachable
Request failed because directory was unreachable.
@ get_tickets_error
Shard error during get tickets.
@ prepare_error
Shard error during prepare.
@ finish_error
Shard error during finish.
@ shard_unreachable
Request failed because a shard was unreachable.
@ prepared
Request invalid because ticket is prepared.
@ commit_hazard
A commit is attempted without associating update keys with ticket.
@ waiting_for_locks
Cannot prepare because ticket still waiting for locks to be acquired.
@ ticket_number_assignment
Error during ticket number assignment.
@ invalid_shard_state
Request failed because shard was in an invalid state for the given ticket.
@ begun
Request invalid because ticket is not committed or rolled back.
@ ticket_machine_unreachable
Request failed because the ticket machine was unreachable.
@ aborted
Request invalid because ticket is rolled back.
@ not_prepared
Request invalid because ticket is not prepared.
@ unknown_ticket
Request for an unknown ticket.
@ committed
Reqeust invalid because ticket is committed.
std::function< void(finish_return_type)> finish_callback_type
Callback function type for a finish operation.
virtual auto highest_ticket() -> ticket_number_type=0
Get the highest ticket number that was used.
auto operator=(interface &&) -> interface &=delete
std::function< void(commit_return_type)> commit_callback_type
Callback function type for a commit operation.
std::optional< error_code > recover_return_type
Return type from a recover operation.
virtual auto commit(ticket_number_type ticket_number, state_update_type state_updates, commit_callback_type result_callback) -> bool=0
Prepares and commits a ticket on all shards involved in the ticket.
std::variant< ticket_number_type, error_code > ticketnum_or_errcode_type
Return type from a begin operation.
std::function< void(try_lock_return_type)> try_lock_callback_type
Callback function type for a try lock operation.
std::optional< std::variant< error_code, runtime_locking_shard::error_code > > rollback_return_type
Return type from a rollback operation.
runtime_locking_shard::value_type value_type
Shard value type.
runtime_locking_shard::state_update_type state_update_type
Shard state updates type.
ticket_machine::ticket_number_type ticket_number_type
Ticket number type.
std:: unordered_map< key_type, lock_type, hashing::const_sip_hash< key_type > > held_locks_set_type
Set of held locks.
buffer key_type
Type for keys held by shards.
buffer value_type
Type for values held by shards.
std:: unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_update_type
Type for state updates to a shard. A map of keys and their new values.
lock_type
Types of key lock supported by shards.
uint64_t ticket_number_type
Type alias for a ticket number.