Commit b7ff02a5 authored by unknown's avatar unknown

Merge dev3-127.(none):/mnt/mysql/home/ngb/mysql-5.0-ndb-bj

into  dev3-127.(none):/mnt/mysql/home/ngb/bug19620


ndb/src/mgmclient/CommandInterpreter.cpp:
  Auto merged
parents 0c3b4080 d55edcda
...@@ -55,11 +55,11 @@ class CommandInterpreter { ...@@ -55,11 +55,11 @@ class CommandInterpreter {
* *
* @return true until quit/bye/exit has been typed * @return true until quit/bye/exit has been typed
*/ */
int execute(const char *_line, int _try_reconnect=-1, int *error= 0); int execute(const char *_line, int _try_reconnect=-1, bool interactive=1, int *error= 0);
private: private:
void printError(); void printError();
int execute_impl(const char *_line); int execute_impl(const char *_line, bool interactive=1);
/** /**
* Analyse the command line, after the first token. * Analyse the command line, after the first token.
...@@ -99,7 +99,7 @@ class CommandInterpreter { ...@@ -99,7 +99,7 @@ class CommandInterpreter {
*/ */
void executeHelp(char* parameters); void executeHelp(char* parameters);
void executeShow(char* parameters); void executeShow(char* parameters);
void executeConnect(char* parameters); void executeConnect(char* parameters, bool interactive);
void executePurge(char* parameters); void executePurge(char* parameters);
int executeShutdown(char* parameters); int executeShutdown(char* parameters);
void executeRun(char* parameters); void executeRun(char* parameters);
...@@ -137,7 +137,7 @@ class CommandInterpreter { ...@@ -137,7 +137,7 @@ class CommandInterpreter {
void executeCpc(char * parameters); void executeCpc(char * parameters);
public: public:
bool connect(); bool connect(bool interactive);
bool disconnect(); bool disconnect();
/** /**
...@@ -198,9 +198,9 @@ Ndb_mgmclient::~Ndb_mgmclient() ...@@ -198,9 +198,9 @@ Ndb_mgmclient::~Ndb_mgmclient()
{ {
delete m_cmd; delete m_cmd;
} }
int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, int *error) int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, bool interactive, int *error)
{ {
return m_cmd->execute(_line,_try_reconnect,error); return m_cmd->execute(_line,_try_reconnect,interactive, error);
} }
int int
Ndb_mgmclient::disconnect() Ndb_mgmclient::disconnect()
...@@ -246,7 +246,7 @@ extern "C" { ...@@ -246,7 +246,7 @@ extern "C" {
#include <util/InputStream.hpp> #include <util/InputStream.hpp>
#include <util/OutputStream.hpp> #include <util/OutputStream.hpp>
int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error) int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, bool interactive, int *error)
{ {
if (argc <= 0) if (argc <= 0)
return 0; return 0;
...@@ -255,7 +255,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error ...@@ -255,7 +255,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error
{ {
_line.appfmt(" %s", argv[i]); _line.appfmt(" %s", argv[i]);
} }
return m_cmd->execute(_line.c_str(),_try_reconnect, error); return m_cmd->execute(_line.c_str(),_try_reconnect, interactive, error);
} }
/***************************************************************************** /*****************************************************************************
...@@ -720,7 +720,7 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose) ...@@ -720,7 +720,7 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose)
{ {
m_constr= _host; m_constr= _host;
m_connected= false; m_connected= false;
m_event_thread= 0; m_event_thread= NULL;
try_reconnect = 0; try_reconnect = 0;
m_print_mutex= NdbMutex_Create(); m_print_mutex= NdbMutex_Create();
#ifdef HAVE_GLOBAL_REPLICATION #ifdef HAVE_GLOBAL_REPLICATION
...@@ -815,7 +815,7 @@ event_thread_run(void* p) ...@@ -815,7 +815,7 @@ event_thread_run(void* p)
} }
bool bool
CommandInterpreter::connect() CommandInterpreter::connect(bool interactive)
{ {
DBUG_ENTER("CommandInterpreter::connect"); DBUG_ENTER("CommandInterpreter::connect");
...@@ -827,10 +827,12 @@ CommandInterpreter::connect() ...@@ -827,10 +827,12 @@ CommandInterpreter::connect()
ndbout_c("Cannot create handle to management server."); ndbout_c("Cannot create handle to management server.");
exit(-1); exit(-1);
} }
m_mgmsrv2 = ndb_mgm_create_handle(); if (interactive) {
if(m_mgmsrv2 == NULL) { m_mgmsrv2 = ndb_mgm_create_handle();
ndbout_c("Cannot create 2:nd handle to management server."); if(m_mgmsrv2 == NULL) {
exit(-1); ndbout_c("Cannot create 2:nd handle to management server.");
exit(-1);
}
} }
if (ndb_mgm_set_connectstring(m_mgmsrv, m_constr)) if (ndb_mgm_set_connectstring(m_mgmsrv, m_constr))
...@@ -844,62 +846,64 @@ CommandInterpreter::connect() ...@@ -844,62 +846,64 @@ CommandInterpreter::connect()
const char *host= ndb_mgm_get_connected_host(m_mgmsrv); const char *host= ndb_mgm_get_connected_host(m_mgmsrv);
unsigned port= ndb_mgm_get_connected_port(m_mgmsrv); unsigned port= ndb_mgm_get_connected_port(m_mgmsrv);
BaseString constr; if (interactive) {
constr.assfmt("%s:%d",host,port); BaseString constr;
if(!ndb_mgm_set_connectstring(m_mgmsrv2, constr.c_str()) && constr.assfmt("%s:%d",host,port);
!ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1)) if(!ndb_mgm_set_connectstring(m_mgmsrv2, constr.c_str()) &&
{ !ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1))
DBUG_PRINT("info",("2:ndb connected to Management Server ok at: %s:%d",
host, port));
assert(m_event_thread == 0);
assert(do_event_thread == 0);
do_event_thread= 0;
struct event_thread_param p;
p.m= &m_mgmsrv2;
p.p= &m_print_mutex;
m_event_thread = NdbThread_Create(event_thread_run,
(void**)&p,
32768,
"CommandInterpreted_event_thread",
NDB_THREAD_PRIO_LOW);
if (m_event_thread != 0)
{ {
DBUG_PRINT("info",("Thread created ok, waiting for started...")); DBUG_PRINT("info",("2:ndb connected to Management Server ok at: %s:%d",
int iter= 1000; // try for 30 seconds host, port));
while(do_event_thread == 0 && assert(m_event_thread == NULL);
iter-- > 0) assert(do_event_thread == 0);
NdbSleep_MilliSleep(30);
}
if (m_event_thread == 0 ||
do_event_thread == 0 ||
do_event_thread == -1)
{
DBUG_PRINT("info",("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d",
errno));
printf("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d\n", errno);
do_event_thread= 0; do_event_thread= 0;
struct event_thread_param p;
p.m= &m_mgmsrv2;
p.p= &m_print_mutex;
m_event_thread = NdbThread_Create(event_thread_run,
(void**)&p,
32768,
"CommandInterpreted_event_thread",
NDB_THREAD_PRIO_LOW);
if (m_event_thread) if (m_event_thread)
{ {
void *res; DBUG_PRINT("info",("Thread created ok, waiting for started..."));
NdbThread_WaitFor(m_event_thread, &res); int iter= 1000; // try for 30 seconds
NdbThread_Destroy(&m_event_thread); while(do_event_thread == 0 &&
iter-- > 0)
NdbSleep_MilliSleep(30);
}
if (m_event_thread == NULL ||
do_event_thread == 0 ||
do_event_thread == -1)
{
DBUG_PRINT("info",("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d",
errno));
printf("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d\n", errno);
do_event_thread= 0;
if (m_event_thread)
{
void *res;
NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread);
}
ndb_mgm_disconnect(m_mgmsrv2);
} }
ndb_mgm_disconnect(m_mgmsrv2);
} }
} else
else {
{ DBUG_PRINT("warning",
DBUG_PRINT("warning", ("Could not do 2:nd connect to mgmtserver for event listening"));
("Could not do 2:nd connect to mgmtserver for event listening")); DBUG_PRINT("info", ("code: %d, msg: %s",
DBUG_PRINT("info", ("code: %d, msg: %s", ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error(m_mgmsrv2), ndb_mgm_get_latest_error_msg(m_mgmsrv2)));
ndb_mgm_get_latest_error_msg(m_mgmsrv2))); printf("Warning, event connect failed, degraded printouts as result\n");
printf("Warning, event connect failed, degraded printouts as result\n"); printf("code: %d, msg: %s\n",
printf("code: %d, msg: %s\n", ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error(m_mgmsrv2), ndb_mgm_get_latest_error_msg(m_mgmsrv2));
ndb_mgm_get_latest_error_msg(m_mgmsrv2)); }
} }
m_connected= true; m_connected= true;
DBUG_PRINT("info",("Connected to Management Server at: %s:%d", host, port)); DBUG_PRINT("info",("Connected to Management Server at: %s:%d", host, port));
...@@ -922,7 +926,7 @@ CommandInterpreter::disconnect() ...@@ -922,7 +926,7 @@ CommandInterpreter::disconnect()
do_event_thread= 0; do_event_thread= 0;
NdbThread_WaitFor(m_event_thread, &res); NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread); NdbThread_Destroy(&m_event_thread);
m_event_thread= 0; m_event_thread= NULL;
ndb_mgm_destroy_handle(&m_mgmsrv2); ndb_mgm_destroy_handle(&m_mgmsrv2);
} }
if (m_connected) if (m_connected)
...@@ -938,11 +942,11 @@ CommandInterpreter::disconnect() ...@@ -938,11 +942,11 @@ CommandInterpreter::disconnect()
int int
CommandInterpreter::execute(const char *_line, int _try_reconnect, CommandInterpreter::execute(const char *_line, int _try_reconnect,
int *error) bool interactive, int *error)
{ {
if (_try_reconnect >= 0) if (_try_reconnect >= 0)
try_reconnect=_try_reconnect; try_reconnect=_try_reconnect;
int result= execute_impl(_line); int result= execute_impl(_line, interactive);
if (error) if (error)
*error= m_error; *error= m_error;
...@@ -957,7 +961,7 @@ invalid_command(const char *cmd) ...@@ -957,7 +961,7 @@ invalid_command(const char *cmd)
} }
int int
CommandInterpreter::execute_impl(const char *_line) CommandInterpreter::execute_impl(const char *_line, bool interactive)
{ {
DBUG_ENTER("CommandInterpreter::execute_impl"); DBUG_ENTER("CommandInterpreter::execute_impl");
DBUG_PRINT("enter",("line=\"%s\"",_line)); DBUG_PRINT("enter",("line=\"%s\"",_line));
...@@ -1006,7 +1010,7 @@ CommandInterpreter::execute_impl(const char *_line) ...@@ -1006,7 +1010,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcasecmp(firstToken, "CONNECT") == 0) { else if (strcasecmp(firstToken, "CONNECT") == 0) {
executeConnect(allAfterFirstToken); executeConnect(allAfterFirstToken, interactive);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcasecmp(firstToken, "SLEEP") == 0) { else if (strcasecmp(firstToken, "SLEEP") == 0) {
...@@ -1021,7 +1025,7 @@ CommandInterpreter::execute_impl(const char *_line) ...@@ -1021,7 +1025,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(false); DBUG_RETURN(false);
} }
if (!connect()) if (!connect(interactive))
DBUG_RETURN(true); DBUG_RETURN(true);
if (strcasecmp(firstToken, "SHOW") == 0) { if (strcasecmp(firstToken, "SHOW") == 0) {
...@@ -1632,13 +1636,13 @@ CommandInterpreter::executeShow(char* parameters) ...@@ -1632,13 +1636,13 @@ CommandInterpreter::executeShow(char* parameters)
} }
void void
CommandInterpreter::executeConnect(char* parameters) CommandInterpreter::executeConnect(char* parameters, bool interactive)
{ {
disconnect(); disconnect();
if (!emptyString(parameters)) { if (!emptyString(parameters)) {
m_constr= BaseString(parameters).trim().c_str(); m_constr= BaseString(parameters).trim().c_str();
} }
connect(); connect(interactive);
} }
//***************************************************************************** //*****************************************************************************
...@@ -2479,7 +2483,7 @@ CommandInterpreter::executeStartBackup(char* parameters) ...@@ -2479,7 +2483,7 @@ CommandInterpreter::executeStartBackup(char* parameters)
} }
if (result != 0) { if (result != 0) {
ndbout << "Start of backup failed" << endl; ndbout << "Backup failed" << endl;
printError(); printError();
#if 0 #if 0
close(fd); close(fd);
......
...@@ -121,7 +121,7 @@ read_and_execute(int _try_reconnect) ...@@ -121,7 +121,7 @@ read_and_execute(int _try_reconnect)
line_read= strdup(linebuffer); line_read= strdup(linebuffer);
} }
#endif #endif
return com->execute(line_read,_try_reconnect); return com->execute(line_read, _try_reconnect, 1);
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
...@@ -163,7 +163,7 @@ int main(int argc, char** argv){ ...@@ -163,7 +163,7 @@ int main(int argc, char** argv){
} }
else else
{ {
com->execute(opt_execute_str,_try_reconnect, &ret); com->execute(opt_execute_str,_try_reconnect, 0, &ret);
} }
delete com; delete com;
......
...@@ -23,8 +23,8 @@ class Ndb_mgmclient ...@@ -23,8 +23,8 @@ class Ndb_mgmclient
public: public:
Ndb_mgmclient(const char*,int verbose=0); Ndb_mgmclient(const char*,int verbose=0);
~Ndb_mgmclient(); ~Ndb_mgmclient();
int execute(const char *_line, int _try_reconnect=-1, int *error= 0); int execute(const char *_line, int _try_reconnect=-1, bool interactive=1, int *error= 0);
int execute(int argc, char** argv, int _try_reconnect=-1, int *error= 0); int execute(int argc, char** argv, int _try_reconnect=-1, bool interactive=1, int *error= 0);
int disconnect(); int disconnect();
private: private:
CommandInterpreter *m_cmd; CommandInterpreter *m_cmd;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "../mgmapi/ndb_logevent.hpp" #include "../mgmapi/ndb_logevent.hpp"
#include <base64.h> #include <base64.h>
#include <ndberror.h>
extern bool g_StopServer; extern bool g_StopServer;
extern bool g_RestartServer; extern bool g_RestartServer;
...@@ -1325,6 +1326,12 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId) ...@@ -1325,6 +1326,12 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId)
if (ndb_logevent_body[i].index_fn) if (ndb_logevent_body[i].index_fn)
val= (*(ndb_logevent_body[i].index_fn))(val); val= (*(ndb_logevent_body[i].index_fn))(val);
str.appfmt("%s=%d\n",ndb_logevent_body[i].token, val); str.appfmt("%s=%d\n",ndb_logevent_body[i].token, val);
if(strcmp(ndb_logevent_body[i].token,"error") == 0)
{
int m_text_len= strlen(m_text);
snprintf(m_text+m_text_len, 4 , " - ");
ndb_error_string(theData[3], m_text+(m_text_len+3), sizeof(m_text)-m_text_len-3);
}
} }
Vector<NDB_SOCKET_TYPE> copy; Vector<NDB_SOCKET_TYPE> copy;
......
...@@ -378,7 +378,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -378,7 +378,7 @@ ErrorBundle ErrorCodes[] = {
{ 1305, IE, "Backup definition not implemented" }, { 1305, IE, "Backup definition not implemented" },
{ 1306, AE, "Backup not supported in diskless mode (change Diskless)" }, { 1306, AE, "Backup not supported in diskless mode (change Diskless)" },
{ 1321, IE, "Backup aborted by application" }, { 1321, UD, "Backup aborted by user request" },
{ 1322, IE, "Backup already completed" }, { 1322, IE, "Backup already completed" },
{ 1323, IE, "1323" }, { 1323, IE, "1323" },
{ 1324, IE, "Backup log buffer full" }, { 1324, IE, "Backup log buffer full" },
......
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