0.9.8.10
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
home
doug
src
hypertable
src
cc
Tools
client
master
MasterCommandInterpreter.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007-2015 Hypertable, Inc.
3
*
4
* This file is part of Hypertable.
5
*
6
* Hypertable is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; version 3 of the
9
* License, or any later version.
10
*
11
* Hypertable is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
* 02110-1301, USA.
20
*/
21
22
#include <
Common/Compat.h
>
23
24
#include "
MasterCommandInterpreter.h
"
25
26
#include <
Hypertable/Lib/HqlHelpText.h
>
27
#include <
Hypertable/Lib/HqlParser.h
>
28
29
using namespace
Hypertable
;
30
using namespace
Tools::client::master
;
31
using namespace
Hql
;
32
using namespace
std
;
33
34
MasterCommandInterpreter::MasterCommandInterpreter(
Lib::Master::ClientPtr
&master)
35
: m_master(master) {
36
HqlHelpText::install_master_client_text();
37
}
38
39
40
int
MasterCommandInterpreter::execute_line
(
const
String
&line) {
41
Hql::ParserState
state;
42
Hql::Parser
parser(state);
43
parse_info<> info;
44
45
info = parse(line.c_str(), parser, space_p);
46
47
if
(info.full) {
48
49
if
(state.
command
==
COMMAND_SHUTDOWN
) {
50
m_master
->shutdown();
51
}
52
else
if
(state.
command
==
COMMAND_STATUS
) {
53
Status
status
;
54
string
output;
55
Status::Code
code;
56
m_master
->status(status);
57
status.
get
(&code, output);
58
if
(!
m_silent
) {
59
cout <<
"Master "
<<
Status::code_to_string
(code);
60
if
(!output.empty())
61
cout <<
" - "
<< output;
62
cout << endl;
63
}
64
return
static_cast<
int
>
(code);
65
}
66
else
if
(state.
command
==
COMMAND_HELP
) {
67
const
char
**text =
HqlHelpText::get
(state.
str
);
68
if
(text) {
69
for
(
size_t
i=0; text[i]; i++)
70
cout << text[i] << endl;
71
}
72
else
73
cout << endl <<
"no help for '"
<< state.
str
<<
"'"
<< endl << endl;
74
}
75
else
76
HT_THROW
(
Error::HQL_PARSE_ERROR
,
"unsupported command"
);
77
}
78
else
79
HT_THROW
(
Error::HQL_PARSE_ERROR
,
String
(
"parse error at: "
) + info.stop);
80
return
0;
81
}
82
Hypertable::Error::HQL_PARSE_ERROR
Definition:
Error.h:58
Hypertable::Status
Holds Nagios-style program status information.
Definition:
Status.h:42
Hypertable::String
std::string String
A String is simply a typedef to std::string.
Definition:
String.h:44
Hypertable::Hql::ParserState::str
std::string str
Definition:
HqlParser.h:301
std
STL namespace.
Hypertable::Hql::COMMAND_SHUTDOWN
Definition:
HqlParser.h:95
Hypertable::Hql::ParserState::command
int command
Definition:
HqlParser.h:295
MasterCommandInterpreter.h
Tools::client::master::MasterCommandInterpreter::m_master
Lib::Master::ClientPtr m_master
Definition:
MasterCommandInterpreter.h:44
Hypertable::Status::Code
Code
Enumeration for status codes.
Definition:
Status.h:47
Hyperspace::HsParser::COMMAND_STATUS
Definition:
HsParser.h:87
Hypertable::Utility::status
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Definition:
Utility.cc:408
Tools::client::master::MasterCommandInterpreter::execute_line
int execute_line(const String &line) override
Definition:
MasterCommandInterpreter.cc:40
Compat.h
Compatibility Macros for C/C++.
Hql
Hypertable::Config::get
T get(const String &name)
Retrieves a configuration value.
Definition:
Config.h:82
Hypertable::Hql::Parser
Definition:
HqlParser.h:2437
Hypertable
Hypertable definitions
Definition:
ApplicationHandler.h:36
Hypertable::Lib::Master::ClientPtr
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Definition:
Client.h:201
Hypertable::Status::get
void get(Code *code, std::string &text) const
Gets status code and text.
Definition:
Status.h:111
Hyperspace::HsParser::COMMAND_HELP
Definition:
HsParser.h:62
HqlHelpText.h
Declarations for HqlHelpText.
HqlParser.h
HT_THROW
#define HT_THROW(_code_, _msg_)
Definition:
Error.h:478
Hypertable::CommandInterpreter::m_silent
bool m_silent
Definition:
CommandInterpreter.h:49
Tools::client::master
Definition:
MasterCommandInterpreter.h:35
Hypertable::SystemVariable::code_to_string
const char * code_to_string(int var_code)
Converts variable code to variable string.
Definition:
SystemVariable.cc:92
Hypertable::Hql::ParserState
Definition:
HqlParser.h:286
Generated on Tue Dec 22 2015 18:43:18 for Hypertable by
1.8.8