/Users/deen/code/yugabyte-db/src/yb/master/catalog_manager_if.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_MASTER_CATALOG_MANAGER_IF_H |
15 | | #define YB_MASTER_CATALOG_MANAGER_IF_H |
16 | | |
17 | | #include "yb/common/common_fwd.h" |
18 | | #include "yb/common/common_types.pb.h" |
19 | | |
20 | | #include "yb/consensus/consensus_fwd.h" |
21 | | |
22 | | #include "yb/docdb/docdb_fwd.h" |
23 | | |
24 | | #include "yb/master/master_admin.fwd.h" |
25 | | #include "yb/master/master_client.fwd.h" |
26 | | #include "yb/master/master_cluster.fwd.h" |
27 | | #include "yb/master/master_ddl.fwd.h" |
28 | | #include "yb/master/master_replication.fwd.h" |
29 | | #include "yb/master/master_fwd.h" |
30 | | |
31 | | #include "yb/rpc/rpc_fwd.h" |
32 | | |
33 | | #include "yb/server/server_fwd.h" |
34 | | |
35 | | #include "yb/tablet/tablet_fwd.h" |
36 | | |
37 | | #include "yb/util/result.h" |
38 | | #include "yb/util/status.h" |
39 | | |
40 | | namespace google { |
41 | | namespace protobuf { |
42 | | template <class T> |
43 | | class RepeatedPtrField; |
44 | | } |
45 | | } |
46 | | |
47 | | namespace yb { |
48 | | |
49 | | class ThreadPool; |
50 | | |
51 | | namespace master { |
52 | | |
53 | | YB_DEFINE_ENUM(GetTablesMode, (kAll) // All tables |
54 | | (kRunning) // All running tables |
55 | | (kVisibleToClient) // All tables visible to the client |
56 | | ); |
57 | | |
58 | | class CatalogManagerIf { |
59 | | public: |
60 | | virtual void CheckTableDeleted(const TableInfoPtr& table) = 0; |
61 | | |
62 | | virtual void NotifyTabletDeleteFinished( |
63 | | const TabletServerId& tserver_uuid, const TableId& table_id, const TableInfoPtr& table) = 0; |
64 | | |
65 | | virtual std::string GenerateId() = 0; |
66 | | |
67 | | virtual Result<std::shared_ptr<tablet::AbstractTablet>> GetSystemTablet(const TabletId& id) = 0; |
68 | | |
69 | | virtual CHECKED_STATUS WaitForWorkerPoolTests( |
70 | | const MonoDelta& timeout = MonoDelta::FromSeconds(10)) const = 0; |
71 | | |
72 | | virtual Result<uint64_t> IncrementYsqlCatalogVersion() = 0; |
73 | | |
74 | | virtual Result<std::vector<TableDescription>> CollectTables( |
75 | | const google::protobuf::RepeatedPtrField<TableIdentifierPB>& table_identifiers, |
76 | | bool add_indexes, |
77 | | bool include_parent_colocated_table = false) = 0; |
78 | | |
79 | | virtual ThreadPool* AsyncTaskPool() = 0; |
80 | | |
81 | | virtual CHECKED_STATUS ScheduleTask(std::shared_ptr<RetryingTSRpcTask> task) = 0; |
82 | | |
83 | | virtual CHECKED_STATUS HandleTabletSchemaVersionReport( |
84 | | TabletInfo *tablet, uint32_t version, const scoped_refptr<TableInfo>& table = nullptr) = 0; |
85 | | |
86 | | virtual std::vector<TableInfoPtr> GetTables(GetTablesMode mode) = 0; |
87 | | |
88 | | virtual void GetAllNamespaces( |
89 | | std::vector<scoped_refptr<NamespaceInfo>>* namespaces, |
90 | | bool include_only_running_namespaces = false) = 0; |
91 | | |
92 | | virtual Result<size_t> GetReplicationFactor() = 0; |
93 | 56.0k | Result<size_t> GetReplicationFactor(NamespaceName namespace_name) { |
94 | | // TODO ENG-282 We currently don't support per-namespace replication factor. |
95 | 56.0k | return GetReplicationFactor(); |
96 | 56.0k | } |
97 | | |
98 | | virtual const NodeInstancePB& NodeInstance() const = 0; |
99 | | |
100 | | virtual CHECKED_STATUS GetYsqlCatalogVersion( |
101 | | uint64_t* catalog_version, uint64_t* last_breaking_version) = 0; |
102 | | |
103 | | virtual CHECKED_STATUS GetClusterConfig(GetMasterClusterConfigResponsePB* resp) = 0; |
104 | | virtual CHECKED_STATUS GetClusterConfig(SysClusterConfigEntryPB* config) = 0; |
105 | | |
106 | | virtual CHECKED_STATUS SetClusterConfig( |
107 | | const ChangeMasterClusterConfigRequestPB* req, ChangeMasterClusterConfigResponsePB* resp) = 0; |
108 | | |
109 | | virtual CHECKED_STATUS ListTables( |
110 | | const ListTablesRequestPB* req, ListTablesResponsePB* resp) = 0; |
111 | | |
112 | | virtual CHECKED_STATUS CheckIsLeaderAndReady() const = 0; |
113 | | |
114 | | virtual void AssertLeaderLockAcquiredForReading() const = 0; |
115 | | |
116 | | virtual bool IsUserTable(const TableInfo& table) const = 0; |
117 | | |
118 | | virtual bool HasTablegroups() = 0; |
119 | | |
120 | | virtual NamespaceName GetNamespaceName(const NamespaceId& id) const = 0; |
121 | | |
122 | | virtual bool IsUserIndex(const TableInfo& table) const = 0; |
123 | | |
124 | | virtual TableInfoPtr GetTableInfo(const TableId& table_id) = 0; |
125 | | |
126 | | virtual Result<ReplicationInfoPB> GetTableReplicationInfo( |
127 | | const ReplicationInfoPB& table_replication_info, |
128 | | const TablespaceId& tablespace_id) = 0; |
129 | | |
130 | | virtual std::vector<std::shared_ptr<server::MonitoredTask>> GetRecentJobs() = 0; |
131 | | |
132 | | virtual bool IsSystemTable(const TableInfo& table) const = 0; |
133 | | |
134 | | virtual Result<scoped_refptr<NamespaceInfo>> FindNamespaceById( |
135 | | const NamespaceId& id) const = 0; |
136 | | |
137 | | virtual scoped_refptr<TableInfo> GetTableInfoFromNamespaceNameAndTableName( |
138 | | YQLDatabase db_type, const NamespaceName& namespace_name, const TableName& table_name) = 0; |
139 | | |
140 | | virtual std::vector<std::shared_ptr<server::MonitoredTask>> GetRecentTasks() = 0; |
141 | | |
142 | | virtual Result<boost::optional<TablespaceId>> GetTablespaceForTable( |
143 | | const scoped_refptr<TableInfo>& table) = 0; |
144 | | |
145 | | virtual bool IsLoadBalancerEnabled() = 0; |
146 | | |
147 | | // API to check if all the live tservers have similar tablet workload. |
148 | | virtual CHECKED_STATUS IsLoadBalanced( |
149 | | const IsLoadBalancedRequestPB* req, IsLoadBalancedResponsePB* resp) = 0; |
150 | | |
151 | | virtual bool IsUserCreatedTable(const TableInfo& table) const = 0; |
152 | | |
153 | | virtual BlacklistSet BlacklistSetFromPB() const = 0; |
154 | | |
155 | | virtual void GetAllUDTypes(std::vector<scoped_refptr<UDTypeInfo>>* types) = 0; |
156 | | |
157 | | virtual CHECKED_STATUS GetTabletLocations( |
158 | | const TabletId& tablet_id, |
159 | | TabletLocationsPB* locs_pb, |
160 | | IncludeInactive include_inactive = IncludeInactive::kFalse) = 0; |
161 | | |
162 | | virtual CHECKED_STATUS GetTabletLocations( |
163 | | scoped_refptr<TabletInfo> tablet_info, |
164 | | TabletLocationsPB* locs_pb, |
165 | | IncludeInactive include_inactive = IncludeInactive::kFalse) = 0; |
166 | | |
167 | | virtual void HandleCreateTabletSnapshotResponse(TabletInfo *tablet, bool error) = 0; |
168 | | |
169 | | virtual void HandleRestoreTabletSnapshotResponse(TabletInfo *tablet, bool error) = 0; |
170 | | |
171 | | virtual void HandleDeleteTabletSnapshotResponse( |
172 | | const SnapshotId& snapshot_id, TabletInfo *tablet, bool error) = 0; |
173 | | |
174 | | virtual CHECKED_STATUS GetTableLocations(const GetTableLocationsRequestPB* req, |
175 | | GetTableLocationsResponsePB* resp) = 0; |
176 | | |
177 | | virtual CHECKED_STATUS IsCreateTableDone(const IsCreateTableDoneRequestPB* req, |
178 | | IsCreateTableDoneResponsePB* resp) = 0; |
179 | | |
180 | | virtual CHECKED_STATUS CreateTable(const CreateTableRequestPB* req, |
181 | | CreateTableResponsePB* resp, |
182 | | rpc::RpcContext* rpc) = 0; |
183 | | |
184 | | virtual CHECKED_STATUS CreateNamespace(const CreateNamespaceRequestPB* req, |
185 | | CreateNamespaceResponsePB* resp, |
186 | | rpc::RpcContext* rpc) = 0; |
187 | | |
188 | | virtual CHECKED_STATUS GetTableSchema( |
189 | | const GetTableSchemaRequestPB* req, GetTableSchemaResponsePB* resp) = 0; |
190 | | |
191 | | virtual CHECKED_STATUS TEST_IncrementTablePartitionListVersion(const TableId& table_id) = 0; |
192 | | |
193 | | virtual Result<scoped_refptr<TabletInfo>> GetTabletInfo(const TabletId& tablet_id) = 0; |
194 | | |
195 | | virtual bool AreTablesDeleting() = 0; |
196 | | |
197 | | virtual CHECKED_STATUS GetCurrentConfig(consensus::ConsensusStatePB *cpb) const = 0; |
198 | | |
199 | | virtual CHECKED_STATUS WaitUntilCaughtUpAsLeader(const MonoDelta& timeout) = 0; |
200 | | |
201 | | virtual CHECKED_STATUS ListCDCStreams( |
202 | | const ListCDCStreamsRequestPB* req, ListCDCStreamsResponsePB* resp) = 0; |
203 | | |
204 | | virtual CHECKED_STATUS GetCDCDBStreamInfo( |
205 | | const GetCDCDBStreamInfoRequestPB* req, GetCDCDBStreamInfoResponsePB* resp) = 0; |
206 | | |
207 | | virtual Result<scoped_refptr<TableInfo>> FindTable( |
208 | | const TableIdentifierPB& table_identifier) const = 0; |
209 | | |
210 | | virtual CHECKED_STATUS IsInitDbDone( |
211 | | const IsInitDbDoneRequestPB* req, IsInitDbDoneResponsePB* resp) = 0; |
212 | | |
213 | | virtual void DumpState(std::ostream* out, bool on_disk_dump = false) const = 0; |
214 | | |
215 | | virtual CHECKED_STATUS VisitSysCatalog(int64_t term) = 0; |
216 | | |
217 | | virtual scoped_refptr<TableInfo> NewTableInfo(TableId id) = 0; |
218 | | |
219 | | // If select_all_tablets_for_split is true, we will not call ShouldSplitValidCandidate. |
220 | | virtual CHECKED_STATUS SplitTablet( |
221 | | const TabletId& tablet_id, bool select_all_tablets_for_split) = 0; |
222 | | |
223 | | virtual CHECKED_STATUS TEST_SplitTablet( |
224 | | const scoped_refptr<TabletInfo>& source_tablet_info, docdb::DocKeyHash split_hash_code) = 0; |
225 | | |
226 | | virtual CHECKED_STATUS TEST_SplitTablet( |
227 | | const TabletId& tablet_id, const std::string& split_encoded_key, |
228 | | const std::string& split_partition_key) = 0; |
229 | | |
230 | | virtual uint64_t GetTransactionTablesVersion() = 0; |
231 | | |
232 | | virtual Result<scoped_refptr<TableInfo>> FindTableById(const TableId& table_id) const = 0; |
233 | | |
234 | | virtual SysCatalogTable* sys_catalog() = 0; |
235 | | |
236 | | virtual PermissionsManager* permissions_manager() = 0; |
237 | | |
238 | | virtual int64_t leader_ready_term() = 0; |
239 | | |
240 | | virtual ClusterLoadBalancer* load_balancer() = 0; |
241 | | |
242 | | virtual TabletSplitManager* tablet_split_manager() = 0; |
243 | | |
244 | | virtual std::shared_ptr<tablet::TabletPeer> tablet_peer() const = 0; |
245 | | |
246 | | virtual intptr_t tablets_version() const = 0; |
247 | | |
248 | | virtual intptr_t tablet_locations_version() const = 0; |
249 | | |
250 | | virtual tablet::SnapshotCoordinator& snapshot_coordinator() = 0; |
251 | | |
252 | 92 | virtual ~CatalogManagerIf() = default; |
253 | | }; |
254 | | |
255 | | // Returns whether the namespace is a YCQL namespace. |
256 | | bool IsYcqlNamespace(const NamespaceInfo& ns); |
257 | | |
258 | | // Returns whether the table is a YCQL table. |
259 | | bool IsYcqlTable(const TableInfo& table); |
260 | | |
261 | | } // namespace master |
262 | | } // namespace yb |
263 | | |
264 | | #endif // YB_MASTER_CATALOG_MANAGER_IF_H |