libfoedus-core
FOEDUS Core Library
foedus::log::LogOptions Struct Referencefinal

Set of options for log manager. More...

Detailed Description

Set of options for log manager.

This is a POD struct. Default destructor/copy-constructor/assignment operator work fine.

Definition at line 39 of file log_options.hpp.

#include <log_options.hpp>

Inheritance diagram for foedus::log::LogOptions:
Collaboration diagram for foedus::log::LogOptions:

Public Types

enum  Constants { kDefaultLogBufferKb = (1 << 16), kDefaultLogSizeMb = (1 << 14) }
 Constant values. More...
 

Public Member Functions

 LogOptions ()
 Constructs option values with default values. More...
 
std::string convert_folder_path_pattern (int node, int logger) const
 converts folder_path_pattern_ into a string with the given IDs. More...
 
std::string construct_suffixed_log_path (int node, int logger, LogFileOrdinal ordinal) const
 construct full path of individual log file (log_folder/LOGGERID_ORDINAL.log) More...
 
std::string construct_meta_log_path () const
 metadata log file is placed in node-0/logger-0 folder 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...
 
- Public Member Functions inherited from foedus::externalize::Externalizable
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

fs::FixedPath folder_path_pattern_
 String pattern of path of log folders in each NUMA node. More...
 
uint16_t loggers_per_node_
 Number of loggers per NUMA node. More...
 
uint32_t log_buffer_kb_
 Size in KB of log buffer for each worker thread. More...
 
uint32_t log_file_size_mb_
 Size in MB of each file loggers write out. More...
 
bool flush_at_shutdown_
 Whether to flush transaction logs and take savepoint when uninitialize() is called. More...
 
foedus::fs::DeviceEmulationOptions emulation_
 Settings to emulate slower logging device. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const LogOptions &v)
 

Additional Inherited Members

- Static Public Member Functions inherited from foedus::externalize::Externalizable
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...
 

Member Enumeration Documentation

Constant values.

Enumerator
kDefaultLogBufferKb 

Default value for log_buffer_kb_.

kDefaultLogSizeMb 

Default value for log_file_size_mb_.

Definition at line 41 of file log_options.hpp.

41  {
43  kDefaultLogBufferKb = (1 << 16),
45  kDefaultLogSizeMb = (1 << 14),
46  };
Default value for log_file_size_mb_.
Definition: log_options.hpp:45
Default value for log_buffer_kb_.
Definition: log_options.hpp:43

Constructor & Destructor Documentation

foedus::log::LogOptions::LogOptions ( )

Constructs option values with default values.

Definition at line 28 of file log_options.cpp.

References flush_at_shutdown_, folder_path_pattern_, kDefaultLogBufferKb, kDefaultLogSizeMb, log_buffer_kb_, log_file_size_mb_, and loggers_per_node_.

28  {
30  folder_path_pattern_ = "logs/node_$NODE$/logger_$LOGGER$";
33  flush_at_shutdown_ = true;
34 }
bool flush_at_shutdown_
Whether to flush transaction logs and take savepoint when uninitialize() is called.
fs::FixedPath folder_path_pattern_
String pattern of path of log folders in each NUMA node.
Definition: log_options.hpp:70
uint32_t log_buffer_kb_
Size in KB of log buffer for each worker thread.
Definition: log_options.hpp:83
Default value for log_file_size_mb_.
Definition: log_options.hpp:45
Default value for log_buffer_kb_.
Definition: log_options.hpp:43
uint32_t log_file_size_mb_
Size in MB of each file loggers write out.
Definition: log_options.hpp:92
uint16_t loggers_per_node_
Number of loggers per NUMA node.
Definition: log_options.hpp:80

Member Function Documentation

void foedus::log::LogOptions::assign ( const foedus::externalize::Externalizable other)
inlineoverridevirtual

Polymorphic assign operator.

This should invoke operator= of the derived class.

Parameters
[in]otherassigned value. It must be dynamic-castable to the assignee class.

Implements foedus::externalize::Externalizable.

Definition at line 113 of file log_options.hpp.

std::string foedus::log::LogOptions::construct_meta_log_path ( ) const

metadata log file is placed in node-0/logger-0 folder

Definition at line 51 of file log_options.cpp.

References convert_folder_path_pattern().

Referenced by foedus::log::MetaLogger::initialize_once(), and foedus::restart::RestartManagerPimpl::redo_meta_logs().

51  {
52  return convert_folder_path_pattern(0, 0) + std::string("/meta.log");
53 }
std::string convert_folder_path_pattern(int node, int logger) const
converts folder_path_pattern_ into a string with the given IDs.
Definition: log_options.cpp:36

Here is the call graph for this function:

Here is the caller graph for this function:

std::string foedus::log::LogOptions::construct_suffixed_log_path ( int  node,
int  logger,
LogFileOrdinal  ordinal 
) const

construct full path of individual log file (log_folder/LOGGERID_ORDINAL.log)

