libfoedus-core
FOEDUS Core Library
engine_memory.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_MEMORY_ENGINE_MEMORY_HPP_
19 #define FOEDUS_MEMORY_ENGINE_MEMORY_HPP_
20 
21 #include <string>
22 #include <vector>
23 
24 #include "foedus/assert_nd.hpp"
25 #include "foedus/cxx11.hpp"
26 #include "foedus/error_stack.hpp"
27 #include "foedus/fwd.hpp"
28 #include "foedus/initializable.hpp"
29 #include "foedus/cache/fwd.hpp"
31 #include "foedus/memory/fwd.hpp"
34 #include "foedus/storage/fwd.hpp"
36 
37 namespace foedus {
38 namespace memory {
53  public:
55  explicit EngineMemory(Engine* engine) : engine_(engine), local_memory_(CXX11_NULLPTR) {}
58 
64  void* get_shared_user_memory() const;
70  uint64_t get_shared_user_memory_size() const;
71 
72  // accessors for child memories
74  return local_memory_;
75  }
77  return node_memories_[group];
78  }
79 
81  std::string dump_free_memory_stat() const;
82 
91  return global_volatile_page_resolver_;
92  }
93 
102  storage::Page** page);
103 
110  cache::SnapshotFileSet* fileset,
111  storage::SnapshotPagePointer snapshot_pointer,
113  storage::Page** page);
114 
115  private:
116  Engine* const engine_;
117 
122  NumaNodeMemory* local_memory_;
123 
127  std::vector<NumaNodeMemoryRef*> node_memories_;
128 
132  GlobalVolatilePageResolver global_volatile_page_resolver_;
133 };
134 } // namespace memory
135 } // namespace foedus
136 #endif // FOEDUS_MEMORY_ENGINE_MEMORY_HPP_
ErrorStack uninitialize_once() override
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Typedefs of ID types used in thread package.
const GlobalVolatilePageResolver & get_global_volatile_page_resolver() const
Returns the page resolver to convert volatile page ID to page pointer.
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.
ErrorStack load_one_volatile_page(cache::SnapshotFileSet *fileset, storage::SnapshotPagePointer snapshot_pointer, storage::VolatilePagePointer *pointer, storage::Page **page)
Another convenience method that also reads an existing snapshot page to the volatile page...
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Typical implementation of Initializable as a skeleton base class.
Holds a set of read-only file objects for snapshot files.
ErrorStack initialize_once() override
void * get_shared_user_memory() const
As part of the global shared memory, we reserve this size of 'user memory' that can be used for arbit...
Forward declarations of classes in cache package.
A view of NumaNodeMemory for other SOCs and master engine.
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
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
Repository of memories dynamically acquired and shared within one NUMA node (socket).
NumaNodeMemoryRef * get_node_memory(foedus::thread::ThreadGroupId group) const
Just a marker to denote that the memory region represents a data page.
Definition: page.hpp:334
ErrorStack grab_one_volatile_page(foedus::thread::ThreadGroupId node, storage::VolatilePagePointer *pointer, storage::Page **page)
A convenience function to grab one free volatile page from the given node.
uint64_t get_shared_user_memory_size() const
Forward declarations of classes in memory package.
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
Definition: cxx11.hpp:134
std::string dump_free_memory_stat() const
Report rough statistics of free memory.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
NumaNodeMemory * get_local_memory() const
Resolves an offset in a volatile page pool to an actual pointer and vice versa.
Repository of all memories dynamically acquired and shared within one database engine.
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
Definition: thread_id.hpp:38