libfoedus-core
FOEDUS Core Library
log_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  */
18 #include "foedus/assert_nd.hpp"
21 namespace foedus {
22 namespace log {
23 LogManager::LogManager(Engine* engine) : pimpl_(nullptr) {
24  pimpl_ = new LogManagerPimpl(engine);
25 }
27  delete pimpl_;
28  pimpl_ = nullptr;
29 }
30 
32 bool LogManager::is_initialized() const { return pimpl_->is_initialized(); }
34 
37  return pimpl_->get_durable_global_epoch();
38 }
40  return pimpl_->get_durable_global_epoch_weak();
41 }
43  pimpl_->announce_new_durable_global_epoch(new_epoch);
44 }
45 
46 ErrorCode LogManager::wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds) {
47  return pimpl_->wait_until_durable(commit_epoch, wait_microseconds);
48 }
50  ASSERT_ND(logger_id < pimpl_->logger_refs_.size());
51  return pimpl_->logger_refs_[logger_id];
52 }
53 
55  return pimpl_->refresh_global_durable_epoch();
56 }
58  pimpl_->copy_logger_states(new_savepoint);
59 }
60 
62  return &pimpl_->meta_buffer_;
63 }
64 
66  return pimpl_->meta_logger_;
67 }
68 
69 } // namespace log
70 } // namespace foedus
LoggerRef get_logger(LoggerId logger_id)
Returns a reference to the logger of the given ID.
Definition: log_manager.cpp:49
MetaLogBuffer * get_meta_buffer()
Definition: log_manager.cpp:61
MetaLogger * get_meta_logger()
Definition: log_manager.cpp:65
void wakeup_loggers()
Wake up loggers if they are sleeping.
Definition: log_manager.cpp:35
Epoch get_durable_global_epoch_weak() const
Non-atomic version of the method.
Definition: log_manager.cpp:39
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
bool is_initialized() const override
Returns whether the object has been already initialized or not.
Definition: log_manager.cpp:32
ErrorStack uninitialize() override
An idempotent method to release all resources of this object, if any.
Definition: log_manager.cpp:33
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
The information we maintain in savepoint manager and externalize to a file.
Definition: savepoint.hpp:40
ErrorStack refresh_global_durable_epoch()
Called whenever there is a chance that the global durable epoch advances.
Definition: log_manager.cpp:54
A log writer for metadata operation.
Pimpl object of LogManager.
ErrorStack initialize() override
Acquires resources in this object, usually called right after constructor.
Definition: log_manager.cpp:31
void copy_logger_states(savepoint::Savepoint *new_savepoint)
Fillup the given savepoint with the current information of the loggers.
Definition: log_manager.cpp:57
A view of Logger object for other SOCs and master engine.
Definition: logger_ref.hpp:35
MetaLogger * meta_logger_
Metadata log writer.
A single log buffer for metadata (eg create/drop storage).
MetaLogBuffer meta_buffer_
Metadata log buffer.
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
std::vector< LoggerRef > logger_refs_
All log writers.
Epoch get_durable_global_epoch_weak() const
ErrorCode wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds=-1)
Synchronously blocks until the durable global epoch reaches the given commit epoch or the given durat...
Definition: log_manager.cpp:46
Epoch get_durable_global_epoch() const
Returns the durable epoch of the entire engine.
Definition: log_manager.cpp:36
void announce_new_durable_global_epoch(Epoch new_epoch)
Sets the new global durable epoch and also wakes up threads that were waiting for it...
Definition: log_manager.cpp:42
void copy_logger_states(savepoint::Savepoint *new_savepoint)
void announce_new_durable_global_epoch(Epoch new_epoch)
ErrorCode wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds)
#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
uint16_t LoggerId
Typedef for an ID of Logger.
Definition: log_id.hpp:36
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85
bool is_initialized() const override final
Returns whether the object has been already initialized or not.