libfoedus-core
FOEDUS Core Library
foedus::proc::ProcManagerPimpl Class Referencefinal

Pimpl object of ProcManager. More...

Detailed Description

Pimpl object of ProcManager.

A private pimpl object for ProcManager. Do not include this header from a client program unless you know what you are doing.

Definition at line 65 of file proc_manager_pimpl.hpp.

#include <proc_manager_pimpl.hpp>

Inheritance diagram for foedus::proc::ProcManagerPimpl:
Collaboration diagram for foedus::proc::ProcManagerPimpl:

Classes

struct  SharedData
 All shared data in this module. More...
 

Public Member Functions

 ProcManagerPimpl ()=delete
 
 ProcManagerPimpl (Engine *engine)
 
ErrorStack initialize_once () override
 
ErrorStack uninitialize_once () override
 
std::string describe_registered_procs () const
 
ErrorStack get_proc (const ProcName &name, Proc *out)
 
ErrorStack pre_register (const ProcAndName &proc_and_name)
 
ErrorStack local_register (const ProcAndName &proc_and_name)
 
ErrorStack emulated_register (const ProcAndName &proc_and_name)
 
SharedDataget_local_data ()
 
const SharedDataget_local_data () const
 
- Public Member Functions inherited from foedus::DefaultInitializable
 DefaultInitializable ()
 
virtual ~DefaultInitializable ()
 
 DefaultInitializable (const DefaultInitializable &)=delete
 
DefaultInitializableoperator= (const DefaultInitializable &)=delete
 
ErrorStack initialize () override final
 Typical implementation of Initializable::initialize() that provides initialize-once semantics. More...
 
ErrorStack uninitialize () override final
 Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics. More...
 
bool is_initialized () const override final
 Returns whether the object has been already initialized or not. More...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Static Public Member Functions

static LocalProcId find_by_name (const ProcName &name, SharedData *shared_data)
 
static LocalProcId insert (const ProcAndName &proc_and_name, SharedData *shared_data)
 

Public Attributes

Engine *const engine_
 
std::vector< ProcAndNamepre_registered_procs_
 
std::vector< SharedDataall_soc_procs_
 Shared data of all SOCs. More...
 

Constructor & Destructor Documentation

foedus::proc::ProcManagerPimpl::ProcManagerPimpl ( )
delete
foedus::proc::ProcManagerPimpl::ProcManagerPimpl ( Engine engine)
inlineexplicit

Definition at line 78 of file proc_manager_pimpl.hpp.

78 : engine_(engine) {}

Member Function Documentation

std::string foedus::proc::ProcManagerPimpl::describe_registered_procs ( ) const

Definition at line 172 of file proc_manager_pimpl.cpp.

References foedus::proc::ProcManagerPimpl::SharedData::control_block_, foedus::proc::ProcManagerControlBlock::count_, engine_, get_local_data(), foedus::Engine::is_master(), and foedus::proc::ProcManagerPimpl::SharedData::procs_.

Referenced by foedus::proc::ProcManager::describe_registered_procs().

172  {
173  if (engine_->is_master()) {
174  return "<Master engine has no proc>";
175  }
176  std::stringstream str;
177  const SharedData* data = get_local_data();
178  str << "Proc Count=" << data->control_block_->count_ << ", (name,address)=[";
179  for (LocalProcId i = 0; i < data->control_block_->count_; ++i) {
180  if (i > 0) {
181  str << ",";
182  }
183  str << "(" << data->procs_[i].first << "," << data->procs_[i].second << ")";
184  }
185  str << "]";
186 
187  return str.str();
188 }
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::emulated_register ( const ProcAndName proc_and_name)

Definition at line 129 of file proc_manager_pimpl.cpp.

References engine_, ERROR_STACK, foedus::get_error_message(), foedus::Engine::get_options(), foedus::DefaultInitializable::is_initialized(), foedus::kChildEmulated, foedus::kErrorCodeProcRegisterTooEarly, foedus::kErrorCodeProcRegisterUnsupportedSocType, foedus::kRetOk, foedus::EngineOptions::soc_, and foedus::soc::SocOptions::soc_type_.

