libfoedus-core
FOEDUS Core Library
metadata.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_METADATA_HPP_
19 #define FOEDUS_STORAGE_METADATA_HPP_
20 #include <iosfwd>
21 #include <string>
22 
23 #include "foedus/assert_nd.hpp"
24 #include "foedus/cxx11.hpp"
27 #include "foedus/storage/fwd.hpp"
29 
30 namespace foedus {
31 namespace storage {
58 struct Metadata {
77  };
78 
81  }
82  Metadata(StorageId id, StorageType type, const StorageName& name)
83  : id_(id), type_(type), name_(name), root_snapshot_page_id_(0), snapshot_thresholds_() {}
85  StorageId id,
86  StorageType type,
87  const StorageName& name,
88  SnapshotPagePointer root_snapshot_page_id)
89  : id_(id),
90  type_(type),
91  name_(name),
92  root_snapshot_page_id_(root_snapshot_page_id),
94 
96  static std::string describe(const Metadata& metadata);
97 
98  bool keeps_all_volatile_pages() const {
99  return snapshot_thresholds_.snapshot_keep_threshold_ == 0xFFFFFFFFU;
100  }
101 
113 
115 };
116 
119  explicit MetadataSerializer(Metadata *data) : data_(data) {}
120  virtual ~MetadataSerializer() {}
121 
123  ErrorStack load_base(tinyxml2::XMLElement* element);
125  ErrorStack save_base(tinyxml2::XMLElement* element) const;
126 
128  storage::StorageId largest_storage_id,
129  tinyxml2::XMLElement* element,
130  StorageControlBlock* blocks);
132  storage::StorageId largest_storage_id,
133  tinyxml2::XMLElement* element,
134  StorageControlBlock* blocks);
135 
137 };
138 
139 } // namespace storage
140 } // namespace foedus
141 #endif // FOEDUS_STORAGE_METADATA_HPP_
Definitions of IDs in this package and a few related constant values.
Represents an object that can be written to and read from files/bytes in XML format.
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
ErrorStack load_base(tinyxml2::XMLElement *element)
common routine for the implementation of load()
Definition: metadata.cpp:50
bool keeps_all_volatile_pages() const
Definition: metadata.hpp:98
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
0 indicates invalid type.
Definition: storage_id.hpp:124
Metadata of one storage.
Definition: metadata.hpp:58
Metadata(StorageId id, StorageType type, const StorageName &name)
Definition: metadata.hpp:82
Forward declarations of classes in storage package.
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Definition: storage_id.hpp:79
uint32_t snapshot_keep_threshold_
[Only partially implemented] When a log gleaner created new snapshot pages for this storage...
Definition: metadata.hpp:76
StorageName name_
the unique name of this storage.
Definition: metadata.hpp:107
Tuning parameters related to snapshotting.
Definition: metadata.hpp:60
SnapshotThresholds snapshot_thresholds_
Definition: metadata.hpp:114
StorageType
Type of the storage, such as hash.
Definition: storage_id.hpp:122
StorageType type_
type of the storage.
Definition: metadata.hpp:105
static ErrorStack save_all_storages_to_xml(storage::StorageId largest_storage_id, tinyxml2::XMLElement *element, StorageControlBlock *blocks)
Definition: metadata.cpp:166
ErrorStack save_base(tinyxml2::XMLElement *element) const
common routine for the implementation of save()
Definition: metadata.cpp:66
static std::string describe(const Metadata &metadata)
to_string operator of all Metadata objects.
Definition: metadata.cpp:35
Metadata(StorageId id, StorageType type, const StorageName &name, SnapshotPagePointer root_snapshot_page_id)
Definition: metadata.hpp:84
uint32_t snapshot_trigger_threshold_
[Not implemented yet] If this storage has more than this number of volatile pages, log gleaner will soon start to drop some of the volatile pages.
Definition: metadata.hpp:67
A base layout of shared data for all storage types.
Definition: storage.hpp:53
StorageId id_
the unique ID of this storage.
Definition: metadata.hpp:103
static ErrorStack load_all_storages_from_xml(storage::StorageId largest_storage_id, tinyxml2::XMLElement *element, StorageControlBlock *blocks)
Definition: metadata.cpp:125
SnapshotPagePointer root_snapshot_page_id_
Pointer to a snapshotted page this storage is rooted at.
Definition: metadata.hpp:112