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 
22 #include "Common/Compat.h"
23 #include "Common/InetAddr.h"
24 #include "Config.h"
25 #include "Thrift.h"
26 
27 namespace Hypertable { namespace Config {
28 
30  cmdline_desc().add_options()
31  ("thrift-broker", str()->default_value("localhost:15867"),
32  "Thrift client endpoint in <host:port> format")
33  ("thrift-timeout", i32(),
34  "Timeout in milli-seconds for thrift client connections")
35  ;
36  alias("thrift-timeout", "ThriftBroker.Timeout");
37  // hidden aliases
38  alias("thrift-host", "ThriftBroker.Host");
39  alias("thrift-port", "ThriftBroker.Port");
40 }
41 
43  // prepare hidden aliases to be synced
44  Endpoint e = InetAddr::parse_endpoint(get_str("thrift-broker"));
45  bool defaulted = properties->defaulted("thrift-broker");
46  properties->set("thrift-host", e.host, defaulted);
47  properties->set("thrift-port", e.port, !e.port || defaulted);
48  // redirect thrift output
50 }
51 
53  cmdline_desc().add_options()
54  ("port", i16()->default_value(15867), "Listening port")
55  ("pidfile", str(), "File to contain the process id")
56  ("log-api", boo()->default_value(false), "Enable or disable API logging")
57  ("workers", i32()->default_value(50), "Worker threads")
58  ;
59  alias("port", "ThriftBroker.Port");
60  alias("log-api", "ThriftBroker.API.Logging");
61  alias("workers", "ThriftBroker.Workers");
62  // hidden aliases
63  alias("thrift-timeout", "ThriftBroker.Timeout");
64 }
65 
68  // redirect thrift output
70 }
71 
72 static void thrift_output_handler(const char *message) {
73 #if !defined(HT_DISABLE_LOG_ALL) && !defined(HT_DISABLE_LOG_ERROR)
74  if (message && Logger::get()->is_enabled(Logger::Priority::ERROR))
76 #endif
77 }
78 
80  apache::thrift::GlobalOutput.setOutputFunction(thrift_output_handler);
81 }
82 
83 }} // namespace Hypertable::Config
PropertiesPtr properties
This singleton map stores all options.
Definition: Config.cc:47
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< uint16_t > * i16(uint16_t *v=0)
Definition: Properties.h:174
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
Po::typed_value< int32_t > * i32(int32_t *v=0)
Definition: Properties.h:178
Compatibility Macros for C/C++.
Po::typed_value< bool > * boo(bool *v=0)
Definition: Properties.h:162
void init_thrift_client()
Definition: Config.cc:42
bool defaulted(const String &name)
Check if a configuration value is defaulted.
Definition: Config.h:67
Hypertable definitions
void log(int priority, const char *format,...)
Prints a message with variable arguments.
Definition: Logger.cc:95
void init_thrift_client_options()
Definition: Config.cc:29
void init_generic_server()
Initializes generic server by writing the pidfile.
Definition: Config.cc:65
void init_thrift_broker_options()
Definition: Config.cc:52
void redirect_thrift_output()
Definition: Config.cc:79
LogWriter * get()
Accessor for the LogWriter singleton instance.
Definition: Logger.cc:49
static void thrift_output_handler(const char *message)
Definition: Config.cc:72
Internet address wrapper classes and utility functions.
void init_thrift_broker()
Definition: Config.cc:66
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
High-level entry point to a service; wraps a host:port pair.
Definition: InetAddr.h:44