Configuration.cpp 18.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include "Configuration.hpp"
#include <ErrorHandlingMacros.hpp>
#include "GlobalData.hpp"

#include <ConfigRetriever.hpp>
#include <IPCConfig.hpp>
#include <ndb_version.h>
#include <NdbMem.h>
#include <NdbOut.hpp>
#include <WatchDog.hpp>

#include <getarg.h>

30 31 32 33 34 35 36 37
#include <mgmapi_configuration.hpp>
#include <mgmapi_config_parameters_debug.h>
#include <kernel_config_parameters.h>

#include <kernel_types.h>
#include <ndb_limits.h>
#include "pc.hpp"
#include <LogLevel.hpp>
joreland@mysql.com's avatar
joreland@mysql.com committed
38
#include <NdbSleep.h>
39

40 41 42 43
extern "C" {
  void ndbSetOwnVersion();
}

44 45 46
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;

47 48 49 50 51 52
bool
Configuration::init(int argc, const char** argv){

  /**
   * Default values for arguments
   */
53
  int _no_start = 0;
54 55 56 57 58 59 60 61 62 63
  int _initial = 0;
  const char* _connect_str = NULL;
  int _deamon = 0;
  int _help = 0;
  int _print_version = 0;
  
  /**
   * Arguments to NDB process
   */ 

64 65 66 67 68 69
  struct getargs args[] = {
    { "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" },
    { "nostart", 'n', arg_flag, &_no_start,
      "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" },
    { "daemon", 'd', arg_flag, &_deamon, "Start ndbd as daemon", "" },
    { "initial", 'i', arg_flag, &_initial,
tomas@poseidon.(none)'s avatar
tomas@poseidon.(none) committed
70
      "Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" },
71 72 73 74

    { "connect-string", 'c', arg_string, &_connect_str,
      "Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file",
      "<constr>" },
75 76 77 78 79 80 81 82 83 84 85 86 87
    { "usage", '?', arg_flag, &_help, "Print help", "" }
  };
  int num_args = sizeof(args) / sizeof(args[0]);
  int optind = 0;
  char desc[] = 
    "The MySQL Cluster kernel";
  
  if(getarg(args, num_args, argc, argv, &optind) || _help) {
    arg_printusage(args, num_args, argv[0], desc);
    return false;
  }

#if 0  
88
  ndbout << "no_start=" <<_no_start<< endl;
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  ndbout << "initial=" <<_initial<< endl;
  ndbout << "deamon=" <<_deamon<< endl;
  ndbout << "connect_str="<<_connect_str<<endl;
  arg_printusage(args, num_args, argv[0], desc);
  return false;
#endif

  ndbSetOwnVersion();

  if (_print_version) {
    ndbPrintVersion();
    return false;
  }

  // Check the start flag
104
  if (_no_start)
105
    globalData.theRestartFlag = initial_state;
106 107
  else 
    globalData.theRestartFlag = perform_start;
108 109 110 111 112 113

  // Check the initial flag
  if (_initial)
    _initialStart = true;
  
  // Check connectstring
114
  if (_connect_str)
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    _connectString = strdup(_connect_str);
  
  // Check deamon flag
  if (_deamon)
    _daemonMode = true;

  // Save programname
  if(argc > 0 && argv[0] != 0)
    _programName = strdup(argv[0]);
  else
    _programName = strdup("");
  
  return true;
}

130
Configuration::Configuration()
131 132 133 134 135 136
{
  _programName = 0;
  _connectString = 0;
  _fsPath = 0;
  _initialStart = false;
  _daemonMode = false;
137
  m_config_retriever= 0;
138 139 140 141 142 143 144 145
}

Configuration::~Configuration(){
  if(_programName != NULL)
    free(_programName);

  if(_fsPath != NULL)
    free(_fsPath);
146 147 148 149 150 151 152 153 154 155 156 157

  if (m_config_retriever) {
    delete m_config_retriever;
  }
}

void
Configuration::closeConfiguration(){
  if (m_config_retriever) {
    delete m_config_retriever;
  }
  m_config_retriever= 0;
158 159 160
}

