#include <ndb_global.h>#include <ndb_opts.h>#include <readline/readline.h>#include <NdbMain.h>#include <NdbHost.h>#include <BaseString.hpp>#include <NdbOut.hpp>#include <mgmapi.h>#include <ndb_version.h>#include "ndb_mgmclient.hpp"Include dependency graph for main.cpp:

Go to the source code of this file.
Defines | |
| #define | HAVE_READLINE |
Functions | |
| int | add_history (const char *command) |
| void | handler (int sig) |
| static void | short_usage_sub (void) |
| static void | usage () |
| static int | read_and_execute (int _try_reconnect) |
| int | main (int argc, char **argv) |
Variables | |
| const char * | progname = "ndb_mgm" |
| static Ndb_mgmclient * | com |
| NDB_STD_OPTS_VARS | |
| static const char | default_prompt [] = "ndb_mgm> " |
| static unsigned | _try_reconnect |
| static const char * | prompt = default_prompt |
| static char * | opt_execute_str = 0 |
| static struct my_option | my_long_options [] |
| int add_history | ( | const char * | command | ) |
Definition at line 1172 of file readline.c.
01173 { 01174 HistEvent ev; 01175 01176 if (h == NULL || e == NULL) 01177 rl_initialize(); 01178 01179 (void)history(h, &ev, H_ENTER, line); 01180 if (history(h, &ev, H_GETSIZE) == 0) 01181 history_length = ev.num; 01182 01183 return (!(history_length > 0)); /* return 0 if all is okay */ 01184 }
| void handler | ( | int | sig | ) |
Definition at line 47 of file main.cpp.
References com, DBUG_ENTER, DBUG_VOID_RETURN, Ndb_mgmclient::disconnect(), and SIGPIPE.
Referenced by Logger::addHandler(), ft_nlq_close_search(), ft_nlq_find_relevance(), ft_nlq_get_relevance(), ft_nlq_read_next(), ft_nlq_reinit_search(), and make_empty_rec().
00048 { 00049 DBUG_ENTER("handler"); 00050 switch(sig){ 00051 case SIGPIPE: 00056 com->disconnect(); 00057 break; 00058 } 00059 DBUG_VOID_RETURN; 00060 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 127 of file main.cpp.
References _try_reconnect, buf, com, Ndb_mgmclient::execute(), exit, handle_options(), load_default_groups, load_defaults(), MAXHOSTNAMELEN, MY_CHECK_ERROR, MY_GIVE_INFO, my_long_options, ndb_end(), NDB_INIT, ndb_std_get_one_option(), ndbout(), opt_connect_str, opt_debug, opt_endinfo, opt_execute_str, prompt, read_and_execute(), SIGPIPE, and BaseString::snprintf().
00127 { 00128 NDB_INIT(argv[0]); 00129 const char *_host = 0; 00130 int _port = 0; 00131 const char *load_default_groups[]= { "mysql_cluster","ndb_mgm",0 }; 00132 00133 load_defaults("my",load_default_groups,&argc,&argv); 00134 int ho_error; 00135 #ifndef DBUG_OFF 00136 opt_debug= "d:t:O,/tmp/ndb_mgm.trace"; 00137 #endif 00138 if ((ho_error=handle_options(&argc, &argv, my_long_options, 00139 ndb_std_get_one_option))) 00140 exit(ho_error); 00141 00142 char buf[MAXHOSTNAMELEN+10]; 00143 if(argc == 1) { 00144 BaseString::snprintf(buf, sizeof(buf), "%s", argv[0]); 00145 opt_connect_str= buf; 00146 } else if (argc >= 2) { 00147 BaseString::snprintf(buf, sizeof(buf), "%s:%s", argv[0], argv[1]); 00148 opt_connect_str= buf; 00149 } 00150 00151 if (!isatty(0) || opt_execute_str) 00152 { 00153 prompt= 0; 00154 } 00155 00156 signal(SIGPIPE, handler); 00157 com = new Ndb_mgmclient(opt_connect_str,1); 00158 int ret= 0; 00159 if (!opt_execute_str) 00160 { 00161 ndbout << "-- NDB Cluster -- Management Client --" << endl; 00162 while(read_and_execute(_try_reconnect)); 00163 } 00164 else 00165 { 00166 com->execute(opt_execute_str,_try_reconnect, &ret); 00167 } 00168 delete com; 00169 00170 ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); 00171 return ret; 00172 }
Here is the call graph for this function:

| static int read_and_execute | ( | int | _try_reconnect | ) | [static] |
Definition at line 95 of file main.cpp.
References add_history(), com, Ndb_mgmclient::execute(), free, NULL, prompt, readline(), and strdup().
00096 { 00097 static char *line_read = (char *)NULL; 00098 00099 /* If the buffer has already been allocated, return the memory 00100 to the free pool. */ 00101 if (line_read) 00102 { 00103 free (line_read); 00104 line_read = (char *)NULL; 00105 } 00106 #ifdef HAVE_READLINE 00107 /* Get a line from the user. */ 00108 line_read = readline (prompt); 00109 /* If the line has any text in it, save it on the history. */ 00110 if (line_read && *line_read) 00111 add_history (line_read); 00112 #else 00113 static char linebuffer[254]; 00114 fputs(prompt, stdout); 00115 linebuffer[sizeof(linebuffer)-1]=0; 00116 line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); 00117 if (line_read == linebuffer) { 00118 char *q=linebuffer; 00119 while (*q > 31) q++; 00120 *q=0; 00121 line_read= strdup(linebuffer); 00122 } 00123 #endif 00124 return com->execute(line_read,_try_reconnect); 00125 }
Here is the call graph for this function:

| static void short_usage_sub | ( | void | ) | [static] |
Definition at line 82 of file main.cpp.
References my_progname.
00083 { 00084 printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); 00085 }
| static void usage | ( | void | ) | [static] |
Definition at line 86 of file main.cpp.
References my_long_options, my_print_help(), my_print_variables(), ndb_std_print_version(), and short_usage_sub().
00087 { 00088 short_usage_sub(); 00089 ndb_std_print_version(); 00090 my_print_help(my_long_options); 00091 my_print_variables(my_long_options); 00092 }
Here is the call graph for this function:

unsigned _try_reconnect [static] |
Ndb_mgmclient* com [static] |
Definition at line 43 of file main.cpp.
Referenced by add_line(), handler(), Ndb::handleReceivedSignal(), main(), and read_and_execute().
const char default_prompt[] = "ndb_mgm> " [static] |
struct my_option my_long_options[] [static] |
Initial value:
{
NDB_STD_OPTS("ndb_mgm"),
{ "execute", 'e',
"execute command and exit",
(gptr*) &opt_execute_str, (gptr*) &opt_execute_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "try-reconnect", 't',
"Specify number of tries for connecting to ndb_mgmd (0 = infinite)",
(gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0,
GET_UINT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}
char* opt_execute_str = 0 [static] |
const char* prompt = default_prompt [static] |
Definition at line 66 of file main.cpp.
Referenced by construct_prompt(), main(), and read_and_execute().
1.4.7

