summaryrefslogtreecommitdiff
path: root/ndb/src/ndbapi/ClusterMgr.cpp
diff options
context:
space:
mode:
authorunknown <joreland@mysql.com>2004-05-26 10:56:32 +0200
committerunknown <joreland@mysql.com>2004-05-26 10:56:32 +0200
commit1a9eb476f185d94ec13ed4f13dbfbdb14f9217c1 (patch)
tree32b839686028c5bc61304dbd566705a3bc085f6d /ndb/src/ndbapi/ClusterMgr.cpp
parent3cfddc421d53e28f398a2db98002cab2be15fc9e (diff)
downloadmariadb-git-1a9eb476f185d94ec13ed4f13dbfbdb14f9217c1.tar.gz
WL1371 - Cleanup configuration handling
WL1356 - Discless db node WL1357 - sp 1-2
Diffstat (limited to 'ndb/src/ndbapi/ClusterMgr.cpp')
-rw-r--r--ndb/src/ndbapi/ClusterMgr.cpp123
1 files changed, 73 insertions, 50 deletions
diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp
index 1b536b6d741..bb2f1bf1182 100644
--- a/ndb/src/ndbapi/ClusterMgr.cpp
+++ b/ndb/src/ndbapi/ClusterMgr.cpp
@@ -33,6 +33,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*
@@ -70,32 +74,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
}
}
@@ -163,45 +184,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
*/
@@ -282,6 +301,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];