19 #include <ndb_global.h>
21 #include "ClusterConfiguration.hpp"
22 #include <ErrorHandlingMacros.hpp>
25 #include <BlockNumbers.h>
26 #include <signaldata/AccSizeAltReq.hpp>
27 #include <signaldata/DictSizeAltReq.hpp>
28 #include <signaldata/DihSizeAltReq.hpp>
29 #include <signaldata/LqhSizeAltReq.hpp>
30 #include <signaldata/TcSizeAltReq.hpp>
31 #include <signaldata/TupSizeAltReq.hpp>
32 #include <signaldata/TuxSizeAltReq.hpp>
34 ClusterConfiguration::ClusterConfiguration()
36 for (
unsigned i= 0;
i< MAX_SIZEALT_BLOCKS;
i++)
37 for (
unsigned j= 0; j< MAX_SIZEALT_RECORD; j++) {
38 the_clusterData.SizeAltData.varSize[
i][j].valid =
false;
39 the_clusterData.SizeAltData.varSize[
i][j].nrr = 0;
42 for (
unsigned i1 = 0; i1< 5; i1++)
43 for (
unsigned j1= 0; j1< CmvmiCfgConf::NO_OF_WORDS; j1++)
44 the_clusterData.ispValues[i1][j1] = 0;
46 the_clusterData.SizeAltData.noOfNodes = 0;
47 the_clusterData.SizeAltData.noOfNDBNodes = 0;
48 the_clusterData.SizeAltData.noOfAPINodes = 0;
49 the_clusterData.SizeAltData.noOfMGMNodes = 0;
52 ClusterConfiguration::~ClusterConfiguration(){
56 setValue(
VarSize* dst,
const int index, UintR variableValue){
58 assert(index >= 0 && index < MAX_SIZEALT_RECORD);
60 dst[
index].nrr = variableValue;
61 dst[
index].valid =
true;
65 ClusterConfiguration::calcSizeAlteration()
70 size->noOfTables += size->noOfIndexes;
71 size->noOfAttributes += 2;
73 size->noOfTables *= 2;
75 Uint32 noOfDBNodes = size->noOfNDBNodes;
76 if (noOfDBNodes > 15) {
79 Uint32 noOfLocalScanRecords = (noOfDBNodes * size->noOfScanRecords) + 1;
80 Uint32 noOfTCScanRecords = size->noOfScanRecords;
85 size->blockNo[ACC] = DBACC;
87 VarSize *
const acc = &(size->varSize[ACC][0]);
90 setValue(acc, AccSizeAltReq::IND_DIR_RANGE,
91 4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
93 setValue(acc, AccSizeAltReq::IND_DIR_ARRAY,
94 (size->noOfIndexPages >> 8) +
95 4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
97 setValue(acc, AccSizeAltReq::IND_FRAGMENT,
98 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
107 setValue(acc, AccSizeAltReq::IND_OP_RECS,
108 size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50) +
109 (noOfLocalScanRecords * MAX_PARALLEL_SCANS_PER_FRAG) +
110 NODE_RECOVERY_SCAN_OP_RECORDS);
112 setValue(acc, AccSizeAltReq::IND_OVERFLOW_RECS,
113 size->noOfIndexPages +
114 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
116 setValue(acc, AccSizeAltReq::IND_PAGE8,
117 size->noOfIndexPages + 32);
119 setValue(acc, AccSizeAltReq::IND_ROOT_FRAG,
120 NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
122 setValue(acc, AccSizeAltReq::IND_TABLE,
125 setValue(acc, AccSizeAltReq::IND_SCAN,
126 noOfLocalScanRecords);
133 size->blockNo[DICT] = DBDICT;
135 VarSize *
const dict = &(size->varSize[DICT][0]);
137 setValue(dict, DictSizeAltReq::IND_ATTRIBUTE,
138 size->noOfAttributes);
140 setValue(dict, DictSizeAltReq::IND_CONNECT,
141 size->noOfOperations + 32);
143 setValue(dict, DictSizeAltReq::IND_FRAG_CONNECT,
144 NO_OF_FRAG_PER_NODE * size->noOfNDBNodes * size->noOfReplicas);
146 setValue(dict, DictSizeAltReq::IND_TABLE,
149 setValue(dict, DictSizeAltReq::IND_TC_CONNECT,
150 2* size->noOfOperations);
157 size->blockNo[DIH] = DBDIH;
159 VarSize *
const dih = &(size->varSize[DIH][0]);
161 setValue(dih, DihSizeAltReq::IND_API_CONNECT,
162 2 * size->noOfTransactions);
164 setValue(dih, DihSizeAltReq::IND_CONNECT,
165 size->noOfOperations + 46);
167 setValue(dih, DihSizeAltReq::IND_FRAG_CONNECT,
168 NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfNDBNodes);
171 temp = size->noOfReplicas - 2;
176 setValue(dih, DihSizeAltReq::IND_MORE_NODES,
177 temp * NO_OF_FRAG_PER_NODE *
178 size->noOfTables * size->noOfNDBNodes);
180 setValue(dih, DihSizeAltReq::IND_REPLICAS,
181 NO_OF_FRAG_PER_NODE * size->noOfTables *
182 size->noOfNDBNodes * size->noOfReplicas);
184 setValue(dih, DihSizeAltReq::IND_TABLE,
192 size->blockNo[LQH] = DBLQH;
194 VarSize *
const lqh = &(size->varSize[LQH][0]);
196 setValue(lqh, LqhSizeAltReq::IND_FRAG,
197 NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfReplicas);
199 setValue(lqh, LqhSizeAltReq::IND_CONNECT,
200 size->noOfReplicas*((11 * size->noOfOperations) / 10 + 50));
202 setValue(lqh, LqhSizeAltReq::IND_TABLE,
205 setValue(lqh, LqhSizeAltReq::IND_TC_CONNECT,
206 size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50));
208 setValue(lqh, LqhSizeAltReq::IND_REPLICAS,
211 setValue(lqh, LqhSizeAltReq::IND_LOG_FILES,
212 (4 * the_clusterData.ispValues[1][4]));
214 setValue(lqh, LqhSizeAltReq::IND_SCAN,
215 noOfLocalScanRecords);
223 size->blockNo[TC] = DBTC;
225 VarSize *
const tc = &(size->varSize[TC][0]);
227 setValue(tc, TcSizeAltReq::IND_API_CONNECT,
228 3 * size->noOfTransactions);
230 setValue(tc, TcSizeAltReq::IND_TC_CONNECT,
231 size->noOfOperations + 16 + size->noOfTransactions);
233 setValue(tc, TcSizeAltReq::IND_TABLE,
236 setValue(tc, TcSizeAltReq::IND_LOCAL_SCAN,
237 noOfLocalScanRecords);
239 setValue(tc, TcSizeAltReq::IND_TC_SCAN,
247 size->blockNo[TUP] = DBTUP;
249 VarSize *
const tup = &(size->varSize[TUP][0]);
251 setValue(tup, TupSizeAltReq::IND_DISK_PAGE_ARRAY,
252 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
254 setValue(tup, TupSizeAltReq::IND_DISK_PAGE_REPRESENT,
255 size->noOfDiskClusters);
257 setValue(tup, TupSizeAltReq::IND_FRAG,
258 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
260 setValue(tup, TupSizeAltReq::IND_PAGE_CLUSTER,
261 size->noOfFreeClusters);
263 setValue(tup, TupSizeAltReq::IND_LOGIC_PAGE,
264 size->noOfDiskBufferPages + size->noOfDiskClusters);
266 setValue(tup, TupSizeAltReq::IND_OP_RECS,
267 size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50));
269 setValue(tup, TupSizeAltReq::IND_PAGE,
270 size->noOfDataPages);
272 setValue(tup, TupSizeAltReq::IND_PAGE_RANGE,
273 4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas);
275 setValue(tup, TupSizeAltReq::IND_TABLE,
278 setValue(tup, TupSizeAltReq::IND_TABLE_DESC,
279 4 * NO_OF_FRAG_PER_NODE * size->noOfAttributes* size->noOfReplicas +
280 12 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas );
282 setValue(tup, TupSizeAltReq::IND_DELETED_BLOCKS,
283 size->noOfFreeClusters);
285 setValue(tup, TupSizeAltReq::IND_STORED_PROC,
286 noOfLocalScanRecords);
293 size->blockNo[TUX] = DBTUX;
295 VarSize *
const tux = &(size->varSize[TUX][0]);
297 setValue(tux, TuxSizeAltReq::IND_INDEX,
300 setValue(tux, TuxSizeAltReq::IND_FRAGMENT,
301 2 * NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfReplicas);
303 setValue(tux, TuxSizeAltReq::IND_ATTRIBUTE,
304 size->noOfIndexes * 4);
306 setValue(tux, TuxSizeAltReq::IND_SCAN,
307 noOfLocalScanRecords);
312 ClusterConfiguration::clusterData()
const
314 return the_clusterData;
318 const char *
msg =
"Invalid configuration fetched";
320 ClusterData & cd = the_clusterData;
322 struct AttribStorage {
const char * attrib; Uint32 * storage; };
323 AttribStorage tmp[] = {
324 {
"MaxNoOfConcurrentScans", &cd.SizeAltData.noOfScanRecords },
325 {
"MaxNoOfTables", &cd.SizeAltData.noOfTables },
326 {
"MaxNoOfIndexes", &cd.SizeAltData.noOfIndexes },
327 {
"NoOfReplicas", &cd.SizeAltData.noOfReplicas },
328 {
"MaxNoOfAttributes", &cd.SizeAltData.noOfAttributes },
329 {
"MaxNoOfConcurrentOperations", &cd.SizeAltData.noOfOperations },
330 {
"MaxNoOfConcurrentTransactions", &cd.SizeAltData.noOfTransactions },
331 {
"NoOfIndexPages", &cd.SizeAltData.noOfIndexPages },
332 {
"NoOfDataPages", &cd.SizeAltData.noOfDataPages },
333 {
"NoOfDiskBufferPages", &cd.SizeAltData.noOfDiskBufferPages },
334 {
"NoOfDiskClusters", &cd.SizeAltData.noOfDiskClusters },
335 {
"NoOfFreeDiskClusters", &cd.SizeAltData.noOfFreeClusters },
336 {
"TimeToWaitAlive", &cd.ispValues[0][0] },
337 {
"HeartbeatIntervalDbDb", &cd.ispValues[0][2] },
338 {
"HeartbeatIntervalDbApi", &cd.ispValues[0][3] },
339 {
"ArbitrationTimeout", &cd.ispValues[0][5] },
340 {
"TimeBetweenLocalCheckpoints", &cd.ispValues[1][2] },
341 {
"NoOfFragmentLogFiles", &cd.ispValues[1][4] },
342 {
"MaxNoOfConcurrentScans", &cd.SizeAltData.noOfScanRecords },
343 {
"NoOfConcurrentCheckpointsDuringRestart", &cd.ispValues[1][5] },
344 {
"TransactionDeadlockDetectionTimeout", &cd.ispValues[1][6] },
345 {
"NoOfConcurrentProcessesHandleTakeover", &cd.ispValues[1][7] },
346 {
"TimeBetweenGlobalCheckpoints", &cd.ispValues[2][3] },
347 {
"NoOfConcurrentCheckpointsAfterRestart", &cd.ispValues[2][4] },
348 {
"TransactionInactiveTimeout", &cd.ispValues[2][7] },
349 {
"NoOfDiskPagesToDiskDuringRestartTUP", &cd.ispValues[3][8] },
350 {
"NoOfDiskPagesToDiskAfterRestartTUP", &cd.ispValues[3][9] },
351 {
"NoOfDiskPagesToDiskDuringRestartACC", &cd.ispValues[3][10] },
352 {
"NoOfDiskPagesToDiskAfterRestartACC", &cd.ispValues[3][11] },
353 {
"NoOfDiskClustersPerDiskFile", &cd.ispValues[4][8] },
354 {
"NoOfDiskFiles", &cd.ispValues[4][9] },
355 {
"NoOfReplicas", &cd.ispValues[2][2] }
359 const int sz =
sizeof(tmp)/
sizeof(AttribStorage);
360 for(
int i = 0;
i<sz;
i++){
361 if(!db.get(tmp[
i].attrib, tmp[i].storage)){
364 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
368 if(!p.get(
"NoOfNodes", &cd.SizeAltData.noOfNodes)){
369 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg,
"NoOfNodes missing");
373 const char *
name = 0;
375 for(name = it.first(); name != NULL; name = it.next()){
376 if(strncmp(name,
"Node_", strlen(
"Node_")) == 0){
379 const char * nodeType;
382 if(!p.get(name, &node)){
383 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg,
"Node data missing");
386 if(!node->get(
"Id", &nodeId)){
387 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg,
"Node data (Id) missing");
390 if(!node->get(
"Type", &nodeType)){
391 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg,
"Node data (Type) missing");
394 if(nodeId > MAX_NODES){
396 snprintf(buf,
sizeof(buf),
397 "Maximum DB node id allowed is: %d", MAX_NDB_NODES);
398 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
403 snprintf(buf,
sizeof(buf),
404 "Minimum node id allowed in the cluster is: 1");
405 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
408 for(
unsigned j = 0; j<nodeNo; j++){
409 if(cd.nodeData[j].nodeId == nodeId){
412 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
417 for(
unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
419 if(db.get(LogLevel::LOGLEVEL_CATEGORY_NAME[j].name, &logLevel)){
420 cd.SizeAltData.logLevel.setLogLevel((LogLevel::EventCategory)j,
426 cd.nodeData[nodeNo].nodeId = nodeId;
427 const char* tmpApiMgmProperties = 0;
428 if(strcmp(
"DB", nodeType) == 0){
430 cd.SizeAltData.noOfNDBNodes++;
432 if(nodeId > MAX_NDB_NODES){
435 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
437 if(cd.SizeAltData.noOfNDBNodes > MAX_NDB_NODES){
440 "Maximum %d ndb nodes is allowed in the cluster",
442 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, msg, buf);
444 }
else if(strcmp(
"API", nodeType) == 0){
446 cd.SizeAltData.noOfAPINodes++;
447 tmpApiMgmProperties =
"API";
448 }
else if(strcmp(
"REP", nodeType) == 0){
449 cd.nodeData[nodeNo].nodeType = NodeInfo::REP;
451 tmpApiMgmProperties =
"REP";
452 }
else if(strcmp(
"MGM", nodeType) == 0){
454 cd.SizeAltData.noOfMGMNodes++;
455 tmpApiMgmProperties =
"MGM";
457 ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG,
458 "Invalid configuration: Unknown node type",
462 if (tmpApiMgmProperties) {
471 if (node->get(
"ArbitrationRank", &rank) && rank > 0) {
472 cd.nodeData[nodeNo].arbitRank = rank;
476 cd.nodeData[nodeNo].arbitRank = 0;
482 cd.SizeAltData.exist =
true;
483 calcSizeAlteration();