40 #include <boost/algorithm/string.hpp>
41 #include <boost/thread/condition.hpp>
42 #include <boost/thread/mutex.hpp>
49 #include <editline/readline.h>
61 "Usage: ht_fsbroker [options] <host>[:<port>]\n\nOptions"
64 struct AppPolicy :
Policy {
65 static void init_options() {
67 (
"nowait",
"Don't wait for certain commands to complete (e.g. shutdown)")
68 (
"output-only",
"Display status output and exit with status 0")
89 int main(
int argc,
char **argv) {
95 init_with_policies<Policies>(argc, argv);
97 String host = get_str(
"FsBroker.Host");
99 ::uint32_t timeout_ms;
100 bool nowait =
has(
"nowait");
102 output_only =
has(
"output-only");
103 silent =
has(
"silent") && get_bool(
"silent");
105 if (
has(
"DfsBroker.Port"))
106 port = get_i16(
"DfsBroker.Port");
108 port = get_i16(
"FsBroker.Port");
111 timeout_ms = get_i32(
"timeout");
113 timeout_ms = get_i32(
"Hypertable.Request.Timeout");
125 quick_exit(output_only ? 0 : 2);
129 if (!sync_handler->wait_for_connection()) {
131 cout <<
"FsBroker CRITICAL - connect error" << endl;
132 quick_exit(output_only ? 0 : 2);
141 error = shell->run();
146 const char *msg = e.what();
148 cout <<
" - " << msg;
151 quick_exit(output_only ? 0 : 2);
Declarations for configuration properties.
static Comm * instance()
Creates/returns singleton instance of the Comm class.
Interface and base of config policy.
Cons< DefaultPolicy, CommPolicy > DefaultCommPolicy
Default comm layer config policy.
PropertiesPtr properties
This singleton map stores all options.
std::string String
A String is simply a typedef to std::string.
static Endpoint parse_endpoint(const char *endpoint, int defport=0)
Parse an endpoint string in (host:port) format.
int connect(const CommAddress &addr, const DispatchHandlerPtr &default_handler)
Establishes a TCP connection and attaches a default dispatch handler.
Helper class for printing usage banners on the command line.
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.
std::shared_ptr< Event > EventPtr
Smart pointer to 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.
const char * get_text(int error)
Returns a descriptive error message.
Encapsulate an internet address.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Declarations for CommandInterpreter.
Compatibility Macros for C/C++.
Initialization helper for applications.
std::shared_ptr< CommandInterpreter > CommandInterpreterPtr
std::shared_ptr< CommandShell > CommandShellPtr
DispatchHandler class used to synchronize with response messages.
static bool initialize(sockaddr_in *addr, const char *host, uint16_t port)
Initialize a sockaddr_in structure from host:port.
Entry point to AsyncComm service.
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)
int main(int argc, char **argv)
PositionalDesc & cmdline_positional_desc()
Get the command line positional options description.
Error codes, Exception handling, error logging.
int code() const
Returns the error code.
High-level entry point to a service; wraps a host:port pair.