/Users/deen/code/yugabyte-db/src/yb/master/master_options.cc
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 | | #include "yb/master/master_options.h" |
34 | | |
35 | | #include <glog/logging.h> |
36 | | |
37 | | #include "yb/master/master.h" |
38 | | #include "yb/server/server_base_options.h" |
39 | | #include "yb/util/flag_tags.h" |
40 | | #include "yb/util/result.h" |
41 | | |
42 | | using std::make_shared; |
43 | | using std::vector; |
44 | | |
45 | | namespace yb { |
46 | | namespace master { |
47 | | |
48 | | DEFINE_string(master_addresses, "", |
49 | | "Comma-separated list of the host/port RPC addresses of the peer masters. This is needed " |
50 | | "for initial cluster create, and is recreated from persisted metadata on master restart." |
51 | | "This flag also defaults to empty, which is overloaded to be able to either: " |
52 | | "a) start a non-distributed mode master if local instance file is not present. " |
53 | | "b) allow for a master to be restarted gracefully and get its peer list from the " |
54 | | "local cmeta file of the last committed config, if local instance file is present."); |
55 | | TAG_FLAG(master_addresses, experimental); |
56 | | DEFINE_uint64(master_replication_factor, 0, |
57 | | "Number of master replicas. By default it is detected based on master_addresses option, but " |
58 | | "could be specified explicitly together with passing one or more master service domain name and" |
59 | | " port through master_addresses for masters auto-discovery when running on Kubernetes."); |
60 | | |
61 | | // NOTE: This flag is deprecated. |
62 | | DEFINE_bool(create_cluster, false, |
63 | | "(DEPRECATED). This flag was earlier used to distinguish if the master process is " |
64 | | "being started to create a cluster or if this just a restart."); |
65 | | TAG_FLAG(create_cluster, hidden); |
66 | | |
67 | | const char* MasterOptions::kServerType = "master"; |
68 | | |
69 | | MasterOptions::MasterOptions(server::MasterAddressesPtr master_addresses) |
70 | 5.45k | : ServerBaseOptions(kMasterDefaultPort) { |
71 | 5.45k | server_type = kServerType; |
72 | | |
73 | 5.45k | SetMasterAddresses(master_addresses); |
74 | 5.45k | } |
75 | | |
76 | 4.93k | Result<MasterOptions> MasterOptions::CreateMasterOptions() { |
77 | 4.93k | server::MasterAddresses master_addresses; |
78 | 4.93k | std::string master_addresses_resolved_str; |
79 | 4.93k | RETURN_NOT_OK(server::DetermineMasterAddresses( |
80 | 4.93k | "master_addresses", FLAGS_master_addresses, FLAGS_master_replication_factor, |
81 | 4.93k | &master_addresses, &master_addresses_resolved_str)); |
82 | | |
83 | 4.93k | MasterOptions opts(std::make_shared<server::MasterAddresses>(std::move(master_addresses))); |
84 | 4.93k | opts.master_addresses_flag = master_addresses_resolved_str; |
85 | 4.93k | return opts; |
86 | 4.93k | } |
87 | | |
88 | | } // namespace master |
89 | | } // namespace yb |