Commit facaf4f7 authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-clean
parents 14b60dfc 8c3144c1
...@@ -379,18 +379,30 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries, ...@@ -379,18 +379,30 @@ ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__,
"Unable to connect with connect string: %s", "Unable to connect with connect string: %s",
cfg.makeConnectString(buf,sizeof(buf))); cfg.makeConnectString(buf,sizeof(buf)));
if (verbose == -2)
ndbout << ", failed." << endl;
return -1; return -1;
} }
if (verbose == -1) { if (verbose == -1) {
ndbout << "retrying every " << retry_delay_in_seconds << " seconds:"; ndbout << "Retrying every " << retry_delay_in_seconds << " seconds";
if (no_retries > 0)
ndbout << ". Attempts left:";
else
ndbout << ", until connected.";;
ndbout << flush;
verbose= -2; verbose= -2;
} }
NdbSleep_SecSleep(retry_delay_in_seconds); if (no_retries > 0) {
if (verbose == -2) { if (verbose == -2) {
ndbout << " " << no_retries; ndbout << " " << no_retries;
ndbout << flush;
}
no_retries--;
} }
no_retries--; NdbSleep_SecSleep(retry_delay_in_seconds);
} }
if (verbose == -2)
ndbout << endl;
handle->cfg_i = i; handle->cfg_i = i;
......
This diff is collapsed.
...@@ -56,17 +56,18 @@ handler(int sig){ ...@@ -56,17 +56,18 @@ handler(int sig){
} }
} }
static const char default_prompt[]= "ndb_mgm> ";
static unsigned _try_reconnect; static unsigned _try_reconnect;
static char *opt_connect_str= 0; static char *opt_connect_str= 0;
static const char *prompt= default_prompt;
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
NDB_STD_OPTS("ndb_mgm"), NDB_STD_OPTS("ndb_mgm"),
{ "try-reconnect", 't', { "try-reconnect", 't',
"Specify number of retries for connecting to ndb_mgmd, default infinite", "Specify number of tries for connecting to ndb_mgmd (0 = infinite)",
(gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static void short_usage_sub(void) static void short_usage_sub(void)
...@@ -116,13 +117,13 @@ read_and_execute(int _try_reconnect) ...@@ -116,13 +117,13 @@ read_and_execute(int _try_reconnect)
} }
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
/* Get a line from the user. */ /* Get a line from the user. */
line_read = readline ("ndb_mgm> "); line_read = readline (prompt);
/* If the line has any text in it, save it on the history. */ /* If the line has any text in it, save it on the history. */
if (line_read && *line_read) if (line_read && *line_read)
add_history (line_read); add_history (line_read);
#else #else
static char linebuffer[254]; static char linebuffer[254];
fputs("ndb_mgm> ", stdout); fputs(prompt, stdout);
linebuffer[sizeof(linebuffer)-1]=0; linebuffer[sizeof(linebuffer)-1]=0;
line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin);
if (line_read == linebuffer) { if (line_read == linebuffer) {
...@@ -155,12 +156,16 @@ int main(int argc, char** argv){ ...@@ -155,12 +156,16 @@ int main(int argc, char** argv){
opt_connect_str= buf; opt_connect_str= buf;
} }
if (!isatty(0))
{
prompt= 0;
}
ndbout << "-- NDB Cluster -- Management Client --" << endl; ndbout << "-- NDB Cluster -- Management Client --" << endl;
printf("Connecting to Management Server: %s\n", opt_connect_str ? opt_connect_str : "default");
signal(SIGPIPE, handler); signal(SIGPIPE, handler);
com = new Ndb_mgmclient(opt_connect_str); com = new Ndb_mgmclient(opt_connect_str,1);
while(read_and_execute(_try_reconnect)); while(read_and_execute(_try_reconnect));
delete com; delete com;
......
...@@ -21,7 +21,7 @@ class CommandInterpreter; ...@@ -21,7 +21,7 @@ class CommandInterpreter;
class Ndb_mgmclient class Ndb_mgmclient
{ {
public: public:
Ndb_mgmclient(const char*); Ndb_mgmclient(const char*,int verbose=0);
~Ndb_mgmclient(); ~Ndb_mgmclient();
int execute(const char *_line, int _try_reconnect=-1); int execute(const char *_line, int _try_reconnect=-1);
int execute(int argc, char** argv, int _try_reconnect=-1); int execute(int argc, char** argv, int _try_reconnect=-1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment