46 "Usage: ht_thriftbroker [options] <host>[:<port>]\n\nOptions"
49 struct AppPolicy :
Policy {
50 static void init_options() {
52 (
"nowait",
"Don't wait for certain commands to complete (e.g. shutdown)")
53 (
"output-only",
"Display status output and exit with status 0")
75 int main(
int argc,
char **argv) {
81 init_with_policies<Policies>(argc, argv);
82 ::uint32_t timeout_ms;
83 bool nowait =
has(
"nowait");
85 output_only =
has(
"output-only");
86 silent =
has(
"silent") && get_bool(
"silent");
89 timeout_ms = get_i32(
"timeout");
91 timeout_ms = get_i32(
"Hypertable.Request.Timeout");
96 string host { get_str(
"thrift-host") };
97 int port { get_i16(
"thrift-port") };
102 client = make_shared<Thrift::Client>(host, port, timeout_ms);
109 error = shell->run();
114 const char *msg = e.what();
116 cout <<
" - " << msg;
119 quick_exit(output_only ? 0 : 2);
121 catch (ThriftGen::ClientException &e) {
123 cout <<
"ThriftBroker CRITICAL - ";
124 if (e.__isset.code && e.code != 0)
126 if (e.__isset.message && !e.message.empty())
127 cout <<
" - " << e.message;
130 quick_exit(output_only ? 0 : 2);
132 catch (std::exception &e) {
134 cout <<
"ThriftBroker CRITICAL - " << e.what() << endl;
135 quick_exit(output_only ? 0 : 2);
Declarations for configuration properties.
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.
void init(int argc, char *argv[], const Desc *desc=NULL)
Initialize with default policy.
Po::typed_value< String > * str(String *v=0)
Program options handling.
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.
Declaration for ConsoleOutputSquelcher.
const char * get_text(int error)
Returns a descriptive error message.
Compatibility Macros for C/C++.
int main(int argc, char **argv)
Initialization helper for applications.
std::shared_ptr< CommandInterpreter > CommandInterpreterPtr
std::shared_ptr< CommandShell > CommandShellPtr
Temporarily redirects stdout and stderr to /dev/null.
Meta::list< MyPolicy, DefaultPolicy > Policies
This is a generic exception class for Hypertable.
std::shared_ptr< Client > ClientPtr
Smart pointer to client.
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.
Error codes, Exception handling, error logging.
Declarations for CommandInterpreter.
int code() const
Returns the error code.
High-level entry point to a service; wraps a host:port pair.