libfoedus-core
FOEDUS Core Library
savepoint_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_SAVEPOINT_SAVEPOINT_MANAGER_PIMPL_HPP_
19 #define FOEDUS_SAVEPOINT_SAVEPOINT_MANAGER_PIMPL_HPP_
20 
21 #include <atomic>
22 #include <thread>
23 
24 #include "foedus/epoch.hpp"
25 #include "foedus/fwd.hpp"
26 #include "foedus/initializable.hpp"
27 #include "foedus/fs/path.hpp"
28 #include "foedus/savepoint/fwd.hpp"
33 
34 namespace foedus {
35 namespace savepoint {
36 
39  // this is backed by shared memory. not instantiation. just reinterpret_cast.
42 
43  void initialize() {
49  }
50  void uninitialize() {
52  }
53 
54  std::atomic<bool> master_initialized_;
58 
72 
78 
85 
95 
101 };
102 
111  public:
112  SavepointManagerPimpl() = delete;
113  explicit SavepointManagerPimpl(Engine* engine) : engine_(engine) {}
114  ErrorStack initialize_once() override;
115  ErrorStack uninitialize_once() override;
116 
123  }
126  }
129  }
130  void update_shared_savepoint(const Savepoint& src);
132  ErrorStack take_savepoint(Epoch new_global_durable_epoch);
134  snapshot::SnapshotId new_snapshot_id,
135  Epoch new_snapshot_epoch);
136 
137  Engine* const engine_;
139 
140 
141  // the followings are used only in master. child SOCs just request the master to take savepoint.
142  void savepoint_main();
144 
146  std::thread savepoint_thread_;
147 
149 
152 
157 };
158 
159 static_assert(
161  "SavepointManagerControlBlock is too large.");
162 
163 } // namespace savepoint
164 } // namespace foedus
165 #endif // FOEDUS_SAVEPOINT_SAVEPOINT_MANAGER_PIMPL_HPP_
soc::SharedMutex savepoint_mutex_
Read/write to savepoint_ is protected with this mutex.
fs::Path savepoint_path_
Path of the savepoint file.
FixedSavepoint savepoint_
The content of latest savepoint.
soc::SharedPolling save_wakeup_
savepoint thread sleeps on this condition variable.
Epoch::EpochInteger new_snapshot_epoch_
Set with new_snapshot_id_.
snapshot::SnapshotId get_latest_snapshot_id() const
void initialize(bool recursive=false)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
snapshot::SnapshotId latest_snapshot_id_
Definition: savepoint.hpp:177
uint32_t EpochInteger
Unsigned integer representation of epoch.
Definition: epoch.hpp:64
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.
soc::SharedPolling save_done_event_
Whenever a savepoint has been taken, this event is fired.
A mutex that can be placed in shared memory and used from multiple processes.
Zero is always reserved for invalid epoch.
Definition: epoch.hpp:68
Epoch::EpochInteger saved_durable_epoch_
The durable epoch that has been made persistent in previous savepoint-ing.
Epoch::EpochInteger latest_snapshot_epoch_
Definition: savepoint.hpp:178
Analogue of boost::filesystem::path.
Definition: path.hpp:37
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
ErrorStack take_savepoint(Epoch new_global_durable_epoch)
ErrorStack take_savepoint_after_snapshot(snapshot::SnapshotId new_snapshot_id, Epoch new_snapshot_epoch)
uint16_t SnapshotId
Unique ID of Snapshot.
Definition: snapshot_id.hpp:43
const SnapshotId kNullSnapshotId
Definition: snapshot_id.hpp:45
Savepoint that can be stored in shared memory.
Definition: savepoint.hpp:169
Forward declarations of classes in savepoint manager package.
Savepoint savepoint_
The current progress of the entire engine.
snapshot::SnapshotId new_snapshot_id_
The ID of the new snapshot to remember.
Epoch::EpochInteger requested_durable_epoch_
Client SOC sets this value and then wakes up the savepoint thread.
Information in savepoint for one logger.
Definition: savepoint.hpp:140
uint16_t LoggerId
Typedef for an ID of Logger.
Definition: log_id.hpp:36
LoggerSavepointInfo get_logger_savepoint(log::LoggerId logger_id)
std::thread savepoint_thread_
The thread to take savepoints.