removed init on ConfigRetriever

    added some debug printouts
    some changes in ndbcluster_init to make start of mysqld first work
parent 2027459c
......@@ -31,16 +31,10 @@ public:
ConfigRetriever(LocalConfig &local_config, Uint32 version, Uint32 nodeType);
~ConfigRetriever();
/**
* Read local config
* @return Own node id, -1 means fail
*/
int init();
int do_connect(int exit_on_connect_failure= false);
/**
* Get configuration for current (nodeId given in local config file) node.
* Get configuration for current node.
*
* Configuration is fetched from one MGM server configured in local config
* file. The method loops over all the configured MGM servers and tries
......
......@@ -52,6 +52,7 @@ ConfigRetriever::ConfigRetriever(LocalConfig &local_config,
m_handle= 0;
m_version = version;
m_node_type = node_type;
_ownNodeId = _localConfig._ownNodeId;
}
ConfigRetriever::~ConfigRetriever(){
......@@ -66,11 +67,6 @@ ConfigRetriever::~ConfigRetriever(){
//****************************************************************************
//****************************************************************************
int
ConfigRetriever::init() {
return _ownNodeId = _localConfig._ownNodeId;
}
int
ConfigRetriever::do_connect(int exit_on_connect_failure){
......@@ -93,12 +89,18 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){
BaseString tmp;
for (unsigned int i = 0; i<_localConfig.ids.size(); i++){
MgmtSrvrId * m = &_localConfig.ids[i];
DBUG_PRINT("info",("trying %s:%d",
m->name.c_str(),
m->port));
switch(m->type){
case MgmId_TCP:
tmp.assfmt("%s:%d", m->name.c_str(), m->port);
if (ndb_mgm_connect(m_handle, tmp.c_str()) == 0) {
m_mgmd_port= m->port;
m_mgmd_host= m->name.c_str();
DBUG_PRINT("info",("connected to ndb_mgmd at %s:%d",
m_mgmd_host,
m_mgmd_port));
return 0;
}
setError(CR_RETRY, ndb_mgm_get_latest_error_desc(m_handle));
......@@ -106,9 +108,10 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){
break;
}
}
if(latestErrorType == CR_RETRY){
DBUG_PRINT("info",("CR_RETRY"));
if (exit_on_connect_failure)
return 1;
if(latestErrorType == CR_RETRY){
REPORT_WARNING("Failed to retrieve cluster configuration");
ndbout << "(Cause of failure: " << getErrorString() << ")" << endl;
ndbout << "Attempt " << retry << " of " << retry_max << ". "
......
......@@ -196,13 +196,10 @@ Configuration::fetch_configuration(LocalConfig &local_config){
m_mgmd_port= 0;
m_mgmd_host= 0;
m_config_retriever= new ConfigRetriever(local_config, NDB_VERSION, NODE_TYPE_DB);
if(m_config_retriever->init() == -1 ||
m_config_retriever->do_connect() == -1){
if(m_config_retriever->do_connect() == -1){
const char * s = m_config_retriever->getErrorString();
if(s == 0)
s = "No error given!";
/* Set stop on error to true otherwise NDB will
go into an restart loop...
*/
......
......@@ -60,6 +60,7 @@ void Ndb_cluster_connection::connect_thread()
DBUG_ENTER("Ndb_cluster_connection::connect_thread");
int r;
do {
NdbSleep_SecSleep(1);
if ((r = connect(1)) == 0)
break;
if (r == -1) {
......@@ -80,6 +81,7 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void))
m_connect_callback= connect_callback;
if ((r = connect(1)) == 1)
{
DBUG_PRINT("info",("starting thread"));
m_connect_thread= NdbThread_Create(run_ndb_cluster_connection_connect_thread,
(void**)this,
32768,
......@@ -114,8 +116,6 @@ int Ndb_cluster_connection::connect(int reconnect)
}
}
m_config_retriever= new ConfigRetriever(*m_local_config, NDB_VERSION, NODE_TYPE_API);
if(m_config_retriever->init() == -1)
break;
}
else
if (reconnect == 0)
......@@ -131,6 +131,7 @@ int Ndb_cluster_connection::connect(int reconnect)
else
if(m_config_retriever->do_connect() == -1)
break;
Uint32 nodeId = m_config_retriever->allocNodeId();
for(Uint32 i = 0; nodeId == 0 && i<5; i++){
NdbSleep_SecSleep(3);
......
......@@ -3746,11 +3746,13 @@ bool ndbcluster_init()
{
g_ndb->waitUntilReady(10);
}
else if(res == 1 && g_ndb_cluster_connection->start_connect_thread())
else if(res == 1)
{
if (g_ndb_cluster_connection->start_connect_thread()) {
DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()"));
DBUG_RETURN(TRUE);
}
}
else
{
DBUG_ASSERT(res == -1);
......@@ -3764,7 +3766,7 @@ bool ndbcluster_init()
ndbcluster_inited= 1;
#ifdef USE_DISCOVER_ON_STARTUP
if (ndb_discover_tables() != 0)
if (res == 0 && ndb_discover_tables() != 0)
DBUG_RETURN(TRUE);
#endif
DBUG_RETURN(false);
......
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