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 
26 #include <algorithm>
27 #include <iostream>
28 #include <vector>
29 
30 #include <strings.h>
31 
32 namespace Hypertable { namespace Config {
33 
35  cmdline_desc().add_options()
36  ("hyperspace", str(),
37  "hyperspace master server to connect to in <host:port> format")
38  ("hyperspace-timeout", i32()->default_value(30000),
39  "Timeout in milliseconds for hyperspace connection")
40  ("keepalive", i32()->default_value(10000),
41  "Interval in milliseconds of keepalive message from Hyperspace client")
42  ("lease-interval", i32()->default_value(60000),
43  "Hyperspace master lease interval in milliseconds")
44  ("grace-period", i32()->default_value(60000),
45  "Grace period in milliseconds before 'jeopardy' for hyperspace client")
46  ;
47  alias("hyperspace-timeout", "Hyperspace.Timeout");
48  alias("keepalive", "Hyperspace.KeepAlive.Interval");
49  alias("lease-interval", "Hyperspace.Lease.Interval");
50  alias("grace-period", "Hyperspace.GracePeriod");
51  // hidden aliases
52  alias("hs-host", "Hyperspace.Replica.Host");
53  alias("hs-port", "Hyperspace.Replica.Port");
54 }
55 
57  // prepare hidden aliases to be synced
58  if (properties->has("hyperspace")) {
59  Endpoint e = InetAddr::parse_endpoint(get_str("hyperspace"));
60  bool defaulted = properties->defaulted("hyperspace");
61  Strings hosts;
62  if (properties->has("Hyperspace.Replica.Host"))
63  hosts = properties->get_strs("Hyperspace.Replica.Host");
64 
65  size_t i;
66  for (i=0; i<hosts.size(); i++) {
67 #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
68  if (stricmp(hosts[i].c_str(), e.host.c_str()) == 0)
69  break;
70 #else
71  if (strcasecmp(hosts[i].c_str(), e.host.c_str()) == 0)
72  break;
73 #endif
74  }
75  // if not found ...
76  if (i == hosts.size()) {
77  hosts.insert(hosts.begin(), e.host);
78  properties->set("hs-host", hosts, defaulted);
79  }
80  properties->set("hs-port", e.port, !e.port || defaulted);
81  }
82 }
83 
86 }
87 
89  cmdline_desc().add_options()
90  ("port", i16(),
91  "Hyperspace master listening port")
92  ("dir", str()->default_value("hyperspace"),
93  "Hyperspace root directory name")
94  ("keepalive", i32()->default_value(10000),
95  "Interval in milliseconds of keepalive message from Hyperspace client")
96  ("lease-interval", i32()->default_value(20000),
97  "Hyperspace master lease interval in milliseconds")
98  ;
99  alias("reactors", "Hyperspace.Replica.Reactors");
100  alias("workers", "Hyperspace.Replica.Workers");
101  alias("port", "Hyperspace.Replica.Port");
102  alias("dir", "Hyperspace.Replica.Dir");
103  alias("keepalive", "Hyperspace.KeepAlive.Interval");
104  alias("lease-interval", "Hyperspace.Lease.Interval");
105 }
106 
107 }} // 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
void init_hyperspace_client_options()
Definition: Config.cc:34
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
std::vector< String > Strings
Definition: Properties.h:148
void init_hyperspace_command_shell_options()
Definition: Config.cc:84
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
Definition: Config.cc:72
void init_hyperspace_client()
Definition: Config.cc:56
Po::typed_value< int32_t > * i32(int32_t *v=0)
Definition: Properties.h:178
Compatibility Macros for C/C++.
static void add_options(PropertiesDesc &)
bool defaulted(const String &name)
Check if a configuration value is defaulted.
Definition: Config.h:67
Hypertable definitions
Internet address wrapper classes and utility functions.
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_hyperspace_master_options()
Definition: Config.cc:88
High-level entry point to a service; wraps a host:port pair.
Definition: InetAddr.h:44