libfoedus-core
FOEDUS Core Library
soc_manager_pimpl.hpp
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  */
18 #ifndef FOEDUS_SOC_SOC_MANAGER_PIMPL_HPP_
19 #define FOEDUS_SOC_SOC_MANAGER_PIMPL_HPP_
20 
21 #include <unistd.h>
22 #include <sys/types.h>
23 
24 #include <thread>
25 #include <vector>
26 
27 #include "foedus/fwd.hpp"
28 #include "foedus/initializable.hpp"
29 #include "foedus/proc/proc_id.hpp"
30 #include "foedus/soc/fwd.hpp"
32 #include "foedus/soc/soc_id.hpp"
33 
34 namespace foedus {
35 namespace soc {
43 class SocManagerPimpl final : public DefaultInitializable {
44  public:
45  SocManagerPimpl() = delete;
46  explicit SocManagerPimpl(Engine* engine) : engine_(engine) {}
47  ErrorStack initialize_once() override;
48  ErrorStack uninitialize_once() override;
49 
51 
54 
57 
70  ErrorStack wait_for_master_module(bool init, ModuleType module);
73  void emulated_child_main(SocId node);
75  int forked_child_main(SocId node);
77  static void spawned_child_main(const std::vector< proc::ProcAndName >& procedures);
78 
80  EngineType engine_type,
81  Upid master_upid,
82  Eid master_eid,
83  SocId node,
84  const std::vector< proc::ProcAndName >& procedures);
85 
86  Engine* const engine_;
88 
93  std::vector<std::thread> child_emulated_threads_;
95  std::vector< Engine* > child_emulated_engines_;
96 
102 };
103 } // namespace soc
104 } // namespace foedus
105 #endif // FOEDUS_SOC_SOC_MANAGER_PIMPL_HPP_
ErrorStack uninitialize_once() override
Upid child_upids_[kMaxSocs]
Process IDs of child SOCs.
void emulated_child_main(SocId node)
Main routine of emulated SOCs.
static ErrorStack child_main_common(EngineType engine_type, Upid master_upid, Eid master_eid, SocId node, const std::vector< proc::ProcAndName > &procedures)
ErrorStack launch_forked_children()
Launch children via fork.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
std::vector< std::thread > child_emulated_threads_
Threads that emulate child SOCs.
static void spawned_child_main(const std::vector< proc::ProcAndName > &procedures)
Main routine of spawned SOCs.
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Typedefs of ID types used in SOC package.
Typical implementation of Initializable as a skeleton base class.
ErrorStack initialize_master()
Called as part of initialize_once() if this is a master engine.
ModuleType
Enumerates modules in FOEDUS engine.
Definition: module_type.hpp:26
ErrorStack wait_for_child_attach()
Wait for child SOCs to start up and at least finish attaching shared memory.
ErrorStack wait_for_children_module(bool init, ModuleType module)
ErrorStack launch_emulated_children()
Launch emulated children as threads.
int forked_child_main(SocId node)
Main routine of forked SOCs.
ErrorStack wait_for_master_module(bool init, ModuleType module)
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
Typedefs of ID types used in procedure package.
std::vector< Engine * > child_emulated_engines_
And their engines.
ErrorStack initialize_once() override
EngineType
Type of an engine instance of how to launch it.
Definition: engine_type.hpp:35
ErrorStack launch_spawned_children()
Launch children via spawn.
ErrorStack wait_for_master_status(MasterEngineStatus::StatusCode target_status)
Wait for master engine to finish upto the specified status.
uint64_t Upid
Universal (or Unique) ID of a process.
Definition: soc_id.hpp:48
Repository of all shared memory in one FOEDUS instance.
Forward declarations of classes in SOC package.
ErrorStack wait_for_child_terminate()
Wait for child SOCs to terminate.
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
Pimpl object of SocManager.
uint64_t Eid
An Engine ID to differentiate two Engine objects instantiated in the same process.
Definition: engine_type.hpp:29
ErrorStack initialize_child()
Called as part of initialize_once() if this is a child SOC engine.
const uint16_t kMaxSocs
Maximum number of SOCs.
Definition: soc_id.hpp:35
StatusCode
These statuses represent each step described in SocManager comment.