diff options
author | unknown <joreland@mysql.com> | 2004-05-27 11:36:09 +0200 |
---|---|---|
committer | unknown <joreland@mysql.com> | 2004-05-27 11:36:09 +0200 |
commit | 0aee1b0ad6fc959fd10e7fdf96920328aaa5db91 (patch) | |
tree | 25a975842ec69bd8a85ea76406696c8aeb6e0d85 /ndb/src/ndbapi/ClusterMgr.cpp | |
parent | 489aa9be1ce31a0b7f4e8901faa818b21a8f7c7a (diff) | |
parent | d887ce18a45e2211dd9c81e04e0b40cf071da386 (diff) | |
download | mariadb-git-0aee1b0ad6fc959fd10e7fdf96920328aaa5db91.tar.gz |
Merge mysql.com:/home/jonas/src/mysql-4.1-ndb
into mysql.com:/home/jonas/src/mysql-4.1-ndb-jonas
ndb/src/kernel/blocks/dblqh/Dblqh.hpp:
Auto merged
ndb/Epilogue.mk_old:
Auto merged
ndb/src/common/debugger/signaldata/Makefile_old:
Auto merged
ndb/src/common/mgmcommon/Makefile_old:
Auto merged
ndb/src/common/util/Makefile_old:
Auto merged
ndb/src/kernel/Makefile_old:
Auto merged
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
Auto merged
ndb/src/kernel/ndb-main/Main.cpp:
Auto merged
ndb/src/kernel/ndb-main/Makefile_old:
Auto merged
ndb/src/kernel/vm/Makefile_old:
Auto merged
ndb/src/mgmapi/Makefile_old:
Auto merged
ndb/src/mgmclient/Makefile_old:
Auto merged
ndb/src/mgmsrv/Makefile_old:
Auto merged
ndb/src/mgmsrv/MgmtSrvr.cpp:
Auto merged
ndb/src/ndbapi/ClusterMgr.cpp:
Auto merged
ndb/src/ndbapi/Makefile_old:
Auto merged
ndb/src/ndbapi/Ndb.cpp:
Auto merged
ndb/src/ndbapi/Ndbif.cpp:
Auto merged
ndb/src/ndbapi/Ndbinit.cpp:
Auto merged
ndb/src/ndbapi/TransporterFacade.cpp:
Auto merged
ndb/src/ndbapi/TransporterFacade.hpp:
Auto merged
ndb/test/ndbapi/testDict.cpp:
Auto merged
ndb/test/ndbapi/testSystemRestart.cpp:
Auto merged
ndb/test/ndbapi/testTimeout.cpp:
Auto merged
ndb/test/src/Makefile_old:
Auto merged
Diffstat (limited to 'ndb/src/ndbapi/ClusterMgr.cpp')
-rw-r--r-- | ndb/src/ndbapi/ClusterMgr.cpp | 123 |
1 files changed, 73 insertions, 50 deletions
diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp index 57967e5534f..b26d550fe31 100644 --- a/ndb/src/ndbapi/ClusterMgr.cpp +++ b/ndb/src/ndbapi/ClusterMgr.cpp @@ -32,6 +32,10 @@ #include <signaldata/NFCompleteRep.hpp> #include <signaldata/ApiRegSignalData.hpp> +#include <mgmapi.h> +#include <mgmapi_configuration.hpp> +#include <mgmapi_config_parameters.h> + // Just a C wrapper for threadMain extern "C" void* @@ -69,32 +73,49 @@ ClusterMgr::~ClusterMgr(){ } void -ClusterMgr::init(const IPCConfig & config){ - NodeId tmp = 0; - while(config.getNextRemoteNodeId(tmp)) { +ClusterMgr::init(ndb_mgm_configuration_iterator & iter){ + for(iter.first(); iter.valid(); iter.next()){ + Uint32 tmp = 0; + if(iter.get(CFG_NODE_ID, &tmp)) + continue; + theNodes[tmp].defined = true; #if 0 ndbout << "--------------------------------------" << endl; - config.print(); ndbout << "--------------------------------------" << endl; ndbout_c("ClusterMgr: Node %d defined as %s", tmp, config.getNodeType(tmp)); #endif - if(strcmp(config.getNodeType(tmp), "DB") == 0) { + + unsigned type; + if(iter.get(CFG_TYPE_OF_SECTION, &type)) + continue; + + switch(type){ + case NODE_TYPE_DB: theNodes[tmp].m_info.m_type = NodeInfo::DB; - } else if(strcmp(config.getNodeType(tmp), "API") == 0) { + break; + case NODE_TYPE_API: theNodes[tmp].m_info.m_type = NodeInfo::API; - } else if(strcmp(config.getNodeType(tmp), "MGM") == 0) { + break; + case NODE_TYPE_MGM: theNodes[tmp].m_info.m_type = NodeInfo::MGM; - } else if(strcmp(config.getNodeType(tmp), "REP") == 0) { + break; + case NODE_TYPE_REP: theNodes[tmp].m_info.m_type = NodeInfo::REP; - } else if(strcmp(config.getNodeType(tmp), "EXTERNAL REP") == 0) { + break; + case NODE_TYPE_EXT_REP: theNodes[tmp].m_info.m_type = NodeInfo::REP; - theNodes[tmp].hbFrequency = config.getREPHBFrequency(tmp); - assert(100 <= theNodes[tmp].hbFrequency && - theNodes[tmp].hbFrequency < 60 * 60 * 1000); - } else { + { + Uint32 hbFreq = 10000; + //ndb_mgm_get_int_parameter(iter, CFG_, &hbFreq); + theNodes[tmp].hbFrequency = hbFreq; + assert(100 <= hbFreq && hbFreq < 60 * 60 * 1000); + } + break; + default: + type = type; #if 0 - ndbout_c("ClusterMgr: Unknown node type: %s", config.getNodeType(tmp)); + ndbout_c("ClusterMgr: Unknown node type: %d", type); #endif } } @@ -162,45 +183,43 @@ ClusterMgr::threadMain( ){ const NodeId nodeId = i; Node & theNode = theNodes[nodeId]; - if (theNode.defined == true) { -#if 0 - ndbout_c("ClusterMgr: compatible %d", (int)nodeId); -#endif + if (!theNode.defined) + continue; - if (theNode.connected == false){ - theFacade.doConnect(nodeId); - continue; + if (theNode.connected == false){ + theFacade.doConnect(nodeId); + continue; + } + + if (!theNode.compatible){ + continue; + } + + theNode.hbCounter += timeSlept; + if (theNode.hbCounter >= theNode.hbFrequency){ + /** + * It is now time to send a new Heartbeat + */ + theNode.hbSent++; + theNode.hbCounter = 0; + /** + * If the node is of type REP, + * then the receiver of the signal should be API_CLUSTERMGR + */ + if (theNode.m_info.m_type == NodeInfo::REP) { + signal.theReceiversBlockNumber = API_CLUSTERMGR; } - -#if 0 - ndbout_c("ClusterMgr: connected %d", (int)nodeId); +#if 0 + ndbout_c("ClusterMgr: Sending API_REGREQ to node %d", (int)nodeId); #endif - - theNode.hbCounter += timeSlept; - if (theNode.hbCounter >= theNode.hbFrequency){ - /** - * It is now time to send a new Heartbeat - */ - theNode.hbSent++; - theNode.hbCounter = 0; - /** - * If the node is of type REP, - * then the receiver of the signal should be API_CLUSTERMGR - */ - if (theNode.m_info.m_type == NodeInfo::REP) { - signal.theReceiversBlockNumber = API_CLUSTERMGR; - } -#if 0 - ndbout_c("ClusterMgr: Sending API_REGREQ to node %d", (int)nodeId); -#endif - theFacade.sendSignalUnCond(&signal, nodeId); - }//if - - if (theNode.hbSent == 4 && theNode.hbFrequency > 0){ - reportNodeFailed(i); - }//if - }//if(defined) - }//for + theFacade.sendSignalUnCond(&signal, nodeId); + }//if + + if (theNode.hbSent == 4 && theNode.hbFrequency > 0){ + reportNodeFailed(i); + }//if + } + /** * End of secure area. Let other threads in */ @@ -281,6 +300,10 @@ ClusterMgr::execAPI_REGCONF(const Uint32 * theData){ const ApiRegConf * const apiRegConf = (ApiRegConf *)&theData[0]; const NodeId nodeId = refToNode(apiRegConf->qmgrRef); +#if 0 + ndbout_c("ClusterMgr: Recd API_REGCONF from node %d", nodeId); +#endif + assert(nodeId > 0 && nodeId < MAX_NODES); Node & node = theNodes[nodeId]; |