libfoedus-core
FOEDUS Core Library
|
SOC manager, which maintains the shared resource across SOCs and, if this engine is a master engine, manages child SOCs. More...
SOC manager, which maintains the shared resource across SOCs and, if this engine is a master engine, manages child SOCs.
Initialization of this module is quite special because a master engine launches child SOCs potentially as different processes. Also, to avoid leak of shared memory, we take a bit complicated steps.
When the user instantiates an Engine object, the engine is initialized in the following order:
Notice the annotated region. If there is an unexpected crash in master engine during this period, we leak shared memory until reboot or manual reclamation (ipcrm command). We must avoid it as much as possible. Be extra careful!
Definition at line 60 of file soc_manager.hpp.
#include <soc_manager.hpp>
Public Member Functions | |
SocManager (Engine *engine) | |
~SocManager () | |
SocManager ()=delete | |
SocManager (const SocManager &)=delete | |
SocManager & | operator= (const SocManager &)=delete |
ErrorStack | initialize () override |
Acquires resources in this object, usually called right after constructor. More... | |
bool | is_initialized () const override |
Returns whether the object has been already initialized or not. More... | |
ErrorStack | uninitialize () override |
An idempotent method to release all resources of this object, if any. More... | |
SharedMemoryRepo * | get_shared_memory_repo () |
Returns the shared memories maintained across SOCs. More... | |
void * | get_shared_user_memory () const |
Shortcut for get_shared_memory_repo()->get_global_user_memory() More... | |
uint64_t | get_shared_user_memory_size () const |
ErrorStack | wait_for_master_module (bool init, ModuleType module) |
Wait for master engine to finish init/uninit the module. More... | |
ErrorStack | wait_for_children_module (bool init, ModuleType module) |
Wait for other engines to finish init/uninit the module. More... | |
void | report_engine_fatal_error () |
Announce fatal error state of this (either master or child) engine if possible. More... | |
![]() | |
virtual | ~Initializable () |
Static Public Member Functions | |
static void | trap_spawned_soc_main () |
This should be called at the beginning of main() if the executable expects to be spawned as SOC engines. More... | |
static void | trap_spawned_soc_main (const std::vector< proc::ProcAndName > &procedures) |
This version also receives user-defined procedures to be registered in this SOC. More... | |
Friends | |
class | SocManagerPimpl |
|
explicit |
foedus::soc::SocManager::~SocManager | ( | ) |
Definition at line 29 of file soc_manager.cpp.
|
delete |
|
delete |
SharedMemoryRepo * foedus::soc::SocManager::get_shared_memory_repo | ( | ) |
Returns the shared memories maintained across SOCs.
Definition at line 38 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::memory_repo_.
Referenced by foedus::snapshot::LogGleaner::execute(), foedus::snapshot::LogReducerRef::get_buffer(), foedus::snapshot::LogReducerRef::get_cur_snapshot(), foedus::storage::PartitionerMetadata::get_index0_metadata(), foedus::storage::PartitionerMetadata::get_metadata(), foedus::restart::RestartManagerPimpl::initialize_once(), foedus::log::MetaLogger::initialize_once(), foedus::memory::NumaNodeMemory::initialize_once(), foedus::EnginePimpl::initialize_once(), foedus::storage::StorageManagerPimpl::initialize_once(), foedus::proc::ProcManagerPimpl::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::xct::XctManagerPimpl::initialize_once(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), foedus::thread::ThreadPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), foedus::storage::PartitionerMetadata::locate_data(), foedus::snapshot::LogGleanerRef::LogGleanerRef(), foedus::snapshot::LogReducer::LogReducer(), foedus::snapshot::LogReducerRef::LogReducerRef(), foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef(), foedus::EnginePimpl::on_module_initialized(), foedus::EnginePimpl::on_module_uninitialized(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), foedus::thread::ThreadRef::ThreadRef(), foedus::EnginePimpl::uninitialize_once(), and foedus::snapshot::SnapshotManagerPimpl::uninitialize_once().
void * foedus::soc::SocManager::get_shared_user_memory | ( | ) | const |
Shortcut for get_shared_memory_repo()->get_global_user_memory()
Definition at line 40 of file soc_manager.cpp.
References foedus::soc::SharedMemoryRepo::get_global_user_memory(), and foedus::soc::SocManagerPimpl::memory_repo_.
Referenced by foedus::memory::EngineMemory::get_shared_user_memory().
uint64_t foedus::soc::SocManager::get_shared_user_memory_size | ( | ) | const |
Definition at line 43 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::engine_, foedus::Engine::get_options(), foedus::soc::SocOptions::shared_user_memory_size_kb_, and foedus::EngineOptions::soc_.
Referenced by foedus::memory::EngineMemory::get_shared_user_memory_size().
|
overridevirtual |
Acquires resources in this object, usually called right after constructor.
If and only if the return value was not an error, is_initialized() will return TRUE. This method is usually not idempotent, but some implementation can choose to be. In that case, the implementation class should clarify that it's idempotent. This method is responsible for releasing all acquired resources when initialization fails. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 34 of file soc_manager.cpp.
References foedus::DefaultInitializable::initialize().
Referenced by foedus::EnginePimpl::initialize_once().
|
overridevirtual |
Returns whether the object has been already initialized or not.
Implements foedus::Initializable.
Definition at line 35 of file soc_manager.cpp.
References foedus::DefaultInitializable::is_initialized().
Referenced by foedus::EnginePimpl::initialize_modules(), and foedus::EnginePimpl::uninitialize_once().
|
delete |
void foedus::soc::SocManager::report_engine_fatal_error | ( | ) |
Announce fatal error state of this (either master or child) engine if possible.
Definition at line 64 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::report_engine_fatal_error().
Referenced by foedus::EnginePimpl::initialize_once().
|
static |
This should be called at the beginning of main() if the executable expects to be spawned as SOC engines.
This method detects if the process has been spawned from FOEDUS as an SOC engine. If so, it starts running as an SOC engine and exits the process (via _exit()) when done. This should be called as early as possible like following:
If the process has not been spawned as FOEDUS's SOC engine, this method does nothing and immediately returns.
Definition at line 48 of file soc_manager.cpp.
|
static |
This version also receives user-defined procedures to be registered in this SOC.
[in] | procedures | user-defined procedures' name and function pointer in this process. |
Example:
Definition at line 53 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::spawned_child_main().
|
overridevirtual |
An idempotent method to release all resources of this object, if any.
After this method, is_initialized() will return FALSE. Whether this method encounters an error or not, the implementation should make the best effort to release as many resources as possible. In other words, Do not leak all resources because of one issue. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 36 of file soc_manager.cpp.
References foedus::DefaultInitializable::uninitialize().
Referenced by foedus::EnginePimpl::uninitialize_once().
ErrorStack foedus::soc::SocManager::wait_for_children_module | ( | bool | init, |
ModuleType | module | ||
) |
Wait for other engines to finish init/uninit the module.
Definition at line 57 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::wait_for_children_module().
Referenced by foedus::EnginePimpl::initialize_modules(), and foedus::EnginePimpl::uninitialize_once().
ErrorStack foedus::soc::SocManager::wait_for_master_module | ( | bool | init, |
ModuleType | module | ||
) |
Wait for master engine to finish init/uninit the module.
Definition at line 61 of file soc_manager.cpp.
References foedus::soc::SocManagerPimpl::wait_for_master_module().
Referenced by foedus::EnginePimpl::initialize_modules(), and foedus::EnginePimpl::uninitialize_once().
|
friend |
Definition at line 62 of file soc_manager.hpp.
Referenced by SocManager().