libfoedus-core
FOEDUS Core Library
meta_log_buffer.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_LOG_META_LOG_BUFFER_HPP_
19 #define FOEDUS_LOG_META_LOG_BUFFER_HPP_
20 #include <stdint.h>
21 
22 #include <iosfwd>
23 
24 #include "foedus/attachable.hpp"
25 #include "foedus/epoch.hpp"
26 #include "foedus/error_stack.hpp"
27 #include "foedus/fwd.hpp"
28 #include "foedus/log/fwd.hpp"
31 
32 namespace foedus {
33 namespace log {
34 
39  void initialize() {
42  buffer_used_ = 0;
43  oldest_offset_ = 0;
44  durable_offset_ = 0;
45  }
46  void uninitialize() {
48  }
49 
50  bool has_waiting_log() const { return buffer_used_ > 0; }
51 
57  char buffer_[1 << 12];
58  uint32_t buffer_used_;
60  uint64_t oldest_offset_;
62  uint64_t durable_offset_;
71 };
72 
91 class MetaLogBuffer : public Attachable<MetaLogControlBlock> {
92  public:
95  : Attachable<MetaLogControlBlock>(engine, block) {}
96 
100  void commit(BaseLogType* metalog, Epoch* commit_epoch);
101 
102  friend std::ostream& operator<<(std::ostream& o, const MetaLogBuffer& v);
103 };
104 } // namespace log
105 } // namespace foedus
106 #endif // FOEDUS_LOG_META_LOG_BUFFER_HPP_
107 
soc::SharedPolling logger_wakeup_
the logger sleeps on this variable
Forward declarations of classes in log manager package.
void initialize(bool recursive=false)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
char buffer_[1<< 12]
The content of current log buffer.
MetaLogBuffer(Engine *engine, MetaLogControlBlock *block)
Forward declarations of classes in root package.
Represents a time epoch.
Definition: epoch.hpp:61
A polling-wait mechanism that can be placed in shared memory and used from multiple processes...
Base class for log type.
A mutex that can be placed in shared memory and used from multiple processes.
A single log buffer for metadata (eg create/drop storage).
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
soc::SharedMutex mutex_
Accesses in MetaLogBuffer are protected with this mutex.
Attachable Resources on Shared Memory.
Definition: attachable.hpp:58
uint64_t durable_offset_
Offset upto which log entries are fsynced.
friend std::ostream & operator<<(std::ostream &o, const MetaLogBuffer &v)
void commit(BaseLogType *metalog, Epoch *commit_epoch)
Synchronously writes out the given log to metadata log file.
uint64_t oldest_offset_
Offset from which log entries are not gleaned yet.
Control block for MetaLogBuffer and MetaLogger.