Referenced by foedus::proc::ProcManager::emulated_register().

129  {
130  if (!is_initialized()) {
131  LOG(ERROR) << "Incorrect use of emulated_register(): "
134  }
135 
137  if (soc_type != kChildEmulated) {
138  LOG(ERROR) << "Incorrect use of emulated_register(): "
141  }
142  LOG(INFO) << "emulated-registered a user procedure: " << proc_and_name.first;
143  return kRetOk;
144 }
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
0x0D02 : "PROC : Post-register can be called only after engine initialization." ...
Definition: error_code.hpp:234
EngineType soc_type_
How to launch SOC engine instances.
Definition: soc_options.hpp:54
0x0D03 : "PROC : This registration type cannot be used for this SOC type." .
Definition: error_code.hpp:235
const EngineOptions & get_options() const
Definition: engine.cpp:39
EngineType
Type of an engine instance of how to launch it.
Definition: engine_type.hpp:35
const ErrorStack kRetOk
Normal return value for no-error case.
const char * get_error_message(ErrorCode code)
Returns the error messages corresponding to ErrorCode enum defined in error_code.xmacro.
Definition: error_code.hpp:120
bool is_initialized() const override final
Returns whether the object has been already initialized or not.
A child SOC instance launched just as a thread in the same process as master.
Definition: engine_type.hpp:51

Here is the call graph for this function:

Here is the caller graph for this function:

LocalProcId foedus::proc::ProcManagerPimpl::find_by_name ( const ProcName name,
SharedData shared_data 
)
static

Definition at line 146 of file proc_manager_pimpl.cpp.

References foedus::proc::ProcManagerPimpl::SharedData::control_block_, foedus::proc::ProcManagerControlBlock::count_, foedus::proc::kLocalProcInvalid, foedus::assorted::memory_fence_acquire(), and foedus::proc::ProcManagerPimpl::SharedData::procs_.

Referenced by get_proc(), and insert().

146  {
147  // so far just a seqnetial search.
148  LocalProcId count = shared_data->control_block_->count_;
150  for (LocalProcId i = 0; i < count; ++i) {
151  if (shared_data->procs_[i].first == name) {
152  return i;
153  }
154  }
155  return kLocalProcInvalid;
156 }
const LocalProcId kLocalProcInvalid
Definition: proc_id.hpp:58
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56

Here is the call graph for this function:

Here is the caller graph for this function:

ProcManagerPimpl::SharedData * foedus::proc::ProcManagerPimpl::get_local_data ( )

Definition at line 80 of file proc_manager_pimpl.cpp.

References all_soc_procs_, ASSERT_ND, engine_, foedus::Engine::get_soc_id(), and foedus::Engine::is_master().

Referenced by describe_registered_procs(), initialize_once(), local_register(), and uninitialize_once().

80  {
82  return &all_soc_procs_[engine_->get_soc_id()];
83 }
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
soc::SocId get_soc_id() const
If this is a child instance, returns its SOC ID (NUMA node).
Definition: engine.cpp:73
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

const ProcManagerPimpl::SharedData * foedus::proc::ProcManagerPimpl::get_local_data ( ) const

Definition at line 84 of file proc_manager_pimpl.cpp.

References all_soc_procs_, ASSERT_ND, engine_, foedus::Engine::get_soc_id(), and foedus::Engine::is_master().

84  {
86  return &all_soc_procs_[engine_->get_soc_id()];
87 }
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
soc::SocId get_soc_id() const
If this is a child instance, returns its SOC ID (NUMA node).
Definition: engine.cpp:73
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::get_proc ( const ProcName name,
Proc out 
)

Definition at line 71 of file proc_manager_pimpl.cpp.

