libfoedus-core
FOEDUS Core Library
|
The information we maintain in savepoint manager and externalize to a file. More...
The information we maintain in savepoint manager and externalize to a file.
This object is a very compact representation of progress of the entire engine. This object holds only a few integers per module to denote upto what we are surely done. We update this object for each epoch-based group commit and write out this as an xml durably and atomically.
Definition at line 40 of file savepoint.hpp.
#include <savepoint.hpp>
Public Member Functions | |
Savepoint () | |
Constructs an empty savepoint. More... | |
ErrorStack | load (tinyxml2::XMLElement *element) override |
Reads the content of this object from the given XML element. More... | |
ErrorStack | save (tinyxml2::XMLElement *element) const override |
Writes the content of this object to the given XML element. More... | |
const char * | get_tag_name () const override |
Returns an XML tag name for this object as a root element. More... | |
void | assign (const foedus::externalize::Externalizable *other) override |
Polymorphic assign operator. More... | |
void | populate_empty (log::LoggerId logger_count) |
Populate variables as an initial state. More... | |
bool | consistent (log::LoggerId logger_count) const |
Tells if the variables are consistent. More... | |
Epoch | get_durable_epoch () const |
Epoch | get_current_epoch () const |
Epoch | get_earliest_epoch () const |
void | assert_epoch_values () const |
Check invariants on current_epoch_/durable_epoch_. More... | |
![]() | |
ErrorStack | load_from_string (const std::string &xml) |
Load the content of this object from the given XML string. More... | |
void | save_to_stream (std::ostream *ptr) const |
Invokes save() and directs the resulting XML text to the given stream. More... | |
ErrorStack | load_from_file (const fs::Path &path) |
Load the content of this object from the specified XML file. More... | |
ErrorStack | save_to_file (const fs::Path &path) const |
Atomically and durably writes out this object to the specified XML file. More... | |
Public Attributes | |
Epoch::EpochInteger | current_epoch_ |
Current epoch of the entire engine. More... | |
Epoch::EpochInteger | durable_epoch_ |
Latest epoch whose logs were all flushed to disk. More... | |
Epoch::EpochInteger | earliest_epoch_ |
The earliest epoch that can exist in this system. More... | |
snapshot::SnapshotId | latest_snapshot_id_ |
The most recent complete snapshot. More... | |
Epoch::EpochInteger | latest_snapshot_epoch_ |
The most recently snapshot-ed epoch, all logs upto this epoch is safe to delete. More... | |
uint64_t | meta_log_oldest_offset_ |
Offset from which metadata log entries are not gleaned yet. More... | |
uint64_t | meta_log_durable_offset_ |
Offset upto which metadata log entries are fsynced. More... | |
std::vector< log::LogFileOrdinal > | oldest_log_files_ |
Ordinal of the oldest active log file in each logger. More... | |
std::vector< uint64_t > | oldest_log_files_offset_begin_ |
Indicates the inclusive beginning of active region in the oldest log file. More... | |
std::vector< log::LogFileOrdinal > | current_log_files_ |
Indicates the log file each logger is currently appending to. More... | |
std::vector< uint64_t > | current_log_files_offset_durable_ |
Indicates the exclusive end of durable region in the current log file. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const Savepoint &v) |
Additional Inherited Members | |
![]() | |
static ErrorStack | insert_comment (tinyxml2::XMLElement *element, const std::string &comment) |
static ErrorStack | append_comment (tinyxml2::XMLElement *parent, const std::string &comment) |
static ErrorStack | create_element (tinyxml2::XMLElement *parent, const std::string &name, tinyxml2::XMLElement **out) |
template<typename T > | |
static ErrorStack | add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, T value) |
Only declaration in header. More... | |
template<uint MAXLEN, typename CHAR > | |
static ErrorStack | add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const assorted::FixedString< MAXLEN, CHAR > &value) |
template<typename T > | |
static ErrorStack | add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const std::vector< T > &value) |
vector version More... | |
template<typename ENUM > | |
static ErrorStack | add_enum_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, ENUM value) |
enum version More... | |
static ErrorStack | add_child_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const Externalizable &child) |
child Externalizable version More... | |
template<typename T > | |
static ErrorStack | get_element (tinyxml2::XMLElement *parent, const std::string &tag, T *out, bool optional=false, T value=0) |
Only declaration in header. More... | |
static ErrorStack | get_element (tinyxml2::XMLElement *parent, const std::string &tag, std::string *out, bool optional=false, const char *value="") |
string type is bit special. More... | |
template<uint MAXLEN, typename CHAR > | |
static ErrorStack | get_element (tinyxml2::XMLElement *parent, const std::string &tag, assorted::FixedString< MAXLEN, CHAR > *out, bool optional=false, const assorted::FixedString< MAXLEN, CHAR > &value=assorted::FixedString< MAXLEN, CHAR >()) |
template<typename ENUM > | |
static ErrorStack | get_enum_element (tinyxml2::XMLElement *parent, const std::string &tag, ENUM *out, bool optional=false, ENUM default_value=static_cast< ENUM >(0)) |
enum version More... | |
template<typename T > | |
static ErrorStack | get_element (tinyxml2::XMLElement *parent, const std::string &tag, std::vector< T > *out, bool optional=false) |
vector version. More... | |
static ErrorStack | get_child_element (tinyxml2::XMLElement *parent, const std::string &tag, Externalizable *child, bool optional=false) |
child Externalizable version More... | |
foedus::savepoint::Savepoint::Savepoint | ( | ) |
void foedus::savepoint::Savepoint::assert_epoch_values | ( | ) | const |
Check invariants on current_epoch_/durable_epoch_.
Definition at line 25 of file savepoint.cpp.
References ASSERT_ND, current_epoch_, durable_epoch_, earliest_epoch_, and latest_snapshot_epoch_.
Referenced by consistent(), load(), populate_empty(), save(), and foedus::savepoint::SavepointManagerPimpl::savepoint_main().
|
inlineoverridevirtual |
Polymorphic assign operator.
This should invoke operator= of the derived class.
[in] | other | assigned value. It must be dynamic-castable to the assignee class. |
Implements foedus::externalize::Externalizable.
Definition at line 116 of file savepoint.hpp.
|
inline |
Tells if the variables are consistent.
Definition at line 121 of file savepoint.hpp.
References assert_epoch_values().
Referenced by foedus::savepoint::SavepointManagerPimpl::initialize_once().
|
inline |
Definition at line 134 of file savepoint.hpp.
|
inline |
Definition at line 133 of file savepoint.hpp.
|
inline |
Definition at line 135 of file savepoint.hpp.
|
inlineoverridevirtual |
Returns an XML tag name for this object as a root element.
We might want to give a different name for same externalizable objects, so this is used only when it is the root element of xml.
Implements foedus::externalize::Externalizable.
Definition at line 116 of file savepoint.hpp.
|
overridevirtual |
Reads the content of this object from the given XML element.
[in] | element | the XML element that represents this object |
Expect errors due to missing-elements, out-of-range values, etc.
Implements foedus::externalize::Externalizable.
Definition at line 36 of file savepoint.cpp.
References assert_epoch_values(), current_epoch_, current_log_files_, current_log_files_offset_durable_, durable_epoch_, earliest_epoch_, EXTERNALIZE_LOAD_ELEMENT, foedus::kRetOk, latest_snapshot_epoch_, latest_snapshot_id_, meta_log_durable_offset_, meta_log_oldest_offset_, oldest_log_files_, and oldest_log_files_offset_begin_.
void foedus::savepoint::Savepoint::populate_empty | ( | log::LoggerId | logger_count | ) |
Populate variables as an initial state.
Definition at line 79 of file savepoint.cpp.
References assert_epoch_values(), current_epoch_, current_log_files_, current_log_files_offset_durable_, durable_epoch_, earliest_epoch_, foedus::Epoch::kEpochInitialCurrent, foedus::Epoch::kEpochInitialDurable, foedus::Epoch::kEpochInvalid, foedus::snapshot::kNullSnapshotId, latest_snapshot_epoch_, latest_snapshot_id_, meta_log_durable_offset_, meta_log_oldest_offset_, oldest_log_files_, and oldest_log_files_offset_begin_.
Referenced by foedus::savepoint::SavepointManagerPimpl::initialize_once().
|
overridevirtual |
Writes the content of this object to the given XML element.
[in] | element | the XML element that represents this object |
Expect only out-of-memory error. We receive the XML element this object will represent, so this method does not determine the XML element name of itself. The parent object determines children's tag names because one parent object might have multiple child objects of the same type with different XML element name.
Implements foedus::externalize::Externalizable.
Definition at line 52 of file savepoint.cpp.
References assert_epoch_values(), CHECK_ERROR, current_epoch_, current_log_files_, current_log_files_offset_durable_, durable_epoch_, earliest_epoch_, EXTERNALIZE_SAVE_ELEMENT, foedus::externalize::Externalizable::insert_comment(), foedus::kRetOk, latest_snapshot_epoch_, latest_snapshot_id_, meta_log_durable_offset_, meta_log_oldest_offset_, oldest_log_files_, and oldest_log_files_offset_begin_.
|
friend |
Definition at line 116 of file savepoint.hpp.
Epoch::EpochInteger foedus::savepoint::Savepoint::current_epoch_ |
Current epoch of the entire engine.
This value is advanced by transaction manager periodically. This is equal or larger than all other epoch values below.
Definition at line 53 of file savepoint.hpp.
Referenced by assert_epoch_values(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
std::vector<log::LogFileOrdinal> foedus::savepoint::Savepoint::current_log_files_ |
Indicates the log file each logger is currently appending to.
Definition at line 107 of file savepoint.hpp.
Referenced by foedus::log::LoggerRef::copy_logger_state(), foedus::log::LogManagerPimpl::copy_logger_states(), load(), populate_empty(), save(), and foedus::savepoint::FixedSavepoint::update().
std::vector<uint64_t> foedus::savepoint::Savepoint::current_log_files_offset_durable_ |
Indicates the exclusive end of durable region in the current log file.
In other words, epochs are larger than durable_epoch_ from this offset. During restart, current log files are truncated to this size to discard incomplete logs.
Definition at line 114 of file savepoint.hpp.
Referenced by foedus::log::LoggerRef::copy_logger_state(), foedus::log::LogManagerPimpl::copy_logger_states(), load(), populate_empty(), save(), and foedus::savepoint::FixedSavepoint::update().
Epoch::EpochInteger foedus::savepoint::Savepoint::durable_epoch_ |
Latest epoch whose logs were all flushed to disk.
Upto this epoch, we can guarantee durability. In other words, transactions are not deemed as "done" until this value reaches their epoch values issued on commit time. While the engine restarts, all log entries in log files after this epoch are truncated because there might be some logger that did not finish its writing.
Definition at line 65 of file savepoint.hpp.
Referenced by assert_epoch_values(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
Epoch::EpochInteger foedus::savepoint::Savepoint::earliest_epoch_ |
The earliest epoch that can exist in this system.
it advances only after we do a system-wide compaction. Otherwise, it's kEpochInitialDurable, which is indeed the earliest until the epoch wraps around.
Definition at line 72 of file savepoint.hpp.
Referenced by assert_epoch_values(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
Epoch::EpochInteger foedus::savepoint::Savepoint::latest_snapshot_epoch_ |
The most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.
If not snapshot has been taken, invalid epoch. This is equivalent to snapshots_.back().valid_entil_epoch_ with empty check.
Definition at line 84 of file savepoint.hpp.
Referenced by assert_epoch_values(), load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
snapshot::SnapshotId foedus::savepoint::Savepoint::latest_snapshot_id_ |
The most recent complete snapshot.
kNullSnapshotId if no snapshot has been taken yet.
Definition at line 78 of file savepoint.hpp.
Referenced by load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
uint64_t foedus::savepoint::Savepoint::meta_log_durable_offset_ |
Offset upto which metadata log entries are fsynced.
Definition at line 89 of file savepoint.hpp.
Referenced by load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
uint64_t foedus::savepoint::Savepoint::meta_log_oldest_offset_ |
Offset from which metadata log entries are not gleaned yet.
Definition at line 87 of file savepoint.hpp.
Referenced by load(), populate_empty(), save(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), and foedus::savepoint::FixedSavepoint::update().
std::vector<log::LogFileOrdinal> foedus::savepoint::Savepoint::oldest_log_files_ |
Ordinal of the oldest active log file in each logger.
Each logger writes out files suffixed with ordinal (eg ".0", ".1"...). The older logs files are deactivated and deleted after log gleaner consumes them. This variable indicates the oldest active file for each logger.
Definition at line 101 of file savepoint.hpp.
Referenced by foedus::log::LoggerRef::copy_logger_state(), foedus::log::LogManagerPimpl::copy_logger_states(), load(), populate_empty(), save(), and foedus::savepoint::FixedSavepoint::update().
std::vector<uint64_t> foedus::savepoint::Savepoint::oldest_log_files_offset_begin_ |
Indicates the inclusive beginning of active region in the oldest log file.
Definition at line 104 of file savepoint.hpp.
Referenced by foedus::log::LoggerRef::copy_logger_state(), foedus::log::LogManagerPimpl::copy_logger_states(), load(), populate_empty(), save(), and foedus::savepoint::FixedSavepoint::update().