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 | |
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')
-rw-r--r-- | ndb/src/common/mgmcommon/IPCConfig.cpp | 29 | ||||
-rw-r--r-- | ndb/src/common/transporter/TransporterRegistry.cpp | 60 | ||||
-rw-r--r-- | ndb/src/kernel/main.cpp | 4 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.cpp | 2 | ||||
-rw-r--r-- | ndb/src/ndbapi/Ndb.cpp | 4 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbTransaction.cpp | 8 | ||||
-rw-r--r-- | ndb/src/ndbapi/TransporterFacade.cpp | 5 | ||||
-rw-r--r-- | ndb/src/ndbapi/TransporterFacade.hpp | 3 | ||||
-rw-r--r-- | ndb/src/ndbapi/ndb_cluster_connection.cpp | 2 |
9 files changed, 80 insertions, 37 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)); diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index b511f003429..4bc99c61f69 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -92,10 +92,6 @@ int main(int argc, char** argv) } } - globalTransporterRegistry.set_mgm_handle(theConfig - ->get_config_retriever() - ->get_mgmHandle()); - #ifndef NDB_WIN32 for(pid_t child = fork(); child != 0; child = fork()){ /** diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index c584356927b..cf98f3a09ae 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -576,7 +576,7 @@ MgmtSrvr::start(BaseString &error_string) } } theFacade= TransporterFacade::theFacadeInstance - = new TransporterFacade(m_config_retriever->get_mgmHandle()); + = new TransporterFacade(); if(theFacade == 0) { DEBUG("MgmtSrvr.cpp: theFacade is NULL."); diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 59d1e45ca46..b047ae1bd1a 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -84,7 +84,9 @@ NdbTransaction* Ndb::doConnect(Uint32 tConNode) } else if (TretCode != 0) { tAnyAlive= 1; }//if - DBUG_PRINT("info",("tried node %d TretCode %d", tNode, TretCode)); + DBUG_PRINT("info",("tried node %d, TretCode %d, error code %d, %s", + tNode, TretCode, getNdbError().code, + getNdbError().message)); } } else // just do a regular round robin diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index ab6c0ca3e38..67581e4a0f8 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -1420,14 +1420,18 @@ Remark: Sets TC Connect pointer. int NdbTransaction::receiveTCSEIZEREF(NdbApiSignal* aSignal) { + DBUG_ENTER("NdbTransaction::receiveTCSEIZEREF"); if (theStatus != Connecting) { - return -1; + DBUG_RETURN(-1); } else { theStatus = ConnectFailure; theNdb->theError.code = aSignal->readData(2); - return 0; + DBUG_PRINT("info",("error code %d, %s", + theNdb->getNdbError().code, + theNdb->getNdbError().message)); + DBUG_RETURN(0); } }//NdbTransaction::receiveTCSEIZEREF() diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 5b5394f0965..7f1e68a42d3 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -466,8 +466,7 @@ void TransporterFacade::threadMainReceive(void) theTransporterRegistry->stopReceiving(); } -TransporterFacade::TransporterFacade(NdbMgmHandle mgm_handle) : - m_mgm_handle(mgm_handle), +TransporterFacade::TransporterFacade() : theTransporterRegistry(0), theStopReceive(0), theSendThread(NULL), @@ -496,7 +495,7 @@ bool TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props) { theOwnId = nodeId; - theTransporterRegistry = new TransporterRegistry(m_mgm_handle,this); + theTransporterRegistry = new TransporterRegistry(this); const int res = IPCConfig::configureTransporters(nodeId, * props, diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index bd3fc67a8d6..e74f4b51e00 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -47,7 +47,7 @@ extern "C" { class TransporterFacade { public: - TransporterFacade(NdbMgmHandle mgm_handle); + TransporterFacade(); virtual ~TransporterFacade(); bool init(Uint32, const ndb_mgm_configuration *); @@ -133,7 +133,6 @@ private: bool isConnected(NodeId aNodeId); void doStop(); - NdbMgmHandle m_mgm_handle; TransporterRegistry* theTransporterRegistry; SocketServer m_socket_server; int sendPerformedLastInterval; diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 4a33be7c597..e6f5d464d80 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -284,7 +284,7 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * m_transporter_facade= TransporterFacade::theFacadeInstance= - new TransporterFacade(m_config_retriever->get_mgmHandle()); + new TransporterFacade(); DBUG_VOID_RETURN; } |