libfoedus-core
FOEDUS Core Library
snapshot_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  */
20 namespace foedus {
21 namespace snapshot {
22 SnapshotManager::SnapshotManager(Engine* engine) : pimpl_(nullptr) {
23  pimpl_ = new SnapshotManagerPimpl(engine);
24 }
26  delete pimpl_;
27  pimpl_ = nullptr;
28 }
29 
31 bool SnapshotManager::is_initialized() const { return pimpl_->is_initialized(); }
33 
36  return pimpl_->get_snapshot_epoch_weak();
37 }
38 
40  return pimpl_->get_previous_snapshot_id();
41 }
42 
44  return pimpl_->get_previous_snapshot_id_weak();
45 }
46 
48  return pimpl_->read_snapshot_metadata(snapshot_id, out);
49 }
50 
51 
53  bool wait_completion,
54  Epoch suggested_snapshot_epoch) {
55  pimpl_->trigger_snapshot_immediate(wait_completion, suggested_snapshot_epoch);
56 }
57 
58 } // namespace snapshot
59 } // namespace foedus
ErrorStack uninitialize() override
An idempotent method to release all resources of this object, if any.
Represents the data in one snapshot metadata file.
ErrorStack read_snapshot_metadata(SnapshotId snapshot_id, SnapshotMetadata *out)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
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 read_snapshot_metadata(SnapshotId snapshot_id, SnapshotMetadata *out)
Read the snapshot metadata file that contains storages as of the snapshot.
Epoch get_snapshot_epoch_weak() const
Non-atomic version.
void trigger_snapshot_immediate(bool wait_completion, Epoch suggested_snapshot_epoch=INVALID_EPOCH)
Immediately take a snapshot.
SnapshotId get_previous_snapshot_id_weak() const
Non-atomic version.
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
uint16_t SnapshotId
Unique ID of Snapshot.
Definition: snapshot_id.hpp:43
bool is_initialized() const override
Returns whether the object has been already initialized or not.
SnapshotId get_previous_snapshot_id() const
Returns the most recent snapshot's ID.
ErrorStack initialize() override
Acquires resources in this object, usually called right after constructor.
Epoch get_snapshot_epoch() const
Returns the most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.
void trigger_snapshot_immediate(bool wait_completion, Epoch suggested_snapshot_epoch)
bool is_initialized() const override final
Returns whether the object has been already initialized or not.