/Users/deen/code/yugabyte-db/src/yb/tserver/tablet_server_options.cc
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 | | |
33 | | #include "yb/tserver/tablet_server_options.h" |
34 | | |
35 | | #include "yb/tserver/tablet_server.h" |
36 | | #include "yb/tserver/tserver_flags.h" |
37 | | #include "yb/util/result.h" |
38 | | |
39 | | using std::vector; |
40 | | |
41 | | namespace yb { |
42 | | namespace tserver { |
43 | | |
44 | | const char* TabletServerOptions::kServerType = "tserver"; |
45 | | |
46 | 9.28k | Result<TabletServerOptions> TabletServerOptions::CreateTabletServerOptions() { |
47 | 9.28k | server::MasterAddresses master_addresses; |
48 | 9.28k | std::string master_addresses_resolved_str; |
49 | 9.28k | RETURN_NOT_OK(server::DetermineMasterAddresses( |
50 | 9.28k | "tserver_master_addrs", FLAGS_tserver_master_addrs, |
51 | 9.28k | FLAGS_tserver_master_replication_factor, &master_addresses, &master_addresses_resolved_str)); |
52 | | |
53 | 9.28k | TabletServerOptions opts(std::make_shared<server::MasterAddresses>(std::move(master_addresses))); |
54 | 9.28k | opts.master_addresses_flag = master_addresses_resolved_str; |
55 | 9.28k | opts.rocksdb_env = rocksdb::Env::Default(); |
56 | 9.28k | opts.env = Env::Default(); |
57 | 9.28k | return opts; |
58 | 9.28k | } |
59 | | |
60 | | TabletServerOptions::TabletServerOptions(server::MasterAddressesPtr master_addresses) |
61 | 9.28k | : ServerBaseOptions(TabletServer::kDefaultPort) { |
62 | 9.28k | server_type = kServerType; |
63 | | |
64 | 9.28k | SetMasterAddresses(std::move(master_addresses)); |
65 | 9.28k | ValidateMasterAddresses(); |
66 | 9.28k | } |
67 | | |
68 | | |
69 | 9.28k | void TabletServerOptions::ValidateMasterAddresses() const { |
70 | 9.28k | auto master_addresses = GetMasterAddresses(); |
71 | 9.28k | if (master_addresses->empty()) { |
72 | 0 | LOG(FATAL) << "No masters were specified in the master addresses flag '" |
73 | 0 | << master_addresses_flag << "', but a minimum of one is required."; |
74 | 0 | } |
75 | 9.28k | } |
76 | | |
77 | | } // namespace tserver |
78 | | } // namespace yb |