/Users/deen/code/yugabyte-db/src/yb/integration-tests/mini_cluster_base.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 | | |
14 | | #ifndef YB_INTEGRATION_TESTS_MINI_CLUSTER_BASE_H_ |
15 | | #define YB_INTEGRATION_TESTS_MINI_CLUSTER_BASE_H_ |
16 | | |
17 | | #include "yb/rpc/rpc_fwd.h" |
18 | | |
19 | | #include "yb/util/status_fwd.h" |
20 | | #include "yb/util/net/net_fwd.h" |
21 | | |
22 | | namespace yb { |
23 | | |
24 | | namespace client { |
25 | | class YBClientBuilder; |
26 | | class YBClient; |
27 | | } // namespace client |
28 | | |
29 | | // Base class for ExternalMiniCluster and MiniCluster with common interface required by |
30 | | // ClusterVerifier and TestWorkload. Introduced in order to be able to use ClusterVerifier |
31 | | // for both types of mini cluster. |
32 | | class MiniClusterBase { |
33 | | public: |
34 | | |
35 | | // Create a client configured to talk to this cluster. Builder may contain override options for |
36 | | // the client. The master address will be overridden to talk to the running master. |
37 | | // If 'builder' is not specified, default options will be used. |
38 | | // Client is wrapped into a holder which will shutdown client on holder destruction. |
39 | | // |
40 | | // REQUIRES: the cluster must have already been Start()ed. |
41 | | |
42 | | // Created client won't shutdown messenger. |
43 | | Result<std::unique_ptr<client::YBClient>> CreateClient(rpc::Messenger* messenger); |
44 | | |
45 | | // Created client will shutdown messenger on client shutdown. |
46 | | Result<std::unique_ptr<client::YBClient>> CreateClient( |
47 | | client::YBClientBuilder* builder = nullptr); |
48 | | |
49 | | // Created client gets messenger ownership and will shutdown messenger on client shutdown. |
50 | | Result<std::unique_ptr<client::YBClient>> CreateClient( |
51 | | std::unique_ptr<rpc::Messenger>&& messenger); |
52 | | |
53 | | Result<HostPort> GetLeaderMasterBoundRpcAddr(); |
54 | | |
55 | 0 | bool running() const { return running_.load(std::memory_order_acquire); } |
56 | | |
57 | | protected: |
58 | 371 | virtual ~MiniClusterBase() = default; |
59 | | |
60 | | std::atomic<bool> running_ { false }; |
61 | | |
62 | | template<class Options> |
63 | 1.43k | int32_t NumTabletsPerTransactionTable(Options options) { |
64 | 1.43k | return std::max(2, static_cast<int32_t>(options.num_tablet_servers)); |
65 | 1.43k | } int yb::MiniClusterBase::NumTabletsPerTransactionTable<yb::ExternalMiniClusterOptions>(yb::ExternalMiniClusterOptions) Line | Count | Source | 63 | 440 | int32_t NumTabletsPerTransactionTable(Options options) { | 64 | 440 | return std::max(2, static_cast<int32_t>(options.num_tablet_servers)); | 65 | 440 | } |
int yb::MiniClusterBase::NumTabletsPerTransactionTable<yb::MiniClusterOptions>(yb::MiniClusterOptions) Line | Count | Source | 63 | 992 | int32_t NumTabletsPerTransactionTable(Options options) { | 64 | 992 | return std::max(2, static_cast<int32_t>(options.num_tablet_servers)); | 65 | 992 | } |
|
66 | | private: |
67 | | virtual void ConfigureClientBuilder(client::YBClientBuilder* builder) = 0; |
68 | | |
69 | | virtual Result<HostPort> DoGetLeaderMasterBoundRpcAddr() = 0; |
70 | | }; |
71 | | |
72 | | } // namespace yb |
73 | | |
74 | | #endif // YB_INTEGRATION_TESTS_MINI_CLUSTER_BASE_H_ |