diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-02-16 20:37:14 +0100 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-02-16 20:37:14 +0100 |
commit | 4d9e12438250c1a9d9b624746dca468d69b4a2b7 (patch) | |
tree | 291ceb6cc5278770ce7f6cdba00d8785a99ed7c0 /ndb/src/common | |
parent | 7663198d08a67fec733475b22f7e77d08806fb07 (diff) | |
download | mariadb-git-4d9e12438250c1a9d9b624746dca468d69b4a2b7.tar.gz |
removed NdbMgmHandle from TransporterRegistry constructor
changed to set NdbMgmHandle from IPPConfig, and use info from configuration, instead of mgm handle from config retrieval
ndb/src/ndbapi/Ndb.cpp:
added som debug printout
ndb/src/ndbapi/NdbTransaction.cpp:
added some debug printout
Diffstat (limited to 'ndb/src/common')
-rw-r--r-- | ndb/src/common/mgmcommon/IPCConfig.cpp | 29 | ||||
-rw-r--r-- | ndb/src/common/transporter/TransporterRegistry.cpp | 60 |
2 files changed, 66 insertions, 23 deletions
diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index af24e738e05..f188a433f1b 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -170,6 +170,35 @@ IPCConfig::configureTransporters(Uint32 nodeId, DBUG_ENTER("IPCConfig::configureTransporters"); + /** + * Iterate over all MGM's an construct a connectstring + * create mgm_handle and give it to the Transporter Registry + */ + { + const char *separator= ""; + BaseString connect_string; + ndb_mgm_configuration_iterator iter(config, CFG_SECTION_NODE); + for(iter.first(); iter.valid(); iter.next()) + { + Uint32 type; + if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; + if(type != NODE_TYPE_MGM) continue; + const char* hostname; + Uint32 port; + if(iter.get(CFG_NODE_HOST, &hostname)) continue; + if( strlen(hostname) == 0 ) continue; + if(iter.get(CFG_MGM_PORT, &port)) continue; + connect_string.appfmt("%s%s:port",separator,hostname,port); + separator= ","; + } + NdbMgmHandle h= ndb_mgm_create_handle(); + if ( h && connect_string.length() > 0 ) + { + ndb_mgm_set_connectstring(h,connect_string.c_str()); + tr.set_mgm_handle(h); + } + } + Uint32 noOfTransportersCreated= 0; ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION); diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index f07deafc98d..f489d12f91a 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -71,15 +71,14 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd) DBUG_RETURN(0); } -TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle, - void * callback, +TransporterRegistry::TransporterRegistry(void * callback, unsigned _maxTransporters, unsigned sizeOfLongSignalMemory) { nodeIdSpecified = false; maxTransporters = _maxTransporters; sendCounter = 1; - m_mgm_handle = mgm_handle; + m_mgm_handle= 0; callbackObj=callback; @@ -114,6 +113,27 @@ TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle, theOSEJunkSocketRecv = 0; } +void TransporterRegistry::set_mgm_handle(NdbMgmHandle h) +{ + DBUG_ENTER("TransporterRegistry::set_mgm_handle"); + if (m_mgm_handle) + ndb_mgm_destroy_handle(&m_mgm_handle); + m_mgm_handle= h; +#ifndef DBUG_OFF + if (h) + { + char buf[256]; + DBUG_PRINT("info",("handle set with connectstring: %s", + ndb_mgm_get_connectstring(h,buf, sizeof(buf)))); + } + else + { + DBUG_PRINT("info",("handle set to NULL")); + } +#endif + DBUG_VOID_RETURN; +}; + TransporterRegistry::~TransporterRegistry() { removeAll(); @@ -134,6 +154,8 @@ TransporterRegistry::~TransporterRegistry() { theOSEReceiver = 0; } #endif + if (m_mgm_handle) + ndb_mgm_destroy_handle(&m_mgm_handle); } void @@ -1211,40 +1233,32 @@ TransporterRegistry::start_clients_thread() switch(performStates[nodeId]){ case CONNECTING: if(!t->isConnected() && !t->isServer) { - int result= 0; + bool connected= false; /** * First, we try to connect (if we have a port number). */ if (t->get_s_port()) - result= t->connect_client(); + connected= t->connect_client(); - - if (result<0 && t->get_s_port()!=0) - g_eventLogger.warning("Error while trying to make connection " - "(Node %u to %u via port %u) " - "error: %d. Retrying...", - t->getRemoteNodeId(), - t->getLocalNodeId(), - t->get_s_port()); - /** * If dynamic, get the port for connecting from the management server */ - if(t->get_s_port() <= 0) { // Port is dynamic + if( !connected && t->get_s_port() <= 0) { // Port is dynamic int server_port= 0; struct ndb_mgm_reply mgm_reply; - int res; + int res= -1; if(!ndb_mgm_is_connected(m_mgm_handle)) if(ndb_mgm_connect(m_mgm_handle, 0, 0, 0)<0) ndbout_c("Failed to reconnect to management server"); - - res= ndb_mgm_get_connection_int_parameter(m_mgm_handle, - t->getRemoteNodeId(), - t->getLocalNodeId(), - CFG_CONNECTION_SERVER_PORT, - &server_port, - &mgm_reply); + else + res= + ndb_mgm_get_connection_int_parameter(m_mgm_handle, + t->getRemoteNodeId(), + t->getLocalNodeId(), + CFG_CONNECTION_SERVER_PORT, + &server_port, + &mgm_reply); DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)", server_port,t->getRemoteNodeId(), t->getLocalNodeId(),res)); |