References all_soc_procs_, foedus::assorted::FixedString< MAXLEN, CHAR >::c_str(), engine_, ERROR_STACK_MSG, find_by_name(), foedus::Engine::get_soc_id(), foedus::kErrorCodeProcNotFound, foedus::proc::kLocalProcInvalid, and foedus::kRetOk.

Referenced by foedus::proc::ProcManager::get_proc().

71  {
72  soc::SocId node = engine_->get_soc_id();
73  LocalProcId id = find_by_name(name, &all_soc_procs_[node]);
74  if (id == kLocalProcInvalid) {
75  return ERROR_STACK_MSG(kErrorCodeProcNotFound, name.c_str());
76  }
77  *out = all_soc_procs_[node].procs_[id].second;
78  return kRetOk;
79 }
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
static LocalProcId find_by_name(const ProcName &name, SharedData *shared_data)
const LocalProcId kLocalProcInvalid
Definition: proc_id.hpp:58
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
const ErrorStack kRetOk
Normal return value for no-error case.
0x0D06 : "PROC : The specified procedure name is not found in this engine." .
Definition: error_code.hpp:238
#define ERROR_STACK_MSG(e, m)
Overload of ERROR_STACK(e) to receive a custom error message.
soc::SocId get_soc_id() const
If this is a child instance, returns its SOC ID (NUMA node).
Definition: engine.cpp:73
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::initialize_once ( )
overridevirtual

Implements foedus::DefaultInitializable.

Definition at line 35 of file proc_manager_pimpl.cpp.

References all_soc_procs_, foedus::proc::ProcManagerPimpl::SharedData::control_block_, foedus::Engine::describe_short(), engine_, get_local_data(), foedus::soc::SharedMemoryRepo::get_node_memory_anchors(), foedus::Engine::get_options(), foedus::soc::SocManager::get_shared_memory_repo(), foedus::Engine::get_soc_manager(), foedus::thread::ThreadOptions::group_count_, foedus::proc::ProcManagerControlBlock::initialize(), foedus::Engine::is_master(), foedus::kRetOk, foedus::proc::ProcManagerPimpl::SharedData::name_sort_, foedus::soc::NodeMemoryAnchors::proc_manager_memory_, foedus::soc::NodeMemoryAnchors::proc_memory_, foedus::soc::NodeMemoryAnchors::proc_name_sort_memory_, foedus::proc::ProcManagerPimpl::SharedData::procs_, and foedus::EngineOptions::thread_.

35  {
36  // attach shared memories of all SOCs
37  all_soc_procs_.clear();
39  soc::SharedMemoryRepo* memory_repo = engine_->get_soc_manager()->get_shared_memory_repo();
40  for (soc::SocId node = 0; node < soc_count; ++node) {
41  soc::NodeMemoryAnchors* anchors = memory_repo->get_node_memory_anchors(node);
42  SharedData data;
43  data.control_block_ = anchors->proc_manager_memory_;
44  data.name_sort_ = anchors->proc_name_sort_memory_;
45  data.procs_ = anchors->proc_memory_;
46  all_soc_procs_.push_back(data);
47  }
48 
49  if (!engine_->is_master()) {
50  LOG(INFO) << "Initializing ProcManager(" << engine_->describe_short() << ")..";
52  }
53 
54  // TODO(Hideaki) load shared libraries
55  return kRetOk;
56 }
std::string describe_short() const
Definition: engine.cpp:38
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
NodeMemoryAnchors * get_node_memory_anchors(SocId node)
const EngineOptions & get_options() const
Definition: engine.cpp:39
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
proc::ProcManagerControlBlock * proc_manager_memory_
ProcManagers's status and its synchronization mechanism on this node.
uint16_t group_count_
Number of ThreadGroup in the engine.
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
thread::ThreadOptions thread_
const ErrorStack kRetOk
Normal return value for no-error case.
soc::SocManager * get_soc_manager() const
See SOC and IPC.
Definition: engine.cpp:59
SharedMemoryRepo * get_shared_memory_repo()
Returns the shared memories maintained across SOCs.
Definition: soc_manager.cpp:38

