libfoedus-core
FOEDUS Core Library
soc_options.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <cstdlib>
21 #include <sstream>
22 #include <string>
23 
26 
27 namespace foedus {
28 namespace soc {
34 }
35 
36 std::string SocOptions::convert_spawn_executable_pattern(int node) const {
38  // if empty, use the current binary
40  }
41  return assorted::replace_all(spawn_executable_pattern_.str(), "$NODE$", node);
42 }
43 
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 }
56 
57 ErrorStack SocOptions::load(tinyxml2::XMLElement* element) {
62  return kRetOk;
63 }
64 
65 ErrorStack SocOptions::save(tinyxml2::XMLElement* element) const {
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 }
84 
85 } // namespace soc
86 } // namespace foedus
#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
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
SocOptions()
Constructs option values with default values.
Definition: soc_options.cpp:29
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
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.
std::string convert_spawn_executable_pattern(int node) const
converts spawn_executable_pattern_ into a string with the given node ID.
Definition: soc_options.cpp:36
std::string get_current_executable_path()
Returns the full path of current executable.
#define EXTERNALIZE_LOAD_ENUM_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
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.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ErrorStack load(tinyxml2::XMLElement *element) override
Reads the content of this object from the given XML element.
Definition: soc_options.cpp:57
#define EXTERNALIZE_SAVE_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
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
ErrorStack save(tinyxml2::XMLElement *element) const override
Writes the content of this object to the given XML element.
Definition: soc_options.cpp:65
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.
Definition: soc_options.cpp:44
A child SOC instance launched just as a thread in the same process as master.
Definition: engine_type.hpp:51