From: Jonas Oreland Date: January 10 2011 1:55pm Subject: bzr push into mysql-5.1-telco-7.0 branch (jonas:4100 to 4101) List-Archive: http://lists.mysql.com/commits/128305 Message-Id: <20110110135537.970D534159D@perch.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4101 Jonas Oreland 2011-01-10 ndb - This patch removes all usage of ClusterMgr/TransporterFacade::lock_mutex() from outside of TransporterFacade. Various misc methods used by e.g ndb_mgmd has been added to TransporterFacade with prefix ext_ e.g ext_update_connections modified: storage/ndb/src/mgmsrv/MgmtSrvr.cpp storage/ndb/src/ndbapi/ClusterMgr.cpp storage/ndb/src/ndbapi/ClusterMgr.hpp storage/ndb/src/ndbapi/SignalSender.cpp storage/ndb/src/ndbapi/SignalSender.hpp storage/ndb/src/ndbapi/TransporterFacade.cpp storage/ndb/src/ndbapi/TransporterFacade.hpp 4100 Jonas Oreland 2011-01-10 ndb - remore trp_client::trp_node_status modified: storage/ndb/include/kernel/signaldata/NodeFailRep.hpp storage/ndb/include/ndbapi/Ndb.hpp storage/ndb/src/mgmsrv/ConfigManager.cpp storage/ndb/src/mgmsrv/MgmtSrvr.cpp storage/ndb/src/ndbapi/ClusterMgr.cpp storage/ndb/src/ndbapi/ClusterMgr.hpp storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp storage/ndb/src/ndbapi/NdbImpl.hpp storage/ndb/src/ndbapi/NdbInfoScanOperation.cpp storage/ndb/src/ndbapi/Ndbif.cpp storage/ndb/src/ndbapi/SignalSender.cpp storage/ndb/src/ndbapi/SignalSender.hpp storage/ndb/src/ndbapi/TransporterFacade.cpp storage/ndb/src/ndbapi/TransporterFacade.hpp storage/ndb/src/ndbapi/trp_client.cpp storage/ndb/src/ndbapi/trp_client.hpp === modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp' --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2011-01-10 13:30:14 +0000 @@ -437,7 +437,7 @@ MgmtSrvr::start_transporter(const Config /** * Wait for loopback interface to be enabled */ - while (!theFacade->isConnected(_ownNodeId)) + while (!theFacade->ext_isConnected(_ownNodeId)) { NdbSleep_MilliSleep(20); } @@ -452,7 +452,7 @@ MgmtSrvr::start_transporter(const Config is not dependent on heartbeat settings in the configuration */ - theFacade->theClusterMgr->set_max_api_reg_req_interval(100); + theFacade->ext_set_max_api_reg_req_interval(100); DBUG_RETURN(true); } @@ -803,10 +803,10 @@ int MgmtSrvr::okToSendTo(NodeId nodeId, return WRONG_PROCESS_TYPE; // Check if we have contact with it if(unCond){ - if(theFacade->theClusterMgr->getNodeInfo(nodeId).is_confirmed()) + if (getNodeInfo(nodeId).is_confirmed()) return 0; } - else if (theFacade->get_node_alive(nodeId) == true) + else if (getNodeInfo(nodeId).m_alive == true) return 0; return NO_CONTACT_WITH_PROCESS; } @@ -882,7 +882,7 @@ MgmtSrvr::versionNode(int nodeId, Uint32 } else if (getNodeType(nodeId) == NDB_MGM_NODE_TYPE_NDB) { - trp_node node = theFacade->theClusterMgr->getNodeInfo(nodeId); + trp_node node = getNodeInfo(nodeId); if(node.is_connected()) { version= node.m_info.m_version; @@ -1425,7 +1425,7 @@ bool MgmtSrvr::is_any_node_stopping() trp_node node; while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) { - node = theFacade->theClusterMgr->getNodeInfo(nodeId); + node = getNodeInfo(nodeId); if((node.m_state.startLevel == NodeState::SL_STOPPING_1) || (node.m_state.startLevel == NodeState::SL_STOPPING_2) || (node.m_state.startLevel == NodeState::SL_STOPPING_3) || @@ -1441,7 +1441,7 @@ bool MgmtSrvr::is_any_node_starting() trp_node node; while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) { - node = theFacade->theClusterMgr->getNodeInfo(nodeId); + node = getNodeInfo(nodeId); if((node.m_state.startLevel == NodeState::SL_STARTING)) return true; // At least one node was starting } @@ -1454,7 +1454,7 @@ bool MgmtSrvr::is_cluster_single_user() trp_node node; while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) { - node = theFacade->theClusterMgr->getNodeInfo(nodeId); + node = getNodeInfo(nodeId); if((node.m_state.startLevel == NodeState::SL_SINGLEUSER)) return true; // Cluster is in single user modes } @@ -1673,12 +1673,10 @@ MgmtSrvr::exitSingleUser(int * stopCount * Status ****************************************************************************/ -#include - void MgmtSrvr::updateStatus() { - theFacade->theClusterMgr->forceHB(); + theFacade->ext_forceHB(); } int @@ -1700,8 +1698,7 @@ MgmtSrvr::status(int nodeId, *address= get_connect_address(nodeId); } - const trp_node node = - theFacade->theClusterMgr->getNodeInfo(nodeId); + const trp_node node = getNodeInfo(nodeId); if(!node.is_connected()){ * _status = NDB_MGM_NODE_STATUS_NO_CONTACT; @@ -1807,7 +1804,7 @@ MgmtSrvr::setEventReportingLevelImpl(int continue; if (okToSendTo(nodeId, true)) { - if (theFacade->theClusterMgr->getNodeInfo(nodeId).is_connected() == false) + if (getNodeInfo(nodeId).is_connected() == false) { // node not connected we can safely skip this one continue; @@ -1834,7 +1831,7 @@ MgmtSrvr::setEventReportingLevelImpl(int { if (nodeTypes[nodeId] != NODE_TYPE_DB) continue; - if (theFacade->theClusterMgr->getNodeInfo(nodeId).is_connected() == false) + if (getNodeInfo(nodeId).is_connected() == false) continue; // node is not connected, skip if (ss.sendSignal(nodeId, &ssig) == SEND_OK) nodes.set(nodeId); @@ -2577,16 +2574,13 @@ MgmtSrvr::getNodeType(NodeId nodeId) con const char *MgmtSrvr::get_connect_address(Uint32 node_id) { if (m_connect_address[node_id].s_addr == 0 && - theFacade && theFacade->theTransporterRegistry && - theFacade->theClusterMgr && + theFacade && getNodeType(node_id) == NDB_MGM_NODE_TYPE_NDB) { - const trp_node &node= - theFacade->theClusterMgr->getNodeInfo(node_id); + const trp_node &node= getNodeInfo(node_id); if (node.is_connected()) { - m_connect_address[node_id]= - theFacade->theTransporterRegistry->get_connect_address(node_id); + m_connect_address[node_id] = theFacade->ext_get_connect_address(node_id); } } return inet_ntoa(m_connect_address[node_id]); @@ -2595,13 +2589,13 @@ const char *MgmtSrvr::get_connect_addres void MgmtSrvr::get_connected_nodes(NodeBitmask &connected_nodes) const { - if (theFacade && theFacade->theClusterMgr) + if (theFacade) { for(Uint32 i = 0; i < MAX_NDB_NODES; i++) { if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB) { - const trp_node &node= theFacade->theClusterMgr->getNodeInfo(i); + const trp_node &node= getNodeInfo(i); connected_nodes.bitOR(node.m_state.m_connected_nodes); } } @@ -2635,7 +2629,7 @@ MgmtSrvr::alloc_node_id_req(NodeId free_ { bool next; while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true && - theFacade->get_node_alive(nodeId) == false); + getNodeInfo(nodeId).m_alive == false); if (!next) return NO_CONTACT_WITH_DB_NODES; do_send = 1; @@ -2670,7 +2664,7 @@ MgmtSrvr::alloc_node_id_req(NodeId free_ { do_send = 1; nodeId = refToNode(ref->masterRef); - if (!theFacade->get_node_alive(nodeId)) + if (!getNodeInfo(nodeId).m_alive) nodeId = 0; if (ref->errorCode != AllocNodeIdRef::NotMaster) { @@ -2911,9 +2905,7 @@ MgmtSrvr::try_alloc(unsigned id, const c /** * Make sure we're ready to accept connections from this node */ - theFacade->lock_mutex(); - theFacade->doConnect(id); - theFacade->unlock_mutex(); + theFacade->ext_doConnect(id); } g_eventLogger->info("Mgmt server state: nodeid %d reserved for ip %s, " @@ -3231,7 +3223,7 @@ MgmtSrvr::startBackup(Uint32& backupId, ndbout_c("I'm not master resending to %d", nodeId); #endif do_send = 1; // try again - if (!theFacade->get_node_alive(nodeId)) + if (!getNodeInfo(nodeId).m_alive) m_master_node = nodeId = 0; continue; } @@ -3288,7 +3280,7 @@ MgmtSrvr::abortBackup(Uint32 backupId) bool next; NodeId nodeId = 0; while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true && - theFacade->get_node_alive(nodeId) == false); + getNodeInfo(nodeId).m_alive == false); if(!next){ return NO_CONTACT_WITH_DB_NODES; @@ -3544,9 +3536,7 @@ bool MgmtSrvr::transporter_connect(NDB_S with the new connection. Important for correct node id reservation handling */ - theFacade->lock_mutex(); - tr->update_connections(); - theFacade->unlock_mutex(); + theFacade->ext_update_connections(); DBUG_RETURN(true); } === modified file 'storage/ndb/src/ndbapi/ClusterMgr.cpp' --- a/storage/ndb/src/ndbapi/ClusterMgr.cpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp 2011-01-10 13:30:14 +0000 @@ -289,6 +289,14 @@ ClusterMgr::forceHB() } void +ClusterMgr::force_update_connections() +{ + theFacade.lock_mutex(); + theFacade.theTransporterRegistry->update_connections(); + theFacade.unlock_mutex(); +} + +void ClusterMgr::threadMain( ){ NdbApiSignal signal(numberToRef(API_CLUSTERMGR, theFacade.ownId())); === modified file 'storage/ndb/src/ndbapi/ClusterMgr.hpp' --- a/storage/ndb/src/ndbapi/ClusterMgr.hpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp 2011-01-10 13:30:14 +0000 @@ -56,6 +56,7 @@ public: void set_max_api_reg_req_interval(unsigned int millisec) { m_max_api_reg_req_interval = millisec; } + void force_update_connections(); private: void threadMain(); === modified file 'storage/ndb/src/ndbapi/SignalSender.cpp' --- a/storage/ndb/src/ndbapi/SignalSender.cpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/SignalSender.cpp 2011-01-10 13:30:14 +0000 @@ -161,12 +161,6 @@ SignalSender::getOwnRef() const { return numberToRef(m_blockNo, theFacade->ownId()); } -Uint32 -SignalSender::getNoOfConnectedNodes() const { - return theFacade->theClusterMgr->getNoOfConnectedNodes(); -} - - NodeBitmask SignalSender::broadcastSignal(NodeBitmask mask, SimpleSignal& sig, === modified file 'storage/ndb/src/ndbapi/SignalSender.hpp' --- a/storage/ndb/src/ndbapi/SignalSender.hpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/SignalSender.hpp 2011-01-10 13:30:14 +0000 @@ -78,7 +78,6 @@ public: int unlock(); Uint32 getOwnRef() const; - Uint32 getNoOfConnectedNodes() const; NodeId find_confirmed_node(const NodeBitmask& mask); NodeId find_connected_node(const NodeBitmask& mask); === modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp' --- a/storage/ndb/src/ndbapi/TransporterFacade.cpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp 2011-01-10 13:30:14 +0000 @@ -1404,7 +1404,6 @@ TransporterFacade::sendSignal(const NdbA /****************************************************************************** * CONNECTION METHODS Etc ******************************************************************************/ - void TransporterFacade::doConnect(int aNodeId){ theTransporterRegistry->setIOState(aNodeId, NoHalt); @@ -1969,3 +1968,42 @@ TransporterFacade::get_auto_reconnect() { return theClusterMgr->m_auto_reconnect; } + +void +TransporterFacade::ext_set_max_api_reg_req_interval(Uint32 interval) +{ + theClusterMgr->set_max_api_reg_req_interval(interval); +} + +void +TransporterFacade::ext_update_connections() +{ + theClusterMgr->force_update_connections(); +} + +struct in_addr +TransporterFacade::ext_get_connect_address(Uint32 nodeId) +{ + return theTransporterRegistry->get_connect_address(nodeId); +} + +void +TransporterFacade::ext_forceHB() +{ + theClusterMgr->forceHB(); +} + +bool +TransporterFacade::ext_isConnected(NodeId aNodeId) +{ + return theTransporterRegistry->is_connected(aNodeId); +} + +void +TransporterFacade::ext_doConnect(int aNodeId) +{ + lock_mutex(); + doConnect(aNodeId); + unlock_mutex(); +} + === modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp' --- a/storage/ndb/src/ndbapi/TransporterFacade.hpp 2011-01-10 11:22:17 +0000 +++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp 2011-01-10 13:30:14 +0000 @@ -85,6 +85,16 @@ private: const GenericSectionPtr ptr[3], Uint32 secs); public: + /** + * These are functions used by ndb_mgmd + */ + void ext_set_max_api_reg_req_interval(Uint32 ms); + void ext_update_connections(); + struct in_addr ext_get_connect_address(Uint32 nodeId); + void ext_forceHB(); + bool ext_isConnected(NodeId aNodeId); + void ext_doConnect(int aNodeId); + // Is node available for running transactions private: bool get_node_alive(NodeId nodeId) const; @@ -193,11 +203,8 @@ private: friend class trp_client; friend class ClusterMgr; friend class ArbitMgr; - friend class MgmtSrvr; - friend class SignalSender; friend class Ndb_cluster_connection; friend class Ndb_cluster_connection_impl; - friend class NdbImpl; bool isConnected(NodeId aNodeId); void doStop(); No bundle (reason: useless for push emails).