0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Config.cc
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "Common/Compat.h"
23 #include "Config.h"
24 
25 namespace Hypertable { namespace Config {
26 
28  cmdline_desc().add_options()
29  ("log-broker", str(), "Use the specified FS broker (in <host>:<port> "
30  "format for commit log)")
31  ("crash-test", str(), "Arguments for crash simulation")
32  ;
33  alias("port", "Hypertable.RangeServer.Port");
34  alias("log-host", "Hypertable.RangeServer.CommitLog.DfsBroker.Host");
35  alias("log-port", "Hypertable.RangeServer.CommitLog.DfsBroker.Port");
36  alias("reactors", "Hypertable.RangeServer.Reactors");
37  alias("workers", "Hypertable.RangeServer.Workers");
38 }
39 
41  String logbroker = get("log-broker", String());
42 
43  if (logbroker.length()) {
44  Endpoint e = InetAddr::parse_endpoint(logbroker);
45 
46  if (!e.port)
47  HT_THROWF(Error::CONFIG_BAD_ARGUMENT, "expected <host>:<port> format for "
48  "log-broker, got '%s'", logbroker.c_str());
49 
50  properties->set("log-host", e.host);
51  properties->set("log-port", e.port);
52  }
53 }
54 
55 }} // namespace Hypertable::Config
PropertiesPtr properties
This singleton map stores all options.
Definition: Config.cc:47
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
static Endpoint parse_endpoint(const char *endpoint, int defport=0)
Parse an endpoint string in (host:port) format.
Definition: InetAddr.cc:181
Po::typed_value< String > * str(String *v=0)
Definition: Properties.h:166
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
Definition: Config.cc:72
Compatibility Macros for C/C++.
Hypertable definitions
void init_range_server()
Definition: Config.cc:40
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
void alias(const String &cmdline_opt, const String &file_opt, bool overwrite)
Setup command line option alias for config file option.
Definition: Config.cc:607
void init_range_server_options()
Definition: Config.cc:27
High-level entry point to a service; wraps a host:port pair.
Definition: InetAddr.h:44