/Users/deen/code/yugabyte-db/src/yb/master/catalog_loaders.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | // |
18 | | // The following only applies to changes made to this file as part of YugaByte development. |
19 | | // |
20 | | // Portions Copyright (c) YugaByte, Inc. |
21 | | // |
22 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
23 | | // in compliance with the License. You may obtain a copy of the License at |
24 | | // |
25 | | // http://www.apache.org/licenses/LICENSE-2.0 |
26 | | // |
27 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
28 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
29 | | // or implied. See the License for the specific language governing permissions and limitations |
30 | | // under the License. |
31 | | // |
32 | | |
33 | | #ifndef YB_MASTER_CATALOG_LOADERS_H |
34 | | #define YB_MASTER_CATALOG_LOADERS_H |
35 | | |
36 | | #include <type_traits> |
37 | | |
38 | | #include <boost/preprocessor/cat.hpp> |
39 | | |
40 | | #include "yb/master/master_fwd.h" |
41 | | #include "yb/master/catalog_manager.h" |
42 | | #include "yb/master/permissions_manager.h" |
43 | | #include "yb/master/sys_catalog.h" |
44 | | |
45 | | namespace yb { |
46 | | namespace master { |
47 | | |
48 | | #define DECLARE_LOADER_CLASS(name, key_type, entry_pb_name, mutex) \ |
49 | | class BOOST_PP_CAT(name, Loader) : \ |
50 | | public Visitor<BOOST_PP_CAT(BOOST_PP_CAT(Persistent, name), Info)> { \ |
51 | | public: \ |
52 | | explicit BOOST_PP_CAT(name, Loader)( \ |
53 | | CatalogManager* catalog_manager, int64_t term = OpId::kUnknownTerm) \ |
54 | 30.0k | : catalog_manager_(catalog_manager), term_(term) {} \ yb::master::RoleLoader::RoleLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::SysConfigLoader::SysConfigLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::TableLoader::TableLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::TabletLoader::TabletLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::NamespaceLoader::NamespaceLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::UDTypeLoader::UDTypeLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::ClusterConfigLoader::ClusterConfigLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
yb::master::RedisConfigLoader::RedisConfigLoader(yb::master::CatalogManager*, long long) Line | Count | Source | 54 | 3.75k | : catalog_manager_(catalog_manager), term_(term) {} \ |
|
55 | | \ |
56 | | private: \ |
57 | | CHECKED_STATUS Visit( \ |
58 | | const key_type& key, \ |
59 | | const entry_pb_name& metadata) override REQUIRES(mutex); \ |
60 | | \ |
61 | | CatalogManager *catalog_manager_; \ |
62 | | \ |
63 | | int64_t term_; \ |
64 | | \ |
65 | | DISALLOW_COPY_AND_ASSIGN(BOOST_PP_CAT(name, Loader)); \ |
66 | | }; |
67 | | |
68 | | // We have two naming schemes for Sys...EntryPB classes (plural vs. singluar), hence we need the |
69 | | // "entry_pb_suffix" argument to the macro. |
70 | | // |
71 | | // SysTablesEntryPB |
72 | | // SysTabletsEntryPB |
73 | | // |
74 | | // vs. |
75 | | // |
76 | | // SysNamespaceEntryPB |
77 | | // SysUDTypeEntryPB |
78 | | // SysClusterConfigEntryPB |
79 | | // SysRedisConfigEntryPB |
80 | | // SysRoleEntryPB |
81 | | // SysConfigEntryPB |
82 | | |
83 | | // These config PBs don't have associated loaders here: |
84 | | // |
85 | | // SysSecurityConfigEntryPB |
86 | | // SysSnapshotEntryPB |
87 | | // SysYSQLCatalogConfigEntryPB |
88 | | |
89 | | DECLARE_LOADER_CLASS(Table, TableId, SysTablesEntryPB, catalog_manager_->mutex_); |
90 | | DECLARE_LOADER_CLASS(Tablet, TabletId, SysTabletsEntryPB, catalog_manager_->mutex_); |
91 | | DECLARE_LOADER_CLASS(Namespace, NamespaceId, SysNamespaceEntryPB, catalog_manager_->mutex_); |
92 | | DECLARE_LOADER_CLASS(UDType, UDTypeId, SysUDTypeEntryPB, catalog_manager_->mutex_); |
93 | | DECLARE_LOADER_CLASS(ClusterConfig, std::string, SysClusterConfigEntryPB, catalog_manager_->mutex_); |
94 | | DECLARE_LOADER_CLASS(RedisConfig, std::string, SysRedisConfigEntryPB, catalog_manager_->mutex_); |
95 | | DECLARE_LOADER_CLASS(Role, RoleName, SysRoleEntryPB, |
96 | | catalog_manager_->permissions_manager()->mutex()); |
97 | | DECLARE_LOADER_CLASS(SysConfig, std::string, SysConfigEntryPB, |
98 | | catalog_manager_->permissions_manager()->mutex()); |
99 | | |
100 | | #undef DECLARE_LOADER_CLASS |
101 | | |
102 | | bool ShouldLoadObject(const SysNamespaceEntryPB& metadata); |
103 | | bool ShouldLoadObject(const SysTablesEntryPB& pb); |
104 | | bool ShouldLoadObject(const SysTabletsEntryPB& pb); |
105 | | |
106 | | } // namespace master |
107 | | } // namespace yb |
108 | | |
109 | | #endif // YB_MASTER_CATALOG_LOADERS_H |