YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tools/yb-admin_client.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
#ifndef YB_TOOLS_YB_ADMIN_CLIENT_H
33
#define YB_TOOLS_YB_ADMIN_CLIENT_H
34
35
#include <string>
36
#include <vector>
37
38
#include <boost/optional.hpp>
39
40
#include "yb/client/yb_table_name.h"
41
42
#include "yb/rpc/rpc_controller.h"
43
44
#include "yb/util/status_fwd.h"
45
#include "yb/util/monotime.h"
46
#include "yb/util/net/net_util.h"
47
#include "yb/util/net/sockaddr.h"
48
#include "yb/util/status.h"
49
#include "yb/util/type_traits.h"
50
#include "yb/common/entity_ids.h"
51
#include "yb/consensus/consensus_types.pb.h"
52
53
#include "yb/master/master_client.pb.h"
54
#include "yb/master/master_cluster.pb.h"
55
#include "yb/master/master_fwd.h"
56
57
#include "yb/tools/yb-admin_cli.h"
58
#include "yb/rpc/rpc_fwd.h"
59
60
namespace yb {
61
62
class HybridTime;
63
64
namespace consensus {
65
class ConsensusServiceProxy;
66
}
67
68
namespace client {
69
class YBClient;
70
}
71
72
namespace tools {
73
74
struct TypedNamespaceName {
75
  YQLDatabase db_type = YQL_DATABASE_UNKNOWN;
76
  std::string name;
77
};
78
79
class TableNameResolver {
80
 public:
81
  TableNameResolver(std::vector<client::YBTableName> tables,
82
                    std::vector<master::NamespaceIdentifierPB> namespaces);
83
  TableNameResolver(TableNameResolver&&);
84
  ~TableNameResolver();
85
86
  Result<bool> Feed(const std::string& value);
87
  std::vector<client::YBTableName>& values();
88
  master::NamespaceIdentifierPB last_namespace();
89
90
 private:
91
  class Impl;
92
  std::unique_ptr<Impl> impl_;
93
};
94
95
HAS_MEMBER_FUNCTION(error);
96
HAS_MEMBER_FUNCTION(status);
97
98
template<class Response>
99
CHECKED_STATUS ResponseStatus(
100
    const Response& response,
101
0
    typename std::enable_if<HasMemberFunction_error<Response>::value, void*>::type = nullptr) {
102
  // Response has has_error method, use status from it.
103
0
  if (response.has_error()) {
104
0
    return StatusFromPB(response.error().status());
105
0
  }
106
0
  return Status::OK();
107
0
}
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master23ListSnapshotsResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master24CreateSnapshotResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master20ListTablesResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master32CreateSnapshotScheduleResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master31ListSnapshotSchedulesResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master32DeleteSnapshotScheduleResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master25RestoreSnapshotResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master24DeleteSnapshotResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master28ImportSnapshotMetaResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
Unexecuted instantiation: _ZN2yb5tools14ResponseStatusINS_6master28GetTabletLocationsResponsePBEEENS_6StatusERKT_NSt3__19enable_ifIXsr23HasMemberFunction_errorIS5_EE5valueEPvE4typeE
108
109
template<class Response>
110
CHECKED_STATUS ResponseStatus(
111
    const Response& response,
112
0
    typename std::enable_if<HasMemberFunction_status<Response>::value, void*>::type = nullptr) {
113
0
  if (response.has_status()) {
114
0
    return StatusFromPB(response.status());
115
0
  }
116
0
  return Status::OK();
117
0
}
118
119
class ClusterAdminClient {
120
 public:
121
  enum PeerMode {
122
    LEADER = 1,
123
    FOLLOWER
124
  };
125
126
  // Creates an admin client for host/port combination e.g.,
127
  // "localhost" or "127.0.0.1:7050" with the given timeout.
128
  // If certs_dir is non-empty, caller will init the yb_client_.
129
  ClusterAdminClient(std::string addrs, MonoDelta timeout);
130
131
  ClusterAdminClient(const HostPort& init_master_addr, MonoDelta timeout);
132
133
  virtual ~ClusterAdminClient();
134
135
  // Initialized the client and connects to the specified tablet server.
136
  CHECKED_STATUS Init();
137
138
  // Parse the user-specified change type to consensus change type
139
  CHECKED_STATUS ParseChangeType(
140
      const std::string& change_type,
141
      consensus::ChangeConfigType* cc_type);
142
143
  // Change the configuration of the specified tablet.
144
  CHECKED_STATUS ChangeConfig(
145
      const TabletId& tablet_id,
146
      const std::string& change_type,
147
      const PeerId& peer_uuid,
148
      const boost::optional<std::string>& member_type);
149
150
  // Change the configuration of the master tablet.
151
  CHECKED_STATUS ChangeMasterConfig(
152
      const std::string& change_type,
153
      const std::string& peer_host,
154
      uint16_t peer_port,
155
      const std::string& peer_uuid = "");
156
157
  CHECKED_STATUS DumpMasterState(bool to_console);
158
159
  // List all the tables.
160
  CHECKED_STATUS ListTables(bool include_db_type,
161
                            bool include_table_id,
162
                            bool include_table_type);
163
164
  // List all tablets of this table
165
  CHECKED_STATUS ListTablets(const client::YBTableName& table_name,
166
                             int max_tablets,
167
                             bool json,
168
                             bool followers);
169
170
  // Per Tablet list of all tablet servers
171
  CHECKED_STATUS ListPerTabletTabletServers(const PeerId& tablet_id);
172
173
  // Delete a single table by name.
174
  CHECKED_STATUS DeleteTable(const client::YBTableName& table_name);
175
176
  // Delete a single table by ID.
177
  CHECKED_STATUS DeleteTableById(const TableId& table_id);
178
179
  // Delete a single index by name.
180
  CHECKED_STATUS DeleteIndex(const client::YBTableName& table_name);
181
182
  // Delete a single index by ID.
183
  CHECKED_STATUS DeleteIndexById(const TableId& table_id);
184
185
  // Delete a single namespace by name.
186
  CHECKED_STATUS DeleteNamespace(const TypedNamespaceName& name);
187
188
  // Delete a single namespace by ID.
189
  CHECKED_STATUS DeleteNamespaceById(const NamespaceId& namespace_id);
190
191
  // Launch backfill for (deferred) indexes on the specified table.
192
  CHECKED_STATUS LaunchBackfillIndexForTable(const client::YBTableName& table_name);
193
194
  // List all tablet servers known to master
195
  CHECKED_STATUS ListAllTabletServers(bool exclude_dead = false);
196
197
  // List all masters
198
  CHECKED_STATUS ListAllMasters();
199
200
  // List the log locations of all tablet servers, by uuid
201
  CHECKED_STATUS ListTabletServersLogLocations();
202
203
  // List all the tablets a certain tablet server is serving
204
  CHECKED_STATUS ListTabletsForTabletServer(const PeerId& ts_uuid);
205
206
  CHECKED_STATUS SetLoadBalancerEnabled(bool is_enabled);
207
208
  CHECKED_STATUS GetLoadBalancerState();
209
210
  CHECKED_STATUS GetLoadMoveCompletion();
211
212
  CHECKED_STATUS GetLeaderBlacklistCompletion();
213
214
  CHECKED_STATUS GetIsLoadBalancerIdle();
215
216
  CHECKED_STATUS ListLeaderCounts(const client::YBTableName& table_name);
217
218
  Result<std::unordered_map<std::string, int>> GetLeaderCounts(
219
      const client::YBTableName& table_name);
220
221
  CHECKED_STATUS SetupRedisTable();
222
223
  CHECKED_STATUS DropRedisTable();
224
225
  CHECKED_STATUS FlushTables(const std::vector<client::YBTableName>& table_names,
226
                             bool add_indexes,
227
                             int timeout_secs,
228
                             bool is_compaction);
229
230
  CHECKED_STATUS FlushTablesById(const std::vector<TableId>& table_id,
231
                                 bool add_indexes,
232
                                 int timeout_secs,
233
                                 bool is_compaction);
234
235
  CHECKED_STATUS FlushSysCatalog();
236
237
  CHECKED_STATUS CompactSysCatalog();
238
239
  CHECKED_STATUS ModifyTablePlacementInfo(const client::YBTableName& table_name,
240
                                          const std::string& placement_info,
241
                                          int replication_factor,
242
                                          const std::string& optional_uuid);
243
244
  CHECKED_STATUS ModifyPlacementInfo(std::string placement_infos,
245
                                     int replication_factor,
246
                                     const std::string& optional_uuid);
247
248
  CHECKED_STATUS ClearPlacementInfo();
249
250
  CHECKED_STATUS AddReadReplicaPlacementInfo(const std::string& placement_info,
251
                                             int replication_factor,
252
                                             const std::string& optional_uuid);
253
254
  CHECKED_STATUS ModifyReadReplicaPlacementInfo(const std::string& placement_uuid,
255
                                                const std::string& placement_info,
256
                                                int replication_factor);
257
258
  CHECKED_STATUS DeleteReadReplicaPlacementInfo();
259
260
  CHECKED_STATUS GetUniverseConfig();
261
262
  CHECKED_STATUS ChangeBlacklist(const std::vector<HostPort>& servers, bool add,
263
      bool blacklist_leader);
264
265
  Result<const master::NamespaceIdentifierPB&> GetNamespaceInfo(YQLDatabase db_type,
266
                                                                const std::string& namespace_name);
267
268
  CHECKED_STATUS LeaderStepDownWithNewLeader(
269
      const std::string& tablet_id,
270
      const std::string& dest_ts_uuid);
271
272
  CHECKED_STATUS MasterLeaderStepDown(
273
      const std::string& leader_uuid,
274
      const std::string& new_leader_uuid = std::string());
275
276
  CHECKED_STATUS SplitTablet(const std::string& tablet_id);
277
278
  CHECKED_STATUS CreateTransactionsStatusTable(const std::string& table_name);
279
280
  Result<TableNameResolver> BuildTableNameResolver();
281
282
  Result<std::string> GetMasterLeaderUuid();
283
284
  CHECKED_STATUS GetYsqlCatalogVersion();
285
286
  Result<rapidjson::Document> DdlLog();
287
288
  // Upgrade YSQL cluster (all databases) to the latest version, applying necessary migrations.
289
  // Note: Works with a tserver but is placed here (and not in yb-ts-cli) because it doesn't
290
  //       look like this workflow is a good fit there.
291
  CHECKED_STATUS UpgradeYsql();
292
293
  // Set WAL retention time in secs for a table name.
294
  CHECKED_STATUS SetWalRetentionSecs(
295
    const client::YBTableName& table_name, const uint32_t wal_ret_secs);
296
297
  CHECKED_STATUS GetWalRetentionSecs(const client::YBTableName& table_name);
298
299
 protected:
300
  // Fetch the locations of the replicas for a given tablet from the Master.
301
  CHECKED_STATUS GetTabletLocations(const TabletId& tablet_id,
302
                                    master::TabletLocationsPB* locations);
303
304
  // Fetch information about the location of a tablet peer from the leader master.
305
  CHECKED_STATUS GetTabletPeer(
306
      const TabletId& tablet_id,
307
      PeerMode mode,
308
      master::TSInfoPB* ts_info);
309
310
  // Set the uuid and the socket information for a peer of this tablet.
311
  CHECKED_STATUS SetTabletPeerInfo(
312
      const TabletId& tablet_id,
313
      PeerMode mode,
314
      PeerId* peer_uuid,
315
      HostPort* peer_addr);
316
317
  // Fetch the latest list of tablet servers from the Master.
318
  CHECKED_STATUS ListTabletServers(
319
      google::protobuf::RepeatedPtrField<master::ListTabletServersResponsePB_Entry>* servers);
320
321
  // Look up the RPC address of the server with the specified UUID from the Master.
322
  Result<HostPort> GetFirstRpcAddressForTS(const std::string& uuid);
323
324
  // Step down the leader of this tablet.
325
  // If leader_uuid is empty, look it up with the master.
326
  // If leader_uuid is not empty, must provide a leader_proxy.
327
  // If new_leader_uuid is not empty, it is used as a suggestion for the StepDown operation.
328
  CHECKED_STATUS LeaderStepDown(
329
      const PeerId& leader_uuid,
330
      const TabletId& tablet_id,
331
      const PeerId& new_leader_uuid,
332
      std::unique_ptr<consensus::ConsensusServiceProxy>* leader_proxy);
333
334
  CHECKED_STATUS StartElection(const std::string& tablet_id);
335
336
  CHECKED_STATUS WaitUntilMasterLeaderReady();
337
338
  template <class Resp, class F>
339
0
  CHECKED_STATUS RequestMasterLeader(Resp* resp, const F& f) {
340
0
    auto deadline = CoarseMonoClock::now() + timeout_;
341
0
    rpc::RpcController rpc;
342
0
    rpc.set_timeout(timeout_);
343
0
    for (;;) {
344
0
      resp->Clear();
345
0
      RETURN_NOT_OK(f(&rpc));
346
347
0
      auto status = ResponseStatus(*resp);
348
0
      if (status.ok()) {
349
0
        return Status::OK();
350
0
      }
351
352
0
      if (!status.IsLeaderHasNoLease() && !status.IsLeaderNotReadyToServe() &&
353
0
          !status.IsServiceUnavailable()) {
354
0
        return status;
355
0
      }
356
357
0
      auto timeout = deadline - CoarseMonoClock::now();
358
0
      if (timeout <= MonoDelta::kZero) {
359
0
        return status;
360
0
      }
361
362
0
      rpc.Reset();
363
0
      rpc.set_timeout(timeout);
364
0
      ResetMasterProxy();
365
0
    }
366
0
  }
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master23ListSnapshotsResponsePBEZNS0_10enterprise18ClusterAdminClient13ListSnapshotsERKNS_10EnumBitSetINS5_17ListSnapshotsFlagEEEE3$_0EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master34ListSnapshotRestorationsResponsePBEZNS0_10enterprise18ClusterAdminClient13ListSnapshotsERKNS_10EnumBitSetINS5_17ListSnapshotsFlagEEEE3$_1EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master24CreateSnapshotResponsePBEZNS0_10enterprise18ClusterAdminClient14CreateSnapshotERKNSt3__16vectorINS_6client11YBTableNameENS7_9allocatorISA_EEEEbiE3$_2EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master20ListTablesResponsePBEZNS0_10enterprise18ClusterAdminClient23CreateNamespaceSnapshotERKNS0_18TypedNamespaceNameEE3$_3EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master34ListSnapshotRestorationsResponsePBEZNS0_10enterprise18ClusterAdminClient24ListSnapshotRestorationsERKNS_17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEEE3$_4EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master32CreateSnapshotScheduleResponsePBEZNS0_10enterprise18ClusterAdminClient22CreateSnapshotScheduleERKNS_6client11YBTableNameENS_9MonoDeltaESB_E3$_5EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master31ListSnapshotSchedulesResponsePBEZNS0_10enterprise18ClusterAdminClient21ListSnapshotSchedulesERKNS_17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEEE3$_6EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master32DeleteSnapshotScheduleResponsePBEZNS0_10enterprise18ClusterAdminClient22DeleteSnapshotScheduleERKNS_17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEEE3$_7EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master25RestoreSnapshotResponsePBEZNS0_10enterprise18ClusterAdminClient15RestoreSnapshotERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEENS_10HybridTimeEE3$_8EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master24DeleteSnapshotResponsePBEZNS0_10enterprise18ClusterAdminClient14DeleteSnapshotERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEE3$_9EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master23ListSnapshotsResponsePBEZNS0_10enterprise18ClusterAdminClient22CreateSnapshotMetaFileERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEESF_E4$_10EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master28ImportSnapshotMetaResponsePBEZNS0_10enterprise18ClusterAdminClient22ImportSnapshotMetaFileERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS0_18TypedNamespaceNameERKNS7_6vectorINS_6client11YBTableNameENSB_ISL_EEEEE4$_11EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master24CreateSnapshotResponsePBEZNS0_10enterprise18ClusterAdminClient22ImportSnapshotMetaFileERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS0_18TypedNamespaceNameERKNS7_6vectorINS_6client11YBTableNameENSB_ISL_EEEEE4$_13EENS_6StatusEPT_RKT0_
Unexecuted instantiation: yb-admin_client_ent.cc:_ZN2yb5tools18ClusterAdminClient19RequestMasterLeaderINS_6master28GetTabletLocationsResponsePBEZNS0_10enterprise18ClusterAdminClient21ListReplicaTypeCountsERKNS_6client11YBTableNameEE4$_14EENS_6StatusEPT_RKT0_
367
368
  void ResetMasterProxy(const HostPort& leader_addr = HostPort());
369
370
  std::string master_addr_list_;
371
  HostPort init_master_addr_;
372
  const MonoDelta timeout_;
373
  HostPort leader_addr_;
374
  std::unique_ptr<rpc::SecureContext> secure_context_;
375
  std::unique_ptr<rpc::Messenger> messenger_;
376
  std::unique_ptr<rpc::ProxyCache> proxy_cache_;
377
  std::unique_ptr<master::MasterAdminProxy> master_admin_proxy_;
378
  std::unique_ptr<master::MasterBackupProxy> master_backup_proxy_;
379
  std::unique_ptr<master::MasterClientProxy> master_client_proxy_;
380
  std::unique_ptr<master::MasterClusterProxy> master_cluster_proxy_;
381
  std::unique_ptr<master::MasterDdlProxy> master_ddl_proxy_;
382
  std::unique_ptr<master::MasterEncryptionProxy> master_encryption_proxy_;
383
  std::unique_ptr<master::MasterReplicationProxy> master_replication_proxy_;
384
385
  // Skip yb_client_ and related fields' initialization.
386
  std::unique_ptr<client::YBClient> yb_client_;
387
  bool initted_ = false;
388
389
 private:
390
391
  CHECKED_STATUS DiscoverAllMasters(
392
    const HostPort& init_master_addr, std::string* all_master_addrs);
393
394
  CHECKED_STATUS FillPlacementInfo(
395
      master::PlacementInfoPB* placement_info_pb, const std::string& placement_str);
396
397
  Result<int> GetReadReplicaConfigFromPlacementUuid(
398
      master::ReplicationInfoPB* replication_info, const std::string& placement_uuid);
399
400
401
  Result<master::GetMasterClusterConfigResponsePB> GetMasterClusterConfig();
402
403
  // Perform RPC call without checking Response structure for error
404
  template<class Response, class Request, class Object>
405
  Result<Response> InvokeRpcNoResponseCheck(
406
      Status (Object::*func)(const Request&, Response*, rpc::RpcController*) const,
407
      const Object& obj, const Request& req, const char* error_message = nullptr);
408
409
  // Perform RPC call by calling InvokeRpcNoResponseCheck
410
  // and check Response structure for error by using its has_error method (if any)
411
  template<class Response, class Request, class Object>
412
  Result<Response> InvokeRpc(
413
      Status (Object::*func)(const Request&, Response*, rpc::RpcController*) const,
414
      const Object& obj, const Request& req, const char* error_message = nullptr);
415
416
 private:
417
  using NamespaceMap = std::unordered_map<NamespaceId, master::NamespaceIdentifierPB>;
418
  Result<const NamespaceMap&> GetNamespaceMap();
419
420
  NamespaceMap namespace_map_;
421
422
  DISALLOW_COPY_AND_ASSIGN(ClusterAdminClient);
423
};
424
425
static constexpr const char* kColumnSep = " \t";
426
427
std::string RightPadToUuidWidth(const std::string &s);
428
429
Result<TypedNamespaceName> ParseNamespaceName(
430
    const std::string& full_namespace_name,
431
    const YQLDatabase default_if_no_prefix = YQL_DATABASE_CQL);
432
433
void AddStringField(
434
    const char* name, const std::string& value, rapidjson::Value* out,
435
    rapidjson::Value::AllocatorType* allocator);
436
437
// Renders hybrid time to string for user, time is rendered in local TZ.
438
std::string HybridTimeToString(HybridTime ht);
439
440
}  // namespace tools
441
}  // namespace yb
442
443
#endif // YB_TOOLS_YB_ADMIN_CLIENT_H