void
joreland@mysql.com's avatar
joreland@mysql.com committed
161
Configuration::fetch_configuration(){
162 163 164
  /**
   * Fetch configuration from management server
   */
165 166 167 168
  if (m_config_retriever) {
    delete m_config_retriever;
  }

joreland@mysql.com's avatar
joreland@mysql.com committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
  m_config_retriever= new ConfigRetriever(NDB_VERSION, NODE_TYPE_DB);
  m_config_retriever->setConnectString(_connectString ? _connectString : "");
  if(m_config_retriever->init() == -1 ||
     m_config_retriever->do_connect() == -1){
    
    const char * s = m_config_retriever->getErrorString();
    if(s == 0)
      s = "No error given!";
    
    /* Set stop on error to true otherwise NDB will
       go into an restart loop...
    */
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Could connect to ndb_mgmd", s);
  }
  
  ConfigRetriever &cr= *m_config_retriever;
  
  if((globalData.ownId = cr.allocNodeId()) == 0){
    for(Uint32 i = 0; i<3; i++){
      NdbSleep_SecSleep(3);
      if(globalData.ownId = cr.allocNodeId())
	break;
    }
  }
  
  if(globalData.ownId == 0){
    ERROR_SET(fatal, ERR_INVALID_CONFIG, 
	      "Unable to alloc node id", m_config_retriever->getErrorString());
  }
  
  ndb_mgm_configuration * p = cr.getConfig();
200 201 202 203
  if(p == 0){
    const char * s = cr.getErrorString();
    if(s == 0)
      s = "No error given!";
joreland@mysql.com's avatar
joreland@mysql.com committed
204
    
205 206
    /* Set stop on error to true otherwise NDB will
       go into an restart loop...
joreland@mysql.com's avatar
joreland@mysql.com committed
207 208
    */
    
209 210 211
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Could not fetch configuration"
	      "/invalid configuration", s);
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
  if(m_clusterConfig)
    free(m_clusterConfig);
  
  m_clusterConfig = p;
  
  ndb_mgm_configuration_iterator iter(* p, CFG_SECTION_NODE);
  if (iter.find(CFG_NODE_ID, globalData.ownId)){
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", "DB missing");
  }
  
  if(iter.get(CFG_DB_STOP_ON_ERROR, &_stopOnError)){
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
	      "StopOnError missing");
  }
}
227

joreland@mysql.com's avatar
joreland@mysql.com committed
228 229 230
void
Configuration::setupConfiguration(){
  ndb_mgm_configuration * p = m_clusterConfig;
231

232 233 234 235
  /**
   * Configure transporters
   */
  {  
joreland@mysql.com's avatar
joreland@mysql.com committed
236
    int res = IPCConfig::configureTransporters(globalData.ownId,
237 238 239
					       * p, 
					       globalTransporterRegistry);
    if(res <= 0){
240 241 242 243 244 245 246 247
      ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
		"No transporters configured");
    }
  }

  /**
   * Setup cluster configuration data
   */
248 249
  ndb_mgm_configuration_iterator iter(* p, CFG_SECTION_NODE);
  if (iter.find(CFG_NODE_ID, globalData.ownId)){
250 251
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", "DB missing");
  }
252 253 254

  unsigned type;
  if(!(iter.get(CFG_TYPE_OF_SECTION, &type) == 0 && type == NODE_TYPE_DB)){
255 256 257 258
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched",
	      "I'm wrong type of node");
  }
  
259
  if(iter.get(CFG_DB_NO_SAVE_MSGS, &_maxErrorLogs)){
260 261 262 263
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
	      "MaxNoOfSavedMessages missing");
  }
  
264
  if(iter.get(CFG_DB_MEMLOCK, &_lockPagesInMainMemory)){
265 266 267 268
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
	      "LockPagesInMainMemory missing");
  }

269
  if(iter.get(CFG_DB_WATCHDOG_INTERVAL, &_timeBetweenWatchDogCheck)){
270 271 272 273 274 275 276 277 278
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
	      "TimeBetweenWatchDogCheck missing");
  }

  /**
   * Get filesystem path
   */  
  { 
    const char* pFileSystemPath = NULL;
279
    if(iter.get(CFG_DB_FILESYSTEM_PATH, &pFileSystemPath)){
280 281 282
      ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
		"FileSystemPath missing");
    } 
