libfoedus-core
FOEDUS Core Library
foedus::proc::ProcOptions Struct Referencefinal

Set of options for loading system/user procedures. More...

Detailed Description

Set of options for loading system/user procedures.

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

Definition at line 38 of file proc_options.hpp.

#include <proc_options.hpp>

Inheritance diagram for foedus::proc::ProcOptions:
Collaboration diagram for foedus::proc::ProcOptions:

Public Types

enum  Constants { kDefaultMaxProcCount = 1 << 16 }
 

Public Member Functions

 ProcOptions ()
 Constructs option values with default values. More...
 
std::string convert_shared_library_path_pattern (int node) const
 converts shared_library_path_pattern_ into a string with the given node ID. More...
 
std::string convert_shared_library_dir_pattern (int node) const
 converts shared_library_dir_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

uint32_t max_proc_count_
 Maximum number of system/user procedures. More...
 
fs::FixedPath shared_library_path_pattern_
 String pattern of ';'-separated path of shared libraries to load in each NUMA node. More...
 
fs::FixedPath shared_library_dir_pattern_
 String pattern of ';'-separated path of directories that contain shared libaries to load. More...
 

Friends

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

Default value for max_proc_count_.

Definition at line 39 of file proc_options.hpp.

39  {
41  kDefaultMaxProcCount = 1 << 16,
42  };
Default value for max_proc_count_.

Constructor & Destructor Documentation

foedus::proc::ProcOptions::ProcOptions ( )

Constructs option values with default values.

Definition at line 29 of file proc_options.cpp.

References kDefaultMaxProcCount, max_proc_count_, shared_library_dir_pattern_, and shared_library_path_pattern_.

29  {
33 }
Default value for max_proc_count_.
fs::FixedPath shared_library_dir_pattern_
String pattern of ';'-separated path of directories that contain shared libaries to load...
fs::FixedPath shared_library_path_pattern_
String pattern of ';'-separated path of shared libraries to load in each NUMA node.
uint32_t max_proc_count_
Maximum number of system/user procedures.

Member Function Documentation

void foedus::proc::ProcOptions::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 78 of file proc_options.hpp.

std::string foedus::proc::ProcOptions::convert_shared_library_dir_pattern ( int  node) const

converts shared_library_dir_pattern_ into a string with the given node ID.

Definition at line 39 of file proc_options.cpp.

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

39  {
40  return assorted::replace_all(shared_library_dir_pattern_.str(), "$NODE$", node);
41 }
fs::FixedPath shared_library_dir_pattern_
String pattern of ';'-separated path of directories that contain shared libaries to load...
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:

std::string foedus::proc::ProcOptions::convert_shared_library_path_pattern ( int  node) const

converts shared_library_path_pattern_ into a string with the given node ID.

Definition at line 35 of file proc_options.cpp.

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

35  {
36  return assorted::replace_all(shared_library_path_pattern_.str(), "$NODE$", node);
37 }
std::string replace_all(const std::string &target, const std::string &search, const std::string &replacement)
target.replaceAll(search, replacement).
fs::FixedPath shared_library_path_pattern_
String pattern of ';'-separated path of shared libraries to load in each NUMA node.
std::basic_string< CHAR > str() const
Convert to a std::string object.

Here is the call graph for this function:

const char* foedus::proc::ProcOptions::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 78 of file proc_options.hpp.

ErrorStack foedus::proc::ProcOptions::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 43 of file proc_options.cpp.

References EXTERNALIZE_LOAD_ELEMENT, foedus::kRetOk, max_proc_count_, shared_library_dir_pattern_, and shared_library_path_pattern_.

43  {
47  return kRetOk;
48 }
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
fs::FixedPath shared_library_dir_pattern_
String pattern of ';'-separated path of directories that contain shared libaries to load...
fs::FixedPath shared_library_path_pattern_
String pattern of ';'-separated path of shared libraries to load in each NUMA node.
const ErrorStack kRetOk
Normal return value for no-error case.
uint32_t max_proc_count_
Maximum number of system/user procedures.
ErrorStack foedus::proc::ProcOptions::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 50 of file proc_options.cpp.

References CHECK_ERROR, EXTERNALIZE_SAVE_ELEMENT, foedus::externalize::Externalizable::insert_comment(), foedus::kRetOk, max_proc_count_, shared_library_dir_pattern_, and shared_library_path_pattern_.

50  {
51  CHECK_ERROR(insert_comment(element, "Set of options for loading system/user procedures"));
52 
53  EXTERNALIZE_SAVE_ELEMENT(element, max_proc_count_, "Maximum number of system/user procedures.");
55  "String pattern of ';'-separated path of shared libraries to load in each NUMA node.\n"
56  " The default value is empty, which means we don't load any shared libraries.\n"
57  " If non-empty, we load the shared libraries of the path to register user-defined procedures.\n"
58  " A placeholder '$NODE$' is replaced with the NUMA node number.");
59  EXTERNALIZE_SAVE_ELEMENT(element, shared_library_dir_pattern_, "String pattern of "
60  "';'-separated path of directories that contain shared libaries to load.\n"
61  " Similar to shared_library_path_pattern_. The difference is that all '.so' files under"
62  " the directory is loaded. The default value is empty.");
63  return kRetOk;
64 }
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
fs::FixedPath shared_library_dir_pattern_
String pattern of ';'-separated path of directories that contain shared libaries to load...
fs::FixedPath shared_library_path_pattern_
String pattern of ';'-separated path of shared libraries to load in each NUMA node.
#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.
uint32_t max_proc_count_
Maximum number of system/user procedures.

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 78 of file proc_options.hpp.

Member Data Documentation

uint32_t foedus::proc::ProcOptions::max_proc_count_

Maximum number of system/user procedures.

Definition at line 49 of file proc_options.hpp.

Referenced by foedus::soc::SharedMemoryRepo::calculate_node_memory_size(), load(), ProcOptions(), and save().

fs::FixedPath foedus::proc::ProcOptions::shared_library_dir_pattern_

String pattern of ';'-separated path of directories that contain shared libaries to load.

Similar to shared_library_path_pattern_. The difference is that all ".so" files under the directory is loaded. The default value is empty.

Definition at line 71 of file proc_options.hpp.

Referenced by convert_shared_library_dir_pattern(), load(), ProcOptions(), and save().

fs::FixedPath foedus::proc::ProcOptions::shared_library_path_pattern_

String pattern of ';'-separated path of shared libraries to load in each NUMA node.

The default value is empty, which means we don't load any shared libraries. If non-empty, we load the shared libraries of the path to register user-defined procedures. A placeholder '$NODE$' is replaced with the NUMA node number. For example, "/foo/bar/node_$NODE$/mylib.so becomes "/foo/bar/node_1/mylib.so" on node-1. On the other hand, "/foo/bar/mylib.so becomes "/foo/bar/mylib.so" for all nodes. The main purpose of using different binaries for each node is 1) to manually achieve executable/library text replication on NUMA node, and 2) for kChildRemoteSpawned later.

Definition at line 62 of file proc_options.hpp.

Referenced by convert_shared_library_path_pattern(), load(), ProcOptions(), and save().


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