#include <ndb_global.h>#include <my_sys.h>#include <Vector.hpp>#include <mgmapi.h>#include <util/BaseString.hpp>#include "ndb_mgmclient.hpp"#include "ndb_mgmclient.h"#include <mgmapi_debug.h>#include <version.h>#include <NdbAutoPtr.hpp>#include <NdbOut.hpp>#include <NdbSleep.h>#include <NdbMem.h>#include <EventLogger.hpp>#include <signaldata/SetLogLevelOrd.hpp>#include "MgmtErrorReporter.hpp"#include <Parser.hpp>#include <SocketServer.hpp>#include <util/InputStream.hpp>#include <util/OutputStream.hpp>Include dependency graph for CommandInterpreter.cpp:

Go to the source code of this file.
| static bool convert | ( | const char * | s, | |
| int & | val | |||
| ) | [static] |
Definition at line 312 of file CommandInterpreter.cpp.
References errno, NULL, p, strlen(), and strtol().
Referenced by CommandInterpreter::execute_impl(), CommandInterpreter::executeError(), and CommandInterpreter::executeEventReporting().
00312 { 00313 00314 if (s == NULL) 00315 return false; 00316 00317 if (strlen(s) == 0) 00318 return false; 00319 00320 errno = 0; 00321 char* p; 00322 long v = strtol(s, &p, 10); 00323 if (errno != 0) 00324 return false; 00325 00326 if (p != &s[strlen(s)]) 00327 return false; 00328 00329 val = v; 00330 return true; 00331 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static bool emptyString | ( | const char * | s | ) | [static] |
Definition at line 354 of file CommandInterpreter.cpp.
References NULL, and strlen().
Referenced by CommandInterpreter::analyseAfterFirstToken(), CommandInterpreter::executeAbortBackup(), CommandInterpreter::executeClusterLog(), CommandInterpreter::executeConnect(), CommandInterpreter::executeDumpState(), CommandInterpreter::executeError(), CommandInterpreter::executeEventReporting(), CommandInterpreter::executeGetStat(), CommandInterpreter::executeHelp(), CommandInterpreter::executeLogLevel(), CommandInterpreter::executePurge(), CommandInterpreter::executeSet(), CommandInterpreter::executeShow(), CommandInterpreter::executeStatus(), CommandInterpreter::executeTestOff(), CommandInterpreter::executeTestOn(), and CommandInterpreter::parseBlockSpecification().
00355 { 00356 if (s == NULL) { 00357 return true; 00358 } 00359 00360 for (unsigned int i = 0; i < strlen(s); ++i) { 00361 if (! isspace(s[i])) { 00362 return false; 00363 } 00364 } 00365 00366 return true; 00367 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void* event_thread_run | ( | void * | m | ) | [static] |
Definition at line 387 of file CommandInterpreter.cpp.
References buf, DBUG_ENTER, DBUG_RETURN, do_event_thread, SocketInputStream::gets(), handle, memcmp(), NDB_CLOSE_SOCKET(), NDB_INVALID_SOCKET, NDB_MGM_EVENT_CATEGORY_BACKUP, NDB_MGM_EVENT_CATEGORY_STARTUP, ndb_mgm_listen_event(), ndbout(), NdbSleep_MilliSleep(), and NULL.
Referenced by CommandInterpreter::connect().
00388 { 00389 DBUG_ENTER("event_thread_run"); 00390 00391 NdbMgmHandle handle= *(NdbMgmHandle*)m; 00392 00393 int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 00394 1, NDB_MGM_EVENT_CATEGORY_STARTUP, 00395 0 }; 00396 int fd = ndb_mgm_listen_event(handle, filter); 00397 if (fd != NDB_INVALID_SOCKET) 00398 { 00399 do_event_thread= 1; 00400 char *tmp= 0; 00401 char buf[1024]; 00402 SocketInputStream in(fd,10); 00403 do { 00404 if (tmp == 0) NdbSleep_MilliSleep(10); 00405 if((tmp = in.gets(buf, 1024))) 00406 { 00407 const char ping_token[]= "<PING>"; 00408 if (memcmp(ping_token,tmp,sizeof(ping_token)-1)) 00409 ndbout << tmp; 00410 } 00411 } while(do_event_thread); 00412 NDB_CLOSE_SOCKET(fd); 00413 } 00414 else 00415 { 00416 do_event_thread= -1; 00417 } 00418 00419 DBUG_RETURN(NULL); 00420 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int get_next_nodeid | ( | struct ndb_mgm_cluster_state * | cl, | |
| int * | node_id, | |||
| enum ndb_mgm_node_type | type | |||
| ) | [static] |
Get next nodeid larger than the give node_id. node_id will be set to the next node_id in the list. node_id should be set to 0 (zero) on the first call.
| handle | the NDB management handle | |
| node_id | last node_id retreived, 0 at first call | |
| type | type of node to look for |
Definition at line 815 of file CommandInterpreter.cpp.
References ndb_mgm_cluster_state::no_of_nodes, ndb_mgm_node_state::node_id, ndb_mgm_cluster_state::node_states, ndb_mgm_node_state::node_type, and NULL.
Referenced by CommandInterpreter::executeForAll().
00818 { 00819 int i; 00820 00821 if(cl == NULL) 00822 return 0; 00823 00824 i=0; 00825 while((i < cl->no_of_nodes)) { 00826 if((*node_id < cl->node_states[i].node_id) && 00827 (cl->node_states[i].node_type == type)) { 00828 00829 if(i >= cl->no_of_nodes) 00830 return 0; 00831 00832 *node_id = cl->node_states[i].node_id; 00833 return 1; 00834 } 00835 i++; 00836 } 00837 00838 return 0; 00839 }
Here is the caller graph for this function:

| static void invalid_command | ( | const char * | cmd | ) | [static] |
Definition at line 554 of file CommandInterpreter.cpp.
References ndbout().
Referenced by CommandInterpreter::analyseAfterFirstToken(), CommandInterpreter::execute_impl(), CommandInterpreter::executeHelp(), and CommandInterpreter::executeStartBackup().
00555 { 00556 ndbout << "Invalid command: " << cmd << endl; 00557 ndbout << "Type HELP for help." << endl << endl; 00558 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int ndb_mgmclient_execute | ( | Ndb_mgmclient_handle | h, | |
| int | argc, | |||
| char ** | argv | |||
| ) |
Definition at line 197 of file CommandInterpreter.cpp.
Referenced by execute_commands().
00198 { 00199 return ((Ndb_mgmclient*)h)->execute(argc, argv, 1); 00200 }
Here is the caller graph for this function:

| Ndb_mgmclient_handle ndb_mgmclient_handle_create | ( | const char * | connect_string | ) |
Definition at line 193 of file CommandInterpreter.cpp.
Referenced by execute_commands().
00194 { 00195 return (Ndb_mgmclient_handle) new Ndb_mgmclient(connect_string); 00196 }
Here is the caller graph for this function:

| int ndb_mgmclient_handle_destroy | ( | Ndb_mgmclient_handle | h | ) |
Definition at line 201 of file CommandInterpreter.cpp.
Referenced by execute_commands().
00202 { 00203 delete (Ndb_mgmclient*)h; 00204 return 0; 00205 }
Here is the caller graph for this function:

| static void print_nodes | ( | ndb_mgm_cluster_state * | state, | |
| ndb_mgm_configuration_iterator * | it, | |||
| const char * | proc_name, | |||
| int | no_proc, | |||
| ndb_mgm_node_type | type, | |||
| int | master_id | |||
| ) | [static] |
Definition at line 1035 of file CommandInterpreter.cpp.
References CFG_NODE_HOST, CFG_NODE_ID, getBuild(), getMajor(), getMinor(), ndb_mgm_find(), ndb_mgm_first(), ndb_mgm_get_node_type_string(), ndb_mgm_get_string_parameter(), NDB_MGM_NODE_STATUS_STARTED, NDB_MGM_NODE_TYPE_NDB, ndbout(), ndbout_c(), ndb_mgm_cluster_state::no_of_nodes, ndb_mgm_cluster_state::node_states, status_string(), strcasecmp, and strlen().
01038 { 01039 int i; 01040 ndbout << "[" << proc_name 01041 << "(" << ndb_mgm_get_node_type_string(type) << ")]\t" 01042 << no_proc << " node(s)" << endl; 01043 for(i=0; i < state->no_of_nodes; i++) { 01044 struct ndb_mgm_node_state *node_state= &(state->node_states[i]); 01045 if(node_state->node_type == type) { 01046 int node_id= node_state->node_id; 01047 ndbout << "id=" << node_id; 01048 if(node_state->version != 0) { 01049 const char *hostname= node_state->connect_address; 01050 if (hostname == 0 01051 || strlen(hostname) == 0 01052 || strcasecmp(hostname,"0.0.0.0") == 0) 01053 ndbout << " "; 01054 else 01055 ndbout << "\t@" << hostname; 01056 ndbout << " (Version: " 01057 << getMajor(node_state->version) << "." 01058 << getMinor(node_state->version) << "." 01059 << getBuild(node_state->version); 01060 if (type == NDB_MGM_NODE_TYPE_NDB) { 01061 if (node_state->node_status != NDB_MGM_NODE_STATUS_STARTED) { 01062 ndbout << ", " << status_string(node_state->node_status); 01063 } 01064 if (node_state->node_group >= 0) { 01065 ndbout << ", Nodegroup: " << node_state->node_group; 01066 if (master_id && node_state->dynamic_id == master_id) 01067 ndbout << ", Master"; 01068 } 01069 } 01070 ndbout << ")" << endl; 01071 } else { 01072 ndb_mgm_first(it); 01073 if(ndb_mgm_find(it, CFG_NODE_ID, node_id) == 0){ 01074 const char *config_hostname= 0; 01075 ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname); 01076 if (config_hostname == 0 || config_hostname[0] == 0) 01077 config_hostname= "any host"; 01078 ndbout_c(" (not connected, accepting connect from %s)", 01079 config_hostname); 01080 } 01081 else 01082 { 01083 ndbout_c("Unable to find node with id: %d", node_id); 01084 } 01085 } 01086 } 01087 } 01088 ndbout << endl; 01089 }
Here is the call graph for this function:

| static const char* status_string | ( | ndb_mgm_node_status | status | ) | [static] |
Definition at line 1012 of file CommandInterpreter.cpp.
References NDB_MGM_NODE_STATUS_NO_CONTACT, NDB_MGM_NODE_STATUS_NOT_STARTED, NDB_MGM_NODE_STATUS_RESTARTING, NDB_MGM_NODE_STATUS_SHUTTING_DOWN, NDB_MGM_NODE_STATUS_SINGLEUSER, NDB_MGM_NODE_STATUS_STARTED, and NDB_MGM_NODE_STATUS_STARTING.
Referenced by CommandInterpreter::executeStatus(), and print_nodes().
01013 { 01014 switch(status){ 01015 case NDB_MGM_NODE_STATUS_NO_CONTACT: 01016 return "not connected"; 01017 case NDB_MGM_NODE_STATUS_NOT_STARTED: 01018 return "not started"; 01019 case NDB_MGM_NODE_STATUS_STARTING: 01020 return "starting"; 01021 case NDB_MGM_NODE_STATUS_STARTED: 01022 return "started"; 01023 case NDB_MGM_NODE_STATUS_SHUTTING_DOWN: 01024 return "shutting down"; 01025 case NDB_MGM_NODE_STATUS_RESTARTING: 01026 return "restarting"; 01027 case NDB_MGM_NODE_STATUS_SINGLEUSER: 01028 return "single user mode"; 01029 default: 01030 return "unknown state"; 01031 } 01032 }
Here is the caller graph for this function:

const CommandInterpreter::CommandFunctionPair commands[] [static] |
Initial value:
{
{ "START", &CommandInterpreter::executeStart }
,{ "RESTART", &CommandInterpreter::executeRestart }
,{ "STOP", &CommandInterpreter::executeStop }
,{ "STATUS", &CommandInterpreter::executeStatus }
,{ "LOGLEVEL", &CommandInterpreter::executeLogLevel }
,{ "CLUSTERLOG", &CommandInterpreter::executeEventReporting }
,{ "LOG", &CommandInterpreter::executeLog }
,{ "LOGIN", &CommandInterpreter::executeLogIn }
,{ "LOGOUT", &CommandInterpreter::executeLogOut }
,{ "LOGOFF", &CommandInterpreter::executeLogOff }
,{ "TESTON", &CommandInterpreter::executeTestOn }
,{ "TESTOFF", &CommandInterpreter::executeTestOff }
,{ "SET", &CommandInterpreter::executeSet }
,{ "GETSTAT", &CommandInterpreter::executeGetStat }
,{ "DUMP", &CommandInterpreter::executeDumpState }
}
Definition at line 721 of file CommandInterpreter.cpp.
int do_event_thread [static] |
Definition at line 385 of file CommandInterpreter.cpp.
Referenced by CommandInterpreter::connect(), CommandInterpreter::disconnect(), and event_thread_run().
const char* helpText [static] |
Definition at line 241 of file CommandInterpreter.cpp.
Referenced by CommandInterpreter::executeHelp().
const char* helpTextShow [static] |
Initial value:
"---------------------------------------------------------------------------\n" " NDB Cluster -- Management Client -- Help for SHOW command\n" "---------------------------------------------------------------------------\n" "SHOW prints NDB Cluster information\n\n" "SHOW Print information about cluster\n"
Definition at line 275 of file CommandInterpreter.cpp.
Referenced by CommandInterpreter::executeHelp().
1.4.7