283
    
284 285 286 287
    if(pFileSystemPath == 0 || strlen(pFileSystemPath) == 0){
      ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
		"Configuration does not contain valid filesystem path");
    }
288
    
289 290 291
    if(pFileSystemPath[strlen(pFileSystemPath) - 1] == '/')
      _fsPath = strdup(pFileSystemPath);
    else {
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
292
      _fsPath = (char *)NdbMem_Allocate(strlen(pFileSystemPath) + 2);
293 294 295 296
      strcpy(_fsPath, pFileSystemPath);
      strcat(_fsPath, "/");
    }
  }
297 298
  
  if(iter.get(CFG_DB_STOP_ON_ERROR_INSERT, &m_restartOnErrorInsert)){
299 300 301 302 303 304 305 306 307 308 309 310
    ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", 
	      "RestartOnErrorInsert missing");
  }

  /**
   * Create the watch dog thread
   */
  { 
    Uint32 t = _timeBetweenWatchDogCheck;
    t = globalEmulatorData.theWatchDog ->setCheckInterval(t);
    _timeBetweenWatchDogCheck = t;
  }
311 312 313 314 315
  
  ConfigValues* cf = ConfigValuesFactory::extractCurrentSection(iter.m_config);

  m_clusterConfigIter = ndb_mgm_create_configuration_iterator
    (p, CFG_SECTION_NODE);
316

317
  calcSizeAlt(cf);
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
}

bool 
Configuration::lockPagesInMainMemory() const {
  return _lockPagesInMainMemory;
}

int 
Configuration::timeBetweenWatchDogCheck() const {
  return _timeBetweenWatchDogCheck;
}

void 
Configuration::timeBetweenWatchDogCheck(int value) {
  _timeBetweenWatchDogCheck = value;
}

int 
Configuration::maxNoOfErrorLogs() const {
  return _maxErrorLogs;
}

void 
Configuration::maxNoOfErrorLogs(int val){
  _maxErrorLogs = val;
}

bool
Configuration::stopOnError() const {
  return _stopOnError;
}

void 
Configuration::stopOnError(bool val){
  _stopOnError = val;
}

int
Configuration::getRestartOnErrorInsert() const {
  return m_restartOnErrorInsert;
}

void
Configuration::setRestartOnErrorInsert(int i){
  m_restartOnErrorInsert = i;
}

char *
Configuration::getConnectStringCopy() const {
  if(_connectString != 0)
    return strdup(_connectString);
  return 0;
}
371

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
const ndb_mgm_configuration_iterator * 
Configuration::getOwnConfigIterator() const {
  return m_ownConfigIterator;
}
  
ndb_mgm_configuration_iterator * 
Configuration::getClusterConfigIterator() const {
  return m_clusterConfigIter;
}