Here is the call graph for this function:

LocalProcId foedus::proc::ProcManagerPimpl::insert ( const ProcAndName proc_and_name,
SharedData shared_data 
)
static

Definition at line 158 of file proc_manager_pimpl.cpp.

References foedus::proc::ProcManagerPimpl::SharedData::control_block_, foedus::proc::ProcManagerControlBlock::count_, find_by_name(), foedus::proc::kLocalProcInvalid, foedus::proc::ProcManagerControlBlock::lock_, and foedus::proc::ProcManagerPimpl::SharedData::procs_.

Referenced by local_register().

158  {
159  soc::SharedMutexScope lock_scope(&shared_data->control_block_->lock_);
160  LocalProcId found = find_by_name(proc_and_name.first, shared_data);
161  // TASK(Hideaki) max_proc_count check.
162  if (found != kLocalProcInvalid) {
163  return kLocalProcInvalid;
164  }
165  LocalProcId new_id = shared_data->control_block_->count_;
166  shared_data->procs_[new_id] = proc_and_name;
167  ++shared_data->control_block_->count_;
168  // TASK(Hideaki) insert-sort to name_sort
169  return new_id;
170 }
static LocalProcId find_by_name(const ProcName &name, SharedData *shared_data)
const LocalProcId kLocalProcInvalid
Definition: proc_id.hpp:58
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::local_register ( const ProcAndName proc_and_name)

Definition at line 109 of file proc_manager_pimpl.cpp.

References engine_, ERROR_STACK, foedus::get_error_message(), get_local_data(), insert(), foedus::DefaultInitializable::is_initialized(), foedus::Engine::is_master(), foedus::kErrorCodeProcProcAlreadyExists, foedus::kErrorCodeProcRegisterChildOnly, foedus::kErrorCodeProcRegisterTooEarly, foedus::proc::kLocalProcInvalid, and foedus::kRetOk.

Referenced by foedus::proc::ProcManager::local_register().

109  {
110  if (!is_initialized()) {
111  LOG(ERROR) << "Incorrect use of local_register(): "
114  }
115  if (engine_->is_master()) {
116  LOG(ERROR) << "Incorrect use of local_register(): "
119  }
120  LocalProcId result = insert(proc_and_name, get_local_data());
121  if (result == kLocalProcInvalid) {
122  LOG(ERROR) << "A procedure of this name is already registered in this engine: "
123  << proc_and_name.first;
125  }
126  LOG(INFO) << "local-registered a user procedure: " << proc_and_name.first;
127  return kRetOk;
128 }
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
0x0D02 : "PROC : Post-register can be called only after engine initialization." ...
Definition: error_code.hpp:234
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
0x0D07 : "PROC : The specified procedure name already exists in this engine." . ...
Definition: error_code.hpp:239
0x0D05 : "PROC : This registration type can be invoked only at child engine." . ...
Definition: error_code.hpp:237
const LocalProcId kLocalProcInvalid
Definition: proc_id.hpp:58
const ErrorStack kRetOk
Normal return value for no-error case.
const char * get_error_message(ErrorCode code)
Returns the error messages corresponding to ErrorCode enum defined in error_code.xmacro.
Definition: error_code.hpp:120
uint32_t LocalProcId
Represents a locally-unique ID of a procedure in one SOC.
Definition: proc_id.hpp:56
static LocalProcId insert(const ProcAndName &proc_and_name, SharedData *shared_data)
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::pre_register ( const ProcAndName proc_and_name)

Definition at line 89 of file proc_manager_pimpl.cpp.

