/Users/deen/code/yugabyte-db/ent/src/yb/tools/yb-admin_client.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 | | #ifndef ENT_SRC_YB_TOOLS_YB_ADMIN_CLIENT_H |
14 | | #define ENT_SRC_YB_TOOLS_YB_ADMIN_CLIENT_H |
15 | | |
16 | | #include "../../../../src/yb/tools/yb-admin_client.h" |
17 | | #include "yb/cdc/cdc_service.pb.h" |
18 | | #include "yb/common/snapshot.h" |
19 | | #include "yb/rpc/secure_stream.h" |
20 | | #include "yb/server/secure.h" |
21 | | #include "yb/util/env_util.h" |
22 | | #include "yb/util/path_util.h" |
23 | | |
24 | | namespace yb { |
25 | | namespace tools { |
26 | | namespace enterprise { |
27 | | |
28 | | // Flags for list_snapshot command. |
29 | | YB_DEFINE_ENUM(ListSnapshotsFlag, (SHOW_DETAILS)(NOT_SHOW_RESTORED)(SHOW_DELETED)(JSON)); |
30 | | using ListSnapshotsFlags = EnumBitSet<ListSnapshotsFlag>; |
31 | | |
32 | | class ClusterAdminClient : public yb::tools::ClusterAdminClient { |
33 | | typedef yb::tools::ClusterAdminClient super; |
34 | | public: |
35 | | ClusterAdminClient(std::string addrs, MonoDelta timeout) |
36 | 112 | : super(std::move(addrs), timeout) {} |
37 | | |
38 | | ClusterAdminClient(const HostPort& init_master_addrs, MonoDelta timeout) |
39 | 2 | : super(init_master_addrs, timeout) {} |
40 | | |
41 | | // Snapshot operations. |
42 | | CHECKED_STATUS ListSnapshots(const ListSnapshotsFlags& flags); |
43 | | CHECKED_STATUS CreateSnapshot(const std::vector<client::YBTableName>& tables, |
44 | | const bool add_indexes = true, |
45 | | const int flush_timeout_secs = 0); |
46 | | CHECKED_STATUS CreateNamespaceSnapshot(const TypedNamespaceName& ns); |
47 | | Result<rapidjson::Document> ListSnapshotRestorations( |
48 | | const TxnSnapshotRestorationId& restoration_id); |
49 | | Result<rapidjson::Document> CreateSnapshotSchedule(const client::YBTableName& keyspace, |
50 | | MonoDelta interval, MonoDelta retention); |
51 | | Result<rapidjson::Document> ListSnapshotSchedules(const SnapshotScheduleId& schedule_id); |
52 | | Result<rapidjson::Document> DeleteSnapshotSchedule(const SnapshotScheduleId& schedule_id); |
53 | | Result<rapidjson::Document> RestoreSnapshotSchedule( |
54 | | const SnapshotScheduleId& schedule_id, HybridTime restore_at); |
55 | | CHECKED_STATUS RestoreSnapshot(const std::string& snapshot_id, |
56 | | HybridTime timestamp); |
57 | | CHECKED_STATUS DeleteSnapshot(const std::string& snapshot_id); |
58 | | |
59 | | CHECKED_STATUS CreateSnapshotMetaFile(const std::string& snapshot_id, |
60 | | const std::string& file_name); |
61 | | CHECKED_STATUS ImportSnapshotMetaFile(const std::string& file_name, |
62 | | const TypedNamespaceName& keyspace, |
63 | | const std::vector<client::YBTableName>& tables); |
64 | | CHECKED_STATUS ListReplicaTypeCounts(const client::YBTableName& table_name); |
65 | | |
66 | | CHECKED_STATUS SetPreferredZones(const std::vector<string>& preferred_zones); |
67 | | |
68 | | CHECKED_STATUS RotateUniverseKey(const std::string& key_path); |
69 | | |
70 | | CHECKED_STATUS DisableEncryption(); |
71 | | |
72 | | CHECKED_STATUS IsEncryptionEnabled(); |
73 | | |
74 | | CHECKED_STATUS AddUniverseKeyToAllMasters( |
75 | | const std::string& key_id, const std::string& universe_key); |
76 | | |
77 | | CHECKED_STATUS AllMastersHaveUniverseKeyInMemory(const std::string& key_id); |
78 | | |
79 | | CHECKED_STATUS RotateUniverseKeyInMemory(const std::string& key_id); |
80 | | |
81 | | CHECKED_STATUS DisableEncryptionInMemory(); |
82 | | |
83 | | CHECKED_STATUS WriteUniverseKeyToFile(const std::string& key_id, const std::string& file_name); |
84 | | |
85 | | CHECKED_STATUS CreateCDCStream(const TableId& table_id); |
86 | | |
87 | | CHECKED_STATUS CreateCDCSDKDBStream(const TypedNamespaceName& ns, |
88 | | const std::string& CheckPointType); |
89 | | |
90 | | CHECKED_STATUS DeleteCDCStream(const std::string& stream_id, bool force_delete = false); |
91 | | |
92 | | CHECKED_STATUS DeleteCDCSDKDBStream(const std::string& db_stream_id); |
93 | | |
94 | | CHECKED_STATUS ListCDCStreams(const TableId& table_id); |
95 | | |
96 | | CHECKED_STATUS ListCDCSDKStreams(const std::string& namespace_name); |
97 | | |
98 | | CHECKED_STATUS GetCDCDBStreamInfo(const std::string& db_stream_id); |
99 | | |
100 | | CHECKED_STATUS SetupUniverseReplication(const std::string& producer_uuid, |
101 | | const std::vector<std::string>& producer_addresses, |
102 | | const std::vector<TableId>& tables, |
103 | | const std::vector<std::string>& producer_bootstrap_ids); |
104 | | |
105 | | CHECKED_STATUS DeleteUniverseReplication(const std::string& producer_id, |
106 | | bool ignore_errors = false); |
107 | | |
108 | | CHECKED_STATUS AlterUniverseReplication( |
109 | | const std::string& producer_uuid, |
110 | | const std::vector<std::string>& producer_addresses, |
111 | | const std::vector<TableId>& add_tables, |
112 | | const std::vector<TableId>& remove_tables, |
113 | | const std::vector<std::string>& producer_bootstrap_ids_to_add, |
114 | | const std::string& new_producer_universe_id); |
115 | | |
116 | | CHECKED_STATUS RenameUniverseReplication(const std::string& old_universe_name, |
117 | | const std::string& new_universe_name); |
118 | | |
119 | | CHECKED_STATUS WaitForSetupUniverseReplicationToFinish(const string& producer_uuid); |
120 | | |
121 | | CHECKED_STATUS SetUniverseReplicationEnabled(const std::string& producer_id, |
122 | | bool is_enabled); |
123 | | |
124 | | CHECKED_STATUS BootstrapProducer(const std::vector<TableId>& table_id); |
125 | | |
126 | | private: |
127 | | Result<TxnSnapshotId> SuitableSnapshotId( |
128 | | const SnapshotScheduleId& schedule_id, HybridTime restore_at, CoarseTimePoint deadline); |
129 | | |
130 | | CHECKED_STATUS SendEncryptionRequest(const std::string& key_path, bool enable_encryption); |
131 | | |
132 | | Result<HostPort> GetFirstRpcAddressForTS(); |
133 | | |
134 | | void CleanupEnvironmentOnSetupUniverseReplicationFailure( |
135 | | const std::string& producer_uuid, const Status& failure_status); |
136 | | |
137 | | DISALLOW_COPY_AND_ASSIGN(ClusterAdminClient); |
138 | | }; |
139 | | |
140 | | } // namespace enterprise |
141 | | } // namespace tools |
142 | | } // namespace yb |
143 | | |
144 | | #endif // ENT_SRC_YB_TOOLS_YB_ADMIN_CLIENT_H |