libfoedus-core
FOEDUS Core Library
engine_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_ENGINE_PIMPL_HPP_
19 #define FOEDUS_ENGINE_PIMPL_HPP_
20 
21 #include <string>
22 #include <vector>
23 
25 #include "foedus/engine_type.hpp"
26 #include "foedus/fwd.hpp"
27 #include "foedus/initializable.hpp"
28 #include "foedus/module_type.hpp"
29 // This is pimpl. no need for further indirections. just include them all.
38 #include "foedus/soc/soc_id.hpp"
43 
44 namespace foedus {
52 class EnginePimpl final : public DefaultInitializable {
53  public:
55  struct ModulePtr {
56  ModulePtr() : ptr_(nullptr), type_(kInvalid) {}
57  ModulePtr(Initializable* ptr, ModuleType type) : ptr_(ptr), type_(type) {}
60  };
61 
62  EnginePimpl() = delete;
63  EnginePimpl(Engine* engine, const EngineOptions &options);
65  Engine* engine,
66  EngineType type,
67  soc::Upid master_upid,
68  Eid master_eid,
69  soc::SocId soc_id);
70 
71  bool is_master() const { return type_ == kMaster; }
72  ErrorStack initialize_once() override;
74  ErrorStack uninitialize_once() override;
76 
78  void on_module_initialized(ModuleType module);
81 
84 
86  Engine* const engine_;
87 
92 
93 // Individual modules. Placed in initialize()/uninitialize() order
94 // (remember, modules have dependencies between them).
95 
125 
127  std::vector< ModulePtr > get_modules() {
128  std::vector< ModulePtr > modules;
129  // modules.push_back(ModulePtr(&soc_manager_, kSoc)); SOC Manager is specially inited/uninited
130  modules.push_back(ModulePtr(&debug_, kDebug));
131  modules.push_back(ModulePtr(&proc_manager_, kProc));
132  modules.push_back(ModulePtr(&memory_manager_, kMemory));
133  modules.push_back(ModulePtr(&savepoint_manager_, kSavepoint));
134  modules.push_back(ModulePtr(&thread_pool_, kThread));
135  modules.push_back(ModulePtr(&log_manager_, kLog));
136  modules.push_back(ModulePtr(&snapshot_manager_, kSnapshot));
137  modules.push_back(ModulePtr(&cache_manager_, kCache));
138  modules.push_back(ModulePtr(&storage_manager_, kStorage));
139  modules.push_back(ModulePtr(&xct_manager_, kXct));
140  modules.push_back(ModulePtr(&restart_manager_, kRestart));
141  return modules;
142  }
143  std::string describe_short() const;
144 
145  private:
150  static ErrorStack check_transparent_hugepage_setting();
151  ErrorStack check_minimal_pool_size() const;
152 };
153 } // namespace foedus
154 #endif // FOEDUS_ENGINE_PIMPL_HPP_
EngineOptions options_
Options given at boot time.
debugging::DebuggingSupports debug_
Debugging supports.
storage::StorageManager storage_manager_
The pure-virtual interface to initialize/uninitialize non-trivial resources.
void on_module_initialized(ModuleType module)
Called whenever each module has completed its initialization.
void on_module_uninitialized(ModuleType module)
Called whenever each module has completed its uninitialization.
ErrorStack check_valid_options()
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Pimpl object of Engine.
restart::RestartManager restart_manager_
bool is_master() const
ErrorStack initialize_once() override
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.
soc::SocManager soc_manager_
SOC manager.
Procedure manager, which maintains the list of system/user procedures.
snapshot::SnapshotManager snapshot_manager_
std::vector< ModulePtr > get_modules()
Returns in initialization order.
proc::ProcManager proc_manager_
Snapshot manager that atomically and durably writes out a snapshot file.
std::string describe_short() const
ModuleType
Enumerates modules in FOEDUS engine.
Definition: module_type.hpp:26
savepoint::SavepointManager savepoint_manager_
ModulePtr(Initializable *ptr, ModuleType type)
thread::ThreadPool thread_pool_
const EngineType type_
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
xct::XctManager xct_manager_
Set of option values given to the engine at start-up.
EngineType
Type of an engine instance of how to launch it.
Definition: engine_type.hpp:35
cache::CacheManager cache_manager_
Xct Manager class that provides API to begin/abort/commit transaction.
Definition: xct_manager.hpp:35
const soc::SocId soc_id_
Engine *const engine_
Pointer to the enclosing object.
uint64_t Upid
Universal (or Unique) ID of a process.
Definition: soc_id.hpp:48
memory::EngineMemory memory_manager_
Log Manager class that provides API to write/read transaction logs.
Definition: log_manager.hpp:36
The central instance that launches child engines on each NUMA node (SOC).
Definition: engine_type.hpp:41
const soc::Upid master_upid_
pair of module pointer and its type.
log::LogManager log_manager_
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
Snapshot cache manager.
Storage Manager class that provides API to create/open/close/drop key-value stores.
ErrorStack initialize_modules()
uint64_t Eid
An Engine ID to differentiate two Engine objects instantiated in the same process.
Definition: engine_type.hpp:29
SOC manager, which maintains the shared resource across SOCs and, if this engine is a master engine...
Definition: soc_manager.hpp:60
ErrorStack uninitialize_once() override
APIs to support debugging functionalities.
Repository of all memories dynamically acquired and shared within one database engine.
Restart manager, which recovers the state of database by invoking log-gleaner at start-up.
The pool of pre-allocated threads in the engine to execute transactions.
Savepoint manager that atomically and durably writes out a savepoint file.