libfoedus-core
FOEDUS Core Library
foedus::soc::SocOptions Struct Referencefinal

Set of options for SOC manager. More...

Detailed Description

Set of options for SOC manager.

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

Definition at line 38 of file soc_options.hpp.

#include <soc_options.hpp>

Inheritance diagram for foedus::soc::SocOptions:
Collaboration diagram for foedus::soc::SocOptions:

Public Types

enum  Constants { kDefaultSharedUserMemorySizeKb = 4 }
 

Public Member Functions

 SocOptions ()
 Constructs option values with default values. More...
 
std::string convert_spawn_executable_pattern (int node) const
 converts spawn_executable_pattern_ into a string with the given node ID. More...
 
std::string convert_spawn_ld_library_path_pattern (int node) const
 converts spawn_ld_library_path_pattern_ into a string with the given node ID. 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

EngineType soc_type_
 How to launch SOC engine instances. More...
 
uint64_t shared_user_memory_size_kb_
 As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbitrary purporses by the user to communicate between SOCs. More...
 
fs::FixedPath spawn_executable_pattern_
 String pattern of path of executables to spawn SOC engines in each NUMA node. More...
 
fs::FixedPath spawn_ld_library_path_pattern_
 String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const SocOptions &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

Enumerator
kDefaultSharedUserMemorySizeKb 

default for shared_user_memory_size_kb_

Definition at line 39 of file soc_options.hpp.

39  {
42  };
default for shared_user_memory_size_kb_
Definition: soc_options.hpp:41

Constructor & Destructor Documentation

foedus::soc::SocOptions::SocOptions ( )

Constructs option values with default values.

Definition at line 29 of file soc_options.cpp.

References foedus::kChildEmulated, kDefaultSharedUserMemorySizeKb, shared_user_memory_size_kb_, soc_type_, spawn_executable_pattern_, and spawn_ld_library_path_pattern_.

29  {
34 }
fs::FixedPath spawn_ld_library_path_pattern_
String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node...
Definition: soc_options.hpp:85
EngineType soc_type_
How to launch SOC engine instances.
Definition: soc_options.hpp:54
fs::FixedPath spawn_executable_pattern_
String pattern of path of executables to spawn SOC engines in each NUMA node.
Definition: soc_options.hpp:75
default for shared_user_memory_size_kb_
Definition: soc_options.hpp:41
uint64_t shared_user_memory_size_kb_
As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbit...
Definition: soc_options.hpp:60
A child SOC instance launched just as a thread in the same process as master.
Definition: engine_type.hpp:51

Member Function Documentation

void foedus::soc::SocOptions::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 92 of file soc_options.hpp.

std::string foedus::soc::SocOptions::convert_spawn_executable_pattern ( int  node) const

converts spawn_executable_pattern_ into a string with the given node ID.

Definition at line 36 of file soc_options.cpp.

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

Referenced by foedus::soc::SocManagerPimpl::launch_spawned_children().

36  {
38  // if empty, use the current binary
40  }
41  return assorted::replace_all(spawn_executable_pattern_.str(), "$NODE$", node);
42 }
std::string get_current_executable_path()
Returns the full path of current executable.
std::string replace_all(const std::string &target, const std::string &search, const std::string &replacement)
target.replaceAll(search, replacement).
bool empty() const noexcept
Test if string is empty.
fs::FixedPath spawn_executable_pattern_
String pattern of path of executables to spawn SOC engines in each NUMA node.
Definition: soc_options.hpp:75
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:

std::string foedus::soc::SocOptions::convert_spawn_ld_library_path_pattern ( int  node) const

converts spawn_ld_library_path_pattern_ into a string with the given node ID.

Definition at line 44 of file soc_options.cpp.

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

Referenced by foedus::soc::SocManagerPimpl::launch_spawned_children().

44  {
46  // if empty, retrieve it from environment variable
47  const char* master_value = std::getenv("LD_LIBRARY_PATH");
48  if (master_value) {
49  return master_value;
50  } else {
51  return "";
52  }
53  }
55 }
fs::FixedPath spawn_ld_library_path_pattern_
String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node...
Definition: soc_options.hpp:85
std::string replace_all(const std::string &target, const std::string &search, const std::string &replacement)
target.replaceAll(search, replacement).
bool empty() const noexcept
Test if string is empty.
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::soc::SocOptions::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 92 of file soc_options.hpp.

ErrorStack foedus::soc::SocOptions::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 57 of file soc_options.cpp.

References EXTERNALIZE_LOAD_ELEMENT, EXTERNALIZE_LOAD_ENUM_ELEMENT, foedus::kRetOk, shared_user_memory_size_kb_, soc_type_, spawn_executable_pattern_, and spawn_ld_library_path_pattern_.

