libfoedus-core
FOEDUS Core Library
engine.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_HPP_
19 #define FOEDUS_ENGINE_HPP_
20 
21 #include <string>
22 
23 #include "foedus/cxx11.hpp"
24 #include "foedus/engine_type.hpp"
25 #include "foedus/epoch.hpp"
26 #include "foedus/error_stack.hpp"
27 #include "foedus/initializable.hpp"
28 #include "foedus/module_type.hpp"
29 #include "foedus/cache/fwd.hpp"
30 #include "foedus/debugging/fwd.hpp"
31 #include "foedus/log/fwd.hpp"
32 #include "foedus/memory/fwd.hpp"
33 #include "foedus/proc/fwd.hpp"
34 #include "foedus/restart/fwd.hpp"
35 #include "foedus/savepoint/fwd.hpp"
36 #include "foedus/snapshot/fwd.hpp"
37 #include "foedus/soc/fwd.hpp"
38 #include "foedus/soc/soc_id.hpp"
39 #include "foedus/storage/fwd.hpp"
40 #include "foedus/thread/fwd.hpp"
41 #include "foedus/xct/fwd.hpp"
42 namespace foedus {
43 
44 // forward declarations
45 class EnginePimpl;
46 struct EngineOptions;
47 
109 class Engine CXX11_FINAL : public virtual Initializable {
110  public:
118  explicit Engine(const EngineOptions &options);
119 
130  Engine(EngineType type, soc::Upid master_upid, Eid master_eid, soc::SocId soc_id);
131 
140  ~Engine();
141 
142  // Disable default constructors
146 
147  std::string describe_short() const;
148 
154 
159  bool is_initialized() const CXX11_OVERRIDE;
160 
166 
168  const EngineOptions& get_options() const;
193 
195  EngineType get_type() const;
197  bool is_master() const;
199  bool is_emulated_child() const;
201  bool is_forked_child() const;
203  bool is_local_spawned_child() const;
205  bool is_remote_spawned_child() const;
207  soc::SocId get_soc_id() const;
209  soc::SocId get_soc_count() const;
211  soc::Upid get_master_upid() const;
213  Eid get_master_eid() const;
226  Epoch get_earliest_epoch() const;
227 
234 
242 
249 
256 
257  private:
258  EnginePimpl* pimpl_;
259 };
260 } // namespace foedus
261 #endif // FOEDUS_ENGINE_HPP_
restart::RestartManager * get_restart_manager() const
See Restart Manager.
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
storage::StorageManager * get_storage_manager() const
See Storage Manager.
Definition: engine.cpp:60
The pure-virtual interface to initialize/uninitialize non-trivial resources.
Forward declarations of classes in log manager package.
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
Forward declarations of classes in transaction package.
Engine()=delete
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Forward declarations of classes in snapshot manager package.
Represents a time epoch.
Definition: epoch.hpp:61
Typedefs of ID types used in SOC package.
Forward declarations of classes in debugging package.
Procedure manager, which maintains the list of system/user procedures.
Forward declarations of classes in cache package.
const EngineOptions & get_options() const
Definition: engine.cpp:39
Epoch get_durable_global_epoch() const
Returns the durable epoch of the entire engine.
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
Forward declarations of classes in restart package.
Snapshot manager that atomically and durably writes out a snapshot file.
soc::SocId get_soc_count() const
Shorthand for get_options().thread_.group_count_.
Definition: engine.cpp:74
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
Forward declarations of classes in storage package.
log::LogManager * get_log_manager() const
See Log Manager.
Definition: engine.cpp:49
Epoch get_current_global_epoch() const
Returns the current global epoch, the epoch a newly started transaction will be in.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
~Engine()
Do NOT rely on this destructor to release resources.
Definition: engine.cpp:33
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
Xct Manager class that provides API to begin/abort/commit transaction.
Definition: xct_manager.hpp:35
uint64_t Upid
Universal (or Unique) ID of a process.
Definition: soc_id.hpp:48
Log Manager class that provides API to write/read transaction logs.
Definition: log_manager.hpp:36
proc::ProcManager * get_proc_manager() const
See System and User Procedures.
Definition: engine.cpp:51
EngineOptions * get_nonconst_options()
Returns an updatable reference to options.
Definition: engine.cpp:40
Forward declarations of classes in memory package.
bool is_initialized() const override
Returns whether the engine is currently running.
Definition: engine.cpp:63
Engine & operator=(const Engine &)=delete
xct::XctManager * get_xct_manager() const
See Transaction Manager.
Definition: engine.cpp:61
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
Definition: cxx11.hpp:134
Forward declarations of classes in SOC package.
uint16_t SocId
Represents an ID of an SOC, or NUMA node.
Definition: soc_id.hpp:41
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
Forward declarations of classes in savepoint manager package.
Snapshot cache manager.
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
Epoch get_current_grace_epoch() const
Returns the current grace-period epoch (global epoch - 1), the epoch some transaction might be still ...
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.
Epoch get_earliest_epoch() const
Returns the Earliest-Epoch, the minimum epoch that is valid within this engine.
Forward declarations of classes in thread package.
Forward declarations of classes in proc package.
Restart manager, which recovers the state of database by invoking log-gleaner at start-up.
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
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.
ErrorStack uninitialize() override
Terminates the database engine.
Definition: engine.cpp:65