Definition at line 41 of file log_options.cpp.

References convert_folder_path_pattern().

Referenced by foedus::snapshot::LogMapper::handle_process(), and foedus::log::Logger::initialize_once().

44  {
45  std::string folder = convert_folder_path_pattern(node, logger);
46  std::stringstream path_str;
47  path_str << folder << "/" << logger << "_" << ordinal << ".log";
48  return path_str.str();
49 }
std::string convert_folder_path_pattern(int node, int logger) const
converts folder_path_pattern_ into a string with the given IDs.
Definition: log_options.cpp:36

Here is the call graph for this function:

Here is the caller graph for this function:

std::string foedus::log::LogOptions::convert_folder_path_pattern ( int  node,
int  logger 
) const

converts folder_path_pattern_ into a string with the given IDs.

Definition at line 36 of file log_options.cpp.

References folder_path_pattern_, foedus::assorted::replace_all(), and foedus::assorted::FixedString< MAXLEN, CHAR >::str().

Referenced by construct_meta_log_path(), construct_suffixed_log_path(), and foedus::log::LogManagerPimpl::initialize_once().

36  {
37  std::string tmp = assorted::replace_all(folder_path_pattern_.str(), "$NODE$", node);
38  return assorted::replace_all(tmp, "$LOGGER$", logger);
39 }
fs::FixedPath folder_path_pattern_
String pattern of path of log folders in each NUMA node.
Definition: log_options.hpp:70
std::string replace_all(const std::string &target, const std::string &search, const std::string &replacement)
target.replaceAll(search, replacement).
std::basic_string< CHAR > str() const
Convert to a std::string object.

Here is the call graph for this function:

Here is the caller graph for this function:

const char* foedus::log::LogOptions::get_tag_name ( ) const
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 113 of file log_options.hpp.

ErrorStack foedus::log::LogOptions::load ( tinyxml2::XMLElement *  element)
overridevirtual

Reads the content of this object from the given XML element.

Parameters
[in]elementthe XML element that represents this object

Expect errors due to missing-elements, out-of-range values, etc.

Implements foedus::externalize::Externalizable.

Definition at line 55 of file log_options.cpp.

References CHECK_ERROR, emulation_, EXTERNALIZE_LOAD_ELEMENT, flush_at_shutdown_, folder_path_pattern_, foedus::externalize::Externalizable::get_child_element(), foedus::kRetOk, log_buffer_kb_, log_file_size_mb_, and loggers_per_node_.

55  {
61  CHECK_ERROR(get_child_element(element, "LogDeviceEmulationOptions", &emulation_))
62  return kRetOk;
63 }
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
static ErrorStack get_child_element(tinyxml2::XMLElement *parent, const std::string &tag, Externalizable *child, bool optional=false)
child Externalizable version
bool flush_at_shutdown_
Whether to flush transaction logs and take savepoint when uninitialize() is called.
fs::FixedPath folder_path_pattern_
String pattern of path of log folders in each NUMA node.
Definition: log_options.hpp:70
uint32_t log_buffer_kb_
Size in KB of log buffer for each worker thread.
Definition: log_options.hpp:83
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
foedus::fs::DeviceEmulationOptions emulation_
Settings to emulate slower logging device.
const ErrorStack kRetOk
Normal return value for no-error case.
uint32_t log_file_size_mb_
Size in MB of each file loggers write out.
Definition: log_options.hpp:92
uint16_t loggers_per_node_
Number of loggers per NUMA node.
Definition: log_options.hpp:80

Here is the call graph for this function:

ErrorStack foedus::log::LogOptions::save ( tinyxml2::XMLElement *  element) const
overridevirtual

Writes the content of this object to the given XML element.

Parameters
[in]elementthe 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 65 of file log_options.cpp.

References foedus::externalize::Externalizable::add_child_element(), CHECK_ERROR, emulation_, EXTERNALIZE_SAVE_ELEMENT, flush_at_shutdown_, folder_path_pattern_, foedus::externalize::Externalizable::insert_comment(), foedus::kRetOk, log_buffer_kb_, log_file_size_mb_, and loggers_per_node_.