57  {
62  return kRetOk;
63 }
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
fs::FixedPath spawn_ld_library_path_pattern_
String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node...
Definition: soc_options.hpp:85
EngineType soc_type_
How to launch SOC engine instances.
Definition: soc_options.hpp:54
#define EXTERNALIZE_LOAD_ENUM_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
fs::FixedPath spawn_executable_pattern_
String pattern of path of executables to spawn SOC engines in each NUMA node.
Definition: soc_options.hpp:75
const ErrorStack kRetOk
Normal return value for no-error case.
uint64_t shared_user_memory_size_kb_
As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbit...
Definition: soc_options.hpp:60
ErrorStack foedus::soc::SocOptions::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 soc_options.cpp.

References CHECK_ERROR, EXTERNALIZE_SAVE_ELEMENT, EXTERNALIZE_SAVE_ENUM_ELEMENT, foedus::externalize::Externalizable::insert_comment(), foedus::kRetOk, shared_user_memory_size_kb_, soc_type_, spawn_executable_pattern_, and spawn_ld_library_path_pattern_.

65  {
66  CHECK_ERROR(insert_comment(element, "Set of options for SOC manager"));
67 
68  EXTERNALIZE_SAVE_ENUM_ELEMENT(element, soc_type_, "How to launch SOC engine instances.");
70  "As part of the global shared memory, we reserve this size of 'user memory' that can be"
71  " used for arbitrary purporses by the user to communicate between SOCs.");
73  "String pattern of path of executables to spawn SOC engines in each NUMA node.\n"
74  " The default value is empty, which means we use the binary of the master (/proc/self/exe).\n"
75  " If non-empty, we use the path to launch each SOC engine.\n"
76  " A placeholder '$NODE$' is replaced with the NUMA node number.\n"
77  " If soc_type_ is not kChildLocalSpawned or kChildRemoteSpawned, this option is ignored.");
78  EXTERNALIZE_SAVE_ELEMENT(element, spawn_ld_library_path_pattern_, "String pattern of "
79  "LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node.\n"
80  " The default value is empty, which means we don't overwrite LD_LIBRARY_PATH of this master"
81  " process. To overwrite master process's LD_LIBRARY_PATH with empty value, put one space etc.");
82  return kRetOk;
83 }
fs::FixedPath spawn_ld_library_path_pattern_
String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node...
Definition: soc_options.hpp:85
EngineType soc_type_
How to launch SOC engine instances.
Definition: soc_options.hpp:54
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
#define EXTERNALIZE_SAVE_ENUM_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
fs::FixedPath spawn_executable_pattern_
String pattern of path of executables to spawn SOC engines in each NUMA node.
Definition: soc_options.hpp:75
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
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.
uint64_t shared_user_memory_size_kb_
As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbit...
Definition: soc_options.hpp:60

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 92 of file soc_options.hpp.

Member Data Documentation

uint64_t foedus::soc::SocOptions::shared_user_memory_size_kb_

As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbitrary purporses by the user to communicate between SOCs.

Definition at line 60 of file soc_options.hpp.

Referenced by foedus::soc::SharedMemoryRepo::calculate_global_memory_size(), foedus::soc::SocManager::get_shared_user_memory_size(), load(), save(), and SocOptions().

fs::FixedPath foedus::soc::SocOptions::spawn_executable_pattern_

String pattern of path of executables to spawn SOC engines in each NUMA node.

The default value is empty, which means we use the binary of the master ("/proc/self/exe"). If non-empty, we use the path to launch each SOC engine. A placeholder '$NODE$' is replaced with the NUMA node number. For example, "/foo/bar/node_$NODE$/my_exec becomes "/foo/bar/node_1/my_exec" on node-1. On the other hand, "/foo/bar/my_exec becomes "/foo/bar/my_exec" for all nodes. The main purpose of using different binaries for each SOC is 1) to manually achieve executable/library text replication on NUMA node, and 2) for kChildRemoteSpawned later.

If soc_type_ is not kChildLocalSpawned or kChildRemoteSpawned, this option is ignored.

Definition at line 75 of file soc_options.hpp.

Referenced by convert_spawn_executable_pattern(), load(), save(), and SocOptions().

fs::FixedPath foedus::soc::SocOptions::spawn_ld_library_path_pattern_

String pattern of LD_LIBRARY_PATH environment variable to spawn SOC engines in each NUMA node.

Similar to spawn_executable_pattern_. The default value is empty, which means we don't overwrite LD_LIBRARY_PATH of this master process. To overwrite master process's LD_LIBRARY_PATH with empty value, put one space etc.

Definition at line 85 of file soc_options.hpp.

Referenced by convert_spawn_ld_library_path_pattern(), load(), save(), and SocOptions().


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