clusterconfiguration.cpp

来自「MySQL数据库开发源码 值得一看哦」· C++ 代码 · 共 485 行 · 第 1/2 页

CPP
485
字号
     */    size->blockNo[TUP] = DBTUP;        VarSize * const tup = &(size->varSize[TUP][0]);    setValue(tup, TupSizeAltReq::IND_DISK_PAGE_ARRAY, 	     2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);        setValue(tup, TupSizeAltReq::IND_DISK_PAGE_REPRESENT,              size->noOfDiskClusters);        setValue(tup, TupSizeAltReq::IND_FRAG,          2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);        setValue(tup, TupSizeAltReq::IND_PAGE_CLUSTER,              size->noOfFreeClusters);        setValue(tup, TupSizeAltReq::IND_LOGIC_PAGE,              size->noOfDiskBufferPages + size->noOfDiskClusters);        setValue(tup, TupSizeAltReq::IND_OP_RECS,              size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50));        setValue(tup, TupSizeAltReq::IND_PAGE,              size->noOfDataPages);        setValue(tup, TupSizeAltReq::IND_PAGE_RANGE, 	     4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);        setValue(tup, TupSizeAltReq::IND_TABLE,              size->noOfTables);        setValue(tup, TupSizeAltReq::IND_TABLE_DESC, 	     4 * NO_OF_FRAG_PER_NODE * size->noOfAttributes* size->noOfReplicas +	     12 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas );        setValue(tup, TupSizeAltReq::IND_DELETED_BLOCKS,              size->noOfFreeClusters);    setValue(tup, TupSizeAltReq::IND_STORED_PROC,             noOfLocalScanRecords);  }  {    /**     * Tux Size Alt values     */    size->blockNo[TUX] = DBTUX;        VarSize * const tux = &(size->varSize[TUX][0]);        setValue(tux, TuxSizeAltReq::IND_INDEX,              size->noOfTables);        setValue(tux, TuxSizeAltReq::IND_FRAGMENT,          2 * NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfReplicas);        setValue(tux, TuxSizeAltReq::IND_ATTRIBUTE,              size->noOfIndexes * 4);        setValue(tux, TuxSizeAltReq::IND_SCAN, 	     noOfLocalScanRecords);  }}  const ClusterConfiguration::ClusterData&ClusterConfiguration::clusterData() const{  return the_clusterData;}void ClusterConfiguration::init(const Properties & p, const Properties & db){  const char * msg = "Invalid configuration fetched";  ClusterData & cd = the_clusterData;    struct AttribStorage { const char * attrib; Uint32 * storage; };  AttribStorage tmp[] = {    {"MaxNoOfConcurrentScans", &cd.SizeAltData.noOfScanRecords },    {"MaxNoOfTables", &cd.SizeAltData.noOfTables },    {"MaxNoOfIndexes", &cd.SizeAltData.noOfIndexes },    {"NoOfReplicas", &cd.SizeAltData.noOfReplicas },    {"MaxNoOfAttributes", &cd.SizeAltData.noOfAttributes },    {"MaxNoOfConcurrentOperations", &cd.SizeAltData.noOfOperations },    {"MaxNoOfConcurrentTransactions", &cd.SizeAltData.noOfTransactions },    {"NoOfIndexPages", &cd.SizeAltData.noOfIndexPages },    {"NoOfDataPages",  &cd.SizeAltData.noOfDataPages },    {"NoOfDiskBufferPages", &cd.SizeAltData.noOfDiskBufferPages },    {"NoOfDiskClusters", &cd.SizeAltData.noOfDiskClusters },    {"NoOfFreeDiskClusters", &cd.SizeAltData.noOfFreeClusters },    {"TimeToWaitAlive", &cd.ispValues[0][0] },    {"HeartbeatIntervalDbDb", &cd.ispValues[0][2] },    {"HeartbeatIntervalDbApi", &cd.ispValues[0][3] },    {"ArbitrationTimeout", &cd.ispValues[0][5] },    {"TimeBetweenLocalCheckpoints", &cd.ispValues[1][2] },    {"NoOfFragmentLogFiles", &cd.ispValues[1][4] },    {"MaxNoOfConcurrentScans", &cd.SizeAltData.noOfScanRecords },    {"NoOfConcurrentCheckpointsDuringRestart", &cd.ispValues[1][5] },    {"TransactionDeadlockDetectionTimeout", &cd.ispValues[1][6] },    {"NoOfConcurrentProcessesHandleTakeover", &cd.ispValues[1][7] },    {"TimeBetweenGlobalCheckpoints", &cd.ispValues[2][3] },    {"NoOfConcurrentCheckpointsAfterRestart", &cd.ispValues[2][4] },    {"TransactionInactiveTimeout", &cd.ispValues[2][7] },    {"NoOfDiskPagesToDiskDuringRestartTUP", &cd.ispValues[3][8] },    {"NoOfDiskPagesToDiskAfterRestartTUP", &cd.ispValues[3][9] },    {"NoOfDiskPagesToDiskDuringRestartACC", &cd.ispValues[3][10] },    {"NoOfDiskPagesToDiskAfterRestartACC", &cd.ispValues[3][11] },    {"NoOfDiskClustersPerDiskFile", &cd.ispValues[4][8] },    {"NoOfDiskFiles", &cd.ispValues[4][9] },    {"NoOfReplicas", &cd.ispValues[2][2] }  };  const int sz = sizeof(tmp)/sizeof(AttribStorage);  for(int i = 0; i<sz; i++){    if(!db.get(tmp[i].attrib, tmp[i].storage)){      char buf[255];      BaseString::snprintf(buf, sizeof(buf), "%s not found", tmp[i].attrib);      ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);    }  }  if(!p.get("NoOfNodes", &cd.SizeAltData.noOfNodes)){    ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, "NoOfNodes missing");  }    Properties::Iterator it(&p);  const char * name = 0;  Uint32 nodeNo = 0;  for(name = it.first(); name != NULL; name = it.next()){    if(strncmp(name, "Node_", strlen("Node_")) == 0){      Uint32 nodeId;      const char * nodeType;      const Properties * node;            if(!p.get(name, &node)){	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, "Node data missing");      }            if(!node->get("Id", &nodeId)){	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, "Node data (Id) missing");      }            if(!node->get("Type", &nodeType)){	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, "Node data (Type) missing");      }            if(nodeId > MAX_NODES){	char buf[255];	snprintf(buf, sizeof(buf),		 "Maximum DB node id allowed is: %d", MAX_NDB_NODES);	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);      }            if(nodeId == 0){	char buf[255];	snprintf(buf, sizeof(buf),		 "Minimum node id allowed in the cluster is: 1");	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);      }      for(unsigned j = 0; j<nodeNo; j++){	if(cd.nodeData[j].nodeId == nodeId){	  char buf[255];	  BaseString::snprintf(buf, sizeof(buf), "Two node can not have the same node id");	  ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);	}      }            {	for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){	  Uint32 logLevel;	  if(db.get(LogLevel::LOGLEVEL_CATEGORY_NAME[j].name, &logLevel)){	    cd.SizeAltData.logLevel.setLogLevel((LogLevel::EventCategory)j, 						logLevel);	  }	}      }            cd.nodeData[nodeNo].nodeId = nodeId;      const char* tmpApiMgmProperties = 0;      if(strcmp("DB", nodeType) == 0){	cd.nodeData[nodeNo].nodeType = NodeInfo::DB;	cd.SizeAltData.noOfNDBNodes++; // No of NDB processes		if(nodeId > MAX_NDB_NODES){	  char buf[255];	  BaseString::snprintf(buf, sizeof(buf), "Maximum node id for a ndb node is: %d", MAX_NDB_NODES);	  ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);	}	if(cd.SizeAltData.noOfNDBNodes > MAX_NDB_NODES){	  char buf[255];	  BaseString::snprintf(buf, sizeof(buf),		   "Maximum %d ndb nodes is allowed in the cluster", 		  MAX_NDB_NODES);	  ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);	}      } else if(strcmp("API", nodeType) == 0){	cd.nodeData[nodeNo].nodeType = NodeInfo::API;	cd.SizeAltData.noOfAPINodes++; // No of API processes	tmpApiMgmProperties = "API";      } else if(strcmp("REP", nodeType) == 0){	cd.nodeData[nodeNo].nodeType = NodeInfo::REP;	//cd.SizeAltData.noOfAPINodes++; // No of API processes	tmpApiMgmProperties = "REP";      } else if(strcmp("MGM", nodeType) == 0){	cd.nodeData[nodeNo].nodeType = NodeInfo::MGM;	cd.SizeAltData.noOfMGMNodes++; // No of MGM processes	tmpApiMgmProperties = "MGM";      } else {	ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, 		  "Invalid configuration: Unknown node type",		  nodeType);      }            if (tmpApiMgmProperties) {	/*	  const Properties* q = 0;	  	  if (!p.get(tmpApiMgmProperties, nodeId, &q)) {	  ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, tmpApiMgmProperties);	  } else {	*/        Uint32 rank = 0;        if (node->get("ArbitrationRank", &rank) && rank > 0) {          cd.nodeData[nodeNo].arbitRank = rank;	  //        }	}      } else {	cd.nodeData[nodeNo].arbitRank = 0;      }            nodeNo++;    }  }   cd.SizeAltData.exist = true;  calcSizeAlteration();  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?