|
OpenCBDC Transaction Processor
|
NuRaft log_store implementation using LevelDB. More...
#include <log_store.hpp>


Public Types | |
| using | log_entries_t = nuraft::ptr<std::vector<nuraft::ptr<nuraft::log_entry>>> |
| List of log entries. | |
Public Member Functions | |
| log_store ()=default | |
| ~log_store () override=default | |
| log_store (const log_store &other)=delete | |
| auto | operator= (const log_store &other) -> log_store &=delete |
| log_store (log_store &&other) noexcept | |
| auto | operator= (log_store &&other) noexcept -> log_store & |
| auto | load (const std::string &db_dir) -> bool |
| Load the log store from the given LevelDB database directory. | |
| auto | next_slot () const -> uint64_t override |
| Return the log index of the next empty log entry. | |
| auto | start_index () const -> uint64_t override |
| Return the first log index stored by the log store. | |
| auto | last_entry () const -> nuraft::ptr< nuraft::log_entry > override |
| Return the last log entry in the log store. | |
| auto | append (nuraft::ptr< nuraft::log_entry > &entry) -> uint64_t override |
| Append the given log entry to the end of the log. | |
| void | write_at (uint64_t index, nuraft::ptr< nuraft::log_entry > &entry) override |
| Write a log entry at the given index. | |
| auto | log_entries (uint64_t start, uint64_t end) -> log_entries_t override |
| Return the log entries in the given range of indices. | |
| auto | entry_at (uint64_t index) -> nuraft::ptr< nuraft::log_entry > override |
| Return the log entry at the given index. | |
| auto | term_at (uint64_t index) -> uint64_t override |
| Return the log term associated with the log entry at the given index. | |
| auto | pack (uint64_t index, int32_t cnt) -> nuraft::ptr< nuraft::buffer > override |
| Serialize the given number of log entries from the given index. | |
| void | apply_pack (uint64_t index, nuraft::buffer &pack) override |
| Deserialize the given log entries and write them starting at the given log index. | |
| auto | compact (uint64_t last_log_index) -> bool override |
| Delete log entries from the start of the log up to the given log index. | |
| auto | flush () -> bool override |
| Flush any buffered writes to disk. | |
NuRaft log_store implementation using LevelDB.
Definition at line 17 of file log_store.hpp.
| using cbdc::raft::log_store::log_entries_t = nuraft::ptr<std::vector<nuraft::ptr<nuraft::log_entry>>> |
List of log entries.
Definition at line 60 of file log_store.hpp.
|
default |
|
overridedefault |
|
delete |
|
noexcept |
|
override |
Append the given log entry to the end of the log.
| entry | log entry to append. |
Definition at line 124 of file log_store.cpp.
References cbdc::raft::get_key_slice(), and cbdc::raft::get_value_slice().

|
override |
Deserialize the given log entries and write them starting at the given log index.
| index | log index at which to write the first log entry. |
| pack | serialized log entries. |
Definition at line 249 of file log_store.cpp.
References cbdc::raft::get_first_or_last_index(), cbdc::raft::get_key_slice(), cbdc::raft::get_value_slice(), and pack().

|
override |
Delete log entries from the start of the log up to the given log index.
| last_log_index | last log index to delete (inclusive). |
Definition at line 290 of file log_store.cpp.
References cbdc::raft::get_key_slice().

|
nodiscardoverride |
Return the log entry at the given index.
Returns a null log entry if there is no log entry at the given index.
| index | log index. |
Definition at line 190 of file log_store.cpp.
References cbdc::raft::get_key_slice(), and cbdc::raft::log_entry_from_slice().

|
override |
Flush any buffered writes to disk.
Definition at line 314 of file log_store.cpp.
|
nodiscardoverride |
Return the last log entry in the log store.
Returns an empty log entry at index zero if the log store is empty.
Definition at line 85 of file log_store.cpp.
References last_entry(), and cbdc::raft::log_entry_from_slice().
Referenced by last_entry().

|
nodiscard |
Load the log store from the given LevelDB database directory.
| db_dir | database directory. |
Definition at line 40 of file log_store.cpp.
References cbdc::raft::get_first_or_last_index().

|
nodiscardoverride |
Return the log entries in the given range of indices.
| start | first log entry to retrieve. |
| end | last log entry to retrieve (exclusive). |
Definition at line 163 of file log_store.cpp.
References cbdc::raft::get_key_slice(), and cbdc::raft::log_entry_from_slice().

|
nodiscardoverride |
Return the log index of the next empty log entry.
Definition at line 66 of file log_store.cpp.
|
nodiscardoverride |
Serialize the given number of log entries from the given index.
| index | starting log index. |
| cnt | number of log entries to serialize. Must be positive. |
Definition at line 216 of file log_store.cpp.
Referenced by apply_pack().
|
nodiscardoverride |
Return the first log index stored by the log store.
Definition at line 71 of file log_store.cpp.
|
nodiscardoverride |
Return the log term associated with the log entry at the given index.
| index | log index. |
Definition at line 211 of file log_store.cpp.
|
override |
Write a log entry at the given index.
| index | log index at which to write the entry. |
| entry | log entry to write. |
Definition at line 138 of file log_store.cpp.
References cbdc::raft::get_key_slice(), and cbdc::raft::get_value_slice().
