Commit 18f12ee4 authored by unknown's avatar unknown

adopted testprograms to changes in mgmapi

parent 57b6bfc9
...@@ -538,15 +538,19 @@ connect_ndb_mgm(atrt_process & proc){ ...@@ -538,15 +538,19 @@ connect_ndb_mgm(atrt_process & proc){
} }
BaseString tmp = proc.m_hostname; BaseString tmp = proc.m_hostname;
tmp.appfmt(":%d", proc.m_ndb_mgm_port); tmp.appfmt(":%d", proc.m_ndb_mgm_port);
time_t start = time(0);
const time_t max_connect_time = 30; if (ndb_mgm_set_connectstring(handle,tmp.c_str()))
do { {
if(ndb_mgm_connect(handle, tmp.c_str()) != -1){ g_logger.critical("Unable to create parse connectstring");
return false;
}
if(ndb_mgm_connect(handle, 30, 1, 0) != -1)
{
proc.m_ndb_mgm_handle = handle; proc.m_ndb_mgm_handle = handle;
return true; return true;
} }
sleep(1);
} while(time(0) < (start + max_connect_time));
g_logger.critical("Unable to connect to ndb mgm %s", tmp.c_str()); g_logger.critical("Unable to connect to ndb mgm %s", tmp.c_str());
return false; return false;
} }
......
...@@ -69,16 +69,14 @@ NdbBackup::getBackupDataDirForNode(int _node_id){ ...@@ -69,16 +69,14 @@ NdbBackup::getBackupDataDirForNode(int _node_id){
/** /**
* Fetch configuration from management server * Fetch configuration from management server
*/ */
LocalConfig lc; ConfigRetriever cr(0, 0, NODE_TYPE_API);
if (!lc.init(0,0)) {
abort();
}
ConfigRetriever cr(lc, 0, NODE_TYPE_API);
ndb_mgm_configuration * p = 0; ndb_mgm_configuration * p = 0;
BaseString tmp; tmp.assfmt("%s:%d", host.c_str(), port); BaseString tmp; tmp.assfmt("%s:%d", host.c_str(), port);
NdbMgmHandle handle = ndb_mgm_create_handle(); NdbMgmHandle handle = ndb_mgm_create_handle();
if(handle == 0 || ndb_mgm_connect(handle, tmp.c_str()) != 0 || if(handle == 0 ||
ndb_mgm_set_connectstring(handle,tmp.c_str()) != 0 ||
ndb_mgm_connect(handle,0,0,0) != 0 ||
(p = ndb_mgm_get_configuration(handle, 0)) == 0){ (p = ndb_mgm_get_configuration(handle, 0)) == 0){
const char * s = 0; const char * s = 0;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <NdbTick.h> #include <NdbTick.h>
#include <LocalConfig.hpp>
#include <mgmapi_debug.h> #include <mgmapi_debug.h>
#include <NDBT_Output.hpp> #include <NDBT_Output.hpp>
#include <random.h> #include <random.h>
...@@ -38,37 +37,7 @@ NdbRestarter::NdbRestarter(const char* _addr): ...@@ -38,37 +37,7 @@ NdbRestarter::NdbRestarter(const char* _addr):
m_config(0) m_config(0)
{ {
if (_addr == NULL){ if (_addr == NULL){
LocalConfig lcfg; addr.assign("");
if(!lcfg.init()){
lcfg.printError();
lcfg.printUsage();
g_err << "NdbRestarter - Error parsing local config file" << endl;
return;
}
if (lcfg.ids.size() == 0){
g_err << "NdbRestarter - No management servers configured in local config file" << endl;
return;
}
for (int i = 0; i<lcfg.ids.size(); i++){
MgmtSrvrId * m = &lcfg.ids[i];
switch(m->type){
case MgmId_TCP:
char buf[255];
snprintf(buf, 255, "%s:%d", m->name.c_str(), m->port);
addr.assign(buf);
host.assign(m->name.c_str());
port = m->port;
return;
break;
case MgmId_File:
break;
default:
break;
}
}
} else { } else {
addr.assign(_addr); addr.assign(_addr);
} }
...@@ -397,7 +366,15 @@ NdbRestarter::connect(){ ...@@ -397,7 +366,15 @@ NdbRestarter::connect(){
return -1; return -1;
} }
g_info << "Connecting to mgmsrv at " << addr.c_str() << endl; g_info << "Connecting to mgmsrv at " << addr.c_str() << endl;
if (ndb_mgm_connect(handle, addr.c_str()) == -1) { if (ndb_mgm_set_connectstring(handle,addr.c_str()))
{
MGMERR(handle);
g_err << "Connection to " << addr.c_str() << " failed" << endl;
return -1;
}
if (ndb_mgm_connect(handle, 0, 0, 0) == -1)
{
MGMERR(handle); MGMERR(handle);
g_err << "Connection to " << addr.c_str() << " failed" << endl; g_err << "Connection to " << addr.c_str() << " failed" << endl;
return -1; return -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