libfoedus-core
FOEDUS Core Library
savepoint.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_HPP_
19 #define FOEDUS_SAVEPOINT_SAVEPOINT_HPP_
20 #include <vector>
21 
22 #include "foedus/assert_nd.hpp"
23 #include "foedus/cxx11.hpp"
24 #include "foedus/epoch.hpp"
26 #include "foedus/log/log_id.hpp"
28 
29 namespace foedus {
30 namespace savepoint {
44  Savepoint();
45 
54 
66 
73 
85 
90 
91  // for all the following, index is LoggerId
92 
101  std::vector<log::LogFileOrdinal> oldest_log_files_;
102 
104  std::vector<uint64_t> oldest_log_files_offset_begin_;
105 
107  std::vector<log::LogFileOrdinal> current_log_files_;
108 
114  std::vector<uint64_t> current_log_files_offset_durable_;
115 
116  EXTERNALIZABLE(Savepoint);
117 
119  void populate_empty(log::LoggerId logger_count);
121  bool consistent(log::LoggerId logger_count) const {
123  return (current_epoch_ >= durable_epoch_
124  && current_epoch_ >= earliest_epoch_
125  && durable_epoch_ >= earliest_epoch_
126  && meta_log_oldest_offset_ <= meta_log_durable_offset_
127  && oldest_log_files_.size() == logger_count
128  && oldest_log_files_offset_begin_.size() == logger_count
129  && current_log_files_.size() == logger_count
130  && current_log_files_offset_durable_.size() == logger_count);
131  }
132 
133  Epoch get_durable_epoch() const { return Epoch(durable_epoch_); }
134  Epoch get_current_epoch() const { return Epoch(current_epoch_); }
135  Epoch get_earliest_epoch() const { return Epoch(earliest_epoch_); }
137  void assert_epoch_values() const;
138 };
150 
153 
156 
163 };
164 
170  // only for reinterpret_cast
173 
179 
181  uint16_t node_count_;
184 
187 
194 
195  uint32_t get_total_logger_count() const {
196  return static_cast<uint32_t>(node_count_) * loggers_per_node_count_;
197  }
198 
200  void update(uint16_t node_count, uint16_t loggers_per_node_count, const Savepoint& src);
201 };
202 
203 } // namespace savepoint
204 } // namespace foedus
205 #endif // FOEDUS_SAVEPOINT_SAVEPOINT_HPP_
std::vector< uint64_t > oldest_log_files_offset_begin_
Indicates the inclusive beginning of active region in the oldest log file.
Definition: savepoint.hpp:104
Epoch::EpochInteger current_epoch_
Definition: savepoint.hpp:174
Represents an object that can be written to and read from files/bytes in XML format.
Typedefs of ID types used in snapshot package.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Epoch get_earliest_epoch() const
Definition: savepoint.hpp:135
std::vector< uint64_t > current_log_files_offset_durable_
Indicates the exclusive end of durable region in the current log file.
Definition: savepoint.hpp:114
snapshot::SnapshotId latest_snapshot_id_
Definition: savepoint.hpp:177
uint32_t EpochInteger
Unsigned integer representation of epoch.
Definition: epoch.hpp:64
Savepoint()
Constructs an empty savepoint.
Definition: savepoint.cpp:22
#define EXTERNALIZABLE(clazz)
Macro to declare/define essential methods for an externalizable class.
log::LogFileOrdinal oldest_log_file_
Ordinal of the oldest active log file in each logger.
Definition: savepoint.hpp:149
Epoch::EpochInteger current_epoch_
Current epoch of the entire engine.
Definition: savepoint.hpp:53
Represents a time epoch.
Definition: epoch.hpp:61
The information we maintain in savepoint manager and externalize to a file.
Definition: savepoint.hpp:40
uint64_t meta_log_oldest_offset_
Offset from which metadata log entries are not gleaned yet.
Definition: savepoint.hpp:87
Typedefs of ID types used in log package.
uint64_t meta_log_durable_offset_
Offset upto which metadata log entries are fsynced.
Definition: savepoint.hpp:89
uint64_t oldest_log_file_offset_begin_
Indicates the inclusive beginning of active region in the oldest log file.
Definition: savepoint.hpp:155
uint64_t current_log_file_offset_durable_
Indicates the exclusive end of durable region in the current log file.
Definition: savepoint.hpp:162
Epoch::EpochInteger latest_snapshot_epoch_
Definition: savepoint.hpp:178
uint32_t LogFileOrdinal
Ordinal of log files (eg "log.0", "log.1").
Definition: log_id.hpp:46
Epoch::EpochInteger latest_snapshot_epoch_
The most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.
Definition: savepoint.hpp:84
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
log::LogFileOrdinal current_log_file_
Indicates the log file each logger is currently appending to.
Definition: savepoint.hpp:152
Epoch::EpochInteger durable_epoch_
Definition: savepoint.hpp:175
Epoch get_current_epoch() const
Definition: savepoint.hpp:134
uint16_t SnapshotId
Unique ID of Snapshot.
Definition: snapshot_id.hpp:43
void populate_empty(log::LoggerId logger_count)
Populate variables as an initial state.
Definition: savepoint.cpp:79
Savepoint that can be stored in shared memory.
Definition: savepoint.hpp:169
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
Epoch::EpochInteger earliest_epoch_
The earliest epoch that can exist in this system.
Definition: savepoint.hpp:72
uint16_t loggers_per_node_count_
Number of loggers per node.
Definition: savepoint.hpp:183
std::vector< log::LogFileOrdinal > oldest_log_files_
Ordinal of the oldest active log file in each logger.
Definition: savepoint.hpp:101
void assert_epoch_values() const
Check invariants on current_epoch_/durable_epoch_.
Definition: savepoint.cpp:25
LoggerSavepointInfo logger_info_[1U<< 16]
Stores all loggers' information.
Definition: savepoint.hpp:193
Epoch::EpochInteger earliest_epoch_
Definition: savepoint.hpp:176
Epoch get_durable_epoch() const
Definition: savepoint.hpp:133
uint32_t get_total_logger_count() const
Definition: savepoint.hpp:195
bool consistent(log::LoggerId logger_count) const
Tells if the variables are consistent.
Definition: savepoint.hpp:121
Information in savepoint for one logger.
Definition: savepoint.hpp:140
snapshot::SnapshotId latest_snapshot_id_
The most recent complete snapshot.
Definition: savepoint.hpp:78
Epoch::EpochInteger durable_epoch_
Latest epoch whose logs were all flushed to disk.
Definition: savepoint.hpp:65
uint16_t LoggerId
Typedef for an ID of Logger.
Definition: log_id.hpp:36
std::vector< log::LogFileOrdinal > current_log_files_
Indicates the log file each logger is currently appending to.
Definition: savepoint.hpp:107
uint16_t node_count_
Number of NUMA nodes.
Definition: savepoint.hpp:181
void update(uint16_t node_count, uint16_t loggers_per_node_count, const Savepoint &src)
Write out the content of the given Savepoint to this object.
Definition: savepoint.cpp:94