Merge jhe@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb

into  qa3-104.qa.cn.tlan:/mnt/sda7/justin.he/mysql/mysql-5.1-ndb-bj
parents 6a6b5eb1 f6878f0b
......@@ -168,8 +168,8 @@ static long ndb_cluster_node_id= 0;
static const char * ndb_connected_host= 0;
static long ndb_connected_port= 0;
static long ndb_number_of_replicas= 0;
long ndb_number_of_storage_nodes= 0;
long ndb_number_of_ready_storage_nodes= 0;
long ndb_number_of_data_nodes= 0;
long ndb_number_of_ready_data_nodes= 0;
long ndb_connect_count= 0;
static int update_status_variables(Ndb_cluster_connection *c)
......@@ -178,8 +178,8 @@ static int update_status_variables(Ndb_cluster_connection *c)
ndb_connected_port= c->get_connected_port();
ndb_connected_host= c->get_connected_host();
ndb_number_of_replicas= 0;
ndb_number_of_storage_nodes= c->no_db_nodes();
ndb_number_of_ready_storage_nodes= c->get_no_ready();
ndb_number_of_ready_data_nodes= c->get_no_ready();
ndb_number_of_data_nodes= c->no_db_nodes();
ndb_connect_count= c->get_connect_count();
return 0;
}
......@@ -189,7 +189,7 @@ SHOW_VAR ndb_status_variables[]= {
{"config_from_host", (char*) &ndb_connected_host, SHOW_CHAR_PTR},
{"config_from_port", (char*) &ndb_connected_port, SHOW_LONG},
// {"number_of_replicas", (char*) &ndb_number_of_replicas, SHOW_LONG},
{"number_of_storage_nodes",(char*) &ndb_number_of_storage_nodes, SHOW_LONG},
{"number_of_data_nodes",(char*) &ndb_number_of_data_nodes, SHOW_LONG},
{NullS, NullS, SHOW_LONG}
};
......@@ -9666,14 +9666,14 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
"cluster_node_id=%u, "
"connected_host=%s, "
"connected_port=%u, "
"number_of_storage_nodes=%u, "
"number_of_ready_storage_nodes=%u, "
"number_of_data_nodes=%u, "
"number_of_ready_data_nodes=%u, "
"connect_count=%u",
ndb_cluster_node_id,
ndb_connected_host,
ndb_connected_port,
ndb_number_of_storage_nodes,
ndb_number_of_ready_storage_nodes,
ndb_number_of_data_nodes,
ndb_number_of_ready_data_nodes,
ndb_connect_count);
if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
STRING_WITH_LEN("connection"), buf, buflen))
......
......@@ -48,11 +48,11 @@ public:
*
* @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:
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.
......@@ -92,7 +92,7 @@ private:
*/
void executeHelp(char* parameters);
void executeShow(char* parameters);
void executeConnect(char* parameters);
void executeConnect(char* parameters, bool interactive);
void executePurge(char* parameters);
int executeShutdown(char* parameters);
void executeRun(char* parameters);
......@@ -130,7 +130,7 @@ public:
void executeCpc(char * parameters);
public:
bool connect();
bool connect(bool interactive);
bool disconnect();
/**
......@@ -186,9 +186,9 @@ Ndb_mgmclient::~Ndb_mgmclient()
{
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
Ndb_mgmclient::disconnect()
......@@ -230,7 +230,7 @@ extern "C" {
#include <util/InputStream.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)
return 0;
......@@ -239,7 +239,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error
{
_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);
}
/*****************************************************************************
......@@ -345,7 +345,7 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose)
{
m_constr= _host;
m_connected= false;
m_event_thread= 0;
m_event_thread= NULL;
try_reconnect = 0;
m_print_mutex= NdbMutex_Create();
}
......@@ -435,7 +435,7 @@ event_thread_run(void* p)
}
bool
CommandInterpreter::connect()
CommandInterpreter::connect(bool interactive)
{
DBUG_ENTER("CommandInterpreter::connect");
......@@ -447,10 +447,12 @@ CommandInterpreter::connect()
ndbout_c("Cannot create handle to management server.");
exit(-1);
}
m_mgmsrv2 = ndb_mgm_create_handle();
if(m_mgmsrv2 == NULL) {
ndbout_c("Cannot create 2:nd handle to management server.");
exit(-1);
if (interactive) {
m_mgmsrv2 = ndb_mgm_create_handle();
if(m_mgmsrv2 == NULL) {
ndbout_c("Cannot create 2:nd handle to management server.");
exit(-1);
}
}
if (ndb_mgm_set_connectstring(m_mgmsrv, m_constr))
......@@ -464,62 +466,64 @@ CommandInterpreter::connect()
const char *host= ndb_mgm_get_connected_host(m_mgmsrv);
unsigned port= ndb_mgm_get_connected_port(m_mgmsrv);
BaseString constr;
constr.assfmt("%s:%d",host,port);
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)
if (interactive) {
BaseString constr;
constr.assfmt("%s:%d",host,port);
if(!ndb_mgm_set_connectstring(m_mgmsrv2, constr.c_str()) &&
!ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1))
{
DBUG_PRINT("info",("Thread created ok, waiting for started..."));
int iter= 1000; // try for 30 seconds
while(do_event_thread == 0 &&
iter-- > 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);
DBUG_PRINT("info",("2:ndb connected to Management Server ok at: %s:%d",
host, port));
assert(m_event_thread == NULL);
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)
{
void *res;
NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread);
DBUG_PRINT("info",("Thread created ok, waiting for started..."));
int iter= 1000; // try for 30 seconds
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
{
DBUG_PRINT("warning",
("Could not do 2:nd connect to mgmtserver for event listening"));
DBUG_PRINT("info", ("code: %d, msg: %s",
ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error_msg(m_mgmsrv2)));
printf("Warning, event connect failed, degraded printouts as result\n");
printf("code: %d, msg: %s\n",
ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error_msg(m_mgmsrv2));
else
{
DBUG_PRINT("warning",
("Could not do 2:nd connect to mgmtserver for event listening"));
DBUG_PRINT("info", ("code: %d, msg: %s",
ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error_msg(m_mgmsrv2)));
printf("Warning, event connect failed, degraded printouts as result\n");
printf("code: %d, msg: %s\n",
ndb_mgm_get_latest_error(m_mgmsrv2),
ndb_mgm_get_latest_error_msg(m_mgmsrv2));
}
}
m_connected= true;
DBUG_PRINT("info",("Connected to Management Server at: %s:%d", host, port));
......@@ -542,7 +546,7 @@ CommandInterpreter::disconnect()
do_event_thread= 0;
NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread);
m_event_thread= 0;
m_event_thread= NULL;
ndb_mgm_destroy_handle(&m_mgmsrv2);
}
if (m_connected)
......@@ -558,11 +562,11 @@ CommandInterpreter::disconnect()
int
CommandInterpreter::execute(const char *_line, int _try_reconnect,
int *error)
bool interactive, int *error)
{
if (_try_reconnect >= 0)
try_reconnect=_try_reconnect;
int result= execute_impl(_line);
int result= execute_impl(_line, interactive);
if (error)
*error= m_error;
......@@ -577,7 +581,7 @@ invalid_command(const char *cmd)
}
int
CommandInterpreter::execute_impl(const char *_line)
CommandInterpreter::execute_impl(const char *_line, bool interactive)
{
DBUG_ENTER("CommandInterpreter::execute_impl");
DBUG_PRINT("enter",("line=\"%s\"",_line));
......@@ -626,7 +630,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "CONNECT") == 0) {
executeConnect(allAfterFirstToken);
executeConnect(allAfterFirstToken, interactive);
DBUG_RETURN(true);
}
else if (strcasecmp(firstToken, "SLEEP") == 0) {
......@@ -641,7 +645,7 @@ CommandInterpreter::execute_impl(const char *_line)
DBUG_RETURN(false);
}
if (!connect())
if (!connect(interactive))
DBUG_RETURN(true);
if (strcasecmp(firstToken, "SHOW") == 0) {
......@@ -1238,13 +1242,13 @@ CommandInterpreter::executeShow(char* parameters)
}
void
CommandInterpreter::executeConnect(char* parameters)
CommandInterpreter::executeConnect(char* parameters, bool interactive)
{
disconnect();
if (!emptyString(parameters)) {
m_constr= BaseString(parameters).trim().c_str();
}
connect();
connect(interactive);
}
//*****************************************************************************
......@@ -2085,7 +2089,7 @@ CommandInterpreter::executeStartBackup(char* parameters)
}
if (result != 0) {
ndbout << "Start of backup failed" << endl;
ndbout << "Backup failed" << endl;
printError();
#if 0
close(fd);
......
......@@ -121,7 +121,7 @@ read_and_execute(int _try_reconnect)
line_read= strdup(linebuffer);
}
#endif
return com->execute(line_read,_try_reconnect);
return com->execute(line_read, _try_reconnect, 1);
}
int main(int argc, char** argv){
......@@ -163,7 +163,7 @@ int main(int argc, char** argv){
}
else
{
com->execute(opt_execute_str,_try_reconnect, &ret);
com->execute(opt_execute_str,_try_reconnect, 0, &ret);
}
delete com;
......
......@@ -23,8 +23,8 @@ class Ndb_mgmclient
public:
Ndb_mgmclient(const char*,int verbose=0);
~Ndb_mgmclient();
int execute(const char *_line, int _try_reconnect=-1, int *error= 0);
int execute(int argc, char** argv, 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, bool interactive=1, int *error= 0);
int disconnect();
private:
CommandInterpreter *m_cmd;
......
......@@ -2688,6 +2688,13 @@ transformNode(InitConfigFileParser::Context & ctx, const char * data){
return false;
}
if(id >= MAX_NODES)
{
ctx.reportError("too many nodes configured, only up to %d nodes supported.",
MAX_NODES);
return false;
}
// next node id _always_ next numbers after last used id
ctx.m_userProperties.put("NextNodeId", id+1, true);
......@@ -3579,11 +3586,11 @@ sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections,
Uint32 mgm_nodes = 0;
Uint32 api_nodes = 0;
if (!ctx.m_userProperties.get("DB", &db_nodes)) {
ctx.reportError("At least one database node should be defined in config file");
ctx.reportError("At least one database node (ndbd) should be defined in config file");
return false;
}
if (!ctx.m_userProperties.get("MGM", &mgm_nodes)) {
ctx.reportError("At least one management server node should be defined in config file");
ctx.reportError("At least one management server node (ndb_mgmd) should be defined in config file");
return false;
}
if (!ctx.m_userProperties.get("API", &api_nodes)) {
......
......@@ -449,7 +449,10 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
// read config locally
_config= readConfig();
if (_config == 0) {
ndbout << "Unable to read config file" << endl;
if (config_filename != NULL)
ndbout << "Invalid configuration file: " << config_filename << endl;
else
ndbout << "Invalid configuration file" << endl;
exit(-1);
}
}
......
......@@ -33,6 +33,7 @@
#include "../mgmapi/ndb_logevent.hpp"
#include <base64.h>
#include <ndberror.h>
extern bool g_StopServer;
extern bool g_RestartServer;
......@@ -1315,6 +1316,12 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId)
if (ndb_logevent_body[i].index_fn)
val= (*(ndb_logevent_body[i].index_fn))(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;
......
......@@ -439,7 +439,7 @@ ErrorBundle ErrorCodes[] = {
{ 1305, DMEC, IE, "Backup definition not implemented" },
{ 1306, DMEC, AE, "Backup not supported in diskless mode (change Diskless)" },
{ 1321, DMEC, IE, "Backup aborted by application" },
{ 1321, DMEC, UD, "Backup aborted by user request" },
{ 1322, DMEC, IE, "Backup already completed" },
{ 1323, DMEC, IE, "1323" },
{ 1324, DMEC, 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