libfoedus-core
FOEDUS Core Library
savepoint.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  */
20 namespace foedus {
21 namespace savepoint {
23 }
24 
26  ASSERT_ND(Epoch(current_epoch_).is_valid());
27  ASSERT_ND(Epoch(durable_epoch_).is_valid());
28  ASSERT_ND(Epoch(earliest_epoch_).is_valid());
32  ASSERT_ND(!Epoch(latest_snapshot_epoch_).is_valid() ||
34 }
35 
36 ErrorStack Savepoint::load(tinyxml2::XMLElement* element) {
49  return kRetOk;
50 }
51 
52 ErrorStack Savepoint::save(tinyxml2::XMLElement* element) const {
54  CHECK_ERROR(insert_comment(element, "progress of the entire engine"));
55 
56  EXTERNALIZE_SAVE_ELEMENT(element, current_epoch_, "Current epoch of the entire engine.");
58  "Latest epoch whose logs were all flushed to disk");
60  "The earliest epoch that can exist in this system");
61  EXTERNALIZE_SAVE_ELEMENT(element, latest_snapshot_id_, "The most recent complete snapshot.");
63  "The most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.");
65  "Offset from which metadata log entries are not gleaned yet");
67  "Offset upto which metadata log entries are fsynced");
69  "Ordinal of the oldest active log file in each logger");
71  "Indicates the inclusive beginning of active region in the oldest log file");
73  "Indicates the log file each logger is currently appending to");
75  "Indicates the exclusive end of durable region in the current log file");
76  return kRetOk;
77 }
78 
87  oldest_log_files_.resize(logger_count, 0);
88  oldest_log_files_offset_begin_.resize(logger_count, 0);
89  current_log_files_.resize(logger_count, 0);
90  current_log_files_offset_durable_.resize(logger_count, 0);
92 }
93 
95  uint16_t node_count,
96  uint16_t loggers_per_node_count,
97  const Savepoint& src) {
98  node_count_ = node_count;
99  loggers_per_node_count_ = loggers_per_node_count;
107  uint32_t count = get_total_logger_count();
108  for (uint32_t i = 0; i < count; ++i) {
113  }
114 }
115 
116 } // namespace savepoint
117 } // namespace foedus
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
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
The first epoch (before wrap-around) that might have transactions is ep-3.
Definition: epoch.hpp:77
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
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
Savepoint()
Constructs an empty savepoint.
Definition: savepoint.cpp:22
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
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
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
uint64_t meta_log_oldest_offset_
Offset from which metadata log entries are not gleaned yet.
Definition: savepoint.hpp:87
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
Zero is always reserved for invalid epoch.
Definition: epoch.hpp:68
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
ErrorStack save(tinyxml2::XMLElement *element) const override
Writes the content of this object to the given XML element.
Definition: savepoint.cpp:52
ErrorStack load(tinyxml2::XMLElement *element) override
Reads the content of this object from the given XML element.
Definition: savepoint.cpp:36
Epoch::EpochInteger latest_snapshot_epoch_
The most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.
Definition: savepoint.hpp:84
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
void populate_empty(log::LoggerId logger_count)
Populate variables as an initial state.
Definition: savepoint.cpp:79
const SnapshotId kNullSnapshotId
Definition: snapshot_id.hpp:45
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
Epoch::EpochInteger earliest_epoch_
The earliest epoch that can exist in this system.
Definition: savepoint.hpp:72
const ErrorStack kRetOk
Normal return value for no-error case.
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
As there is no transaction in ep-1, initial durable_epoch is 1.
Definition: epoch.hpp:70
void assert_epoch_values() const
Check invariants on current_epoch_/durable_epoch_.
Definition: savepoint.cpp:25
#define EXTERNALIZE_SAVE_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
LoggerSavepointInfo logger_info_[1U<< 16]
Stores all loggers' information.
Definition: savepoint.hpp:193
Epoch::EpochInteger earliest_epoch_
Definition: savepoint.hpp:176
#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
uint32_t get_total_logger_count() const
Definition: savepoint.hpp:195
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