libfoedus-core
FOEDUS Core Library
composer.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_STORAGE_COMPOSER_HPP_
19 #define FOEDUS_STORAGE_COMPOSER_HPP_
20 
21 #include <iosfwd>
22 #include <string>
23 
24 #include "foedus/compiler.hpp"
25 #include "foedus/epoch.hpp"
26 #include "foedus/error_stack.hpp"
27 #include "foedus/fwd.hpp"
28 #include "foedus/cache/fwd.hpp"
30 #include "foedus/snapshot/fwd.hpp"
33 #include "foedus/storage/fwd.hpp"
36 
37 namespace foedus {
38 namespace storage {
87  public:
88  Composer(Engine *engine, StorageId storage_id);
89 
90  Engine* get_engine() { return engine_; }
91  StorageId get_storage_id() const { return storage_id_; }
92  StorageType get_storage_type() const { return storage_type_; }
93 
117  };
121  ErrorStack compose(const ComposeArguments& args);
122 
130  const Page* const* root_info_pages_;
137  };
138 
146 
152  uint16_t my_partition_;
163  uint64_t* dropped_count_;
164 
168  void drop(Engine* engine, VolatilePagePointer pointer) const;
169  };
171  struct DropResult {
172  explicit DropResult(const DropVolatilesArguments& args) {
173  max_observed_ = args.snapshot_.valid_until_epoch_; // min value to make store_max easier.
174  dropped_all_ = true; // "so far". zero-inspected, thus zero-failure.
175  }
176  inline void combine(const DropResult& other) {
178  dropped_all_ &= other.dropped_all_;
179  }
180 
181  inline void on_rec_observed(Epoch epoch) {
182  if (epoch > max_observed_) {
183  max_observed_ = epoch;
184  dropped_all_ = false;
185  }
186  }
187 
188  friend std::ostream& operator<<(std::ostream& o, const DropResult& v);
189 
203  bool padding_[3];
204  };
205 
218 
225  void drop_root_volatile(const DropVolatilesArguments& args);
226 
227  friend std::ostream& operator<<(std::ostream& o, const Composer& v);
228 
229  private:
230  Engine* const engine_;
231  const StorageId storage_id_;
232  const StorageType storage_type_;
233 };
234 
235 } // namespace storage
236 } // namespace foedus
237 #endif // FOEDUS_STORAGE_COMPOSER_HPP_
const Page *const * root_info_pages_
Root info pages output by compose()
Definition: composer.hpp:130
memory::PagePoolOffsetChunk * dropped_chunks_
Caches dropped pages to avoid returning every single page.
Definition: composer.hpp:161
Epoch max_observed_
the largest Epoch it observed recursively.
Definition: composer.hpp:200
snapshot::LogGleanerResource * gleaner_resource_
All pre-allocated resouces to help run construct_root(), such as memory buffers.
Definition: composer.hpp:134
Epoch base_epoch_
All log entries in this inputs are assured to be after this epoch.
Definition: composer.hpp:110
Definitions of IDs in this package and a few related constant values.
ErrorStack construct_root(const ConstructRootArguments &args)
Construct root page(s) for one storage based on the ouputs of compose().
Definition: composer.cpp:72
Typedefs of ID types used in snapshot package.
DropResult drop_volatiles(const DropVolatilesArguments &args)
Drops volatile pages that have not been modified since the snapshotted epoch.
Definition: composer.cpp:83
Represents a logic to compose a new version of data pages for one storage.
Definition: composer.hpp:86
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
friend std::ostream & operator<<(std::ostream &o, const DropResult &v)
Definition: composer.cpp:46
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
friend std::ostream & operator<<(std::ostream &o, const Composer &v)
Definition: composer.cpp:39
Typedefs of ID types used in thread package.
Epoch valid_until_epoch_
This snapshot contains all the logs until this epoch.
Definition: snapshot.hpp:55
Represents a pointer to a volatile page with modification count for preventing ABA.
Definition: storage_id.hpp:194
Forward declarations of classes in root package.
Local resource for the log gleaner, which runs only in the master node.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
StorageId get_storage_id() const
Definition: composer.hpp:91
Forward declarations of classes in snapshot manager package.
Represents a time epoch.
Definition: epoch.hpp:61
Represents one input stream of sorted log entries.
Definition: log_buffer.hpp:81
Composer(Engine *engine, StorageId storage_id)
Definition: composer.cpp:55
cache::SnapshotFileSet * previous_snapshot_files_
To read existing snapshots.
Definition: composer.hpp:99
Holds a set of read-only file objects for snapshot files.
uint32_t log_streams_count_
Number of sorted runs.
Definition: composer.hpp:103
Forward declarations of classes in cache package.
Forward declarations of classes in storage package.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Definition: storage_id.hpp:79
Page * root_info_page_
[OUT] Returns pointers and related information that is required to construct the root page...
Definition: composer.hpp:116
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
ErrorStack compose(const ComposeArguments &args)
Construct snapshot pages from sorted run files of one storage.
Definition: composer.cpp:61
Just a marker to denote that the memory region represents a data page.
Definition: page.hpp:334
Represents one snapshot that converts all logs from base epoch to valid_until epoch into snapshot fil...
Definition: snapshot.hpp:37
Retrun value of drop_volatiles()
Definition: composer.hpp:171
SnapshotPagePointer * new_root_page_pointer_
[OUT] Returns pointer to new root snapshot page/
Definition: composer.hpp:136
bool dropped_all_
Whether all volatile pages under the page was dropped.
Definition: composer.hpp:202
uint16_t my_partition_
if partitioned_drop_ is true, the partition this thread should drop volatile pages from ...
Definition: composer.hpp:152
cache::SnapshotFileSet * previous_snapshot_files_
To read existing snapshots.
Definition: composer.hpp:128
StorageType
Type of the storage, such as hash.
Definition: storage_id.hpp:122
DropResult(const DropVolatilesArguments &args)
Definition: composer.hpp:172
void store_max(const Epoch &other)
Kind of std::max(this, other).
Definition: epoch.hpp:165
To reduce the overhead of grabbing/releasing pages from pool, we pack this many pointers for each gra...
Definition: page_pool.hpp:47
snapshot::SnapshotWriter * snapshot_writer_
Writes out composed pages.
Definition: composer.hpp:126
snapshot::SnapshotWriter * snapshot_writer_
Writes out composed pages.
Definition: composer.hpp:97
Represents one memory block aligned to actual OS/hardware pages.
bool partitioned_drop_
if true, one thread for each partition will invoke drop_volatiles()
Definition: composer.hpp:154
uint32_t root_info_pages_count_
Number of root info pages.
Definition: composer.hpp:132
void drop_root_volatile(const DropVolatilesArguments &args)
This is additionally called when no partitions observed any new modifications.
Definition: composer.cpp:94
void combine(const DropResult &other)
Definition: composer.hpp:176
StorageType get_storage_type() const
Definition: composer.hpp:92
uint64_t * dropped_count_
[OUT] Number of volatile pages that were dropped
Definition: composer.hpp:163
snapshot::SortedBuffer *const * log_streams_
Sorted runs.
Definition: composer.hpp:101
snapshot::Snapshot snapshot_
The new snapshot.
Definition: composer.hpp:150
void drop(Engine *engine, VolatilePagePointer pointer) const
Returns (might cache) the given pointer to volatile pool.
Definition: composer.cpp:114
memory::AlignedMemory * work_memory_
Working memory to be used in this method.
Definition: composer.hpp:105
Writes out one snapshot file for all data pages in one reducer.