void
Configuration::calcSizeAlt(ConfigValues * ownConfig){
  const char * msg = "Invalid configuration fetched";
  char buf[255];

  unsigned int noOfTables = 0;
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
388 389
  unsigned int noOfUniqueHashIndexes = 0;
  unsigned int noOfOrderedIndexes = 0;
390 391 392 393 394 395 396
  unsigned int noOfReplicas = 0;
  unsigned int noOfDBNodes = 0;
  unsigned int noOfAPINodes = 0;
  unsigned int noOfMGMNodes = 0;
  unsigned int noOfNodes = 0;
  unsigned int noOfAttributes = 0;
  unsigned int noOfOperations = 0;
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
397
  unsigned int noOfLocalOperations = 0;
398 399 400 401
  unsigned int noOfTransactions = 0;
  unsigned int noOfIndexPages = 0;
  unsigned int noOfDataPages = 0;
  unsigned int noOfScanRecords = 0;
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
402 403
  unsigned int noOfLocalScanRecords = 0;
  unsigned int noBatchSize = 0;
404 405 406 407 408
  m_logLevel = new LogLevel();
  
  struct AttribStorage { int paramId; Uint32 * storage; };
  AttribStorage tmp[] = {
    { CFG_DB_NO_SCANS, &noOfScanRecords },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
409 410
    { CFG_DB_NO_LOCAL_SCANS, &noOfLocalScanRecords },
    { CFG_DB_BATCH_SIZE, &noBatchSize },
411
    { CFG_DB_NO_TABLES, &noOfTables },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
412 413
    { CFG_DB_NO_ORDERED_INDEXES, &noOfOrderedIndexes },
    { CFG_DB_NO_UNIQUE_HASH_INDEXES, &noOfUniqueHashIndexes },
414 415 416
    { CFG_DB_NO_REPLICAS, &noOfReplicas },
    { CFG_DB_NO_ATTRIBUTES, &noOfAttributes },
    { CFG_DB_NO_OPS, &noOfOperations },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
417
    { CFG_DB_NO_LOCAL_OPS, &noOfLocalOperations },
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
    { CFG_DB_NO_TRANSACTIONS, &noOfTransactions }
  };

  ndb_mgm_configuration_iterator db(*(ndb_mgm_configuration*)ownConfig, 0);
  
  const int sz = sizeof(tmp)/sizeof(AttribStorage);
  for(int i = 0; i<sz; i++){
    if(ndb_mgm_get_int_parameter(&db, tmp[i].paramId, tmp[i].storage)){
      snprintf(buf, sizeof(buf), "ConfigParam: %d not found", tmp[i].paramId);
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
    }
  }

  Uint64 indexMem = 0, dataMem = 0;
  ndb_mgm_get_int64_parameter(&db, CFG_DB_DATA_MEM, &dataMem);
  ndb_mgm_get_int64_parameter(&db, CFG_DB_INDEX_MEM, &indexMem);
  if(dataMem == 0){
    snprintf(buf, sizeof(buf), "ConfigParam: %d not found", CFG_DB_DATA_MEM);
    ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
  }

  if(indexMem == 0){
    snprintf(buf, sizeof(buf), "ConfigParam: %d not found", CFG_DB_INDEX_MEM);
    ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
  }

  noOfDataPages = (dataMem / 8192);
  noOfIndexPages = (indexMem / 8192);

  for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){
    Uint32 tmp;
    if(!ndb_mgm_get_int_parameter(&db, LogLevel::MIN_LOGLEVEL_ID+j, &tmp)){
      m_logLevel->setLogLevel((LogLevel::EventCategory)j, tmp);
    }
  }
  
  // tmp
  ndb_mgm_configuration_iterator * p = m_clusterConfigIter;

  Uint32 nodeNo = noOfNodes = 0;
  NodeBitmask nodes;
  for(ndb_mgm_first(p); ndb_mgm_valid(p); ndb_mgm_next(p), nodeNo++){
    
    Uint32 nodeId;
    Uint32 nodeType;
    
    if(ndb_mgm_get_int_parameter(p, CFG_NODE_ID, &nodeId)){
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, "Node data (Id) missing");
    }
    
    if(ndb_mgm_get_int_parameter(p, CFG_TYPE_OF_SECTION, &nodeType)){
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, "Node data (Type) missing");
    }
    
    if(nodeId > MAX_NODES || nodeId == 0){
      snprintf(buf, sizeof(buf),
	       "Invalid node id: %d", nodeId);
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
    }
    
    if(nodes.get(nodeId)){
      snprintf(buf, sizeof(buf), "Two node can not have the same node id: %d",
	       nodeId);
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
    }
    nodes.set(nodeId);
        
    switch(nodeType){
    case NODE_TYPE_DB:
      noOfDBNodes++; // No of NDB processes
      
      if(nodeId > MAX_NDB_NODES){
	snprintf(buf, sizeof(buf), "Maximum node id for a ndb node is: %d", 
		 MAX_NDB_NODES);
	ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
      }
      break;
    case NODE_TYPE_API:
      noOfAPINodes++; // No of API processes
      break;
    case NODE_TYPE_REP:
      break;
    case NODE_TYPE_MGM:
      noOfMGMNodes++; // No of MGM processes
      break;
    case NODE_TYPE_EXT_REP:
      break;
    default:
      snprintf(buf, sizeof(buf), "Unknown node type: %d", nodeType);
      ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf);
    }
  }
  noOfNodes = nodeNo;