65  {
66  CHECK_ERROR(insert_comment(element, "Set of options for log manager"));
67 
69  "String pattern of path of log folders in each NUMA node.\n"
70  " This specifies the path of the folder to contain log file written out in each NUMA node."
71  " Two special placeholders can be used; $NODE$ and $LOGGER$."
72  " $NODE$ is replaced with the NUMA node number."
73  " $LOGGER$ is replaced with the logger index in the node (0 to loggers_per_node_ - 1)."
74  " For example,\n"
75  " /log/node_$NODE$/logger_$LOGGER$ becomes /log/node_1/logger_0 on node-1 and logger-0."
76  " /log/logger_$INDEX$ becomes /log/logger_1 on any node and logger-1."
77  " Both are optional. You can specify a fixed path without the patterns, which means you"
78  " will use the same folder for multiple loggers and nodes. Even in that case, log file"
79  " names include node/logger number, so it wouldn't cause any data corruption."
80  " It just makes things harder for poor sysadmins.");
81  EXTERNALIZE_SAVE_ELEMENT(element, loggers_per_node_, "Number of loggers per NUMA node."
82  "This value must be at least 1 (which is also default)."
83  " A larger value might be able to employ more CPU power if you have succient # of cores."
84  " For the best performance, the number of loggers in each NUMA node must be"
85  " a submultiple of the number of cores in the node (s.t. logger assignment is balanced).");
86  EXTERNALIZE_SAVE_ELEMENT(element, log_buffer_kb_, "Buffer size in KB of each worker thread");
87  EXTERNALIZE_SAVE_ELEMENT(element, log_file_size_mb_, "Size in MB of files loggers write out");
89  "Whether to flush transaction logs and take savepoint when uninitialize() is called");
90  CHECK_ERROR(add_child_element(element, "LogDeviceEmulationOptions",
91  "[Experiments-only] Settings to emulate slower logging device", emulation_));
92  return kRetOk;
93 }
static ErrorStack add_child_element(tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const Externalizable &child)
child Externalizable version
bool flush_at_shutdown_
Whether to flush transaction logs and take savepoint when uninitialize() is called.
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
fs::FixedPath folder_path_pattern_
String pattern of path of log folders in each NUMA node.
Definition: log_options.hpp:70
uint32_t log_buffer_kb_
Size in KB of log buffer for each worker thread.
Definition: log_options.hpp:83
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
foedus::fs::DeviceEmulationOptions emulation_
Settings to emulate slower logging device.
const ErrorStack kRetOk
Normal return value for no-error case.
#define EXTERNALIZE_SAVE_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
uint32_t log_file_size_mb_
Size in MB of each file loggers write out.
Definition: log_options.hpp:92
uint16_t loggers_per_node_
Number of loggers per NUMA node.
Definition: log_options.hpp:80

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const LogOptions v 
)
friend

Definition at line 113 of file log_options.hpp.

Member Data Documentation

bool foedus::log::LogOptions::flush_at_shutdown_

Whether to flush transaction logs and take savepoint when uninitialize() is called.

If false, non-durable transactions since the previous savepoint is lost. This allows quick shutdown when you don't care the aftermath; testcase and experiments. Default is true.

Definition at line 101 of file log_options.hpp.

Referenced by load(), LogOptions(), and save().

fs::FixedPath foedus::log::LogOptions::folder_path_pattern_

String pattern of path of log folders in each NUMA node.

This specifies the path of the folder to contain log file written out in each NUMA node. Two special placeholders can be used; $NODE$ and $LOGGER$. $NODE$ is replaced with the NUMA node number. $LOGGER$ is replaced with the logger index in the node (0 to loggers_per_node_ - 1). For example,

  • "/log/node_$NODE$/logger_$LOGGER$" becomes "/log/node_1/logger_0" on node-1 and logger-0.
  • "/log/logger_$INDEX$" becomes "/log/logger_1" on any node and logger-1.

Both are optional. You can specify a fixed path without the patterns, which means you will use the same folder for multiple loggers and nodes. Even in that case, log file names include node/logger number, so it wouldn't cause any data corruption. It just makes things harder for poor sysadmins.

The default value is "logs/node_$NODE$/logger_$LOGGER$".

Definition at line 70 of file log_options.hpp.

Referenced by convert_folder_path_pattern(), load(), LogOptions(), and save().

uint32_t foedus::log::LogOptions::log_buffer_kb_

Size in KB of log buffer for each worker thread.

Definition at line 83 of file log_options.hpp.

Referenced by foedus::EngineOptions::calculate_required_memory(), load(), LogOptions(), and save().

uint32_t foedus::log::LogOptions::log_file_size_mb_

Size in MB of each file loggers write out.

The logger switches to next file when it wrote out a complete log entry and observed that the current log file size is equal to or larger than this value. Thus, the actual log file size might be a bit larger than this value.

Definition at line 92 of file log_options.hpp.

Referenced by load(), LogOptions(), and save().

uint16_t foedus::log::LogOptions::loggers_per_node_

Number of loggers per NUMA node.

This value must be at least 1 (which is also default). A larger value might be able to employ more CPU power if you have succient # of cores. For the best performance, the number of loggers in each NUMA node must be a submultiple of the number of cores in the node (s.t. logger assignment is balanced).

Definition at line 80 of file log_options.hpp.

Referenced by foedus::soc::NodeMemoryAnchors::allocate_arrays(), foedus::snapshot::calculate_logger_id(), foedus::soc::SharedMemoryRepo::calculate_node_memory_size(), foedus::EngineOptions::calculate_required_memory(), foedus::log::LogManagerPimpl::initialize_once(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), load(), LogOptions(), save(), and foedus::savepoint::SavepointManagerPimpl::update_shared_savepoint().


The documentation for this struct was generated from the following files: