/Users/deen/code/yugabyte-db/ent/src/yb/master/async_snapshot_tasks.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_ASYNC_SNAPSHOT_TASKS_H |
14 | | #define ENT_SRC_YB_MASTER_ASYNC_SNAPSHOT_TASKS_H |
15 | | |
16 | | #include "yb/common/hybrid_time.h" |
17 | | |
18 | | #include "yb/master/async_rpc_tasks.h" |
19 | | #include "yb/master/snapshot_coordinator_context.h" |
20 | | |
21 | | #include "yb/tserver/backup.pb.h" |
22 | | |
23 | | namespace yb { |
24 | | namespace master { |
25 | | |
26 | | // Send the "Create/Restore/.. Tablet Snapshot operation" to the leader replica for the tablet. |
27 | | // Keeps retrying until we get an "ok" response. |
28 | | class AsyncTabletSnapshotOp : public RetryingTSRpcTask { |
29 | | public: |
30 | | AsyncTabletSnapshotOp( |
31 | | Master* master, |
32 | | ThreadPool* callback_pool, |
33 | | const TabletInfoPtr& tablet, |
34 | | const std::string& snapshot_id, |
35 | | tserver::TabletSnapshotOpRequestPB::Operation op); |
36 | | |
37 | 0 | Type type() const override { return ASYNC_SNAPSHOT_OP; } |
38 | | |
39 | 0 | std::string type_name() const override { return "Tablet Snapshot Operation"; } |
40 | | |
41 | | std::string description() const override; |
42 | | |
43 | 0 | void SetSnapshotScheduleId(const SnapshotScheduleId& id) { |
44 | 0 | snapshot_schedule_id_ = id; |
45 | 0 | } |
46 | | |
47 | 0 | void SetSnapshotHybridTime(HybridTime value) { |
48 | 0 | snapshot_hybrid_time_ = value; |
49 | 0 | } |
50 | | |
51 | | void SetMetadata(const SysTablesEntryPB& pb); |
52 | | |
53 | 0 | void SetRestorationId(const TxnSnapshotRestorationId& id) { |
54 | 0 | restoration_id_ = id; |
55 | 0 | } |
56 | | |
57 | 0 | void SetRestorationTime(HybridTime value) { |
58 | 0 | restoration_hybrid_time_ = value; |
59 | 0 | } |
60 | | |
61 | 0 | void SetCallback(TabletSnapshotOperationCallback callback) { |
62 | 0 | callback_ = std::move(callback); |
63 | 0 | } |
64 | | |
65 | | private: |
66 | | TabletId tablet_id() const override; |
67 | | TabletServerId permanent_uuid() const; |
68 | | |
69 | | void HandleResponse(int attempt) override; |
70 | | bool SendRequest(int attempt) override; |
71 | | void Finished(const Status& status) override; |
72 | | bool RetryAllowed(tserver::TabletServerErrorPB::Code code, const Status& status); |
73 | | |
74 | | TabletInfoPtr tablet_; |
75 | | const std::string snapshot_id_; |
76 | | tserver::TabletSnapshotOpRequestPB::Operation operation_; |
77 | | SnapshotScheduleId snapshot_schedule_id_ = SnapshotScheduleId::Nil(); |
78 | | HybridTime snapshot_hybrid_time_; |
79 | | TxnSnapshotRestorationId restoration_id_ = TxnSnapshotRestorationId::Nil(); |
80 | | HybridTime restoration_hybrid_time_; |
81 | | tserver::TabletSnapshotOpResponsePB resp_; |
82 | | TabletSnapshotOperationCallback callback_; |
83 | | bool has_metadata_ = false; |
84 | | uint32_t schema_version_; |
85 | | SchemaPB schema_; |
86 | | google::protobuf::RepeatedPtrField<IndexInfoPB> indexes_; |
87 | | bool hide_ = false; |
88 | | }; |
89 | | |
90 | | } // namespace master |
91 | | } // namespace yb |
92 | | |
93 | | #endif // ENT_SRC_YB_MASTER_ASYNC_SNAPSHOT_TASKS_H |