/Users/deen/code/yugabyte-db/src/yb/master/snapshot_coordinator_context.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_SNAPSHOT_COORDINATOR_CONTEXT_H |
15 | | #define YB_MASTER_SNAPSHOT_COORDINATOR_CONTEXT_H |
16 | | |
17 | | #include "yb/common/common_fwd.h" |
18 | | #include "yb/common/entity_ids.h" |
19 | | #include "yb/common/snapshot.h" |
20 | | |
21 | | #include "yb/docdb/docdb_fwd.h" |
22 | | |
23 | | #include "yb/master/master_fwd.h" |
24 | | #include "yb/master/master_types.pb.h" |
25 | | |
26 | | #include "yb/rpc/rpc_fwd.h" |
27 | | |
28 | | #include "yb/server/server_fwd.h" |
29 | | |
30 | | #include "yb/tablet/tablet_fwd.h" |
31 | | |
32 | | #include "yb/tserver/backup.pb.h" |
33 | | |
34 | | namespace yb { |
35 | | namespace master { |
36 | | |
37 | | using TabletSnapshotOperationCallback = |
38 | | std::function<void(Result<const tserver::TabletSnapshotOpResponsePB&>)>; |
39 | | |
40 | | using ScheduleMinRestoreTime = |
41 | | std::unordered_map<SnapshotScheduleId, HybridTime, SnapshotScheduleIdHash>; |
42 | | |
43 | | YB_STRONGLY_TYPED_BOOL(SendMetadata); |
44 | | |
45 | | // Context class for MasterSnapshotCoordinator. |
46 | | class SnapshotCoordinatorContext { |
47 | | public: |
48 | | // Return tablet infos for specified tablet ids. |
49 | | // The returned vector is always of the same length as the input vector, |
50 | | // with null entries returned for unknown tablet ids. |
51 | | virtual TabletInfos GetTabletInfos(const std::vector<TabletId>& id) = 0; |
52 | | |
53 | | virtual AsyncTabletSnapshotOpPtr CreateAsyncTabletSnapshotOp( |
54 | | const TabletInfoPtr& tablet, const std::string& snapshot_id, |
55 | | tserver::TabletSnapshotOpRequestPB::Operation operation, |
56 | | TabletSnapshotOperationCallback callback) = 0; |
57 | | |
58 | | virtual void ScheduleTabletSnapshotOp(const AsyncTabletSnapshotOpPtr& operation) = 0; |
59 | | |
60 | | virtual Result<SysRowEntries> CollectEntriesForSnapshot( |
61 | | const google::protobuf::RepeatedPtrField<TableIdentifierPB>& tables) = 0; |
62 | | |
63 | | virtual CHECKED_STATUS RestoreSysCatalog( |
64 | | SnapshotScheduleRestoration* restoration, tablet::Tablet* tablet, |
65 | | Status* complete_status) = 0; |
66 | | virtual CHECKED_STATUS VerifyRestoredObjects(const SnapshotScheduleRestoration& restoration) = 0; |
67 | | |
68 | | virtual void CleanupHiddenObjects(const ScheduleMinRestoreTime& schedule_min_restore_time) = 0; |
69 | | |
70 | | virtual const Schema& schema() = 0; |
71 | | |
72 | | virtual void Submit(std::unique_ptr<tablet::Operation> operation, int64_t leader_term) = 0; |
73 | | |
74 | | virtual rpc::Scheduler& Scheduler() = 0; |
75 | | |
76 | | virtual int64_t LeaderTerm() = 0; |
77 | | |
78 | | virtual server::Clock* Clock() = 0; |
79 | | |
80 | | virtual Result<size_t> GetNumLiveTServersForActiveCluster() = 0; |
81 | | |
82 | 92 | virtual ~SnapshotCoordinatorContext() = default; |
83 | | }; |
84 | | |
85 | | Result<docdb::KeyBytes> EncodedKey( |
86 | | SysRowEntryType type, const Slice& id, SnapshotCoordinatorContext* context); |
87 | | |
88 | | } // namespace master |
89 | | } // namespace yb |
90 | | |
91 | | #endif // YB_MASTER_SNAPSHOT_COORDINATOR_CONTEXT_H |