libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
savepoint_manager.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  */
19 
21 
22 namespace foedus {
23 namespace savepoint {
24 SavepointManager::SavepointManager(Engine* engine) : pimpl_(nullptr) {
25  pimpl_ = new SavepointManagerPimpl(engine);
26 }
28  delete pimpl_;
29  pimpl_ = nullptr;
30 }
31 
33 bool SavepointManager::is_initialized() const { return pimpl_->is_initialized(); }
35 
37  return pimpl_->get_initial_current_epoch();
38 }
40  return pimpl_->get_initial_durable_epoch();
41 }
43  return pimpl_->get_earliest_epoch();
44 }
45 
47  return pimpl_->get_saved_durable_epoch();
48 }
50  return pimpl_->get_latest_snapshot_id();
51 }
53  return pimpl_->get_latest_snapshot_epoch();
54 }
55 
57  return pimpl_->take_savepoint(new_global_durable_epoch);
58 }
60  snapshot::SnapshotId new_snapshot_id,
61  Epoch new_snapshot_epoch) {
62  return pimpl_->take_savepoint_after_snapshot(new_snapshot_id, new_snapshot_epoch);
63 }
64 
66  return pimpl_->get_logger_savepoint(logger_id);
67 }
68 
70  uint64_t* oldest_offset,
71  uint64_t* durable_offset) const {
72  *oldest_offset = pimpl_->control_block_->savepoint_.meta_log_oldest_offset_;
73  *durable_offset = pimpl_->control_block_->savepoint_.meta_log_durable_offset_;
74 }
75 
77  ASSERT_ND(pimpl_->control_block_->savepoint_.meta_log_durable_offset_ >= durable_offset);
78  pimpl_->control_block_->savepoint_.meta_log_durable_offset_ = durable_offset;
79 }
80 
81 } // namespace savepoint
82 } // namespace foedus
ErrorStack take_savepoint_after_snapshot(snapshot::SnapshotId new_snapshot_id, Epoch new_snapshot_epoch)
Takes a savepoint just to remember the newly taken snapshot.
snapshot::SnapshotId get_latest_snapshot_id() const
FixedSavepoint savepoint_
The content of latest savepoint.
snapshot::SnapshotId get_latest_snapshot_id() const
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
ErrorStack initialize() override
Acquires resources in this object, usually called right after constructor.
ErrorStack uninitialize() override final
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics...
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Represents a time epoch.
Definition: epoch.hpp:61
ErrorStack take_savepoint(Epoch new_global_durable_epoch)
Atomically and durably takes a savepoint for the given epoch advancement.
void change_meta_logger_durable_offset(uint64_t durable_offset)
Rewrites meta logger's durable_offset.
ErrorStack uninitialize() override
An idempotent method to release all resources of this object, if any.
ErrorStack initialize() override final
Typical implementation of Initializable::initialize() that provides initialize-once semantics...
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
void get_meta_logger_offsets(uint64_t *oldest_offset, uint64_t *durable_offset) const
Returns the saved information of metadata logger in lateset savepoint.
#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
Information in savepoint for one logger.
Definition: savepoint.hpp:140
uint16_t LoggerId
Typedef for an ID of Logger.
Definition: log_id.hpp:36
bool is_initialized() const override
Returns whether the object has been already initialized or not.
LoggerSavepointInfo get_logger_savepoint(log::LoggerId logger_id)
bool is_initialized() const override final
Returns whether the object has been already initialized or not.
LoggerSavepointInfo get_logger_savepoint(log::LoggerId logger_id)
Returns the saved information of the given logger in latest savepoint.