summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-11-30 17:47:47 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-11-30 17:47:47 +0000
commitbe733ad13f5f6c196e9cd465cd32baf3e2faa75b (patch)
tree654e8b49722ec6161ce60d41101cb6ecb6befb0c /ndb
parent99e69f2660dde2d01f198670274221328c19a43c (diff)
downloadmariadb-git-be733ad13f5f6c196e9cd465cd32baf3e2faa75b.tar.gz
fixed error in test result
added extra calls to retrieve connectstring used reengineered connect somewhat to make retries etc explicit mysql-test/r/ndb_index_unique.result: fixed error in test result ndb/include/mgmapi/mgmapi.h: added extra calls to retrieve connectstring used ndb/include/mgmcommon/ConfigRetriever.hpp: added extra calls to retrieve connectstring used ndb/include/ndbapi/ndb_cluster_connection.hpp: added extra calls to retrieve connectstring used reengineered connect somewhat to make retries etc explicit ndb/src/common/mgmcommon/ConfigRetriever.cpp: added extra calls to retrieve connectstring used ndb/src/mgmapi/mgmapi.cpp: added extra calls to retrieve connectstring used ndb/src/mgmclient/CommandInterpreter.cpp: moved parse of quit to avoid connect before ndb/src/ndbapi/Ndbinit.cpp: reengineered connect somewhat to make retries etc explicit ndb/src/ndbapi/ndb_cluster_connection.cpp: added extra calls to retrieve connectstring used reengineered connect somewhat to make retries etc explicit ndb/tools/listTables.cpp: reengineered connect somewhat to make retries etc explicit sql/ha_ndbcluster.cc: added extra calls to retrieve connectstring used reengineered connect somewhat to make retries etc explicit
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/mgmapi/mgmapi.h1
-rw-r--r--ndb/include/mgmcommon/ConfigRetriever.hpp1
-rw-r--r--ndb/include/ndbapi/ndb_cluster_connection.hpp6
-rw-r--r--ndb/src/common/mgmcommon/ConfigRetriever.cpp5
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp7
-rw-r--r--ndb/src/mgmclient/CommandInterpreter.cpp12
-rw-r--r--ndb/src/ndbapi/Ndbinit.cpp2
-rw-r--r--ndb/src/ndbapi/ndb_cluster_connection.cpp69
-rw-r--r--ndb/tools/listTables.cpp3
9 files changed, 63 insertions, 43 deletions
diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h
index 26add86a468..dc4f745adb2 100644
--- a/ndb/include/mgmapi/mgmapi.h
+++ b/ndb/include/mgmapi/mgmapi.h
@@ -375,6 +375,7 @@ extern "C" {
int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle);
int ndb_mgm_get_connected_port(NdbMgmHandle handle);
const char *ndb_mgm_get_connected_host(NdbMgmHandle handle);
+ const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz);
/**
* Destroy a management server handle
diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp
index 80449628867..8461658748e 100644
--- a/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -72,6 +72,7 @@ public:
Uint32 get_mgmd_port() const;
const char *get_mgmd_host() const;
+ const char *get_connectstring(char *buf, int buf_sz) const;
Uint32 get_configuration_nodeid() const;
private:
diff --git a/ndb/include/ndbapi/ndb_cluster_connection.hpp b/ndb/include/ndbapi/ndb_cluster_connection.hpp
index 59d5a038844..6fa25caf5d0 100644
--- a/ndb/include/ndbapi/ndb_cluster_connection.hpp
+++ b/ndb/include/ndbapi/ndb_cluster_connection.hpp
@@ -30,12 +30,14 @@ class Ndb_cluster_connection {
public:
Ndb_cluster_connection(const char * connect_string = 0);
~Ndb_cluster_connection();
- int connect(int reconnect= 0);
+ int connect(int no_retries, int retry_delay_in_seconds, int verbose);
int start_connect_thread(int (*connect_callback)(void)= 0);
+ const char *get_connectstring(char *buf, int buf_sz) const;
+ int get_connected_port() const;
+ const char *get_connected_host() const;
private:
friend void* run_ndb_cluster_connection_connect_thread(void*);
void connect_thread();
- char *m_connect_string;
TransporterFacade *m_facade;
ConfigRetriever *m_config_retriever;
NdbThread *m_connect_thread;
diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 0af5eb2f83c..744412870f5 100644
--- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -90,6 +90,11 @@ const char *ConfigRetriever::get_mgmd_host() const
return ndb_mgm_get_connected_host(m_handle);
}
+const char *ConfigRetriever::get_connectstring(char *buf, int buf_sz) const
+{
+ return ndb_mgm_get_connectstring(m_handle, buf, buf_sz);
+}
+
//****************************************************************************
//****************************************************************************
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index e6328604c1b..651a4a8a725 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -84,7 +84,6 @@ typedef Parser<ParserDummy> Parser_t;
#define NDB_MGM_MAX_ERR_DESC_SIZE 256
struct ndb_mgm_handle {
- char * connectstring;
int cfg_i;
int connected;
@@ -1678,6 +1677,12 @@ const char *ndb_mgm_get_connected_host(NdbMgmHandle handle)
}
extern "C"
+const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz)
+{
+ return handle->cfg.makeConnectString(buf,buf_sz);
+}
+
+extern "C"
int
ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
{
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp
index f36dddf815d..7ef62da9bb3 100644
--- a/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -516,6 +516,12 @@ CommandInterpreter::execute_impl(const char *_line)
executeConnect(allAfterFirstToken);
DBUG_RETURN(true);
}
+ else if((strcasecmp(firstToken, "QUIT") == 0 ||
+ strcasecmp(firstToken, "EXIT") == 0 ||
+ strcasecmp(firstToken, "BYE") == 0) &&
+ allAfterFirstToken == NULL){
+ DBUG_RETURN(false);
+ }
if (!connect())
DBUG_RETURN(true);
@@ -571,12 +577,6 @@ CommandInterpreter::execute_impl(const char *_line)
}
else if (strcasecmp(firstToken, "ALL") == 0) {
analyseAfterFirstToken(-1, allAfterFirstToken);
- }
- else if((strcasecmp(firstToken, "QUIT") == 0 ||
- strcasecmp(firstToken, "EXIT") == 0 ||
- strcasecmp(firstToken, "BYE") == 0) &&
- allAfterFirstToken == NULL){
- DBUG_RETURN(false);
} else {
/**
* First token should be a digit, node ID
diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp
index 698bbcde4c6..48e62c36a5f 100644
--- a/ndb/src/ndbapi/Ndbinit.cpp
+++ b/ndb/src/ndbapi/Ndbinit.cpp
@@ -58,7 +58,7 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) {
theNoOfNdbObjects++;
if (global_ndb_cluster_connection == 0) {
global_ndb_cluster_connection= new Ndb_cluster_connection(ndbConnectString);
- global_ndb_cluster_connection->connect();
+ global_ndb_cluster_connection->connect(12,5,1);
}
setup(global_ndb_cluster_connection, aDataBase, aSchema);
DBUG_VOID_RETURN;
diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp
index 8a5a61df171..f436ee56ede 100644
--- a/ndb/src/ndbapi/ndb_cluster_connection.cpp
+++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp
@@ -40,10 +40,7 @@ Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string)
DBUG_ENTER("Ndb_cluster_connection");
DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this));
m_facade= TransporterFacade::theFacadeInstance= new TransporterFacade();
- if (connect_string)
- m_connect_string= my_strdup(connect_string,MYF(MY_WME));
- else
- m_connect_string= 0;
+
m_config_retriever= 0;
m_connect_thread= 0;
m_connect_callback= 0;
@@ -58,9 +55,39 @@ Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string)
ndb_print_state_mutex= NdbMutex_Create();
}
#endif
+ m_config_retriever=
+ new ConfigRetriever(connect_string, NDB_VERSION, NODE_TYPE_API);
+ if (m_config_retriever->hasError())
+ {
+ printf("Could not connect initialize handle to management server: %s",
+ m_config_retriever->getErrorString());
+ delete m_config_retriever;
+ m_config_retriever= 0;
+ }
DBUG_VOID_RETURN;
}
+int Ndb_cluster_connection::get_connected_port() const
+{
+ if (m_config_retriever)
+ return m_config_retriever->get_mgmd_port();
+ return -1;
+}
+
+const char *Ndb_cluster_connection::get_connected_host() const
+{
+ if (m_config_retriever)
+ return m_config_retriever->get_mgmd_host();
+ return 0;
+}
+
+const char *Ndb_cluster_connection::get_connectstring(char *buf, int buf_sz) const
+{
+ if (m_config_retriever)
+ return m_config_retriever->get_connectstring(buf,buf_sz);
+ return 0;
+}
+
extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me)
{
my_thread_init();
@@ -77,7 +104,7 @@ void Ndb_cluster_connection::connect_thread()
int r;
do {
NdbSleep_SecSleep(1);
- if ((r = connect(1)) == 0)
+ if ((r = connect(0,0,0)) == 0)
break;
if (r == -1) {
printf("Ndb_cluster_connection::connect_thread error\n");
@@ -98,7 +125,7 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void))
int r;
DBUG_ENTER("Ndb_cluster_connection::start_connect_thread");
m_connect_callback= connect_callback;
- if ((r = connect(1)) == 1)
+ if ((r = connect(0,0,0)) == 1)
{
DBUG_PRINT("info",("starting thread"));
m_connect_thread=
@@ -117,36 +144,15 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void))
DBUG_RETURN(0);
}
-int Ndb_cluster_connection::connect(int reconnect)
+int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, int verbose)
{
DBUG_ENTER("Ndb_cluster_connection::connect");
const char* error = 0;
do {
if (m_config_retriever == 0)
- {
- m_config_retriever=
- new ConfigRetriever(m_connect_string, NDB_VERSION, NODE_TYPE_API);
- if (m_config_retriever->hasError())
- {
- printf("Could not connect initialize handle to management server: %s",
- m_config_retriever->getErrorString());
- DBUG_RETURN(-1);
- }
- }
- else
- if (reconnect == 0)
- DBUG_RETURN(0);
- if (reconnect)
- {
- int r= m_config_retriever->do_connect(0,0,0);
- if (r == 1)
- DBUG_RETURN(1); // mgmt server not up yet
- if (r == -1)
- break;
- }
- else
- if(m_config_retriever->do_connect(12,5,1) == -1)
- break;
+ DBUG_RETURN(-1);
+ if (m_config_retriever->do_connect(no_retries,retry_delay_in_seconds,verbose))
+ DBUG_RETURN(1); // mgmt server not up yet
Uint32 nodeId = m_config_retriever->allocNodeId(4/*retries*/,3/*delay*/);
if(nodeId == 0)
@@ -189,7 +195,6 @@ Ndb_cluster_connection::~Ndb_cluster_connection()
abort();
TransporterFacade::theFacadeInstance= 0;
}
- my_free(m_connect_string,MYF(MY_ALLOW_ZERO_PTR));
if (m_config_retriever)
delete m_config_retriever;
DBUG_VOID_RETURN;
diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp
index b923207a4fe..ccb6967e2dc 100644
--- a/ndb/tools/listTables.cpp
+++ b/ndb/tools/listTables.cpp
@@ -228,10 +228,11 @@ int main(int argc, char** argv){
_tabname = argv[0];
ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str);
+ if (ndb_cluster_connection->connect(12,5,1))
+ fatal("unable to connect");
ndb = new Ndb(ndb_cluster_connection, _dbname);
if (ndb->init() != 0)
fatal("init");
- ndb_cluster_connection->connect();
if (ndb->waitUntilReady(30) < 0)
fatal("waitUntilReady");
dic = ndb->getDictionary();