/Users/deen/code/yugabyte-db/ent/src/yb/master/catalog_manager.h
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef ENT_SRC_YB_MASTER_CATALOG_MANAGER_H |
14 | | #define ENT_SRC_YB_MASTER_CATALOG_MANAGER_H |
15 | | |
16 | | #include "../../../../src/yb/master/catalog_manager.h" |
17 | | #include "yb/master/master_snapshot_coordinator.h" |
18 | | #include "yb/master/snapshot_coordinator_context.h" |
19 | | |
20 | | namespace yb { |
21 | | |
22 | | class UniverseKeyRegistryPB; |
23 | | |
24 | | namespace master { |
25 | | namespace enterprise { |
26 | | |
27 | | YB_DEFINE_ENUM(CreateObjects, (kOnlyTables)(kOnlyIndexes)); |
28 | | |
29 | | class CatalogManager : public yb::master::CatalogManager, SnapshotCoordinatorContext { |
30 | | typedef yb::master::CatalogManager super; |
31 | | public: |
32 | | explicit CatalogManager(yb::master::Master* master) |
33 | 5.45k | : super(master), snapshot_coordinator_(this) {} |
34 | | |
35 | | virtual ~CatalogManager(); |
36 | | void CompleteShutdown(); |
37 | | |
38 | | CHECKED_STATUS RunLoaders(int64_t term) override REQUIRES(mutex_); |
39 | | |
40 | | // API to start a snapshot creation. |
41 | | CHECKED_STATUS CreateSnapshot(const CreateSnapshotRequestPB* req, |
42 | | CreateSnapshotResponsePB* resp, |
43 | | rpc::RpcContext* rpc); |
44 | | |
45 | | // API to list all available snapshots. |
46 | | CHECKED_STATUS ListSnapshots(const ListSnapshotsRequestPB* req, |
47 | | ListSnapshotsResponsePB* resp); |
48 | | |
49 | | CHECKED_STATUS ListSnapshotRestorations(const ListSnapshotRestorationsRequestPB* req, |
50 | | ListSnapshotRestorationsResponsePB* resp); |
51 | | |
52 | | // API to restore a snapshot. |
53 | | CHECKED_STATUS RestoreSnapshot(const RestoreSnapshotRequestPB* req, |
54 | | RestoreSnapshotResponsePB* resp); |
55 | | |
56 | | // API to delete a snapshot. |
57 | | CHECKED_STATUS DeleteSnapshot(const DeleteSnapshotRequestPB* req, |
58 | | DeleteSnapshotResponsePB* resp, |
59 | | rpc::RpcContext* rpc); |
60 | | |
61 | | CHECKED_STATUS ImportSnapshotMeta(const ImportSnapshotMetaRequestPB* req, |
62 | | ImportSnapshotMetaResponsePB* resp); |
63 | | |
64 | | CHECKED_STATUS CreateSnapshotSchedule(const CreateSnapshotScheduleRequestPB* req, |
65 | | CreateSnapshotScheduleResponsePB* resp, |
66 | | rpc::RpcContext* rpc); |
67 | | |
68 | | CHECKED_STATUS ListSnapshotSchedules(const ListSnapshotSchedulesRequestPB* req, |
69 | | ListSnapshotSchedulesResponsePB* resp, |
70 | | rpc::RpcContext* rpc); |
71 | | |
72 | | CHECKED_STATUS DeleteSnapshotSchedule(const DeleteSnapshotScheduleRequestPB* req, |
73 | | DeleteSnapshotScheduleResponsePB* resp, |
74 | | rpc::RpcContext* rpc); |
75 | | |
76 | | CHECKED_STATUS ChangeEncryptionInfo(const ChangeEncryptionInfoRequestPB* req, |
77 | | ChangeEncryptionInfoResponsePB* resp) override; |
78 | | |
79 | | CHECKED_STATUS UpdateXClusterConsumerOnTabletSplit( |
80 | | const TableId& consumer_table_id, const SplitTabletIds& split_tablet_ids) override; |
81 | | |
82 | | CHECKED_STATUS UpdateXClusterProducerOnTabletSplit( |
83 | | const TableId& producer_table_id, const SplitTabletIds& split_tablet_ids) override; |
84 | | |
85 | | CHECKED_STATUS InitCDCConsumer(const std::vector<CDCConsumerStreamInfo>& consumer_info, |
86 | | const std::string& master_addrs, |
87 | | const std::string& producer_universe_uuid, |
88 | | std::shared_ptr<CDCRpcTasks> cdc_rpc_tasks); |
89 | | |
90 | | void HandleCreateTabletSnapshotResponse(TabletInfo *tablet, bool error) override; |
91 | | |
92 | | void HandleRestoreTabletSnapshotResponse(TabletInfo *tablet, bool error) override; |
93 | | |
94 | | void HandleDeleteTabletSnapshotResponse( |
95 | | const SnapshotId& snapshot_id, TabletInfo *tablet, bool error) override; |
96 | | |
97 | | void DumpState(std::ostream* out, bool on_disk_dump = false) const override; |
98 | | |
99 | | // Fills the heartbeat response with the decrypted universe key registry. |
100 | | CHECKED_STATUS FillHeartbeatResponse(const TSHeartbeatRequestPB* req, |
101 | | TSHeartbeatResponsePB* resp) override; |
102 | | |
103 | | // Is encryption at rest enabled for this cluster. |
104 | | CHECKED_STATUS IsEncryptionEnabled(const IsEncryptionEnabledRequestPB* req, |
105 | | IsEncryptionEnabledResponsePB* resp); |
106 | | |
107 | | // Create a new CDC stream with the specified attributes. |
108 | | CHECKED_STATUS CreateCDCStream(const CreateCDCStreamRequestPB* req, |
109 | | CreateCDCStreamResponsePB* resp, |
110 | | rpc::RpcContext* rpc); |
111 | | |
112 | | // Delete the specified CDCStream. |
113 | | CHECKED_STATUS DeleteCDCStream(const DeleteCDCStreamRequestPB* req, |
114 | | DeleteCDCStreamResponsePB* resp, |
115 | | rpc::RpcContext* rpc); |
116 | | |
117 | | // List CDC streams (optionally, for a given table). |
118 | | CHECKED_STATUS ListCDCStreams(const ListCDCStreamsRequestPB* req, |
119 | | ListCDCStreamsResponsePB* resp) override; |
120 | | |
121 | | // Fetch CDC stream info corresponding to a db stream id |
122 | | CHECKED_STATUS GetCDCDBStreamInfo(const GetCDCDBStreamInfoRequestPB* req, |
123 | | GetCDCDBStreamInfoResponsePB* resp) override; |
124 | | |
125 | | // Get CDC stream. |
126 | | CHECKED_STATUS GetCDCStream(const GetCDCStreamRequestPB* req, |
127 | | GetCDCStreamResponsePB* resp, |
128 | | rpc::RpcContext* rpc); |
129 | | |
130 | | // Update a CDC stream. |
131 | | CHECKED_STATUS UpdateCDCStream(const UpdateCDCStreamRequestPB* req, |
132 | | UpdateCDCStreamResponsePB* resp, |
133 | | rpc::RpcContext* rpc); |
134 | | |
135 | | // Delete CDC streams for a table. |
136 | | CHECKED_STATUS DeleteCDCStreamsForTable(const TableId& table_id) override; |
137 | | CHECKED_STATUS DeleteCDCStreamsForTables(const vector<TableId>& table_ids) override; |
138 | | |
139 | | // Setup Universe Replication to consume data from another YB universe. |
140 | | CHECKED_STATUS SetupUniverseReplication(const SetupUniverseReplicationRequestPB* req, |
141 | | SetupUniverseReplicationResponsePB* resp, |
142 | | rpc::RpcContext* rpc); |
143 | | |
144 | | // Delete Universe Replication. |
145 | | CHECKED_STATUS DeleteUniverseReplication(const DeleteUniverseReplicationRequestPB* req, |
146 | | DeleteUniverseReplicationResponsePB* resp, |
147 | | rpc::RpcContext* rpc); |
148 | | |
149 | | // Alter Universe Replication. |
150 | | CHECKED_STATUS AlterUniverseReplication(const AlterUniverseReplicationRequestPB* req, |
151 | | AlterUniverseReplicationResponsePB* resp, |
152 | | rpc::RpcContext* rpc); |
153 | | |
154 | | // Rename an existing Universe Replication. |
155 | | CHECKED_STATUS RenameUniverseReplication(scoped_refptr<UniverseReplicationInfo> universe, |
156 | | const AlterUniverseReplicationRequestPB* req, |
157 | | AlterUniverseReplicationResponsePB* resp, |
158 | | rpc::RpcContext* rpc); |
159 | | |
160 | | // Enable/Disable an Existing Universe Replication. |
161 | | CHECKED_STATUS SetUniverseReplicationEnabled(const SetUniverseReplicationEnabledRequestPB* req, |
162 | | SetUniverseReplicationEnabledResponsePB* resp, |
163 | | rpc::RpcContext* rpc); |
164 | | |
165 | | // Get Universe Replication. |
166 | | CHECKED_STATUS GetUniverseReplication(const GetUniverseReplicationRequestPB* req, |
167 | | GetUniverseReplicationResponsePB* resp, |
168 | | rpc::RpcContext* rpc); |
169 | | |
170 | | // Checks if the universe is in an active state or has failed during setup. |
171 | | CHECKED_STATUS IsSetupUniverseReplicationDone(const IsSetupUniverseReplicationDoneRequestPB* req, |
172 | | IsSetupUniverseReplicationDoneResponsePB* resp, |
173 | | rpc::RpcContext* rpc); |
174 | | |
175 | | // On a producer side split, creates new pollers on the consumer for the new tablet children. |
176 | | CHECKED_STATUS UpdateConsumerOnProducerSplit(const UpdateConsumerOnProducerSplitRequestPB* req, |
177 | | UpdateConsumerOnProducerSplitResponsePB* resp, |
178 | | rpc::RpcContext* rpc); |
179 | | |
180 | | // Find all the CDC streams that have been marked as DELETED. |
181 | | CHECKED_STATUS FindCDCStreamsMarkedAsDeleting(std::vector<scoped_refptr<CDCStreamInfo>>* streams); |
182 | | |
183 | | // Delete specified CDC streams. |
184 | | CHECKED_STATUS CleanUpDeletedCDCStreams(const std::vector<scoped_refptr<CDCStreamInfo>>& streams); |
185 | | |
186 | | bool IsCdcEnabled(const TableInfo& table_info) const override; |
187 | | |
188 | 5.35k | tablet::SnapshotCoordinator& snapshot_coordinator() override { |
189 | 5.35k | return snapshot_coordinator_; |
190 | 5.35k | } |
191 | | |
192 | | size_t GetNumLiveTServersForActiveCluster() override; |
193 | | |
194 | | private: |
195 | | friend class SnapshotLoader; |
196 | | friend class yb::master::ClusterLoadBalancer; |
197 | | friend class CDCStreamLoader; |
198 | | friend class UniverseReplicationLoader; |
199 | | |
200 | | CHECKED_STATUS RestoreEntry(const SysRowEntry& entry, const SnapshotId& snapshot_id) |
201 | | REQUIRES(mutex_); |
202 | | |
203 | | // Per table structure for external cluster snapshot importing to this cluster. |
204 | | // Old IDs mean IDs on external cluster, new IDs - IDs on this cluster. |
205 | | struct ExternalTableSnapshotData { |
206 | 0 | bool is_index() const { |
207 | 0 | return !table_entry_pb.indexed_table_id().empty(); |
208 | 0 | } |
209 | | |
210 | | NamespaceId old_namespace_id; |
211 | | TableId old_table_id; |
212 | | TableId new_table_id; |
213 | | SysTablesEntryPB table_entry_pb; |
214 | | std::string pg_schema_name; |
215 | | size_t num_tablets = 0; |
216 | | typedef std::pair<std::string, std::string> PartitionKeys; |
217 | | typedef std::map<PartitionKeys, TabletId> PartitionToIdMap; |
218 | | typedef std::vector<PartitionPB> Partitions; |
219 | | Partitions partitions; |
220 | | PartitionToIdMap new_tablets_map; |
221 | | // Mapping: Old tablet ID -> New tablet ID. |
222 | | google::protobuf::RepeatedPtrField<IdPairPB>* tablet_id_map = nullptr; |
223 | | |
224 | | ImportSnapshotMetaResponsePB_TableMetaPB* table_meta = nullptr; |
225 | | }; |
226 | | |
227 | | // Map: old_namespace_id (key) -> new_namespace_id (value) + db_type. |
228 | | typedef std::pair<NamespaceId, YQLDatabase> NamespaceData; |
229 | | typedef std::map<NamespaceId, NamespaceData> NamespaceMap; |
230 | | typedef std::map<TableId, ExternalTableSnapshotData> ExternalTableSnapshotDataMap; |
231 | | |
232 | | CHECKED_STATUS ImportSnapshotPreprocess(const SnapshotInfoPB& snapshot_pb, |
233 | | ImportSnapshotMetaResponsePB* resp, |
234 | | NamespaceMap* namespace_map, |
235 | | ExternalTableSnapshotDataMap* tables_data); |
236 | | CHECKED_STATUS ImportSnapshotCreateObject(const SnapshotInfoPB& snapshot_pb, |
237 | | ImportSnapshotMetaResponsePB* resp, |
238 | | NamespaceMap* namespace_map, |
239 | | ExternalTableSnapshotDataMap* tables_data, |
240 | | CreateObjects create_objects); |
241 | | CHECKED_STATUS ImportSnapshotWaitForTables(const SnapshotInfoPB& snapshot_pb, |
242 | | ImportSnapshotMetaResponsePB* resp, |
243 | | ExternalTableSnapshotDataMap* tables_data); |
244 | | CHECKED_STATUS ImportSnapshotProcessTablets(const SnapshotInfoPB& snapshot_pb, |
245 | | ImportSnapshotMetaResponsePB* resp, |
246 | | ExternalTableSnapshotDataMap* tables_data); |
247 | | void DeleteNewSnapshotObjects(const NamespaceMap& namespace_map, |
248 | | const ExternalTableSnapshotDataMap& tables_data); |
249 | | |
250 | | // Helper function for ImportTableEntry. |
251 | | Result<bool> CheckTableForImport( |
252 | | scoped_refptr<TableInfo> table, |
253 | | ExternalTableSnapshotData* snapshot_data) REQUIRES_SHARED(mutex_); |
254 | | |
255 | | CHECKED_STATUS ImportNamespaceEntry(const SysRowEntry& entry, |
256 | | NamespaceMap* namespace_map); |
257 | | CHECKED_STATUS RecreateTable(const NamespaceId& new_namespace_id, |
258 | | const ExternalTableSnapshotDataMap& table_map, |
259 | | ExternalTableSnapshotData* table_data); |
260 | | CHECKED_STATUS RepartitionTable(scoped_refptr<TableInfo> table, |
261 | | const ExternalTableSnapshotData* table_data); |
262 | | CHECKED_STATUS ImportTableEntry(const NamespaceMap& namespace_map, |
263 | | const ExternalTableSnapshotDataMap& table_map, |
264 | | ExternalTableSnapshotData* s_data); |
265 | | CHECKED_STATUS PreprocessTabletEntry(const SysRowEntry& entry, |
266 | | ExternalTableSnapshotDataMap* table_map); |
267 | | CHECKED_STATUS ImportTabletEntry(const SysRowEntry& entry, |
268 | | ExternalTableSnapshotDataMap* table_map); |
269 | | |
270 | | TabletInfos GetTabletInfos(const std::vector<TabletId>& ids) override; |
271 | | |
272 | | Result<SysRowEntries> CollectEntries( |
273 | | const google::protobuf::RepeatedPtrField<TableIdentifierPB>& tables, |
274 | | CollectFlags flags); |
275 | | |
276 | | Result<SysRowEntries> CollectEntriesForSnapshot( |
277 | | const google::protobuf::RepeatedPtrField<TableIdentifierPB>& tables) override; |
278 | | |
279 | | server::Clock* Clock() override; |
280 | | |
281 | | const Schema& schema() override; |
282 | | |
283 | | void Submit(std::unique_ptr<tablet::Operation> operation, int64_t leader_term) override; |
284 | | |
285 | | AsyncTabletSnapshotOpPtr CreateAsyncTabletSnapshotOp( |
286 | | const TabletInfoPtr& tablet, const std::string& snapshot_id, |
287 | | tserver::TabletSnapshotOpRequestPB::Operation operation, |
288 | | TabletSnapshotOperationCallback callback) override; |
289 | | |
290 | | void ScheduleTabletSnapshotOp(const AsyncTabletSnapshotOpPtr& operation) override; |
291 | | |
292 | | CHECKED_STATUS RestoreSysCatalog( |
293 | | SnapshotScheduleRestoration* restoration, tablet::Tablet* tablet, |
294 | | Status* complete_status) override; |
295 | | |
296 | | CHECKED_STATUS VerifyRestoredObjects(const SnapshotScheduleRestoration& restoration) override; |
297 | | |
298 | | void CleanupHiddenObjects(const ScheduleMinRestoreTime& schedule_min_restore_time) override; |
299 | | void CleanupHiddenTablets( |
300 | | const std::vector<TabletInfoPtr>& hidden_tablets, |
301 | | const ScheduleMinRestoreTime& schedule_min_restore_time); |
302 | | // Will filter tables content, so pass it by value here. |
303 | | void CleanupHiddenTables(std::vector<TableInfoPtr> tables); |
304 | | |
305 | | rpc::Scheduler& Scheduler() override; |
306 | | |
307 | | int64_t LeaderTerm() override; |
308 | | |
309 | | Result<bool> IsTablePartOfSomeSnapshotSchedule(const TableInfo& table_info) override; |
310 | | |
311 | | Result<SnapshotSchedulesToObjectIdsMap> MakeSnapshotSchedulesToObjectIdsMap( |
312 | | SysRowEntryType type) override; |
313 | | |
314 | | static void SetTabletSnapshotsState(SysSnapshotEntryPB::State state, |
315 | | SysSnapshotEntryPB* snapshot_pb); |
316 | | |
317 | | // Create the cdc_state table if needed (i.e. if it does not exist already). |
318 | | // |
319 | | // This is called at the end of CreateCDCStream. |
320 | | CHECKED_STATUS CreateCdcStateTableIfNeeded(rpc::RpcContext *rpc); |
321 | | |
322 | | // Check if cdc_state table creation is done. |
323 | | CHECKED_STATUS IsCdcStateTableCreated(IsCreateTableDoneResponsePB* resp); |
324 | | |
325 | | // Return all CDC streams. |
326 | | void GetAllCDCStreams(std::vector<scoped_refptr<CDCStreamInfo>>* streams); |
327 | | |
328 | | // Mark specified CDC streams as DELETING so they can be removed later. |
329 | | CHECKED_STATUS MarkCDCStreamsAsDeleting(const std::vector<scoped_refptr<CDCStreamInfo>>& streams); |
330 | | |
331 | | // Find CDC streams for a table. |
332 | | std::vector<scoped_refptr<CDCStreamInfo>> FindCDCStreamsForTable(const TableId& table_id) const; |
333 | | |
334 | | bool CDCStreamExistsUnlocked(const CDCStreamId& stream_id) override REQUIRES_SHARED(mutex_); |
335 | | |
336 | | CHECKED_STATUS FillHeartbeatResponseEncryption(const SysClusterConfigEntryPB& cluster_config, |
337 | | const TSHeartbeatRequestPB* req, |
338 | | TSHeartbeatResponsePB* resp); |
339 | | |
340 | | CHECKED_STATUS FillHeartbeatResponseCDC(const SysClusterConfigEntryPB& cluster_config, |
341 | | const TSHeartbeatRequestPB* req, |
342 | | TSHeartbeatResponsePB* resp); |
343 | | |
344 | 840 | scoped_refptr<ClusterConfigInfo> GetClusterConfigInfo() const { |
345 | 840 | return cluster_config_; |
346 | 840 | } |
347 | | |
348 | | // Helper functions for GetTableSchemaCallback, GetTablegroupSchemaCallback |
349 | | // and GetColocatedTabletSchemaCallback. |
350 | | |
351 | | // Validates a single table's schema with the corresponding table on the consumer side, and |
352 | | // updates consumer_table_id with the new table id. Return the consumer table schema if the |
353 | | // validation is successful. |
354 | | CHECKED_STATUS ValidateTableSchema( |
355 | | const std::shared_ptr<client::YBTableInfo>& info, |
356 | | const std::unordered_map<TableId, std::string>& table_bootstrap_ids, |
357 | | GetTableSchemaResponsePB* resp); |
358 | | // Adds a validated table to the sys catalog table map for the given universe, and if all tables |
359 | | // have been validated, creates a CDC stream for each table. |
360 | | CHECKED_STATUS AddValidatedTableAndCreateCdcStreams( |
361 | | scoped_refptr<UniverseReplicationInfo> universe, |
362 | | const std::unordered_map<TableId, std::string>& table_bootstrap_ids, |
363 | | const TableId& producer_table, |
364 | | const TableId& consumer_table); |
365 | | |
366 | | void GetTableSchemaCallback( |
367 | | const std::string& universe_id, const std::shared_ptr<client::YBTableInfo>& info, |
368 | | const std::unordered_map<TableId, std::string>& producer_bootstrap_ids, const Status& s); |
369 | | void GetTablegroupSchemaCallback( |
370 | | const std::string& universe_id, const std::shared_ptr<std::vector<client::YBTableInfo>>& info, |
371 | | const TablegroupId& producer_tablegroup_id, |
372 | | const std::unordered_map<TableId, std::string>& producer_bootstrap_ids, const Status& s); |
373 | | void GetColocatedTabletSchemaCallback( |
374 | | const std::string& universe_id, const std::shared_ptr<std::vector<client::YBTableInfo>>& info, |
375 | | const std::unordered_map<TableId, std::string>& producer_bootstrap_ids, const Status& s); |
376 | | void GetCDCStreamCallback(const CDCStreamId& bootstrap_id, |
377 | | std::shared_ptr<TableId> table_id, |
378 | | std::shared_ptr<std::unordered_map<std::string, std::string>> options, |
379 | | const std::string& universe_id, |
380 | | const TableId& table, |
381 | | std::shared_ptr<CDCRpcTasks> cdc_rpc, |
382 | | const Status& s); |
383 | | void AddCDCStreamToUniverseAndInitConsumer(const std::string& universe_id, const TableId& table, |
384 | | const Result<CDCStreamId>& stream_id, |
385 | | std::function<void()> on_success_cb = nullptr); |
386 | | |
387 | | void MergeUniverseReplication(scoped_refptr<UniverseReplicationInfo> info); |
388 | | CHECKED_STATUS DeleteUniverseReplicationUnlocked(scoped_refptr<UniverseReplicationInfo> info); |
389 | | void MarkUniverseReplicationFailed(scoped_refptr<UniverseReplicationInfo> universe, |
390 | | const Status& failure_status); |
391 | | |
392 | | // Checks if table has at least one cdc stream (includes producers for xCluster replication). |
393 | | bool IsTableCdcProducer(const TableInfo& table_info) const override REQUIRES_SHARED(mutex_); |
394 | | |
395 | | // Checks if the table is a consumer in an xCluster replication universe. |
396 | | bool IsTableCdcConsumer(const TableInfo& table_info) const REQUIRES_SHARED(mutex_); |
397 | | |
398 | | // Maps producer universe id to the corresponding cdc stream for that table. |
399 | | typedef std::unordered_map<std::string, CDCStreamId> XClusterConsumerTableStreamInfoMap; |
400 | | |
401 | | // Gets the set of CDC stream info for an xCluster consumer table. |
402 | | XClusterConsumerTableStreamInfoMap GetXClusterStreamInfoForConsumerTable(const TableId& table_id) |
403 | | const; |
404 | | |
405 | | CHECKED_STATUS CreateTransactionAwareSnapshot( |
406 | | const CreateSnapshotRequestPB& req, CreateSnapshotResponsePB* resp, rpc::RpcContext* rpc); |
407 | | |
408 | | CHECKED_STATUS CreateNonTransactionAwareSnapshot( |
409 | | const CreateSnapshotRequestPB* req, CreateSnapshotResponsePB* resp, rpc::RpcContext* rpc); |
410 | | |
411 | | CHECKED_STATUS RestoreNonTransactionAwareSnapshot(const SnapshotId& snapshot_id); |
412 | | |
413 | | CHECKED_STATUS DeleteNonTransactionAwareSnapshot(const SnapshotId& snapshot_id); |
414 | | |
415 | | void Started() override; |
416 | | |
417 | | void SysCatalogLoaded(int64_t term) override; |
418 | | |
419 | | // Snapshot map: snapshot-id -> SnapshotInfo. |
420 | | typedef std::unordered_map<SnapshotId, scoped_refptr<SnapshotInfo>> SnapshotInfoMap; |
421 | | SnapshotInfoMap non_txn_snapshot_ids_map_; |
422 | | SnapshotId current_snapshot_id_; |
423 | | |
424 | | // mutex on should_send_universe_key_registry_mutex_. |
425 | | mutable simple_spinlock should_send_universe_key_registry_mutex_; |
426 | | // Should catalog manager resend latest universe key registry to tserver. |
427 | | std::unordered_map<TabletServerId, bool> should_send_universe_key_registry_ |
428 | | GUARDED_BY(should_send_universe_key_registry_mutex_); |
429 | | |
430 | | // CDC Stream map: CDCStreamId -> CDCStreamInfo. |
431 | | typedef std::unordered_map<CDCStreamId, scoped_refptr<CDCStreamInfo>> CDCStreamInfoMap; |
432 | | CDCStreamInfoMap cdc_stream_map_ GUARDED_BY(mutex_); |
433 | | |
434 | | // Map of tables -> number of cdc streams they are producers for. |
435 | | std::unordered_map<TableId, int> cdc_stream_tables_count_map_ GUARDED_BY(mutex_); |
436 | | |
437 | | // Map of all consumer tables that are part of xcluster replication, to a map of the stream infos. |
438 | | std::unordered_map<TableId, XClusterConsumerTableStreamInfoMap> |
439 | | xcluster_consumer_tables_to_stream_map_ GUARDED_BY(mutex_); |
440 | | |
441 | | typedef std::unordered_map<std::string, scoped_refptr<UniverseReplicationInfo>> |
442 | | UniverseReplicationInfoMap; |
443 | | UniverseReplicationInfoMap universe_replication_map_ GUARDED_BY(mutex_); |
444 | | |
445 | | // mutex on should_send_consumer_registry_mutex_. |
446 | | mutable simple_spinlock should_send_consumer_registry_mutex_; |
447 | | // Should catalog manager resend latest consumer registry to tserver. |
448 | | std::unordered_map<TabletServerId, bool> should_send_consumer_registry_ |
449 | | GUARDED_BY(should_send_consumer_registry_mutex_); |
450 | | |
451 | | MasterSnapshotCoordinator snapshot_coordinator_; |
452 | | |
453 | | DISALLOW_COPY_AND_ASSIGN(CatalogManager); |
454 | | }; |
455 | | |
456 | | } // namespace enterprise |
457 | | } // namespace master |
458 | | } // namespace yb |
459 | | |
460 | | #endif // ENT_SRC_YB_MASTER_CATALOG_MANAGER_H |