References engine_, ERROR_STACK, foedus::get_error_message(), foedus::Engine::get_options(), foedus::DefaultInitializable::is_initialized(), foedus::Engine::is_master(), foedus::kChildEmulated, foedus::kChildForked, foedus::kErrorCodeProcPreRegisterTooLate, foedus::kErrorCodeProcRegisterMasterOnly, foedus::kErrorCodeProcRegisterUnsupportedSocType, foedus::kRetOk, pre_registered_procs_, foedus::EngineOptions::soc_, and foedus::soc::SocOptions::soc_type_.

Referenced by foedus::proc::ProcManager::pre_register().

89  {
90  if (is_initialized()) {
91  LOG(ERROR) << "Incorrect use of pre_register(): "
94  }
95  if (!engine_->is_master()) {
96  LOG(ERROR) << "Incorrect use of pre_register(): "
99  }
101  if (soc_type != kChildEmulated && soc_type != kChildForked) {
103  }
104  pre_registered_procs_.push_back(proc_and_name);
105  // This is BEFORE the init, so we shouldn't use GLOG
106  // LOG(INFO) << "pre-registered a user procedure: " << proc_and_name.first;
107  return kRetOk;
108 }
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
0x0D04 : "PROC : This registration type can be invoked only at master engine." .
Definition: error_code.hpp:236
EngineType soc_type_
How to launch SOC engine instances.
Definition: soc_options.hpp:54
0x0D03 : "PROC : This registration type cannot be used for this SOC type." .
Definition: error_code.hpp:235
const EngineOptions & get_options() const
Definition: engine.cpp:39
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
0x0D01 : "PROC : Pre-register can be called only before engine initialization." ...
Definition: error_code.hpp:233
EngineType
Type of an engine instance of how to launch it.
Definition: engine_type.hpp:35
A child SOC instance launched via fork().
Definition: engine_type.hpp:65
const ErrorStack kRetOk
Normal return value for no-error case.
const char * get_error_message(ErrorCode code)
Returns the error messages corresponding to ErrorCode enum defined in error_code.xmacro.
Definition: error_code.hpp:120
bool is_initialized() const override final
Returns whether the object has been already initialized or not.
std::vector< ProcAndName > pre_registered_procs_
A child SOC instance launched just as a thread in the same process as master.
Definition: engine_type.hpp:51

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::proc::ProcManagerPimpl::uninitialize_once ( )
overridevirtual

Implements foedus::DefaultInitializable.

Definition at line 58 of file proc_manager_pimpl.cpp.

References all_soc_procs_, foedus::proc::ProcManagerPimpl::SharedData::control_block_, foedus::Engine::describe_short(), engine_, get_local_data(), foedus::Engine::is_master(), foedus::kRetOk, SUMMARIZE_ERROR_BATCH, and foedus::proc::ProcManagerControlBlock::uninitialize().

58  {
59  ErrorStackBatch batch;
60  // TODO(Hideaki) unload shared libraries
61  if (!engine_->is_master()) {
62  LOG(INFO) << "Uninitializing ProcManager(" << engine_->describe_short() << ")..";
64  return kRetOk;
65  }
66  all_soc_procs_.clear();
67  return SUMMARIZE_ERROR_BATCH(batch);
68 }
std::string describe_short() const
Definition: engine.cpp:38
std::vector< SharedData > all_soc_procs_
Shared data of all SOCs.
bool is_master() const
Returns if this engine object is a master instance.
Definition: engine.cpp:68
#define SUMMARIZE_ERROR_BATCH(x)
This macro calls ErrorStackBatch::summarize() with automatically provided parameters.
const ErrorStack kRetOk
Normal return value for no-error case.

Here is the call graph for this function:

Member Data Documentation

std::vector< SharedData > foedus::proc::ProcManagerPimpl::all_soc_procs_

Shared data of all SOCs.

Index is SOC ID.

Definition at line 99 of file proc_manager_pimpl.hpp.

Referenced by get_local_data(), get_proc(), initialize_once(), and uninitialize_once().

Engine* const foedus::proc::ProcManagerPimpl::engine_
std::vector< ProcAndName > foedus::proc::ProcManagerPimpl::pre_registered_procs_

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