54 "Usage: ht_rangeserver [options] <host>[:<port>]\n\nOptions"
57 struct AppPolicy :
Policy {
58 static void init_options() {
60 (
"no-hyperspace",
"Do not establish a connection to hyperspace")
79 RangeServerDispatchHandler(
bool silent) : m_silent(silent) { }
80 virtual void handle(
EventPtr &event_ptr) {
84 cout <<
"RangeServer CRITICAL - connect error" << endl;
99 int main(
int argc,
char **argv) {
102 bool no_hyperspace =
false;
105 init_with_policies<Policies>(argc, argv);
107 int timeout = get_i32(
"timeout");
108 InetAddr addr(get_str(
"rs-host"), get_i16(
"rs-port"));
109 silent =
has(
"silent") && get_bool(
"silent");
111 if (
has(
"no-hyperspace"))
112 no_hyperspace =
true;
119 DispatchHandlerPtr dispatch_handler_ptr = make_shared<RangeServerDispatchHandler>(silent);
121 if ((error = comm->connect(addr, dispatch_handler_ptr)) !=
Error::OK) {
123 cout <<
"RangeServer CRITICAL - connect error" << endl;
127 this_thread::sleep_for(chrono::milliseconds(100));
131 if (!no_hyperspace) {
132 hyperspace = make_shared<Hyperspace::Session>(comm,
properties);
133 if (!hyperspace->wait_for_connection(timeout)) {
135 cout <<
"RangeServer CRITICAL - Unable to connecto to Hyperspace" << endl;
141 make_shared<RangeServerCommandInterpreter>(hyperspace, addr, client);
145 error = shell->run();
150 const char *msg = e.what();
152 cout <<
" - " << msg;
static Comm * instance()
Creates/returns singleton instance of the Comm class.
int main(int argc, char **argv)
Interface and base of config policy.
Cons< DefaultPolicy, CommPolicy > DefaultCommPolicy
Default comm layer config policy.
PropertiesPtr properties
This singleton map stores all options.
static Endpoint parse_endpoint(const char *endpoint, int defport=0)
Parse an endpoint string in (host:port) format.
Abstract base class for application dispatch handlers registered with AsyncComm.
void init(int argc, char *argv[], const Desc *desc=NULL)
Initialize with default policy.
Po::typed_value< String > * str(String *v=0)
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Declarations for RangeServerClient.
Connection established event.
Desc & cmdline_desc(const char *usage)
A macro which definds global functions like get_bool(), get_str(), get_i16() etc. ...
bool has(const String &name)
Check existence of a configuration value.
Declarations for DispatchHandler.
std::shared_ptr< Session > SessionPtr
const char * get_text(int error)
Returns a descriptive error message.
Encapsulate an internet address.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Compatibility Macros for C/C++.
Initialization helper for applications.
Connection disconnected event.
std::shared_ptr< CommandInterpreter > CommandInterpreterPtr
std::shared_ptr< CommandShell > CommandShellPtr
Declarations for HqlCommandInterpreter.
Entry point to AsyncComm service.
Internet address wrapper classes and utility functions.
Meta::list< MyPolicy, DefaultPolicy > Policies
This is a generic exception class for Hypertable.
std::shared_ptr< DispatchHandler > DispatchHandlerPtr
Smart pointer to DispatchHandler.
Desc & cmdline_hidden_desc()
Get the command line hidden options description (for positional options)
PositionalDesc & cmdline_positional_desc()
Get the command line positional options description.
int code() const
Returns the error code.
High-level entry point to a service; wraps a host:port pair.