libfoedus-core
FOEDUS Core Library
engine.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  */
18 #include "foedus/engine.hpp"
19 
20 #include <string>
21 
22 #include "foedus/assert_nd.hpp"
23 #include "foedus/engine_pimpl.hpp"
24 
25 namespace foedus {
26 Engine::Engine(const EngineOptions& options) : pimpl_(nullptr) {
27  pimpl_ = new EnginePimpl(this, options);
28 }
29 Engine::Engine(EngineType type, uint64_t master_upid, Eid master_eid, uint16_t soc_id)
30  : pimpl_(nullptr) {
31  pimpl_ = new EnginePimpl(this, type, master_upid, master_eid, soc_id);
32 }
34  delete pimpl_;
35 }
36 
37 // simply forward to pimpl object
38 std::string Engine::describe_short() const { return pimpl_->describe_short(); }
39 const EngineOptions& Engine::get_options() const { return pimpl_->options_; }
41  // this must be used only in child SOC's initialization.
42  ASSERT_ND(!is_master());
43  return &pimpl_->options_;
44 }
45 
46 
54  return &pimpl_->savepoint_manager_;
55 }
57  return &pimpl_->snapshot_manager_;
58 }
62 
63 bool Engine::is_initialized() const { return pimpl_->is_initialized(); }
64 ErrorStack Engine::initialize() { return pimpl_->initialize(); }
66 
67 EngineType Engine::get_type() const { return pimpl_->type_; }
68 bool Engine::is_master() const { return pimpl_->type_ == kMaster; }
69 bool Engine::is_emulated_child() const { return pimpl_->type_ == kChildEmulated; }
70 bool Engine::is_forked_child() const { return pimpl_->type_ == kChildForked; }
71 bool Engine::is_local_spawned_child() const { return pimpl_->type_ == kChildLocalSpawned; }
72 bool Engine::is_remote_spawned_child() const { return pimpl_->type_ == kChildRemoteSpawned; }
73 soc::SocId Engine::get_soc_id() const { return pimpl_->soc_id_; }
75 soc::Upid Engine::get_master_upid() const { return pimpl_->master_upid_; }
76 Eid Engine::get_master_eid() const { return pimpl_->master_eid_; }
77 
78 } // namespace foedus
EngineOptions options_
Options given at boot time.
std::string describe_short() const
Definition: engine.cpp:38
cache::CacheManager * get_cache_manager() const
See Snapshot Cache Manager.
Definition: engine.cpp:47
ErrorStack initialize() override
Starts up the database engine.
Definition: engine.cpp:64
debugging::DebuggingSupports debug_
Debugging supports.
storage::StorageManager storage_manager_
storage::StorageManager * get_storage_manager() const
See Storage Manager.
Definition: engine.cpp:60
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Pimpl object of Engine.
Eid get_master_eid() const
Returns Engine ID of the master engine.
Definition: engine.cpp:76
Engine()=delete
ErrorStack uninitialize() override final
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics...
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
A child SOC instance launched in other machines.
Definition: engine_type.hpp:87
soc::SocManager soc_manager_
SOC manager.
Procedure manager, which maintains the list of system/user procedures.
snapshot::SnapshotManager snapshot_manager_
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
savepoint::SavepointManager * get_savepoint_manager() const
See Savepoint Manager.
Definition: engine.cpp:53
proc::ProcManager proc_manager_
Snapshot manager that atomically and durably writes out a snapshot file.
std::string describe_short() const
soc::SocId get_soc_count() const
Shorthand for get_options().thread_.group_count_.
Definition: engine.cpp:74
savepoint::SavepointManager savepoint_manager_
EngineType get_type() const
Returns the type of this engine object.
Definition: engine.cpp:67
bool is_emulated_child() const
Returns if this engine object is a child instance running just as a thread.
Definition: engine.cpp:69
soc::Upid get_master_upid() const
Returns Universal (or Unique) ID of the master process.
Definition: engine.cpp:75
thread::ThreadPool thread_pool_
log::LogManager * get_log_manager() const
See Log Manager.
Definition: engine.cpp:49
const EngineType type_
ErrorStack initialize() override final
Typical implementation of Initializable::initialize() that provides initialize-once semantics...
A child SOC instance launched via spawn().
Definition: engine_type.hpp:78
~Engine()
Do NOT rely on this destructor to release resources.
Definition: engine.cpp:33
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_
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
A child SOC instance launched via fork().
Definition: engine_type.hpp:65
proc::ProcManager * get_proc_manager() const
See System and User Procedures.
Definition: engine.cpp:51
uint16_t group_count_
Number of ThreadGroup in the engine.
The central instance that launches child engines on each NUMA node (SOC).
Definition: engine_type.hpp:41
const soc::Upid master_upid_
EngineOptions * get_nonconst_options()
Returns an updatable reference to options.
Definition: engine.cpp:40
bool is_initialized() const override
Returns whether the engine is currently running.
Definition: engine.cpp:63
xct::XctManager * get_xct_manager() const
See Transaction Manager.
Definition: engine.cpp:61
log::LogManager log_manager_
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
Snapshot cache manager.
thread::ThreadOptions thread_
Storage Manager class that provides API to create/open/close/drop key-value stores.
soc::SocManager * get_soc_manager() const
See SOC and IPC.
Definition: engine.cpp:59
bool is_remote_spawned_child() const
Returns if this engine object is a child instance remotely launched by spawn.
Definition: engine.cpp:72
snapshot::SnapshotManager * get_snapshot_manager() const
See Snapshot Manager.
Definition: engine.cpp:56
soc::SocId get_soc_id() const
If this is a child instance, returns its SOC ID (NUMA node).
Definition: engine.cpp:73
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
debugging::DebuggingSupports * get_debug() const
See Debug-Support functionalities.
Definition: engine.cpp:48
APIs to support debugging functionalities.
Repository of all memories dynamically acquired and shared within one database engine.
#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
memory::EngineMemory * get_memory_manager() const
See Memory Manager.
Definition: engine.cpp:50
thread::ThreadPool * get_thread_pool() const
See Thread and Thread-Group.
Definition: engine.cpp:52
bool is_initialized() const override final
Returns whether the object has been already initialized or not.
The pool of pre-allocated threads in the engine to execute transactions.
bool is_local_spawned_child() const
Returns if this engine object is a child instance launched by spawn.
Definition: engine.cpp:71
bool is_forked_child() const
Returns if this engine object is a child instance launched by fork.
Definition: engine.cpp:70
Savepoint manager that atomically and durably writes out a savepoint file.
A child SOC instance launched just as a thread in the same process as master.
Definition: engine_type.hpp:51
ErrorStack uninitialize() override
Terminates the database engine.
Definition: engine.cpp:65