libfoedus-core
FOEDUS Core Library
log_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_LOG_LOG_MANAGER_PIMPL_HPP_
19 #define FOEDUS_LOG_LOG_MANAGER_PIMPL_HPP_
20 #include <stdint.h>
21 
22 #include <atomic>
23 #include <vector>
24 
25 #include "foedus/epoch.hpp"
26 #include "foedus/fwd.hpp"
27 #include "foedus/initializable.hpp"
28 #include "foedus/log/fwd.hpp"
31 #include "foedus/savepoint/fwd.hpp"
37 
38 namespace foedus {
39 namespace log {
40 
43  // this is backed by shared memory. not instantiation. just reinterpret_cast.
44  LogManagerControlBlock() = delete;
45  ~LogManagerControlBlock() = delete;
46 
47  void initialize() {
50  }
51  void uninitialize() {
53  }
54 
63  std::atomic<Epoch::EpochInteger> durable_global_epoch_;
64 
67 
70 };
71 
79 class LogManagerPimpl final : public DefaultInitializable {
80  public:
81  LogManagerPimpl() = delete;
82  explicit LogManagerPimpl(Engine* engine);
83  ErrorStack initialize_once() override;
84  ErrorStack uninitialize_once() override;
85 
86  void wakeup_loggers();
87  ErrorCode wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds);
89  void copy_logger_states(savepoint::Savepoint *new_savepoint);
90 
93  }
95  return Epoch(control_block_->durable_global_epoch_.load(std::memory_order_relaxed));
96  }
98 
99 
100  Engine* const engine_;
101 
104 
109  std::vector< Logger* > loggers_;
110 
112  std::vector< LoggerRef > logger_refs_;
113 
118 
120 };
121 
122 static_assert(
124  "LogManagerControlBlock is too large.");
125 
126 } // namespace log
127 } // namespace foedus
128 #endif // FOEDUS_LOG_LOG_MANAGER_PIMPL_HPP_
soc::SharedPolling durable_global_epoch_advanced_
Fired (broadcast) whenever durable_global_epoch_ is advanced.
std::vector< Logger * > loggers_
Local log writers.
std::atomic< Epoch::EpochInteger > durable_global_epoch_
The durable epoch of the entire engine.
ErrorStack uninitialize_once() override
Forward declarations of classes in log manager package.
void initialize(bool recursive=false)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Typedefs of ID types used in thread package.
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Represents a time epoch.
Definition: epoch.hpp:61
The information we maintain in savepoint manager and externalize to a file.
Definition: savepoint.hpp:40
A polling-wait mechanism that can be placed in shared memory and used from multiple processes...
Typical implementation of Initializable as a skeleton base class.
LogManagerControlBlock * control_block_
A log writer for metadata operation.
Pimpl object of LogManager.
A mutex that can be placed in shared memory and used from multiple processes.
MetaLogger * meta_logger_
Metadata log writer.
A single log buffer for metadata (eg create/drop storage).
MetaLogBuffer meta_buffer_
Metadata log buffer.
Shared data in LogManagerPimpl.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
std::vector< LoggerRef > logger_refs_
All log writers.
Epoch get_durable_global_epoch_weak() const
Forward declarations of classes in savepoint manager package.
ErrorStack initialize_once() override
void copy_logger_states(savepoint::Savepoint *new_savepoint)
soc::SharedMutex durable_global_epoch_savepoint_mutex_
To-be-removed Serializes the thread to take savepoint to advance durable_global_epoch_.
void announce_new_durable_global_epoch(Epoch new_epoch)
ErrorCode wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds)
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
Definition: thread_id.hpp:38
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85