libfoedus-core
FOEDUS Core Library
storage_manager.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_STORAGE_MANAGER_HPP_
19 #define FOEDUS_STORAGE_STORAGE_MANAGER_HPP_
20 #include <string>
21 
22 #include "foedus/cxx11.hpp"
23 #include "foedus/fwd.hpp"
24 #include "foedus/initializable.hpp"
25 #include "foedus/snapshot/fwd.hpp"
26 #include "foedus/storage/fwd.hpp"
36 #include "foedus/thread/fwd.hpp"
37 #include "foedus/xct/fwd.hpp"
38 #include "foedus/xct/xct_id.hpp"
39 
40 namespace foedus {
41 namespace storage {
46 class StorageManager CXX11_FINAL : public virtual Initializable {
47  public:
48  explicit StorageManager(Engine* engine);
50 
51  // Disable default constructors
55 
56  Engine* get_engine() const;
58  bool is_initialized() const CXX11_OVERRIDE;
60 
65 
74 
79  const StorageName& get_name(StorageId id);
80 
88 
96  }
97 
105  }
106 
114  }
115 
123  }
124 
134 
141  return array::ArrayStorage(get_engine(), get_storage(name));
142  }
143 
150  return hash::HashStorage(get_engine(), get_storage(name));
151  }
152 
160  }
161 
169  }
170 
178  ErrorStack drop_storage(StorageId id, Epoch *commit_epoch);
180  void drop_storage_apply(StorageId id);
181 
190  ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch);
192  void create_storage_apply(const Metadata& metadata);
193 
199  array::ArrayMetadata *metadata,
200  array::ArrayStorage *storage,
201  Epoch *commit_epoch);
202 
208  hash::HashMetadata *metadata,
209  hash::HashStorage *storage,
210  Epoch *commit_epoch);
211 
219  Epoch *commit_epoch);
220 
226  masstree::MasstreeMetadata *metadata,
227  masstree::MasstreeStorage *storage,
228  Epoch *commit_epoch);
229 
235 
247  StorageId storage_id,
248  xct::RwLockableXctId* old_address,
249  xct::WriteXctAccess* write_set);
250 
252  StorageManagerPimpl* get_pimpl() { return pimpl_; }
253 
254  private:
255  StorageManagerPimpl *pimpl_;
256 };
257 } // namespace storage
258 } // namespace foedus
259 #endif // FOEDUS_STORAGE_STORAGE_MANAGER_HPP_
Represents the data in one snapshot metadata file.
StorageManagerPimpl * get_pimpl()
Returns pimpl object.
sequential::SequentialStorage get_sequential(StorageId id)
Returns the sequential storage of given ID.
Definitions of IDs in this package and a few related constant values.
The pure-virtual interface to initialize/uninitialize non-trivial resources.
ErrorStack drop_storage(StorageId id, Epoch *commit_epoch)
Removes the storage object.
ErrorStack create_hash(hash::HashMetadata *metadata, hash::HashStorage *storage, Epoch *commit_epoch)
Just a type-wrapper of create_storage() for hash storages.
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
Represents a record of write-access during a transaction.
Definition: xct_access.hpp:168
Represents a key-value store based on a dense and regular array.
ErrorStack initialize() override
Acquires resources in this object, usually called right after constructor.
Forward declarations of classes in transaction package.
Result of track_moved_record().
Definition: xct_id.hpp:1180
ErrorStack create_sequential(sequential::SequentialMetadata *metadata, sequential::SequentialStorage *storage, Epoch *commit_epoch)
Just a type-wrapper of create_storage() for sequential storages.
array::ArrayStorage get_array(StorageId id)
Returns the array storage of given ID.
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Forward declarations of classes in snapshot manager package.
Represents a time epoch.
Definition: epoch.hpp:61
ErrorStack clone_all_storage_metadata(snapshot::SnapshotMetadata *metadata)
This method is called during snapshotting to clone metadata of all existing storages to the given obj...
Forward declarations of classes in array storage package.
ErrorStack create_masstree(masstree::MasstreeMetadata *metadata, masstree::MasstreeStorage *storage, Epoch *commit_epoch)
Just a type-wrapper of create_storage() for masstree storages.
array::ArrayStorage get_array(const StorageName &name)
Returns the array storage of given name.
void create_storage_apply(const Metadata &metadata)
This is called while restart to apply CREATE STORAGE logs.
masstree::MasstreeStorage get_masstree(StorageId id)
Returns the masstree storage of given ID.
The MCS reader-writer lock variant of LockableXctId.
Definition: xct_id.hpp:1132
Metadata of one storage.
Definition: metadata.hpp:58
Represents an append/scan-only store.
Forward declarations of classes in sequential storage package.
StorageId issue_next_storage_id()
Issue a unique and atomically/monotonically increasing storage ID for a new storage.
Forward declarations of classes in storage package.
Definitions of IDs in this package and a few related constant values.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
bool is_initialized() const override
Returns whether the object has been already initialized or not.
hash::HashStorage get_hash(const StorageName &name)
Returns the hash storage of given name.
Metadata of an array storage.
ErrorStack create_array(array::ArrayMetadata *metadata, array::ArrayStorage *storage, Epoch *commit_epoch)
Just a type-wrapper of create_storage() for array storages.
Pimpl object of StorageManager.
masstree::MasstreeStorage get_masstree(const StorageName &name)
Returns the masstree storage of given name.
sequential::SequentialStorage get_sequential(const StorageName &name)
Returns the sequential storage of given name.
Represents a key-value store based on a dense and regular hash.
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
Definition: cxx11.hpp:134
StorageId get_largest_storage_id()
Returns the largest StorageId that does or did exist.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
ErrorStack uninitialize() override
An idempotent method to release all resources of this object, if any.
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)
Newly creates a storage with the specified metadata and registers it to this manager.
Storage Manager class that provides API to create/open/close/drop key-value stores.
Metadata of an hash storage.
xct::TrackMovedRecordResult track_moved_record(StorageId storage_id, xct::RwLockableXctId *old_address, xct::WriteXctAccess *write_set)
Resolves a "moved" record.
const StorageName & get_name(StorageId id)
Returns the name of the given storage ID.
hash::HashStorage get_hash(StorageId id)
Returns the hash storage of given ID.
void drop_storage_apply(StorageId id)
This is called while restart to apply DROP STORAGE logs.
ErrorStack reinitialize_for_recovered_snapshot()
Special method called only from recovery manager.
Forward declarations of classes in masstree storage package.
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.
Forward declarations of classes in thread package.
A base layout of shared data for all storage types.
Definition: storage.hpp:53
Forward declarations of classes in hash storage package.
StorageManager & operator=(const StorageManager &)=delete