2014-01-06 10:52:35 +05:30
|
|
|
/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
2004-04-14 10:53:21 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2004-04-14 10:53:21 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2013-03-19 15:53:48 +01:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
2004-04-14 10:53:21 +02:00
|
|
|
|
|
|
|
|
2004-10-22 15:13:06 +00:00
|
|
|
#include <ndb_global.h>
|
2004-11-01 13:55:43 +00:00
|
|
|
#include <ndb_opts.h>
|
|
|
|
|
2004-06-03 18:25:46 +00:00
|
|
|
#include <mgmapi.h>
|
2004-04-14 10:53:21 +02:00
|
|
|
#include <NdbMain.h>
|
|
|
|
#include <NdbOut.hpp>
|
|
|
|
#include <NdbSleep.h>
|
|
|
|
|
|
|
|
#include <NDBT.hpp>
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
static int
|
|
|
|
waitClusterStatus(const char* _addr, ndb_mgm_node_status _status);
|
2004-06-03 18:25:46 +00:00
|
|
|
|
2004-12-20 12:36:14 +01:00
|
|
|
enum ndb_waiter_options {
|
2007-03-09 15:37:10 +07:00
|
|
|
OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST,
|
|
|
|
OPT_WAIT_STATUS_SINGLE_USER
|
2004-12-20 12:36:14 +01:00
|
|
|
};
|
|
|
|
NDB_STD_OPTS_VARS;
|
|
|
|
|
2004-11-01 13:55:43 +00:00
|
|
|
static int _no_contact = 0;
|
2005-01-23 12:12:50 +01:00
|
|
|
static int _not_started = 0;
|
2007-03-09 15:37:10 +07:00
|
|
|
static int _single_user = 0;
|
2004-11-01 13:55:43 +00:00
|
|
|
static int _timeout = 120;
|
2006-09-04 16:33:56 +02:00
|
|
|
|
|
|
|
const char *load_default_groups[]= { "mysql_cluster",0 };
|
|
|
|
|
2004-11-01 13:55:43 +00:00
|
|
|
static struct my_option my_long_options[] =
|
|
|
|
{
|
|
|
|
NDB_STD_OPTS("ndb_desc"),
|
|
|
|
{ "no-contact", 'n', "Wait for cluster no contact",
|
2010-07-24 09:24:44 -03:00
|
|
|
&_no_contact, &_no_contact, 0,
|
2004-11-01 13:55:43 +00:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
2005-01-23 12:12:50 +01:00
|
|
|
{ "not-started", OPT_WAIT_STATUS_NOT_STARTED, "Wait for cluster not started",
|
2010-07-24 09:24:44 -03:00
|
|
|
&_not_started, &_not_started, 0,
|
2005-01-23 12:12:50 +01:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
2007-03-09 15:37:10 +07:00
|
|
|
{ "single-user", OPT_WAIT_STATUS_SINGLE_USER,
|
|
|
|
"Wait for cluster to enter single user mode",
|
2010-07-24 09:24:44 -03:00
|
|
|
&_single_user, &_single_user, 0,
|
2007-03-09 15:37:10 +07:00
|
|
|
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
|
2008-02-07 08:08:43 +01:00
|
|
|
{ "timeout", 't', "Timeout to wait in seconds",
|
2010-07-24 09:24:44 -03:00
|
|
|
&_timeout, &_timeout, 0,
|
2004-11-01 13:55:43 +00:00
|
|
|
GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
2005-01-28 00:42:41 +01:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
|
2004-11-01 13:55:43 +00:00
|
|
|
static void usage()
|
|
|
|
{
|
2005-01-28 00:42:41 +01:00
|
|
|
ndb_std_print_version();
|
2006-09-04 16:33:56 +02:00
|
|
|
print_defaults(MYSQL_CONFIG_NAME,load_default_groups);
|
|
|
|
puts("");
|
2004-11-01 13:55:43 +00:00
|
|
|
my_print_help(my_long_options);
|
|
|
|
my_print_variables(my_long_options);
|
|
|
|
}
|
2005-01-28 00:42:41 +01:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
|
2004-11-01 13:55:43 +00:00
|
|
|
int main(int argc, char** argv){
|
|
|
|
NDB_INIT(argv[0]);
|
|
|
|
load_defaults("my",load_default_groups,&argc,&argv);
|
2004-04-14 10:53:21 +02:00
|
|
|
const char* _hostName = NULL;
|
2008-02-07 08:08:43 +01:00
|
|
|
|
2005-02-21 23:15:30 +01:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
opt_debug= "d:t:O,/tmp/ndb_waiter.trace";
|
|
|
|
#endif
|
2008-02-07 08:08:43 +01:00
|
|
|
|
|
|
|
if (handle_options(&argc, &argv, my_long_options,
|
|
|
|
ndb_std_get_one_option))
|
2004-04-14 10:53:21 +02:00
|
|
|
return NDBT_ProgramExit(NDBT_WRONGARGS);
|
2004-06-04 10:24:43 +02:00
|
|
|
|
2004-11-01 13:55:43 +00:00
|
|
|
_hostName = argv[0];
|
2004-04-14 10:53:21 +02:00
|
|
|
|
changed mysqladmin.c to mysqladmin.cc
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
client/Makefile.am:
changed mysqladmin.c to mysqladmin.cc
client/mysqladmin.cc:
changed mysqladmin.c to mysqladmin.cc
configure.in:
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
ndb/include/mgmapi/mgmapi.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/mgmcommon/ConfigRetriever.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/ndbapi/ndb_cluster_connection.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/common/mgmcommon/ConfigRetriever.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/vm/Configuration.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
changed to config setting to always use noOfMetaTables to make sure we don't overflow arrays
ndb/src/kernel/vm/Configuration.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/mgmapi.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/CommandInterpreter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvr.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
ndb/src/mgmsrv/MgmtSrvr.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvrConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/ndbapi/ndb_cluster_connection.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/tools/waiter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
2004-11-18 18:38:38 +00:00
|
|
|
if (_hostName == 0)
|
|
|
|
_hostName= opt_connect_str;
|
2004-04-14 10:53:21 +02:00
|
|
|
|
2005-01-23 12:12:50 +01:00
|
|
|
enum ndb_mgm_node_status wait_status;
|
|
|
|
if (_no_contact)
|
|
|
|
{
|
|
|
|
wait_status= NDB_MGM_NODE_STATUS_NO_CONTACT;
|
|
|
|
}
|
|
|
|
else if (_not_started)
|
|
|
|
{
|
|
|
|
wait_status= NDB_MGM_NODE_STATUS_NOT_STARTED;
|
|
|
|
}
|
2007-03-09 15:37:10 +07:00
|
|
|
else if (_single_user)
|
|
|
|
{
|
|
|
|
wait_status= NDB_MGM_NODE_STATUS_SINGLEUSER;
|
|
|
|
}
|
2005-01-23 12:12:50 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wait_status= NDB_MGM_NODE_STATUS_STARTED;
|
|
|
|
}
|
2004-04-14 10:53:21 +02:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
if (waitClusterStatus(_hostName, wait_status) != 0)
|
2005-01-23 12:12:50 +01:00
|
|
|
return NDBT_ProgramExit(NDBT_FAILED);
|
2004-04-14 10:53:21 +02:00
|
|
|
return NDBT_ProgramExit(NDBT_OK);
|
|
|
|
}
|
2004-06-03 18:25:46 +00:00
|
|
|
|
|
|
|
#define MGMERR(h) \
|
|
|
|
ndbout << "latest_error="<<ndb_mgm_get_latest_error(h) \
|
|
|
|
<< ", line="<<ndb_mgm_get_latest_error_line(h) \
|
|
|
|
<< endl;
|
|
|
|
|
|
|
|
NdbMgmHandle handle= NULL;
|
|
|
|
|
|
|
|
Vector<ndb_mgm_node_state> ndbNodes;
|
|
|
|
|
|
|
|
int
|
|
|
|
getStatus(){
|
|
|
|
int retries = 0;
|
|
|
|
struct ndb_mgm_cluster_state * status;
|
|
|
|
struct ndb_mgm_node_state * node;
|
|
|
|
|
|
|
|
ndbNodes.clear();
|
|
|
|
|
|
|
|
while(retries < 10){
|
|
|
|
status = ndb_mgm_get_status(handle);
|
|
|
|
if (status == NULL){
|
|
|
|
ndbout << "status==NULL, retries="<<retries<<endl;
|
|
|
|
MGMERR(handle);
|
|
|
|
retries++;
|
2006-05-17 00:22:43 +02:00
|
|
|
ndb_mgm_disconnect(handle);
|
|
|
|
if (ndb_mgm_connect(handle,0,0,1)) {
|
|
|
|
MGMERR(handle);
|
|
|
|
g_err << "Reconnect failed" << endl;
|
|
|
|
break;
|
|
|
|
}
|
2004-06-03 18:25:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-07-09 15:10:24 +02:00
|
|
|
int count = status->no_of_nodes;
|
|
|
|
for (int i = 0; i < count; i++){
|
2004-06-03 18:25:46 +00:00
|
|
|
node = &status->node_states[i];
|
|
|
|
switch(node->node_type){
|
|
|
|
case NDB_MGM_NODE_TYPE_NDB:
|
|
|
|
ndbNodes.push_back(*node);
|
|
|
|
break;
|
|
|
|
case NDB_MGM_NODE_TYPE_MGM:
|
2008-02-07 08:08:43 +01:00
|
|
|
/* Don't care about MGM nodes */
|
2004-06-03 18:25:46 +00:00
|
|
|
break;
|
|
|
|
case NDB_MGM_NODE_TYPE_API:
|
2008-02-07 08:08:43 +01:00
|
|
|
/* Don't care about API nodes */
|
2004-06-03 18:25:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if(node->node_status == NDB_MGM_NODE_STATUS_UNKNOWN ||
|
|
|
|
node->node_status == NDB_MGM_NODE_STATUS_NO_CONTACT){
|
|
|
|
retries++;
|
|
|
|
ndbNodes.clear();
|
|
|
|
free(status);
|
|
|
|
status = NULL;
|
2004-07-09 15:10:24 +02:00
|
|
|
count = 0;
|
2004-06-03 18:25:46 +00:00
|
|
|
|
|
|
|
ndbout << "kalle"<< endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(status == 0){
|
|
|
|
ndbout << "status == 0" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
free(status);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-02-07 08:08:43 +01:00
|
|
|
|
2004-06-03 18:25:46 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
static int
|
2004-06-28 19:53:55 +00:00
|
|
|
waitClusterStatus(const char* _addr,
|
2008-02-07 08:08:43 +01:00
|
|
|
ndb_mgm_node_status _status)
|
2004-06-03 18:25:46 +00:00
|
|
|
{
|
|
|
|
int _startphase = -1;
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
/* Ignore SIGPIPE */
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
2004-06-03 18:25:46 +00:00
|
|
|
|
changed mysqladmin.c to mysqladmin.cc
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
client/Makefile.am:
changed mysqladmin.c to mysqladmin.cc
client/mysqladmin.cc:
changed mysqladmin.c to mysqladmin.cc
configure.in:
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
ndb/include/mgmapi/mgmapi.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/mgmcommon/ConfigRetriever.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/ndbapi/ndb_cluster_connection.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/common/mgmcommon/ConfigRetriever.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/vm/Configuration.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
changed to config setting to always use noOfMetaTables to make sure we don't overflow arrays
ndb/src/kernel/vm/Configuration.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/mgmapi.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/CommandInterpreter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvr.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
ndb/src/mgmsrv/MgmtSrvr.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvrConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/ndbapi/ndb_cluster_connection.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/tools/waiter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
2004-11-18 18:38:38 +00:00
|
|
|
handle = ndb_mgm_create_handle();
|
2004-06-03 18:25:46 +00:00
|
|
|
if (handle == NULL){
|
2008-02-07 08:08:43 +01:00
|
|
|
g_err << "Could not create ndb_mgm handle" << endl;
|
2004-06-03 18:25:46 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
g_info << "Connecting to mgmsrv at " << _addr << endl;
|
changed mysqladmin.c to mysqladmin.cc
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
client/Makefile.am:
changed mysqladmin.c to mysqladmin.cc
client/mysqladmin.cc:
changed mysqladmin.c to mysqladmin.cc
configure.in:
no need for dvlags to have DEFINE_CXA_PURE_VIRTUAL anymore
ndb/include/mgmapi/mgmapi.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/mgmcommon/ConfigRetriever.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/include/ndbapi/ndb_cluster_connection.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/common/mgmcommon/ConfigRetriever.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/kernel/vm/Configuration.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
changed to config setting to always use noOfMetaTables to make sure we don't overflow arrays
ndb/src/kernel/vm/Configuration.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/LocalConfig.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmapi/mgmapi.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/CommandInterpreter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmclient/ndb_mgmclient.h:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvr.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
enabled multiple management servrs to fetch data configurations from eachother
ndb/src/mgmsrv/MgmtSrvr.hpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/MgmtSrvrConfig.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/mgmsrv/main.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/src/ndbapi/ndb_cluster_connection.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
ndb/tools/waiter.cpp:
aligned the parsing of connectstring, retries for connect, allocation of nodeid for all cluster nodes
removed all dependencies of LocalConfig, except for mgmapi internals
2004-11-18 18:38:38 +00:00
|
|
|
if (ndb_mgm_set_connectstring(handle, _addr))
|
|
|
|
{
|
|
|
|
MGMERR(handle);
|
|
|
|
g_err << "Connectstring " << _addr << " invalid" << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ndb_mgm_connect(handle,0,0,1)) {
|
2004-06-03 18:25:46 +00:00
|
|
|
MGMERR(handle);
|
|
|
|
g_err << "Connection to " << _addr << " failed" << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
int attempts = 0;
|
|
|
|
int resetAttempts = 0;
|
|
|
|
const int MAX_RESET_ATTEMPTS = 10;
|
|
|
|
bool allInState = false;
|
|
|
|
int timeout_ms= _timeout * 10; /* In number of 100 milliseconds */
|
2004-06-03 18:25:46 +00:00
|
|
|
while (allInState == false){
|
|
|
|
if (_timeout > 0 && attempts > _timeout){
|
|
|
|
/**
|
|
|
|
* Timeout has expired waiting for the nodes to enter
|
|
|
|
* the state we want
|
|
|
|
*/
|
|
|
|
bool waitMore = false;
|
2008-02-07 08:08:43 +01:00
|
|
|
/**
|
|
|
|
* Make special check if we are waiting for
|
2004-06-03 18:25:46 +00:00
|
|
|
* cluster to become started
|
|
|
|
*/
|
|
|
|
if(_status == NDB_MGM_NODE_STATUS_STARTED){
|
|
|
|
waitMore = true;
|
|
|
|
/**
|
|
|
|
* First check if any node is not starting
|
|
|
|
* then it's no idea to wait anymore
|
|
|
|
*/
|
|
|
|
for (size_t n = 0; n < ndbNodes.size(); n++){
|
|
|
|
if (ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTED &&
|
|
|
|
ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTING)
|
|
|
|
waitMore = false;
|
|
|
|
|
|
|
|
}
|
2008-02-07 08:08:43 +01:00
|
|
|
}
|
2004-06-03 18:25:46 +00:00
|
|
|
|
|
|
|
if (!waitMore || resetAttempts > MAX_RESET_ATTEMPTS){
|
|
|
|
g_err << "waitNodeState("
|
|
|
|
<< ndb_mgm_get_node_status_string(_status)
|
|
|
|
<<", "<<_startphase<<")"
|
|
|
|
<< " timeout after " << attempts <<" attemps" << endl;
|
|
|
|
return -1;
|
2008-02-07 08:08:43 +01:00
|
|
|
}
|
2004-06-03 18:25:46 +00:00
|
|
|
|
|
|
|
g_err << "waitNodeState("
|
|
|
|
<< ndb_mgm_get_node_status_string(_status)
|
|
|
|
<<", "<<_startphase<<")"
|
|
|
|
<< " resetting number of attempts "
|
|
|
|
<< resetAttempts << endl;
|
|
|
|
attempts = 0;
|
|
|
|
resetAttempts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getStatus() != 0){
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
/* Assume all nodes are in state(if there is any) */
|
|
|
|
allInState = (ndbNodes.size() > 0);
|
2004-06-03 18:25:46 +00:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
/* Loop through all nodes and check their state */
|
|
|
|
for (size_t n = 0; n < ndbNodes.size(); n++) {
|
|
|
|
ndb_mgm_node_state* ndbNode = &ndbNodes[n];
|
2004-06-03 18:25:46 +00:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
assert(ndbNode != NULL);
|
2004-06-03 18:25:46 +00:00
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
g_info << "Node " << ndbNode->node_id << ": "
|
2004-06-03 18:25:46 +00:00
|
|
|
<< ndb_mgm_get_node_status_string(ndbNode->node_status)<< endl;
|
|
|
|
|
2008-02-07 08:08:43 +01:00
|
|
|
if (ndbNode->node_status != _status)
|
2004-06-03 18:25:46 +00:00
|
|
|
allInState = false;
|
|
|
|
}
|
2008-02-07 08:08:43 +01:00
|
|
|
|
|
|
|
if (!allInState) {
|
|
|
|
g_info << "Waiting for cluster enter state "
|
|
|
|
<< ndb_mgm_get_node_status_string(_status)<< endl;
|
|
|
|
NdbSleep_MilliSleep(100);
|
|
|
|
}
|
|
|
|
|
2004-06-03 18:25:46 +00:00
|
|
|
attempts++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-18 14:26:39 +00:00
|
|
|
|
|
|
|
template class Vector<ndb_mgm_node_state>;
|