libfoedus-core
FOEDUS Core Library
storage_log_types.cpp
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  */
19 
20 #include <glog/logging.h>
21 
22 #include <ostream>
23 #include <string>
24 
25 #include "foedus/engine.hpp"
33 #include "foedus/thread/thread.hpp"
34 
35 namespace foedus {
36 namespace storage {
37 
38 void DropLogType::populate(StorageId storage_id) {
39  ASSERT_ND(storage_id > 0);
40  header_.log_type_code_ = log::get_log_code<DropLogType>();
42  header_.storage_id_ = storage_id;
43 }
44 void DropLogType::apply_storage(Engine* engine, StorageId storage_id) {
45  ASSERT_ND(storage_id > 0);
46  LOG(INFO) << "Applying DROP STORAGE log: " << *this;
47  engine->get_storage_manager()->drop_storage_apply(storage_id);
48  LOG(INFO) << "Applied DROP STORAGE log: " << *this;
49 }
50 
54  ASSERT_ND(header_.get_type() == log::get_log_code<DropLogType>());
55 }
56 std::ostream& operator<<(std::ostream& o, const DropLogType& v) {
57  o << "<StorageDropLog>"
58  << "<storage_id_>" << v.header_.storage_id_ << "</storage_id_>"
59  << "</StorageDropLog>";
60  return o;
61 }
62 
66 }
67 
68 void CreateLogType::apply_storage(Engine* engine, StorageId storage_id) {
69  ASSERT_ND(metadata_.id_ == storage_id);
70  LOG(INFO) << "Applying CREATE STORAGE log: " << *this;
72  LOG(INFO) << "Applied CREATE STORAGE log: " << *this;
73 }
74 
75 std::ostream& operator<<(std::ostream& o, const CreateLogType& v) {
76  switch (v.metadata_.type_) {
77  case kArrayStorage:
78  o << reinterpret_cast<const array::ArrayCreateLogType&>(v);
79  break;
80  case kHashStorage:
81  o << reinterpret_cast<const hash::HashCreateLogType&>(v);
82  break;
83  case kMasstreeStorage:
84  o << reinterpret_cast<const masstree::MasstreeCreateLogType&>(v);
85  break;
86  case kSequentialStorage:
87  o << reinterpret_cast<const sequential::SequentialCreateLogType&>(v);
88  break;
89  default:
90  o << "Unexpected metadata type:" << v.metadata_.type_;
91  }
92  return o;
93 }
94 
95 
96 
97 } // namespace storage
98 } // namespace foedus
Log type of DROP STORAGE operation.
void populate(StorageId storage_id)
storage::StorageManager * get_storage_manager() const
See Storage Manager.
Definition: engine.cpp:60
Declares all log types used in this storage type.
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
Declares all log types used in this storage type.
void create_storage_apply(const Metadata &metadata)
This is called while restart to apply CREATE STORAGE logs.
Declares common log types for all (or at least multiple) storage types.
Declares all log types used in this storage type.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
uint16_t log_type_code_
Actually of LogCode defined in the X-Macro, but we want to make sure the type size is 2 bytes...
uint16_t log_length_
Byte size of this log entry including this header itself and everything.
StorageType type_
type of the storage.
Definition: metadata.hpp:105
Declares all log types used in this storage type.
storage::StorageId storage_id_
The storage this loggable operation mainly affects.
LogCode get_type() const __attribute__((always_inline))
Convenience method to cast into LogCode.
void drop_storage_apply(StorageId id)
This is called while restart to apply DROP STORAGE logs.
std::ostream & operator<<(std::ostream &o, const Composer &v)
Definition: composer.cpp:39
Base type for CREATE STORAGE operation.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
StorageId id_
the unique ID of this storage.
Definition: metadata.hpp:103
void apply_storage(Engine *engine, StorageId storage_id)
void assert_valid_generic() __attribute__((always_inline))
Verifies the log contains essential fields set.
void apply_storage(Engine *engine, StorageId storage_id)