/Users/deen/code/yugabyte-db/src/yb/tools/ysck_remote.h
Line | Count | Source |
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 | | |
33 | | #ifndef YB_TOOLS_YSCK_REMOTE_H |
34 | | #define YB_TOOLS_YSCK_REMOTE_H |
35 | | |
36 | | #include <memory> |
37 | | #include <string> |
38 | | #include <vector> |
39 | | |
40 | | #include "yb/rpc/rpc_fwd.h" |
41 | | |
42 | | #include "yb/server/server_base.proxy.h" |
43 | | |
44 | | #include "yb/tools/ysck.h" |
45 | | |
46 | | #include "yb/tserver/tablet_server.h" |
47 | | |
48 | | namespace yb { |
49 | | |
50 | | class Schema; |
51 | | |
52 | | namespace tools { |
53 | | |
54 | | // This implementation connects to a Tablet Server via RPC. |
55 | | class RemoteYsckTabletServer : public YsckTabletServer { |
56 | | public: |
57 | | explicit RemoteYsckTabletServer(const std::string& id, |
58 | | const HostPort& address, |
59 | | rpc::ProxyCache* proxy_cache); |
60 | | |
61 | | CHECKED_STATUS Connect() const override; |
62 | | |
63 | | CHECKED_STATUS CurrentHybridTime(uint64_t* hybrid_time) const override; |
64 | | |
65 | | void RunTabletChecksumScanAsync( |
66 | | const std::string& tablet_id, |
67 | | const Schema& schema, |
68 | | const ChecksumOptions& options, |
69 | | const ReportResultCallback& callback) override; |
70 | | |
71 | | |
72 | 4.37k | const std::string& address() const override { |
73 | 4.37k | return address_; |
74 | 4.37k | } |
75 | | |
76 | | private: |
77 | | const std::string address_; |
78 | | const std::shared_ptr<server::GenericServiceProxy> generic_proxy_; |
79 | | const std::shared_ptr<tserver::TabletServerServiceProxy> ts_proxy_; |
80 | | }; |
81 | | |
82 | | // This implementation connects to a Master via RPC. |
83 | | class RemoteYsckMaster : public YsckMaster { |
84 | | public: |
85 | | static CHECKED_STATUS Build(const HostPort& address, std::shared_ptr<YsckMaster>* master); |
86 | | |
87 | | virtual ~RemoteYsckMaster(); |
88 | | |
89 | | virtual CHECKED_STATUS Connect() const override; |
90 | | |
91 | | virtual CHECKED_STATUS RetrieveTabletServers(TSMap* tablet_servers) override; |
92 | | |
93 | | virtual CHECKED_STATUS RetrieveTablesList( |
94 | | std::vector<std::shared_ptr<YsckTable> >* tables) override; |
95 | | |
96 | | virtual CHECKED_STATUS RetrieveTabletsList(const std::shared_ptr<YsckTable>& table) override; |
97 | | |
98 | | private: |
99 | | explicit RemoteYsckMaster( |
100 | | const HostPort& address, std::unique_ptr<rpc::Messenger>&& messenger); |
101 | | |
102 | | CHECKED_STATUS GetTableInfo( |
103 | | const TableId& table_id, Schema* schema, int* num_replicas, bool* is_pg_table); |
104 | | |
105 | | // Used to get a batch of tablets from the master, passing a pointer to the |
106 | | // seen last key that will be used as the new start key. The |
107 | | // last_partition_key is updated to point at the new last key that came in |
108 | | // the batch. |
109 | | CHECKED_STATUS GetTabletsBatch( |
110 | | const TableId& table_id, |
111 | | const client::YBTableName& table_name, |
112 | | std::string* last_partition_key, std::vector<std::shared_ptr<YsckTablet> >* tablets, |
113 | | bool* more_tablets); |
114 | | |
115 | | std::unique_ptr<rpc::Messenger> messenger_; |
116 | | std::unique_ptr<rpc::ProxyCache> proxy_cache_; |
117 | | const std::shared_ptr<server::GenericServiceProxy> generic_proxy_; |
118 | | std::shared_ptr<master::MasterClientProxy> client_proxy_; |
119 | | std::shared_ptr<master::MasterClusterProxy> cluster_proxy_; |
120 | | std::shared_ptr<master::MasterDdlProxy> ddl_proxy_; |
121 | | }; |
122 | | |
123 | | } // namespace tools |
124 | | } // namespace yb |
125 | | |
126 | | #endif // YB_TOOLS_YSCK_REMOTE_H |