511 512

  noOfTables+= 2; // Add System tables
513
  noOfAttributes += 9;  // Add System table attributes
514 515 516 517 518

  ConfigValues::Iterator it2(*ownConfig, db.m_config);
  it2.set(CFG_DB_NO_TABLES, noOfTables);
  it2.set(CFG_DB_NO_ATTRIBUTES, noOfAttributes);

519 520 521 522 523
  /**
   * Do size calculations
   */
  ConfigValuesFactory cfg(ownConfig);

mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
524 525 526 527 528 529
  if (noOfLocalScanRecords == 0) {
    noOfLocalScanRecords = (noOfDBNodes * noOfScanRecords) + 1;
  }
  if (noOfLocalOperations == 0) {
    noOfLocalOperations= (11 * noOfOperations) / 10;
  }
530 531 532
  Uint32 noOfTCScanRecords = noOfScanRecords;

  {
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
533
    Uint32 noOfAccTables= noOfTables + noOfUniqueHashIndexes;
534 535 536 537 538
    /**
     * Acc Size Alt values
     */
    // Can keep 65536 pages (= 0.5 GByte)
    cfg.put(CFG_ACC_DIR_RANGE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
539
	    4 * NO_OF_FRAG_PER_NODE * noOfAccTables* noOfReplicas); 
540 541 542
    
    cfg.put(CFG_ACC_DIR_ARRAY,
	    (noOfIndexPages >> 8) + 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
543
	    4 * NO_OF_FRAG_PER_NODE * noOfAccTables* noOfReplicas);
544 545
    
    cfg.put(CFG_ACC_FRAGMENT,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
546
	    2 * NO_OF_FRAG_PER_NODE * noOfAccTables* noOfReplicas);
547 548 549 550 551 552 553 554 555
    
    /*-----------------------------------------------------------------------*/
    // The extra operation records added are used by the scan and node 
    // recovery process. 
    // Node recovery process will have its operations dedicated to ensure
    // that they never have a problem with allocation of the operation record.
    // The remainder are allowed for use by the scan processes.
    /*-----------------------------------------------------------------------*/
    cfg.put(CFG_ACC_OP_RECS,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
556 557
	    (noOfLocalOperations + 50) + 
	    (noOfLocalScanRecords * noBatchSize) +
558 559 560 561
	    NODE_RECOVERY_SCAN_OP_RECORDS);
    
    cfg.put(CFG_ACC_OVERFLOW_RECS,
	    noOfIndexPages + 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
562
	    2 * NO_OF_FRAG_PER_NODE * noOfAccTables* noOfReplicas);
563 564 565 566 567
    
    cfg.put(CFG_ACC_PAGE8, 
	    noOfIndexPages + 32);
    
    cfg.put(CFG_ACC_ROOT_FRAG, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
568
	    NO_OF_FRAG_PER_NODE * noOfAccTables* noOfReplicas);
569
    
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
570
    cfg.put(CFG_ACC_TABLE, noOfAccTables);
571 572 573 574
    
    cfg.put(CFG_ACC_SCAN, noOfLocalScanRecords);
  }
  
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
575 576
  Uint32 noOfMetaTables= noOfTables + noOfOrderedIndexes +
                           noOfUniqueHashIndexes;
577 578 579 580 581 582 583 584
  {
    /**
     * Dict Size Alt values
     */
    cfg.put(CFG_DICT_ATTRIBUTE, 
	    noOfAttributes);

    cfg.put(CFG_DICT_TABLE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
585
	    noOfMetaTables);
586 587 588 589 590 591 592 593 594 595
  }
  
  {
    /**
     * Dih Size Alt values
     */
    cfg.put(CFG_DIH_API_CONNECT, 
	    2 * noOfTransactions);
    
    cfg.put(CFG_DIH_CONNECT, 
596
	    noOfOperations + noOfTransactions + 46);
597 598
    
    cfg.put(CFG_DIH_FRAG_CONNECT, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
599
	    NO_OF_FRAG_PER_NODE *  noOfMetaTables *  noOfDBNodes);
600 601 602 603 604 605 606 607 608
    
    int temp;
    temp = noOfReplicas - 2;
    if (temp < 0)
      temp = 1;
    else
      temp++;
    cfg.put(CFG_DIH_MORE_NODES, 
	    temp * NO_OF_FRAG_PER_NODE *
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
609
	    noOfMetaTables *  noOfDBNodes);
610 611
    
    cfg.put(CFG_DIH_REPLICAS, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
612
	    NO_OF_FRAG_PER_NODE * noOfMetaTables *
613 614 615
	    noOfDBNodes * noOfReplicas);

    cfg.put(CFG_DIH_TABLE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
616
	    noOfMetaTables);
617 618 619 620 621 622 623
  }
  
  {
    /**
     * Lqh Size Alt values
     */
    cfg.put(CFG_LQH_FRAG, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
624
	    NO_OF_FRAG_PER_NODE * noOfMetaTables * noOfReplicas);
625 626
    
    cfg.put(CFG_LQH_TABLE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
627
	    noOfMetaTables);
628 629

    cfg.put(CFG_LQH_TC_CONNECT, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
630
	    noOfLocalOperations + 50);
631 632 633 634 635 636 637 638 639 640 641 642 643
    
    cfg.put(CFG_LQH_SCAN, 
	    noOfLocalScanRecords);
  }
  
  {
    /**
     * Tc Size Alt values
     */
    cfg.put(CFG_TC_API_CONNECT, 
	    3 * noOfTransactions);
    
    cfg.put(CFG_TC_TC_CONNECT, 
644
	    (2 * noOfOperations) + 16 + noOfTransactions);
645 646
    
    cfg.put(CFG_TC_TABLE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
647
	    noOfMetaTables);
648 649 650 651 652 653 654 655 656 657 658 659 660
    
    cfg.put(CFG_TC_LOCAL_SCAN, 
	    noOfLocalScanRecords);
    
    cfg.put(CFG_TC_SCAN, 
	    noOfTCScanRecords);
  }
  
  {
    /**
     * Tup Size Alt values
     */
    cfg.put(CFG_TUP_FRAG, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
661
	    2 * NO_OF_FRAG_PER_NODE * noOfMetaTables* noOfReplicas);
662 663
    
    cfg.put(CFG_TUP_OP_RECS, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
664
	    noOfLocalOperations + 50);
665 666 667 668 669
    
    cfg.put(CFG_TUP_PAGE, 
	    noOfDataPages);
    
    cfg.put(CFG_TUP_PAGE_RANGE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
670
	    4 * NO_OF_FRAG_PER_NODE * noOfMetaTables* noOfReplicas);
671 672
    
    cfg.put(CFG_TUP_TABLE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
673
	    noOfMetaTables);
674 675 676
    
    cfg.put(CFG_TUP_TABLE_DESC, 
	    4 * NO_OF_FRAG_PER_NODE * noOfAttributes* noOfReplicas +
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
677
	    12 * NO_OF_FRAG_PER_NODE * noOfMetaTables* noOfReplicas );
678 679 680 681 682 683 684 685 686 687
    
    cfg.put(CFG_TUP_STORED_PROC,
	    noOfLocalScanRecords);
  }

  {
    /**
     * Tux Size Alt values
     */
    cfg.put(CFG_TUX_INDEX, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
688
	    noOfOrderedIndexes);
689 690
    
    cfg.put(CFG_TUX_FRAGMENT, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
691
	    2 * NO_OF_FRAG_PER_NODE * noOfOrderedIndexes * noOfReplicas);
692 693
    
    cfg.put(CFG_TUX_ATTRIBUTE, 
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
694
	    noOfOrderedIndexes * 4);
695 696 697 698 699 700 701 702 703

    cfg.put(CFG_TUX_SCAN_OP, noOfLocalScanRecords); 
  }

  m_ownConfig = (ndb_mgm_configuration*)cfg.getConfigValues();
  m_ownConfigIterator = ndb_mgm_create_configuration_iterator
    (m_ownConfig, 0);
}

704 705 706 707
void
Configuration::setInitialStart(bool val){
  _initialStart = val;
}