ConfigInfo.cpp 86.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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 */

17 18
#include <ndb_global.h>

19
#include <NdbTCP.h>
20
#include "ConfigInfo.hpp"
21
#include <mgmapi_config_parameters.h>
22
#include <ndb_limits.h>
23
#include "InitConfigFileParser.hpp"
24

25
#define MAX_LINE_LENGTH 255
26
#define KEY_INTERNAL 0
27
#define MAX_INT_RNIL 0xfffffeff
28

29 30
#define _STR_VALUE(x) #x
#define STR_VALUE(x) _STR_VALUE(x)
31

32 33 34
/****************************************************************************
 * Section names
 ****************************************************************************/
35

36 37 38 39
#define DB_TOKEN_PRINT  "ndbd(DB)"
#define MGM_TOKEN_PRINT "ndb_mgmd(MGM)"
#define API_TOKEN_PRINT "mysqld(API)"

tomas@poseidon.(none)'s avatar
tomas@poseidon.(none) committed
40 41 42
#define DB_TOKEN "DB"
#define MGM_TOKEN "MGM"
#define API_TOKEN "API"
43

44 45
const ConfigInfo::AliasPair
ConfigInfo::m_sectionNameAliases[]={
tomas@poseidon.(none)'s avatar
tomas@poseidon.(none) committed
46 47 48
  {API_TOKEN, "MYSQLD"},
  {DB_TOKEN,  "NDBD"},
  {MGM_TOKEN, "NDB_MGMD"},
49 50 51
  {0, 0}
};

52 53 54 55 56 57
const char* 
ConfigInfo::m_sectionNames[]={
  "SYSTEM",
  "EXTERNAL SYSTEM",
  "COMPUTER",

58 59 60
  DB_TOKEN,
  MGM_TOKEN,
  API_TOKEN,
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  "REP",
  "EXTERNAL REP",

  "TCP",
  "SCI",
  "SHM",
  "OSE"
};
const int ConfigInfo::m_noOfSectionNames = 
sizeof(m_sectionNames)/sizeof(char*);


/****************************************************************************
 * Section Rules declarations
 ****************************************************************************/
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
static bool transformComputer(InitConfigFileParser::Context & ctx, const char *);
static bool transformSystem(InitConfigFileParser::Context & ctx, const char *);
static bool transformExternalSystem(InitConfigFileParser::Context & ctx, const char *);
static bool transformNode(InitConfigFileParser::Context & ctx, const char *);
static bool transformExtNode(InitConfigFileParser::Context & ctx, const char *);
static bool transformConnection(InitConfigFileParser::Context & ctx, const char *);
static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *);
static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *);
static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *);
static bool fixShmkey(InitConfigFileParser::Context & ctx, const char *);
static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *);
static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *);
static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *);
static bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data);
static bool fixHostname(InitConfigFileParser::Context & ctx, const char * data);
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data);
static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data);
static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *);
static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *);
95
static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data);
96
static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data);
97 98 99 100 101 102 103

const ConfigInfo::SectionRule 
ConfigInfo::m_SectionRules[] = {
  { "SYSTEM", transformSystem, 0 },
  { "EXTERNAL SYSTEM", transformExternalSystem, 0 },
  { "COMPUTER", transformComputer, 0 },

104 105 106
  { DB_TOKEN,   transformNode, 0 },
  { API_TOKEN,  transformNode, 0 },
  { MGM_TOKEN,  transformNode, 0 },
107 108 109 110 111 112 113 114
  { "REP",  transformNode, 0 },
  { "EXTERNAL REP",  transformExtNode, 0 },

  { "TCP",  transformConnection, 0 },
  { "SHM",  transformConnection, 0 },
  { "SCI",  transformConnection, 0 },
  { "OSE",  transformConnection, 0 },

115 116 117
  { DB_TOKEN,   fixNodeHostname, 0 },
  { API_TOKEN,  fixNodeHostname, 0 },
  { MGM_TOKEN,  fixNodeHostname, 0 },
118 119
  { "REP",  fixNodeHostname, 0 },
  //{ "EXTERNAL REP",  fixNodeHostname, 0 },
120 121 122 123 124 125 126 127 128

  { "TCP",  fixNodeId, "NodeId1" },
  { "TCP",  fixNodeId, "NodeId2" },
  { "SHM",  fixNodeId, "NodeId1" },
  { "SHM",  fixNodeId, "NodeId2" },
  { "SCI",  fixNodeId, "NodeId1" },
  { "SCI",  fixNodeId, "NodeId2" },
  { "OSE",  fixNodeId, "NodeId1" },
  { "OSE",  fixNodeId, "NodeId2" },
129 130 131
  
  { "TCP",  fixHostname, "HostName1" },
  { "TCP",  fixHostname, "HostName2" },
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
132 133
  { "SCI",  fixHostname, "HostName1" },
  { "SCI",  fixHostname, "HostName2" },
134 135
  { "OSE",  fixHostname, "HostName1" },
  { "OSE",  fixHostname, "HostName2" },
136

137
  { "TCP",  fixPortNumber, 0 }, // has to come after fixHostName
138
  { "SHM",  fixPortNumber, 0 }, // has to come after fixHostName
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
139
  { "SCI",  fixPortNumber, 0 }, // has to come after fixHostName
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
140 141
  //{ "SHM",  fixShmKey, 0 },

142 143 144 145 146 147 148 149
  /**
   * fixExtConnection must be after fixNodeId
   */
  { "TCP",  fixExtConnection, 0 },
  { "SHM",  fixExtConnection, 0 },
  { "SCI",  fixExtConnection, 0 },
  { "OSE",  fixExtConnection, 0 },
  
150 151 152 153
  { "*",    applyDefaultValues, "user" },
  { "*",    fixDepricated, 0 },
  { "*",    applyDefaultValues, "system" },

154
  { DB_TOKEN,   fixFileSystemPath, 0 },
155
  { DB_TOKEN,   fixBackupDataDir, 0 },
156 157

  { DB_TOKEN,   checkDbConstraints, 0 },
158

159 160 161 162 163 164 165 166
  /**
   * checkConnectionConstraints must be after fixExtConnection
   */
  { "TCP",  checkConnectionConstraints, 0 },
  { "SHM",  checkConnectionConstraints, 0 },
  { "SCI",  checkConnectionConstraints, 0 },
  { "OSE",  checkConnectionConstraints, 0 },

167 168
  { "TCP",  checkTCPConstraints, "HostName1" },
  { "TCP",  checkTCPConstraints, "HostName2" },
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
169 170
  { "SCI",  checkTCPConstraints, "HostName1" },
  { "SCI",  checkTCPConstraints, "HostName2" },
171
  
172 173
  { "*",    checkMandatory, 0 },
  
174 175 176
  { DB_TOKEN,   saveInConfigValues, 0 },
  { API_TOKEN,  saveInConfigValues, 0 },
  { MGM_TOKEN,  saveInConfigValues, 0 },
177 178 179 180 181 182 183 184
  { "REP",  saveInConfigValues, 0 },

  { "TCP",  saveInConfigValues, 0 },
  { "SHM",  saveInConfigValues, 0 },
  { "SCI",  saveInConfigValues, 0 },
  { "OSE",  saveInConfigValues, 0 }
};
const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);
185

186 187 188
/****************************************************************************
 * Config Rules declarations
 ****************************************************************************/
189
static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
190 191
			  struct InitConfigFileParser::Context &ctx, 
			  const char * rule_data);
192
static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
193 194
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
195
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
196 197
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data);
198
static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
joreland@mysql.com's avatar
joreland@mysql.com committed
199 200
			    struct InitConfigFileParser::Context &ctx, 
			    const char * rule_data);
201 202 203

const ConfigInfo::ConfigRule 
ConfigInfo::m_ConfigRules[] = {
204
  { sanity_checks, 0 },
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
205
  { add_node_connections, 0 },
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
206
  { add_server_ports, 0 },
joreland@mysql.com's avatar
joreland@mysql.com committed
207
  { check_node_vs_replicas, 0 },
208 209 210
  { 0, 0 }
};
	  
211 212 213 214 215 216 217
struct DepricationTransform {
  const char * m_section;
  const char * m_oldName;
  const char * m_newName;
  double m_add;
  double m_mul;
};
218

219 220
static
const DepricationTransform f_deprication[] = {
221
  { DB_TOKEN, "Discless", "Diskless", 0, 1 },
222
  { 0, 0, 0, 0, 0}
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
};

/**
 * The default constructors create objects with suitable values for the
 * configuration parameters. 
 *
 * Some are however given the value MANDATORY which means that the value
 * must be specified in the configuration file. 
 *
 * Min and max values are also given for some parameters.
 * - Attr1:  Name in file (initial config file)
 * - Attr2:  Name in prop (properties object)
 * - Attr3:  Name of Section (in init config file)
 * - Attr4:  Updateable
 * - Attr5:  Type of parameter (INT or BOOL)
 * - Attr6:  Default Value (number only)
 * - Attr7:  Min value
 * - Attr8:  Max value
 * 
 * Parameter constraints are coded in file Config.cpp.
 *
 * *******************************************************************
 * Parameters used under development should be marked "NOTIMPLEMENTED"
 * *******************************************************************
 */
248

249 250
const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {

251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
  /****************************************************************************
   * COMPUTER
   ***************************************************************************/
  {
    KEY_INTERNAL,
    "COMPUTER",
    "COMPUTER",
    "Computer section",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::SECTION,
    0,
    0, 0 },
  
  {
    KEY_INTERNAL,
    "Id",
    "COMPUTER",
    "Name of computer",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
274
    0, 0 },
275 276 277 278 279

  {
    KEY_INTERNAL,
    "HostName",
    "COMPUTER",
280
    "Hostname of computer (e.g. mysql.com)",
281 282 283 284
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
285
    0, 0 },
286 287 288 289 290 291 292 293 294 295 296 297

  {
    KEY_INTERNAL,
    "ByteOrder",
    "COMPUTER",
    0,
    ConfigInfo::DEPRICATED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
    0,
    0 },
298 299 300 301 302 303 304 305 306 307 308 309
  
  /****************************************************************************
   * SYSTEM
   ***************************************************************************/
  {
    CFG_SECTION_SYSTEM,
    "SYSTEM",
    "SYSTEM",
    "System section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
310 311
    (const char *)CFG_SECTION_SYSTEM,
    0, 0 },
312 313 314 315 316 317 318 319 320 321

  {
    CFG_SYS_NAME,
    "Name",
    "SYSTEM",
    "Name of system (NDB Cluster)",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
322
    0, 0 },
323 324 325 326 327 328 329 330 331 332
  
  {
    CFG_SYS_REPLICATION_ROLE,
    "ReplicationRole",
    "SYSTEM",
    "Role in Global Replication (None, Primary, or Standby)",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
333
    0, 0 },
334 335 336 337 338
  
  {
    CFG_SYS_PRIMARY_MGM_NODE,
    "PrimaryMGMNode",
    "SYSTEM",
339
    "Node id of Primary "MGM_TOKEN_PRINT" node",
340 341 342
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
343 344
    "0",
    "0",
345
    STR_VALUE(MAX_INT_RNIL) },
346 347 348 349 350 351 352 353 354

  {
    CFG_SYS_CONFIG_GENERATION,
    "ConfigGenerationNumber",
    "SYSTEM",
    "Configuration generation number",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
355 356
    "0",
    "0",
357
    STR_VALUE(MAX_INT_RNIL) },
358 359 360 361 362 363

  /***************************************************************************
   * DB
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
364 365
    DB_TOKEN,
    DB_TOKEN,
366 367 368 369
    "Node section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
370 371
    (const char *)NODE_TYPE_DB, 
    0, 0
372 373 374 375 376
  },

  {
    CFG_NODE_HOST,
    "HostName",
377
    DB_TOKEN,
378 379 380 381 382
    "Name of computer for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
383
    0, 0 },
384 385 386 387

  {
    CFG_NODE_SYSTEM,
    "System",
388
    DB_TOKEN,
389 390 391 392 393
    "Name of system for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
394
    0, 0 },
395 396 397 398

  {
    CFG_NODE_ID,
    "Id",
399
    DB_TOKEN,
400
    "Number identifying the database node ("DB_TOKEN_PRINT")",
401 402 403 404
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
405
    "1",
406
    STR_VALUE(MAX_NODES) },
407

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
408
  {
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
409
    KEY_INTERNAL,
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
410
    "ServerPort",
411
    DB_TOKEN,
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
412 413 414 415
    "Port used to setup transporter",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
416
    UNDEFINED,
417
    "1",
418
    STR_VALUE(MAX_INT_RNIL) },
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
419

420 421 422
  {
    CFG_DB_NO_REPLICAS,
    "NoOfReplicas",
423
    DB_TOKEN,
424 425 426 427 428
    "Number of copies of all data in the database (1-4)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
429 430
    "1",
    "4" },
431 432 433 434

  {
    CFG_DB_NO_ATTRIBUTES,
    "MaxNoOfAttributes",
435
    DB_TOKEN,
436 437 438 439
    "Total number of attributes stored in database. I.e. sum over all tables",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
440 441
    "1000",
    "32",
442
    STR_VALUE(MAX_INT_RNIL) },
443 444 445 446
  
  {
    CFG_DB_NO_TABLES,
    "MaxNoOfTables",
447
    DB_TOKEN,
448 449 450 451
    "Total number of tables stored in the database",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
452 453
    "128",
    "8",
454
    STR_VALUE(MAX_INT_RNIL) },
455
  
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
456 457 458
  {
    CFG_DB_NO_ORDERED_INDEXES,
    "MaxNoOfOrderedIndexes",
459
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
460 461 462 463
    "Total number of ordered indexes that can be defined in the system",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
464 465
    "128",
    "0",
466
    STR_VALUE(MAX_INT_RNIL) },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
467 468 469 470

  {
    CFG_DB_NO_UNIQUE_HASH_INDEXES,
    "MaxNoOfUniqueHashIndexes",
471
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
472 473 474 475
    "Total number of unique hash indexes that can be defined in the system",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
476 477
    "64",
    "0",
478
    STR_VALUE(MAX_INT_RNIL) },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
479

480 481 482
  {
    CFG_DB_NO_INDEXES,
    "MaxNoOfIndexes",
483
    DB_TOKEN,
484
    "Total number of indexes that can be defined in the system",
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
485
    ConfigInfo::DEPRICATED,
486 487
    false,
    ConfigInfo::INT,
488 489
    "128",
    "0",
490
    STR_VALUE(MAX_INT_RNIL) },
491 492 493 494

  {
    CFG_DB_NO_INDEX_OPS,
    "MaxNoOfConcurrentIndexOperations",
495
    DB_TOKEN,
496
    "Total number of index operations that can execute simultaneously on one "DB_TOKEN_PRINT" node",
497 498 499
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
500 501
    "8K",
    "0",
502
    STR_VALUE(MAX_INT_RNIL) 
503 504 505 506 507
   },

  {
    CFG_DB_NO_TRIGGERS,
    "MaxNoOfTriggers",
508
    DB_TOKEN,
509 510 511 512
    "Total number of triggers that can be defined in the system",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
513 514
    "768",
    "0",
515
    STR_VALUE(MAX_INT_RNIL) },
516 517 518 519

  {
    CFG_DB_NO_TRIGGER_OPS,
    "MaxNoOfFiredTriggers",
520
    DB_TOKEN,
521
    "Total number of triggers that can fire simultaneously in one "DB_TOKEN_PRINT" node",
522 523 524
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
525 526
    "4000",
    "0",
527
    STR_VALUE(MAX_INT_RNIL) },
528 529 530 531

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
532
    DB_TOKEN,
533 534 535 536
    "String referencing an earlier defined COMPUTER",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
537 538
    UNDEFINED,
    0, 0 },
539 540 541 542
  
  {
    CFG_DB_NO_SAVE_MSGS,
    "MaxNoOfSavedMessages",
543
    DB_TOKEN,
544 545 546 547
    "Max number of error messages in error log and max number of trace files",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
548 549
    "25",
    "0",
550
    STR_VALUE(MAX_INT_RNIL) },
551 552 553 554

  {
    CFG_DB_MEMLOCK,
    "LockPagesInMainMemory",
555
    DB_TOKEN,
556 557 558 559
    "If set to yes, then NDB Cluster data will not be swapped out to disk",
    ConfigInfo::USED,
    true,
    ConfigInfo::BOOL,
560 561 562
    "false",
    "false",
    "true" },
563 564 565 566

  {
    CFG_DB_WATCHDOG_INTERVAL,
    "TimeBetweenWatchDogCheck",
567
    DB_TOKEN,
568 569 570 571
    "Time between execution checks inside a database node",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
572 573
    "6000",
    "70",
574
    STR_VALUE(MAX_INT_RNIL) },
575 576 577 578

  {
    CFG_DB_STOP_ON_ERROR,
    "StopOnError",
579
    DB_TOKEN,
580
    "If set to N, "DB_TOKEN_PRINT" automatically restarts/recovers in case of node failure",
581 582 583
    ConfigInfo::USED,
    true,
    ConfigInfo::BOOL,
584 585 586
    "true",
    "false",
    "true" },
587 588 589 590

  { 
    CFG_DB_STOP_ON_ERROR_INSERT,
    "RestartOnErrorInsert",
591
    DB_TOKEN,
592 593 594 595
    "See src/kernel/vm/Emulator.hpp NdbRestartType for details",
    ConfigInfo::INTERNAL,
    true,
    ConfigInfo::INT,
596 597 598
    "2",
    "0",
    "4" },
599 600 601 602
  
  {
    CFG_DB_NO_OPS,
    "MaxNoOfConcurrentOperations",
603
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
604
    "Max number of operation records in transaction coordinator",
605 606 607
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
608
    "32k",
609
    "32",
610
    STR_VALUE(MAX_INT_RNIL) },
611

mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
612 613 614
  {
    CFG_DB_NO_LOCAL_OPS,
    "MaxNoOfLocalOperations",
615
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
616 617 618 619
    "Max number of operation records defined in the local storage node",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
620 621
    UNDEFINED,
    "32",
622
    STR_VALUE(MAX_INT_RNIL) },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
623 624 625 626

  {
    CFG_DB_NO_LOCAL_SCANS,
    "MaxNoOfLocalScans",
627
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
628 629 630 631
    "Max number of fragment scans in parallel in the local storage node",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
632 633
    UNDEFINED,
    "32",
634
    STR_VALUE(MAX_INT_RNIL) },
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
635 636 637 638

  {
    CFG_DB_BATCH_SIZE,
    "BatchSizePerLocalScan",
639
    DB_TOKEN,
mronstrom@mysql.com's avatar
mronstrom@mysql.com committed
640 641 642 643
    "Used to calculate the number of lock records for scan with hold lock",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
joreland@mysql.com's avatar
merge  
joreland@mysql.com committed
644
    STR_VALUE(DEF_BATCH_SIZE),
645
    "1",
joreland@mysql.com's avatar
merge  
joreland@mysql.com committed
646
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
647 648 649 650

  {
    CFG_DB_NO_TRANSACTIONS,
    "MaxNoOfConcurrentTransactions",
651
    DB_TOKEN,
652
    "Max number of transaction executing concurrently on the "DB_TOKEN_PRINT" node",
653 654 655
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
656 657
    "4096",
    "32",
658
    STR_VALUE(MAX_INT_RNIL) },
659 660 661 662

  {
    CFG_DB_NO_SCANS,
    "MaxNoOfConcurrentScans",
663
    DB_TOKEN,
664
    "Max number of scans executing concurrently on the "DB_TOKEN_PRINT" node",
665 666 667
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
668 669 670
    "256",
    "2",
    "500" },
671 672 673 674

  {
    CFG_DB_TRANS_BUFFER_MEM,
    "TransactionBufferMemory",
675
    DB_TOKEN,
676
    "Dynamic buffer space (in bytes) for key and attribute data allocated for each "DB_TOKEN_PRINT" node",
677 678 679
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
680 681
    "1M",
    "1K",
682
    STR_VALUE(MAX_INT_RNIL) },
683 684 685 686
 
  {
    CFG_DB_INDEX_MEM,
    "IndexMemory",
687
    DB_TOKEN,
688
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing indexes",
689 690 691
    ConfigInfo::USED,
    false,
    ConfigInfo::INT64,
692 693 694
    "18M",
    "1M",
    "1024G" },
695 696 697 698

  {
    CFG_DB_DATA_MEM,
    "DataMemory",
699
    DB_TOKEN,
700
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing data",
701 702 703
    ConfigInfo::USED,
    false,
    ConfigInfo::INT64,
704 705 706
    "80M",
    "1M",
    "1024G" },
707

708 709 710
  {
    CFG_DB_UNDO_INDEX_BUFFER,
    "UndoIndexBuffer",
711
    DB_TOKEN,
712
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for index part",
713 714 715
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
716 717
    "2M",
    "1M",
718
    STR_VALUE(MAX_INT_RNIL)},
719 720 721 722

  {
    CFG_DB_UNDO_DATA_BUFFER,
    "UndoDataBuffer",
723
    DB_TOKEN,
724
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for data part",
725 726 727
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
728 729
    "16M",
    "1M",
730
    STR_VALUE(MAX_INT_RNIL)},
731 732 733 734

  {
    CFG_DB_REDO_BUFFER,
    "RedoBuffer",
735
    DB_TOKEN,
736
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing REDO logs",
737 738 739
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
740 741
    "8M",
    "1M",
742
    STR_VALUE(MAX_INT_RNIL)},
743

744 745 746
  {
    CFG_DB_LONG_SIGNAL_BUFFER,
    "LongMessageBuffer",
747
    DB_TOKEN,
748
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for internal long messages",
749 750 751
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
752 753
    "1M",
    "512k",
754
    STR_VALUE(MAX_INT_RNIL)},
755

756 757 758
  {
    CFG_DB_START_PARTIAL_TIMEOUT,
    "StartPartialTimeout",
759
    DB_TOKEN,
760 761 762 763
    "Time to wait before trying to start wo/ all nodes. 0=Wait forever",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
764 765
    "30000",
    "0",
766
    STR_VALUE(MAX_INT_RNIL) },
767 768 769 770

  {
    CFG_DB_START_PARTITION_TIMEOUT,
    "StartPartitionedTimeout",
771
    DB_TOKEN,
772 773 774 775
    "Time to wait before trying to start partitioned. 0=Wait forever",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
776 777
    "60000",
    "0",
778
    STR_VALUE(MAX_INT_RNIL) },
779 780 781 782
  
  {
    CFG_DB_START_FAILURE_TIMEOUT,
    "StartFailureTimeout",
783
    DB_TOKEN,
784 785 786 787
    "Time to wait before terminating. 0=Wait forever",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
788 789
    "0",
    "0",
790
    STR_VALUE(MAX_INT_RNIL) },
791 792 793 794
  
  {
    CFG_DB_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalDbDb",
795
    DB_TOKEN,
796
    "Time between "DB_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "DB_TOKEN_PRINT" considered dead after 3 missed HBs",
797 798 799
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
800 801
    "1500",
    "10",
802
    STR_VALUE(MAX_INT_RNIL) },
803 804 805 806

  {
    CFG_DB_API_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalDbApi",
807
    DB_TOKEN,
808
    "Time between "API_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "API_TOKEN_PRINT" connection closed after 3 missed HBs",
809 810 811
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
812 813
    "1500",
    "100",
814
    STR_VALUE(MAX_INT_RNIL) },
815 816 817 818

  {
    CFG_DB_LCP_INTERVAL,
    "TimeBetweenLocalCheckpoints",
819
    DB_TOKEN,
820 821 822 823
    "Time between taking snapshots of the database (expressed in 2log of bytes)",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
824 825 826
    "20",
    "0",
    "31" },
827 828 829 830

  {
    CFG_DB_GCP_INTERVAL,
    "TimeBetweenGlobalCheckpoints",
831
    DB_TOKEN,
832 833 834 835
    "Time between doing group commit of transactions to disk",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
836 837 838
    "2000",
    "10",
    "32000" },
839 840 841 842

  {
    CFG_DB_NO_REDOLOG_FILES,
    "NoOfFragmentLogFiles",
843
    DB_TOKEN,
844
    "No of 16 Mbyte Redo log files in each of 4 file sets belonging to "DB_TOKEN_PRINT" node",
845 846 847
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
848 849
    "8",
    "1",
850
    STR_VALUE(MAX_INT_RNIL) },
851 852 853 854

  {
    KEY_INTERNAL,
    "MaxNoOfOpenFiles",
855
    DB_TOKEN,
856
    "Max number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)",
857 858 859
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
860 861 862
    "40",
    "20",
    "256" },
863 864 865 866 867

  
  {
    CFG_DB_TRANSACTION_CHECK_INTERVAL,
    "TimeBetweenInactiveTransactionAbortCheck",
868
    DB_TOKEN,
869 870 871 872
    "Time between inactive transaction checks",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
873 874
    "1000",
    "1000",
875
    STR_VALUE(MAX_INT_RNIL) },
876 877 878 879
  
  {
    CFG_DB_TRANSACTION_INACTIVE_TIMEOUT,
    "TransactionInactiveTimeout",
880
    DB_TOKEN,
881 882 883 884 885 886 887 888
    "Time application can wait before executing another transaction part (ms).\n"
    "This is the time the transaction coordinator waits for the application\n"
    "to execute or send another part (query, statement) of the transaction.\n"
    "If the application takes too long time, the transaction gets aborted.\n"
    "Timeout set to 0 means that we don't timeout at all on application wait.",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
889
    STR_VALUE(MAX_INT_RNIL),
890
    "0",
891
    STR_VALUE(MAX_INT_RNIL) },
892 893 894 895

  {
    CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
    "TransactionDeadlockDetectionTimeout",
896
    DB_TOKEN,
897 898 899 900 901 902 903
    "Time transaction can be executing in a DB node (ms).\n"
    "This is the time the transaction coordinator waits for each database node\n"
    "of the transaction to execute a request. If the database node takes too\n"
    "long time, the transaction gets aborted.",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
904 905
    "1200",
    "50",
906
    STR_VALUE(MAX_INT_RNIL) },
907 908 909 910

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskDuringRestartTUP",
911
    DB_TOKEN,
912 913 914 915
    "?",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
916 917
    "40",
    "1",
918
    STR_VALUE(MAX_INT_RNIL) },
919 920 921 922

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskAfterRestartTUP",
923
    DB_TOKEN,
924 925 926 927
    "?",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
928 929
    "40",
    "1",
930
    STR_VALUE(MAX_INT_RNIL) },
931 932 933 934

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskDuringRestartACC",
935
    DB_TOKEN,
936 937 938 939
    "?",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
940 941
    "20",
    "1",
942
    STR_VALUE(MAX_INT_RNIL) },
943 944 945 946

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskAfterRestartACC",
947
    DB_TOKEN,
948 949 950 951
    "?",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
952 953
    "20",
    "1",
954
    STR_VALUE(MAX_INT_RNIL) },
955
  
956 957 958

  {
    CFG_DB_DISCLESS,
magnus@neptunus.(none)'s avatar
magnus@neptunus.(none) committed
959
    "Diskless",
960
    DB_TOKEN,
961 962 963 964
    "Run wo/ disk",
    ConfigInfo::USED,
    true,
    ConfigInfo::BOOL,
965 966 967
    "false",
    "false",
    "true"},
968 969

  {
970
    KEY_INTERNAL,
971
    "Discless",
972
    DB_TOKEN,
973 974 975 976
    "Diskless",
    ConfigInfo::DEPRICATED,
    true,
    ConfigInfo::BOOL,
977 978 979
    "false",
    "false",
    "true"},
980 981
  

982
  
983 984 985
  {
    CFG_DB_ARBIT_TIMEOUT,
    "ArbitrationTimeout",
986
    DB_TOKEN,
987 988 989 990
    "Max time (milliseconds) database partion waits for arbitration signal",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
991 992
    "3000",
    "10",
993
    STR_VALUE(MAX_INT_RNIL) },
994

995 996 997 998 999 1000 1001 1002
  {
    CFG_NODE_DATADIR,
    "DataDir",
    DB_TOKEN,
    "Data directory for this node",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
tomas@poseidon.(none)'s avatar
tomas@poseidon.(none) committed
1003
    MYSQLCLUSTERDIR,
1004 1005
    0, 0 },

1006 1007 1008
  {
    CFG_DB_FILESYSTEM_PATH,
    "FileSystemPath",
1009
    DB_TOKEN,
1010
    "Path to directory where the "DB_TOKEN_PRINT" node stores its data (directory must exist)",
1011 1012 1013
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
1014
    UNDEFINED,
1015
    0, 0 },
1016 1017 1018 1019

  {
    CFG_LOGLEVEL_STARTUP,
    "LogLevelStartup",
1020
    DB_TOKEN,
1021 1022 1023 1024
    "Node startup info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1025 1026 1027
    "1",
    "0",
    "15" },
1028 1029 1030 1031
  
  {
    CFG_LOGLEVEL_SHUTDOWN,
    "LogLevelShutdown",
1032
    DB_TOKEN,
1033 1034 1035 1036
    "Node shutdown info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1037 1038 1039
    "0",
    "0",
    "15" },
1040 1041 1042 1043

  {
    CFG_LOGLEVEL_STATISTICS,
    "LogLevelStatistic",
1044
    DB_TOKEN,
1045 1046 1047 1048
    "Transaction, operation, transporter info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1049 1050 1051
    "0",
    "0",
    "15" },
1052 1053 1054 1055

  {
    CFG_LOGLEVEL_CHECKPOINT,
    "LogLevelCheckpoint",
1056
    DB_TOKEN,
1057 1058 1059 1060
    "Local and Global checkpoint info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1061 1062 1063
    "0",
    "0",
    "15" },
1064 1065 1066 1067

  {
    CFG_LOGLEVEL_NODERESTART,
    "LogLevelNodeRestart",
1068
    DB_TOKEN,
1069 1070 1071 1072
    "Node restart, node failure info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1073 1074 1075
    "0",
    "0",
    "15" },
1076 1077 1078 1079

  {
    CFG_LOGLEVEL_CONNECTION,
    "LogLevelConnection",
1080
    DB_TOKEN,
1081 1082 1083 1084
    "Node connect/disconnect info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1085 1086 1087
    "0",
    "0",
    "15" },
1088 1089 1090 1091

  {
    CFG_LOGLEVEL_ERROR,
    "LogLevelError",
1092
    DB_TOKEN,
1093 1094 1095 1096
    "Transporter, heartbeat errors printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1097 1098 1099
    "0",
    "0",
    "15" },
1100 1101 1102 1103

  {
    CFG_LOGLEVEL_INFO,
    "LogLevelInfo",
1104
    DB_TOKEN,
1105 1106 1107 1108
    "Heartbeat and log info printed on stdout",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1109 1110 1111
    "0",
    "0",
    "15" },
1112 1113 1114 1115 1116 1117 1118

  /**
   * Backup
   */
  { 
    CFG_DB_PARALLEL_BACKUPS,
    "ParallelBackups",
1119
    DB_TOKEN,
1120 1121 1122 1123
    "Maximum number of parallel backups",
    ConfigInfo::NOTIMPLEMENTED,
    false,
    ConfigInfo::INT,
1124 1125 1126
    "1",
    "1",
    "1" },
1127
  
1128
  { 
1129 1130
    CFG_DB_BACKUP_DATADIR,
    "BackupDataDir",
1131 1132 1133 1134 1135 1136 1137 1138
    DB_TOKEN,
    "Path to where to store backups",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
    0, 0 },
  
1139 1140 1141
  { 
    CFG_DB_BACKUP_MEM,
    "BackupMemory",
1142
    DB_TOKEN,
1143 1144 1145 1146
    "Total memory allocated for backups per node (in bytes)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1147 1148
    "4M", // sum of BackupDataBufferSize and BackupLogBufferSize
    "0",
1149
    STR_VALUE(MAX_INT_RNIL) },
1150 1151 1152 1153
  
  { 
    CFG_DB_BACKUP_DATA_BUFFER_MEM,
    "BackupDataBufferSize",
1154
    DB_TOKEN,
1155 1156 1157 1158
    "Default size of databuffer for a backup (in bytes)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1159 1160
    "2M", // remember to change BackupMemory
    "0",
1161
    STR_VALUE(MAX_INT_RNIL) },
1162 1163 1164 1165

  { 
    CFG_DB_BACKUP_LOG_BUFFER_MEM,
    "BackupLogBufferSize",
1166
    DB_TOKEN,
1167 1168 1169 1170
    "Default size of logbuffer for a backup (in bytes)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1171 1172
    "2M", // remember to change BackupMemory
    "0",
1173
    STR_VALUE(MAX_INT_RNIL) },
1174 1175 1176 1177

  { 
    CFG_DB_BACKUP_WRITE_SIZE,
    "BackupWriteSize",
1178
    DB_TOKEN,
1179 1180 1181 1182
    "Default size of filesystem writes made by backup (in bytes)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1183 1184
    "32K",
    "0",
1185
    STR_VALUE(MAX_INT_RNIL) },
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197

  /***************************************************************************
   * REP
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
    "REP",
    "REP",
    "Node section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1198 1199
    (const char *)NODE_TYPE_REP, 
    0, 0
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
  },

  {
    CFG_NODE_HOST,
    "HostName",
    "REP",
    "Name of computer for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1211
    0, 0 },
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221

  {
    CFG_NODE_SYSTEM,
    "System",
    "REP",
    "Name of system for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1222
    0, 0 },
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232

  {
    CFG_NODE_ID,
    "Id",
    "REP",
    "Number identifying replication node (REP)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1233
    "1",
1234
    STR_VALUE(MAX_NODES) },
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
    "REP",
    "String referencing an earlier defined COMPUTER",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
1245
    0, 0 },
1246 1247 1248 1249 1250 1251 1252 1253 1254

  {
    CFG_REP_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalRepRep",
    "REP",
    "Time between REP-REP heartbeats. Connection closed after 3 missed HBs",
    ConfigInfo::USED,
    true,
    ConfigInfo::INT,
1255 1256
    "3000",
    "100",
1257
    STR_VALUE(MAX_INT_RNIL) },
1258 1259 1260 1261 1262 1263

  /***************************************************************************
   * API
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1264 1265
    API_TOKEN,
    API_TOKEN,
1266 1267 1268 1269
    "Node section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1270 1271
    (const char *)NODE_TYPE_API, 
    0, 0
1272 1273 1274 1275 1276
  },

  {
    CFG_NODE_HOST,
    "HostName",
1277
    API_TOKEN,
1278 1279 1280 1281 1282
    "Name of computer for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1283
    0, 0 },
1284 1285 1286 1287

  {
    CFG_NODE_SYSTEM,
    "System",
1288
    API_TOKEN,
1289 1290 1291 1292 1293
    "Name of system for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1294
    0, 0 },
1295 1296 1297 1298

  {
    CFG_NODE_ID,
    "Id",
1299
    API_TOKEN,
1300
    "Number identifying application node ("API_TOKEN_PRINT")",
1301 1302 1303 1304
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1305
    "1",
1306
    STR_VALUE(MAX_NODES) },
1307 1308 1309 1310

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1311
    API_TOKEN,
1312 1313 1314 1315
    "String referencing an earlier defined COMPUTER",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
1316 1317
    UNDEFINED,
    0, 0 },
1318 1319 1320 1321

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1322
    API_TOKEN,
1323
    "If 0, then "API_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
1324 1325 1326
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1327 1328 1329
    "0",
    "0",
    "2" },
1330 1331 1332 1333

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1334
    API_TOKEN,
1335 1336 1337 1338
    "When asked to arbitrate, arbitrator waits this long before voting (msec)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1339 1340
    "0",
    "0",
1341
    STR_VALUE(MAX_INT_RNIL) },
1342

1343 1344 1345 1346 1347 1348 1349 1350
  {
    CFG_MAX_SCAN_BATCH_SIZE,
    "MaxScanBatchSize",
    "API",
    "The maximum collective batch size for one scan",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1351 1352 1353 1354
    STR_VALUE(MAX_SCAN_BATCH_SIZE),
    "32k",
    "16M" },
  
1355 1356 1357 1358 1359 1360 1361 1362
  {
    CFG_BATCH_BYTE_SIZE,
    "BatchByteSize",
    "API",
    "The default batch size in bytes",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1363 1364 1365
    STR_VALUE(SCAN_BATCH_SIZE),
    "1k",
    "1M" },
1366 1367 1368 1369 1370 1371 1372 1373 1374

  {
    CFG_BATCH_SIZE,
    "BatchSize",
    "API",
    "The default batch size in number of records",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1375 1376 1377
    STR_VALUE(DEF_BATCH_SIZE),
    "1",
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
1378

1379 1380 1381 1382 1383
  /****************************************************************************
   * MGM
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1384 1385
    MGM_TOKEN,
    MGM_TOKEN,
1386 1387 1388 1389
    "Node section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1390 1391
    (const char *)NODE_TYPE_MGM, 
    0, 0
1392 1393 1394 1395 1396
  },

  {
    CFG_NODE_HOST,
    "HostName",
1397
    MGM_TOKEN,
1398 1399 1400 1401 1402
    "Name of computer for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1403
    0, 0 },
1404

1405 1406 1407 1408 1409 1410 1411 1412
  {
    CFG_NODE_DATADIR,
    "DataDir",
    MGM_TOKEN,
    "Data directory for this node",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
tomas@poseidon.(none)'s avatar
tomas@poseidon.(none) committed
1413
    MYSQLCLUSTERDIR,
1414 1415
    0, 0 },

1416 1417 1418
  {
    CFG_NODE_SYSTEM,
    "System",
1419
    MGM_TOKEN,
1420 1421 1422 1423 1424
    "Name of system for this node",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1425
    0, 0 },
1426 1427 1428 1429

  {
    CFG_NODE_ID,
    "Id",
1430
    MGM_TOKEN,
1431
    "Number identifying the management server node ("MGM_TOKEN_PRINT")",
1432 1433 1434 1435
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1436
    "1",
1437
    STR_VALUE(MAX_NODES) },
1438 1439 1440 1441
  
  {
    CFG_LOG_DESTINATION,
    "LogDestination",
1442
    MGM_TOKEN,
1443 1444 1445 1446 1447
    "String describing where logmessages are sent",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    0,
1448
    0, 0 },
1449 1450 1451 1452
  
  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1453
    MGM_TOKEN,
1454 1455 1456 1457
    "String referencing an earlier defined COMPUTER",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
1458
    0,
1459 1460
    0, 0 },

1461 1462 1463
  {
    KEY_INTERNAL,
    "MaxNoOfSavedEvents",
1464
    MGM_TOKEN,
1465 1466 1467 1468
    "",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1469 1470
    "100",
    "0",
1471
    STR_VALUE(MAX_INT_RNIL) },
1472 1473 1474 1475

  {
    CFG_MGM_PORT,
    "PortNumber",
1476
    MGM_TOKEN,
1477 1478 1479 1480
    "Port number to give commands to/fetch configurations from management server",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1481
    NDB_BASE_PORT,
1482
    "0",
1483
    STR_VALUE(MAX_INT_RNIL) },
1484 1485 1486 1487

  {
    KEY_INTERNAL,
    "PortNumberStats",
1488
    MGM_TOKEN,
1489 1490 1491 1492
    "Port number used to get statistical information from a management server",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1493 1494
    "2199",
    "0",
1495
    STR_VALUE(MAX_INT_RNIL) },
1496 1497 1498 1499

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1500
    MGM_TOKEN,
1501
    "If 0, then "MGM_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
1502 1503 1504
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1505 1506 1507
    "1",
    "0",
    "2" },
1508 1509 1510 1511

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1512
    MGM_TOKEN,
1513 1514 1515 1516
    "",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1517 1518
    "0",
    "0",
1519
    STR_VALUE(MAX_INT_RNIL) },
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531

  /****************************************************************************
   * TCP
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "TCP",
    "TCP",
    "Connection section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1532 1533
    (const char *)CONNECTION_TYPE_TCP, 
    0, 0
1534 1535 1536
  },

  {
1537
    CFG_CONNECTION_HOSTNAME_1,
1538 1539 1540 1541 1542 1543 1544
    "HostName1",
    "TCP",
    "Name/IP of computer on one side of the connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1545
    0, 0 },
1546 1547

  {
1548
    CFG_CONNECTION_HOSTNAME_2,
1549 1550 1551 1552 1553 1554 1555
    "HostName2",
    "TCP",
    "Name/IP of computer on one side of the connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1556
    0, 0 },
1557 1558 1559 1560 1561

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "TCP",
1562
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1563 1564 1565 1566
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
1567
    0, 0 },
1568 1569 1570 1571 1572

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "TCP",
1573
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1574 1575 1576 1577
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
1578
    0, 0 },
1579 1580 1581 1582 1583 1584 1585 1586 1587

  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "TCP",
    "Sends id in each signal.  Used in trace files.",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1588 1589 1590
    "true",
    "false",
    "true" },
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600


  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "TCP",
    "If checksum is enabled, all signals between nodes are checked for errors",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1601 1602 1603
    "false",
    "false",
    "true" },
1604 1605

  {
1606
    CFG_CONNECTION_SERVER_PORT,
1607 1608 1609 1610 1611 1612
    "PortNumber",
    "TCP",
    "Port used for this transporter",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1613
    MANDATORY,
1614
    "0",
1615
    STR_VALUE(MAX_INT_RNIL) },
1616 1617 1618 1619 1620 1621 1622 1623 1624

  {
    CFG_TCP_SEND_BUFFER_SIZE,
    "SendBufferMemory",
    "TCP",
    "Bytes of buffer for signals sent from this node",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1625 1626
    "256K",
    "16K",
1627
    STR_VALUE(MAX_INT_RNIL) },
1628 1629 1630 1631 1632 1633 1634 1635 1636

  {
    CFG_TCP_RECEIVE_BUFFER_SIZE,
    "ReceiveBufferMemory",
    "TCP",
    "Bytes of buffer for signals received by this node",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1637 1638
    "64K",
    "16K",
1639
    STR_VALUE(MAX_INT_RNIL) },
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649

  {
    CFG_TCP_PROXY,
    "Proxy",
    "TCP",
    "",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1650
    0, 0 },
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "TCP",
    "System for node 1 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1661
    0, 0 },
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "TCP",
    "System for node 2 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1672
    0, 0 },
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685
  

  /****************************************************************************
   * SHM
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SHM",
    "SHM",
    "Connection section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1686 1687
    (const char *)CONNECTION_TYPE_SHM, 
    0, 0 },
1688 1689 1690 1691 1692

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SHM",
1693
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1694 1695 1696 1697
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
1698
    0, 0 },
1699
  
1700 1701 1702 1703 1704 1705 1706 1707 1708
  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
    "SHM",
    "Port used for this transporter",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1709
    "0", 
1710
    STR_VALUE(MAX_INT_RNIL) },
1711

1712 1713 1714 1715
  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SHM",
1716
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1717 1718 1719 1720
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    MANDATORY,
1721
    0, 0 },
1722 1723 1724 1725 1726 1727 1728 1729 1730
  
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SHM",
    "Sends id in each signal.  Used in trace files.",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1731 1732 1733
    "false",
    "false",
    "true" },
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
  
  
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SHM",
    "If checksum is enabled, all signals between nodes are checked for errors",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1744 1745 1746
    "true",
    "false",
    "true" },
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756
  
  {
    CFG_SHM_KEY,
    "ShmKey",
    "SHM",
    "A shared memory key",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1757
    "0",
1758
    STR_VALUE(MAX_INT_RNIL) },
1759 1760 1761 1762 1763 1764 1765 1766 1767
  
  {
    CFG_SHM_BUFFER_MEM,
    "ShmSize",
    "SHM",
    "Size of shared memory segment",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1768 1769
    "1M",
    "4K",
1770
    STR_VALUE(MAX_INT_RNIL) },
1771

1772 1773 1774 1775 1776 1777 1778 1779 1780
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SHM",
    "System for node 1 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1781
    0, 0 },
1782 1783 1784 1785 1786 1787 1788 1789 1790 1791

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SHM",
    "System for node 2 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1792
    0, 0 },
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804

  /****************************************************************************
   * SCI
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SCI",
    "SCI",
    "Connection section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1805
    (const char *)CONNECTION_TYPE_SCI, 
1806 1807 1808 1809 1810 1811 1812
    0, 0 
  },

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SCI",
1813
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1814 1815
    ConfigInfo::USED,
    false,
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1816
    ConfigInfo::STRING,
1817
    MANDATORY,
1818
    "0",
1819
    STR_VALUE(MAX_INT_RNIL) },
1820 1821 1822 1823 1824

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SCI",
1825
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
1826 1827
    ConfigInfo::USED,
    false,
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1828
    ConfigInfo::STRING,
1829
    MANDATORY,
1830
    "0",
1831
    STR_VALUE(MAX_INT_RNIL) },
1832 1833

  {
1834
    CFG_CONNECTION_HOSTNAME_1,
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1835 1836 1837 1838 1839 1840 1841 1842 1843 1844
    "HostName1",
    "SCI",
    "Name/IP of computer on one side of the connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
    0, 0 },

  {
1845
    CFG_CONNECTION_HOSTNAME_2,
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
    "HostName2",
    "SCI",
    "Name/IP of computer on one side of the connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
    0, 0 },

  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
1858
    "SCI",
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1859
    "Port used for this transporter",
1860 1861 1862 1863
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
    "0", 
    STR_VALUE(MAX_INT_RNIL) },

  {
    CFG_SCI_HOST1_ID_0,
    "Host1SciId0",
    "SCI",
    "SCI-node id for adapter 0 on Host1 (a computer can have two adapters)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
    "0",
    STR_VALUE(MAX_INT_RNIL) },

  {
    CFG_SCI_HOST1_ID_1,
    "Host1SciId1",
    "SCI",
    "SCI-node id for adapter 1 on Host1 (a computer can have two adapters)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    "0",
1888
    "0",
1889
    STR_VALUE(MAX_INT_RNIL) },
1890 1891

  {
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1892 1893
    CFG_SCI_HOST2_ID_0,
    "Host2SciId0",
1894
    "SCI",
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1895
    "SCI-node id for adapter 0 on Host2 (a computer can have two adapters)",
1896 1897 1898 1899
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    MANDATORY,
1900
    "0",
1901
    STR_VALUE(MAX_INT_RNIL) },
1902

mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914
  {
    CFG_SCI_HOST2_ID_1,
    "Host2SciId1",
    "SCI",
    "SCI-node id for adapter 1 on Host2 (a computer can have two adapters)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },

1915 1916 1917 1918 1919 1920 1921 1922
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SCI",
    "Sends id in each signal.  Used in trace files.",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1923 1924 1925
    "true",
    "false",
    "true" },
1926 1927 1928 1929 1930 1931 1932 1933 1934

  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SCI",
    "If checksum is enabled, all signals between nodes are checked for errors",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
1935 1936 1937
    "false",
    "false",
    "true" },
1938 1939 1940 1941 1942 1943 1944 1945 1946

  {
    CFG_SCI_SEND_LIMIT,
    "SendLimit",
    "SCI",
    "Transporter send buffer contents are sent when this no of bytes is buffered",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1947
    "8K",
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1948 1949
    "128",
    "32K" },
1950 1951 1952 1953 1954 1955 1956 1957 1958

  {
    CFG_SCI_BUFFER_MEM,
    "SharedBufferSize",
    "SCI",
    "Size of shared memory segment",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
1959
    "1M",
mikael@mc04.(none)'s avatar
mikael@mc04.(none) committed
1960
    "64K",
1961
    STR_VALUE(MAX_INT_RNIL) },
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SCI",
    "System for node 1 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1972
    0, 0 },
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SCI",
    "System for node 2 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
1983
    0, 0 },
1984 1985

  /****************************************************************************
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
   * OSE
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "OSE",
    "OSE",
    "Connection section",
    ConfigInfo::USED,
    false,
    ConfigInfo::SECTION,
1996
    (const char *)CONNECTION_TYPE_OSE, 
1997
    0, 0 
1998 1999
  },

2000
  {
2001
    CFG_CONNECTION_HOSTNAME_1,
2002 2003 2004 2005 2006 2007 2008
    "HostName1",
    "OSE",
    "Name of computer on one side of the connection",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
2009
    0, 0 },
2010 2011

  {
2012
    CFG_CONNECTION_HOSTNAME_2,
2013 2014 2015 2016 2017 2018 2019
    "HostName2",
    "OSE",
    "Name of computer on one side of the connection",
    ConfigInfo::USED,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
2020
    0, 0 },
2021 2022 2023 2024 2025

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "OSE",
2026
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
2027 2028 2029
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
2030
    MANDATORY,
2031
    "0",
2032
    STR_VALUE(MAX_INT_RNIL) },
2033 2034 2035 2036 2037

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "OSE",
2038
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
2039 2040 2041
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
2042
    UNDEFINED,
2043
    "0",
2044
    STR_VALUE(MAX_INT_RNIL) },
2045

2046 2047 2048 2049 2050
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "OSE",
    "Sends id in each signal.  Used in trace files.",
2051 2052
    ConfigInfo::USED,
    false,
2053
    ConfigInfo::BOOL,
2054 2055 2056
    "true",
    "false",
    "true" },
2057

2058 2059 2060 2061 2062 2063 2064 2065
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "OSE",
    "If checksum is enabled, all signals between nodes are checked for errors",
    ConfigInfo::USED,
    false,
    ConfigInfo::BOOL,
2066 2067 2068
    "false",
    "false",
    "true" },
2069 2070 2071 2072 2073 2074

  {
    CFG_OSE_PRIO_A_SIZE,
    "PrioASignalSize",
    "OSE",
    "Size of priority A signals (in bytes)",
2075 2076 2077
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
2078 2079
    "1000",
    "0",
2080
    STR_VALUE(MAX_INT_RNIL) },
2081

2082 2083 2084 2085 2086 2087 2088 2089
  {
    CFG_OSE_PRIO_B_SIZE,
    "PrioBSignalSize",
    "OSE",
    "Size of priority B signals (in bytes)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
2090 2091
    "1000",
    "0",
2092
    STR_VALUE(MAX_INT_RNIL) },
2093 2094 2095 2096 2097 2098 2099 2100 2101
  
  {
    CFG_OSE_RECEIVE_ARRAY_SIZE,
    "ReceiveArraySize",
    "OSE",
    "Number of OSE signals checked for correct ordering (in no of OSE signals)",
    ConfigInfo::USED,
    false,
    ConfigInfo::INT,
2102 2103
    "10",
    "0",
2104
    STR_VALUE(MAX_INT_RNIL) },
2105

2106 2107 2108 2109 2110 2111 2112 2113 2114
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "OSE",
    "System for node 1 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
2115
    0, 0 },
2116

2117 2118 2119 2120 2121 2122 2123 2124 2125
  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "OSE",
    "System for node 2 in connection",
    ConfigInfo::INTERNAL,
    false,
    ConfigInfo::STRING,
    UNDEFINED,
2126
    0, 0 },
2127 2128 2129 2130 2131 2132 2133 2134
};

const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo);


/****************************************************************************
 * Ctor
 ****************************************************************************/
2135
static void require(bool v) { if(!v) abort();}
2136

2137 2138 2139
ConfigInfo::ConfigInfo()
  : m_info(true), m_systemDefaults(true)
{
2140
  int i;
2141 2142 2143
  Properties *section;
  const Properties *oldpinfo;

2144
  for (i=0; i<m_NoOfParams; i++) {
2145
    const ParamInfo & param = m_ParamInfo[i];
2146 2147
    Uint64 default_uint64;
    bool   default_bool;
2148 2149 2150
    
    // Create new section if it did not exist
    if (!m_info.getCopy(param._section, &section)) {
2151
      Properties newsection(true);
2152 2153
      m_info.put(param._section, &newsection);
    }
2154
    
2155 2156 2157 2158
    // Get copy of section
    m_info.getCopy(param._section, &section);
    
    // Create pinfo (parameter info) entry 
2159
    Properties pinfo(true); 
2160
    pinfo.put("Id",          param._paramId);
2161 2162 2163 2164 2165
    pinfo.put("Fname",       param._fname);
    pinfo.put("Description", param._description);
    pinfo.put("Updateable",  param._updateable);
    pinfo.put("Type",        param._type);
    pinfo.put("Status",      param._status);
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191

    if(param._default == MANDATORY){
      pinfo.put("Mandatory", (Uint32)1);
    }

    switch (param._type) {
      case BOOL:
      {
	bool tmp_bool;
	require(InitConfigFileParser::convertStringToBool(param._min, tmp_bool));
	pinfo.put64("Min", tmp_bool);
	require(InitConfigFileParser::convertStringToBool(param._max, tmp_bool));
	pinfo.put64("Max", tmp_bool);
	break;
      }
      case INT:
      case INT64:
      {
	Uint64 tmp_uint64;
	require(InitConfigFileParser::convertStringToUint64(param._min, tmp_uint64));
	pinfo.put64("Min", tmp_uint64);
	require(InitConfigFileParser::convertStringToUint64(param._max, tmp_uint64));
	pinfo.put64("Max", tmp_uint64);
	break;
      }
      case SECTION:
joreland@mysql.com's avatar
joreland@mysql.com committed
2192
	pinfo.put("SectionType", (Uint32)UintPtr(param._default));
2193 2194 2195 2196
	break;
      case STRING:
	break;
    }
2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210

    // Check that pinfo is really new
    if (section->get(param._fname, &oldpinfo)) {
      ndbout << "Error: Parameter " << param._fname
	     << " defined twice in section " << param._section
	     << "." << endl;
      exit(-1);
    }
    
    // Add new pinfo to section
    section->put(param._fname, &pinfo);

    // Replace section with modified section
    m_info.put(param._section, section, true);
2211 2212
    
    if(param._type != ConfigInfo::SECTION){
2213 2214
      Properties * p;
      if(!m_systemDefaults.getCopy(param._section, &p)){
2215
	p = new Properties(true);
2216
      }
2217
      if(param._default != UNDEFINED &&
2218
	 param._default != MANDATORY){
2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241
	switch (param._type)
        {
	  case SECTION:
	    break;
	  case STRING:
	    require(p->put(param._fname, param._default));
	    break;
	  case BOOL:
	    {
	      bool tmp_bool;
	      require(InitConfigFileParser::convertStringToBool(param._default, default_bool));
	      require(p->put(param._fname, default_bool));
	      break;
	    }
	  case INT:
	  case INT64:
	    {
	      Uint64 tmp_uint64;
	      require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64));
	      require(p->put(param._fname, default_uint64));
	      break;
	    }
	}
2242 2243 2244 2245 2246
      }
      require(m_systemDefaults.put(param._section, p, true));
      delete p;
    }
  }
2247
  
2248
  for (i=0; i<m_NoOfParams; i++) {
2249
    if(m_ParamInfo[i]._section == NULL){
2250 2251
      ndbout << "Check that each entry has a section failed." << endl;
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname << endl; 
2252 2253 2254
      ndbout << "Edit file " << __FILE__ << "." << endl;
      exit(-1);
    }
2255 2256 2257 2258
    
    if(m_ParamInfo[i]._type == ConfigInfo::SECTION)
      continue;

2259
    const Properties * p = getInfo(m_ParamInfo[i]._section);
2260
    if (!p || !p->contains(m_ParamInfo[i]._fname)) {
2261
      ndbout << "Check that each pname has an fname failed." << endl;
2262
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname 
2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282
	     << "\" does not exist in section \"" 
	     << m_ParamInfo[i]._section << "\"." << endl;
      ndbout << "Edit file " << __FILE__ << "." << endl;
      exit(-1);
    }
  }
}

/****************************************************************************
 * Getters
 ****************************************************************************/
inline void warning(const char * src, const char * arg){
  ndbout << "Illegal call to ConfigInfo::" << src << "() - " << arg << endl;
  abort();
}

const Properties * 
ConfigInfo::getInfo(const char * section) const {
  const Properties * p;
  if(!m_info.get(section, &p)){
2283 2284
    return 0;
    //    warning("getInfo", section);
2285 2286 2287 2288 2289 2290 2291 2292
  }
  return p;
}

const Properties * 
ConfigInfo::getDefaults(const char * section) const {
  const Properties * p;
  if(!m_systemDefaults.get(section, &p)){
2293 2294
    return 0;
    //warning("getDefaults", section);
2295 2296 2297 2298 2299
  }
  return p;
}

static
2300
Uint64
2301 2302
getInfoInt(const Properties * section, 
	   const char* fname, const char * type){
2303
  Uint32 val32;
2304
  const Properties * p;
2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316
  if (section->get(fname, &p) && p->get(type, &val32)) {
    return val32;
  }

  Uint64 val64;
  if(p && p->get(type, &val64)){
    return val64;
  }
  
  section->print();
  if(section->get(fname, &p)){
    p->print();
2317
  }
2318

2319
  warning(type, fname);
2320
  return 0;
2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335
}

static
const char *
getInfoString(const Properties * section, 
	      const char* fname, const char * type){
  const char* val;
  const Properties * p;
  if (section->get(fname, &p) && p->get(type, &val)) {
    return val;
  }
  warning(type, fname);
  return val;
}

2336
Uint64
2337 2338 2339 2340
ConfigInfo::getMax(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Max");
}

2341
Uint64
2342 2343 2344 2345
ConfigInfo::getMin(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Min");
}

2346
Uint64
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359
ConfigInfo::getDefault(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Default");
}

const char*
ConfigInfo::getDescription(const Properties * section, 
			   const char* fname) const {
  return getInfoString(section, fname, "Description");
}

bool
ConfigInfo::isSection(const char * section) const {
  for (int i = 0; i<m_noOfSectionNames; i++) {
2360
    if(!strcasecmp(section, m_sectionNames[i])) return true;
2361 2362 2363 2364
  }
  return false;
}

2365 2366 2367
const char*
ConfigInfo::getAlias(const char * section) const {
  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
2368
    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
2369 2370 2371 2372
      return m_sectionNameAliases[i].name;
  return 0;
}

2373 2374
bool
ConfigInfo::verify(const Properties * section, const char* fname, 
2375
		   Uint64 value) const {
2376
  Uint64 min, max;
2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424

  min = getInfoInt(section, fname, "Min");
  max = getInfoInt(section, fname, "Max");
  if(min > max){
    warning("verify", fname);
  }
  if (value >= min && value <= max)
    return true;
  else 
    return false;
}

ConfigInfo::Type 
ConfigInfo::getType(const Properties * section, const char* fname) const {
  return (ConfigInfo::Type) getInfoInt(section, fname, "Type");
}

ConfigInfo::Status
ConfigInfo::getStatus(const Properties * section, const char* fname) const {
  return (ConfigInfo::Status) getInfoInt(section, fname, "Status");
}

/****************************************************************************
 * Printers
 ****************************************************************************/

void ConfigInfo::print() const {
  Properties::Iterator it(&m_info);
  for (const char* n = it.first(); n != NULL; n = it.next()) {
    print(n);
  }
}

void ConfigInfo::print(const char* section) const {
  ndbout << "****** " << section << " ******" << endl << endl;
  const Properties * sec = getInfo(section);
  Properties::Iterator it(sec);
  for (const char* n = it.first(); n != NULL; n = it.next()) {
    // Skip entries with different F- and P-names
    if (getStatus(sec, n) == ConfigInfo::INTERNAL) continue;
    if (getStatus(sec, n) == ConfigInfo::DEPRICATED) continue;
    if (getStatus(sec, n) == ConfigInfo::NOTIMPLEMENTED) continue;
    print(sec, n);
  }
}

void ConfigInfo::print(const Properties * section, 
		       const char* parameter) const {
2425
  ndbout << parameter;
2426 2427 2428 2429 2430 2431 2432 2433 2434
  //  ndbout << getDescription(section, parameter) << endl;
  switch (getType(section, parameter)) {
  case ConfigInfo::BOOL:
    ndbout << " (Boolean value)" << endl;
    ndbout << getDescription(section, parameter) << endl;
    if (getDefault(section, parameter) == false) {
      ndbout << "Default: N (Legal values: Y, N)" << endl; 
    } else if (getDefault(section, parameter) == true) {
      ndbout << "Default: Y (Legal values: Y, N)" << endl;
2435
    } else if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2436 2437 2438 2439 2440 2441 2442 2443
      ndbout << "MANDATORY (Legal values: Y, N)" << endl;
    } else {
      ndbout << "UNKNOWN" << endl;
    }
    ndbout << endl;
    break;    
    
  case ConfigInfo::INT:
2444
  case ConfigInfo::INT64:
2445 2446
    ndbout << " (Non-negative Integer)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2447
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2448
      ndbout << "MANDATORY (";
2449
    } else if (getDefault(section, parameter) == (UintPtr)UNDEFINED) {
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461
      ndbout << "UNDEFINED (";
    } else {
      ndbout << "Default: " << getDefault(section, parameter) << " (";
    }
    ndbout << "Min: " << getMin(section, parameter) << ", ";
    ndbout << "Max: " << getMax(section, parameter) << ")" << endl;
    ndbout << endl;
    break;
    
  case ConfigInfo::STRING:
    ndbout << " (String)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2462
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2463 2464 2465 2466 2467 2468
      ndbout << "MANDATORY" << endl;
    } else {
      ndbout << "No default value" << endl;
    }
    ndbout << endl;
    break;
2469 2470
  case ConfigInfo::SECTION:
    break;
2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485
  }
}

/****************************************************************************
 * Section Rules
 ****************************************************************************/

/**
 * Node rule: Add "Type" and update "NoOfNodes"
 */
bool
transformNode(InitConfigFileParser::Context & ctx, const char * data){

  Uint32 id;
  if(!ctx.m_currentSection->get("Id", &id)){
2486 2487 2488 2489 2490 2491 2492 2493
    Uint32 nextNodeId= 1;
    ctx.m_userProperties.get("NextNodeId", &nextNodeId);
    id= nextNodeId;
    while (ctx.m_userProperties.get("AllocatedNodeId_", id, &id))
      id++;
    ctx.m_userProperties.put("NextNodeId", id+1, true);
    ctx.m_currentSection->put("Id", id);
#if 0
2494 2495 2496 2497
    ctx.reportError("Mandatory parameter Id missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
2498 2499 2500 2501 2502 2503
#endif
  } else if(ctx.m_userProperties.get("AllocatedNodeId_", id, &id)) {
    ctx.reportError("Duplicate Id in section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
2504
  }
2505 2506

  ctx.m_userProperties.put("AllocatedNodeId_", id, id);
2507
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
2508 2509 2510 2511 2512 2513 2514
  
  ctx.m_currentSection->put("Type", ctx.fname);

  Uint32 nodes = 0;
  ctx.m_userProperties.get("NoOfNodes", &nodes);
  ctx.m_userProperties.put("NoOfNodes", ++nodes, true);

joreland@mysql.com's avatar
joreland@mysql.com committed
2515 2516 2517 2518 2519 2520 2521
  /**
   * Update count (per type)
   */
  nodes = 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  ctx.m_userProperties.put(ctx.fname, ++nodes, true);

2522 2523 2524
  return true;
}

2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552
static bool checkLocalhostHostnameMix(InitConfigFileParser::Context & ctx)
{
  DBUG_ENTER("checkLocalhostHostnameMix");
  const char * hostname= 0;
  ctx.m_currentSection->get("HostName", &hostname);
  if (hostname == 0 || hostname[0] == 0)
    DBUG_RETURN(true);

  Uint32 localhost_used= 0;
  if(!strcmp(hostname, "localhost") || !strcmp(hostname, "127.0.0.1")){
    localhost_used= 1;
    ctx.m_userProperties.put("$computer-localhost-used", localhost_used);
    if(!ctx.m_userProperties.get("$computer-localhost", &hostname))
      DBUG_RETURN(true);
  } else {
    ctx.m_userProperties.get("$computer-localhost-used", &localhost_used);
    ctx.m_userProperties.put("$computer-localhost", hostname);
  }

  if (localhost_used) {
    ctx.reportError("Mixing of localhost with other hostname(%s) is illegal",
		    hostname);
    DBUG_RETURN(false);
  }

  DBUG_RETURN(true);
}

2553 2554 2555
bool
fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){
  
2556 2557
  const char * hostname;
  if (ctx.m_currentSection->get("HostName", &hostname))
2558
    return checkLocalhostHostnameMix(ctx);
2559

2560 2561
  const char * compId;
  if(!ctx.m_currentSection->get("ExecuteOnComputer", &compId)){
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2562
    const char * type;
2563
    if(ctx.m_currentSection->get("Type", &type) && strcmp(type,DB_TOKEN) == 0)
2564 2565 2566
      require(ctx.m_currentSection->put("HostName", "localhost"));
    else
      require(ctx.m_currentSection->put("HostName", ""));
2567
    return checkLocalhostHostnameMix(ctx);
2568 2569 2570 2571
  }
  
  const Properties * computer;
  char tmp[255];
2572
  BaseString::snprintf(tmp, sizeof(tmp), "Computer_%s", compId);
2573 2574 2575 2576
  if(!ctx.m_config->get(tmp, &computer)){
    ctx.reportError("Computer \"%s\" not declared"
		    "- [%s] starting at line: %d",
		    compId, ctx.fname, ctx.m_sectionLineno);
joreland@mysql.com's avatar
joreland@mysql.com committed
2577
    return false;
2578 2579 2580
  }
  
  if(!computer->get("HostName", &hostname)){
joreland@mysql.com's avatar
joreland@mysql.com committed
2581 2582
    ctx.reportError("HostName missing in [COMPUTER] (Id: %d) "
		    " - [%s] starting at line: %d",
2583
		    compId, ctx.fname, ctx.m_sectionLineno);
joreland@mysql.com's avatar
joreland@mysql.com committed
2584
    return false;
2585 2586 2587
  }
  
  require(ctx.m_currentSection->put("HostName", hostname));
2588
  return checkLocalhostHostnameMix(ctx);
2589 2590
}

2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608
bool
fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data){
  DBUG_ENTER("fixFileSystemPath");

  const char * path;
  if (ctx.m_currentSection->get("FileSystemPath", &path))
    DBUG_RETURN(true);

  if (ctx.m_currentSection->get("DataDir", &path)) {
    require(ctx.m_currentSection->put("FileSystemPath", path));
    DBUG_RETURN(true);
  }

  require(false);
  DBUG_RETURN(false);
}

bool
2609
fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
2610 2611
  
  const char * path;
2612
  if (ctx.m_currentSection->get("BackupDataDir", &path))
2613 2614 2615
    return true;

  if (ctx.m_currentSection->get("FileSystemPath", &path)) {
2616
    require(ctx.m_currentSection->put("BackupDataDir", path));
2617 2618 2619 2620 2621 2622 2623
    return true;
  }

  require(false);
  return false;
}

2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
bool
transformExtNode(InitConfigFileParser::Context & ctx, const char * data){

  Uint32 id;
  const char * systemName;

  if(!ctx.m_currentSection->get("Id", &id)){
    ctx.reportError("Mandatory parameter 'Id' missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  if(!ctx.m_currentSection->get("System", &systemName)){
    ctx.reportError("Mandatory parameter 'System' missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  ctx.m_currentSection->put("Type", ctx.fname);

  Uint32 nodes = 0;
  ctx.m_userProperties.get("ExtNoOfNodes", &nodes);
  require(ctx.m_userProperties.put("ExtNoOfNodes",++nodes, true));

2650
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s:Node_%d", 
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663
	   systemName, id);

  return true;
}

/**
 * Connection rule: Update "NoOfConnections"
 */
bool
transformConnection(InitConfigFileParser::Context & ctx, const char * data){

  Uint32 connections = 0;
  ctx.m_userProperties.get("NoOfConnections", &connections);
2664
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Connection_%d", connections);
2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683
  ctx.m_userProperties.put("NoOfConnections", ++connections, true);
  
  ctx.m_currentSection->put("Type", ctx.fname);
  return true;
}

/**
 * System rule: Just add it
 */
bool
transformSystem(InitConfigFileParser::Context & ctx, const char * data){

  const char * name;
  if(!ctx.m_currentSection->get("Name", &name)){
    ctx.reportError("Mandatory parameter Name missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
2684 2685 2686

  ndbout << "transformSystem " << name << endl;

2687
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "SYSTEM_%s", name);
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703
  
  return true;
}

/**
 * External system rule: Just add it
 */
bool
transformExternalSystem(InitConfigFileParser::Context & ctx, const char * data){
  const char * name;
  if(!ctx.m_currentSection->get("Name", &name)){
    ctx.reportError("Mandatory parameter Name missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
2704
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s", name);
2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720
  
  return true;
}

/**
 * Computer rule: Update "NoOfComputers", add "Type"
 */
bool
transformComputer(InitConfigFileParser::Context & ctx, const char * data){
  const char * id;
  if(!ctx.m_currentSection->get("Id", &id)){
    ctx.reportError("Mandatory parameter Id missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
2721
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Computer_%s", id);
2722 2723 2724 2725 2726
  
  Uint32 computers = 0;
  ctx.m_userProperties.get("NoOfComputers", &computers);
  ctx.m_userProperties.put("NoOfComputers", ++computers, true);
  
2727 2728 2729 2730 2731 2732
  const char * hostname = 0;
  ctx.m_currentSection->get("HostName", &hostname);
  if(!hostname){
    return true;
  }
  
2733
  return checkLocalhostHostnameMix(ctx);
2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745
}

/**
 * Apply default values
 */
void 
applyDefaultValues(InitConfigFileParser::Context & ctx,
		   const Properties * defaults){
  if(defaults != NULL){
    Properties::Iterator it(defaults);

    for(const char * name = it.first(); name != NULL; name = it.next()){
2746
      ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name);
2747 2748 2749 2750 2751 2752 2753 2754 2755
      if(!ctx.m_currentSection->contains(name)){
	switch (ctx.m_info->getType(ctx.m_currentInfo, name)){
	case ConfigInfo::INT:
	case ConfigInfo::BOOL:{
	  Uint32 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
2756 2757 2758 2759 2760 2761
	case ConfigInfo::INT64:{
	  Uint64 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put64(name, val);
	  break;
	}
2762 2763 2764 2765 2766 2767
	case ConfigInfo::STRING:{
	  const char * val;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
2768 2769
	case ConfigInfo::SECTION:
	  break;
2770 2771 2772 2773 2774 2775 2776 2777 2778
	}
      }
    }
  }
}

bool
applyDefaultValues(InitConfigFileParser::Context & ctx, const char * data){
  
2779 2780 2781 2782 2783 2784 2785
  if(strcmp(data, "user") == 0)
    applyDefaultValues(ctx, ctx.m_userDefaults);
  else if (strcmp(data, "system") == 0)
    applyDefaultValues(ctx, ctx.m_systemDefaults);
  else 
    return false;

2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799
  return true;
}

/**
 * Check that a section contains all MANDATORY parameters
 */
bool
checkMandatory(InitConfigFileParser::Context & ctx, const char * data){

  Properties::Iterator it(ctx.m_currentInfo);
  for(const char * name = it.first(); name != NULL; name = it.next()){
    const Properties * info = NULL;
    ::require(ctx.m_currentInfo->get(name, &info));
    Uint32 val;
2800
    if(info->get("Mandatory", &val)){
2801 2802
      const char * fname;
      ::require(info->get("Fname", &fname));
2803
      if(!ctx.m_currentSection->contains(fname)){
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819
	ctx.reportError("Mandatory parameter %s missing from section "
			"[%s] starting at line: %d",
			fname, ctx.fname, ctx.m_sectionLineno);
	return false;
      }
    }
  }
  return true;
}

/**
 * Connection rule: Fix node id
 *
 * Transform a string "NodeidX" (e.g. "uppsala.32") 
 * into a Uint32 "NodeIdX" (e.g. 32) and a string "SystemX" (e.g. "uppsala").
 */
2820
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
2821
{
2822 2823 2824 2825
  char buf[] = "NodeIdX";  buf[6] = data[sizeof("NodeI")];
  char sysbuf[] = "SystemX";  sysbuf[6] = data[sizeof("NodeI")];
  const char* nodeId;
  require(ctx.m_currentSection->get(buf, &nodeId));
2826

2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855
  char tmpLine[MAX_LINE_LENGTH];
  strncpy(tmpLine, nodeId, MAX_LINE_LENGTH);
  char* token1 = strtok(tmpLine, ".");
  char* token2 = strtok(NULL, ".");
  Uint32 id;

  if (token2 == NULL) {                // Only a number given
    errno = 0;
    char* p;
    id = strtol(token1, &p, 10);
    if (errno != 0) warning("STRTOK1", nodeId);
    require(ctx.m_currentSection->put(buf, id, true));
  } else {                             // A pair given (e.g. "uppsala.32")
    errno = 0;
    char* p;
    id = strtol(token2, &p, 10);
    if (errno != 0) warning("STRTOK2", nodeId);
    require(ctx.m_currentSection->put(buf, id, true));
    require(ctx.m_currentSection->put(sysbuf, token1));
  }
  return true;
}

/**
 * @returns true if connection is external (one node is external)
 * Also returns: 
 * - name of external system in parameter extSystemName, and 
 * - nodeId of external node in parameter extSystemNodeId.
 */
2856
static bool 
2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883
isExtConnection(InitConfigFileParser::Context & ctx, 
		const char **extSystemName, Uint32 * extSystemNodeId){

  Uint32 nodeId1, nodeId2;

  if (ctx.m_currentSection->contains("System1") &&
      ctx.m_currentSection->get("System1", extSystemName) &&
      ctx.m_currentSection->get("NodeId1", &nodeId1)) {
    *extSystemNodeId = nodeId1;
    return true;
  }

  if (ctx.m_currentSection->contains("System2") &&
      ctx.m_currentSection->get("System2", extSystemName) &&
      ctx.m_currentSection->get("NodeId2", &nodeId2)) {
    *extSystemNodeId = nodeId2;
    return true;
  }

  return false;
}

/**
 * External Connection Rule: 
 * If connection is to an external system, then move connection into
 * external system configuration (i.e. a sub-property).
 */
2884
static bool
2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896
fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){

  const char * extSystemName;
  Uint32 extSystemNodeId;

  if (isExtConnection(ctx, &extSystemName, &extSystemNodeId)) {

    Uint32 connections = 0;
    ctx.m_userProperties.get("ExtNoOfConnections", &connections);
    require(ctx.m_userProperties.put("ExtNoOfConnections",++connections, true));

    char tmpLine1[MAX_LINE_LENGTH];
2897
    BaseString::snprintf(tmpLine1, MAX_LINE_LENGTH, "Connection_%d", connections-1);
2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938

    /**
     *  Section:   EXTERNAL SYSTEM_<Ext System Name>
     */
    char extSystemPropName[MAX_LINE_LENGTH];
    strncpy(extSystemPropName, "EXTERNAL SYSTEM_", MAX_LINE_LENGTH);
    strncat(extSystemPropName, extSystemName, MAX_LINE_LENGTH);
    strncat(extSystemPropName, ":", MAX_LINE_LENGTH);
    strncat(extSystemPropName, tmpLine1, MAX_LINE_LENGTH);

    /**
     * Increase number of external connections for the system
     *
     * @todo Limitation: Only one external system is allowed
     */
    require(ctx.m_userProperties.put("ExtSystem", extSystemName, true));
    
    /**
     * Make sure section is stored in right place
     */
    strncpy(ctx.pname, extSystemPropName, MAX_LINE_LENGTH);

    /**
     * Since this is an external connection, 
     * decrease number of internal connections
     */
    require(ctx.m_userProperties.get("NoOfConnections", &connections));
    require(ctx.m_userProperties.put("NoOfConnections", --connections, true));
  }

  return true;
}

/**
 * Connection rule: Fix hostname
 * 
 * Unless Hostname is not already specified, do steps:
 * -# Via Connection's NodeId lookup Node
 * -# Via Node's ExecuteOnComputer lookup Hostname
 * -# Add HostName to Connection
 */
2939
static bool
2940 2941 2942 2943 2944 2945 2946 2947
fixHostname(InitConfigFileParser::Context & ctx, const char * data){
  
  char buf[] = "NodeIdX"; buf[6] = data[sizeof("HostNam")];
  char sysbuf[] = "SystemX"; sysbuf[6] = data[sizeof("HostNam")];
  
  if(!ctx.m_currentSection->contains(data)){
    Uint32 id = 0;
    require(ctx.m_currentSection->get(buf, &id));
2948
    
2949 2950 2951 2952
    const Properties * node;
    require(ctx.m_config->get("Node", id, &node));
    
    const char * hostname;
2953
    require(node->get("HostName", &hostname));
2954 2955 2956 2957 2958 2959 2960 2961
    require(ctx.m_currentSection->put(data, hostname));
  }
  return true;
}

/**
 * Connection rule: Fix port number (using a port number adder)
 */
2962
static bool
2963 2964
fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){

2965 2966
  DBUG_ENTER("fixPortNumber");

tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2967
  Uint32 id1= 0, id2= 0;
2968 2969
  const char *hostName1;
  const char *hostName2;
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2970 2971
  require(ctx.m_currentSection->get("NodeId1", &id1));
  require(ctx.m_currentSection->get("NodeId2", &id2));
2972 2973 2974 2975 2976
  require(ctx.m_currentSection->get("HostName1", &hostName1));
  require(ctx.m_currentSection->get("HostName2", &hostName2));
  DBUG_PRINT("info",("NodeId1=%d HostName1=\"%s\"",id1,hostName1));
  DBUG_PRINT("info",("NodeId2=%d HostName2=\"%s\"",id2,hostName2));

2977 2978
  if (id1 > id2) {
    Uint32 tmp= id1;
2979 2980
    const char *tmp_name= hostName1;
    hostName1= hostName2;
2981
    id1= id2;
2982
    hostName2= tmp_name;
2983 2984
    id2= tmp;
  }
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2985 2986 2987

  const Properties * node;
  require(ctx.m_config->get("Node", id1, &node));
2988 2989
  BaseString hostname(hostName1);
  //  require(node->get("HostName", hostname));
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2990 2991
  
  if (hostname.c_str()[0] == 0) {
2992 2993
    ctx.reportError("Hostname required on nodeid %d since it will "
		    "act as server.", id1);
2994
    DBUG_RETURN(false);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
2995 2996 2997
  }

  Uint32 port= 0;
2998 2999
  if (!node->get("ServerPort", &port) &&
      !ctx.m_userProperties.get("ServerPort_", id1, &port)) {
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3000
    Uint32 adder= 0;
3001 3002 3003 3004 3005 3006 3007 3008
    {
      BaseString server_port_adder(hostname);
      server_port_adder.append("_ServerPortAdder");
      ctx.m_userProperties.get(server_port_adder.c_str(), &adder);
      ctx.m_userProperties.put(server_port_adder.c_str(), adder+1, true);
    }

    Uint32 base= 0;
3009
    if (!ctx.m_userProperties.get("ServerPortBase", &base)){
3010 3011
      if(!(ctx.m_userDefaults &&
	   ctx.m_userDefaults->get("PortNumber", &base)) &&
3012
	 !ctx.m_systemDefaults->get("PortNumber", &base)) {
3013
	base= strtoll(NDB_BASE_PORT,0,0)+2;
3014 3015 3016 3017
      //      ctx.reportError("Cannot retrieve base port number");
      //      return false;
      }
      ctx.m_userProperties.put("ServerPortBase", base);
3018
    }
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3019 3020 3021 3022 3023
    port= base + adder;
    ctx.m_userProperties.put("ServerPort_", id1, port);
  }

  if(ctx.m_currentSection->contains("PortNumber")) {
3024 3025 3026
    ndbout << "PortNumber should no longer be specificied "
	   << "per connection, please remove from config. "
	   << "Will be changed to " << port << endl;
3027 3028 3029
    ctx.m_currentSection->put("PortNumber", port, true);
  } else
    ctx.m_currentSection->put("PortNumber", port);
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3030

3031 3032
  DBUG_PRINT("info", ("connection %d-%d port %d host %s",
		      id1, id2, port, hostname.c_str()));
3033 3034

  DBUG_RETURN(true);
3035 3036 3037 3038 3039
}

/**
 * DB Node rule: Check various constraints
 */
3040
static bool
3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072
checkDbConstraints(InitConfigFileParser::Context & ctx, const char *){

  Uint32 t1 = 0, t2 = 0;
  ctx.m_currentSection->get("MaxNoOfConcurrentOperations", &t1);
  ctx.m_currentSection->get("MaxNoOfConcurrentTransactions", &t2);
  
  if (t1 < t2) {
    ctx.reportError("MaxNoOfConcurrentOperations must be greater than "
		    "MaxNoOfConcurrentTransactions - [%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  Uint32 replicas = 0, otherReplicas;
  ctx.m_currentSection->get("NoOfReplicas", &replicas);
  if(ctx.m_userProperties.get("NoOfReplicas", &otherReplicas)){
    if(replicas != otherReplicas){
      ctx.reportError("NoOfReplicas defined differently on different nodes"
		      " - [%s] starting at line: %d",
		      ctx.fname, ctx.m_sectionLineno);
      return false;
    }
  } else {
    ctx.m_userProperties.put("NoOfReplicas", replicas);
  }
  
  return true;
}

/**
 * Connection rule: Check varius constraints
 */
3073
static bool
3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118
checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){

  Uint32 id1 = 0, id2 = 0;
  ctx.m_currentSection->get("NodeId1", &id1);
  ctx.m_currentSection->get("NodeId2", &id2);
  
  // If external connection, just accept it
  if (ctx.m_currentSection->contains("System1") ||
      ctx.m_currentSection->contains("System2")) 
    return true;

  if(id1 == id2){
    ctx.reportError("Illegal connection from node to itself"
		    " - [%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  const Properties * node1;
  if(!ctx.m_config->get("Node", id1, &node1)){
    ctx.reportError("Connection refering to undefined node: %d"
		    " - [%s] starting at line: %d",
		    id1, ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  const Properties * node2;
  if(!ctx.m_config->get("Node", id2, &node2)){
    ctx.reportError("Connection refering to undefined node: %d"
		    " - [%s] starting at line: %d",
		    id2, ctx.fname, ctx.m_sectionLineno);
    return false;
  }

  const char * type1;
  const char * type2;
  require(node1->get("Type", &type1));
  require(node2->get("Type", &type2));

  /**
   * Report error if the following are true
   * -# None of the nodes is of type DB
   * -# Not both of them are MGMs
   * -# None of them contain a "SystemX" name
   */
3119 3120
  if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) &&
     !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0) &&
3121 3122 3123 3124 3125 3126 3127 3128
     !ctx.m_currentSection->contains("System1") &&
     !ctx.m_currentSection->contains("System2")){
    ctx.reportError("Invalid connection between node %d (%s) and node %d (%s)"
		    " - [%s] starting at line: %d",
		    id1, type1, id2, type2, 
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144

  return true;
}

static bool
checkTCPConstraints(InitConfigFileParser::Context & ctx, const char * data){
  
  const char * host;
  struct in_addr addr;
  if(ctx.m_currentSection->get(data, &host) && strlen(host) && 
     Ndb_getInAddr(&addr, host)){
    ctx.reportError("Unable to lookup/illegal hostname %s"
		    " - [%s] starting at line: %d",
		    host, ctx.fname, ctx.m_sectionLineno);
    return false;
  }
3145 3146
  return true;
}
3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167

static
bool
transform(InitConfigFileParser::Context & ctx,
	  Properties & dst, 
	  const char * oldName,
	  const char * newName,
	  double add, double mul){
  
  if(ctx.m_currentSection->contains(newName)){
    ctx.reportError("Both %s and %s specified"
		    " - [%s] starting at line: %d",
		    oldName, newName,
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
  
  PropertiesType oldType;
  require(ctx.m_currentSection->getTypeOf(oldName, &oldType));
  ConfigInfo::Type newType = ctx.m_info->getType(ctx.m_currentInfo, newName);  
  if(!((oldType == PropertiesType_Uint32 || oldType == PropertiesType_Uint64) 
3168 3169
       && (newType == ConfigInfo::INT || newType == ConfigInfo::INT64 || newType == ConfigInfo::BOOL))){
    ndbout << "oldType: " << (int)oldType << ", newType: " << (int)newType << endl;
3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187
    ctx.reportError("Unable to handle type conversion w.r.t deprication %s %s"
		    "- [%s] starting at line: %d",
		    oldName, newName,
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
  Uint64 oldVal;
  require(ctx.m_currentSection->get(oldName, &oldVal));

  Uint64 newVal = (Uint64)(oldVal * mul + add);
  if(!ctx.m_info->verify(ctx.m_currentInfo, newName, newVal)){
    ctx.reportError("Unable to handle deprication, new value not within bounds"
		    "%s %s - [%s] starting at line: %d",
		    oldName, newName,
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }

3188
  if(newType == ConfigInfo::INT || newType == ConfigInfo::BOOL){
3189
    require(dst.put(newName, (Uint32)newVal));
3190
  } else if(newType == ConfigInfo::INT64) {
3191 3192 3193 3194 3195
    require(dst.put64(newName, newVal));    
  }
  return true;
}

3196
static bool
3197
fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
3198
  const char * name;
3199 3200 3201 3202
  /**
   * Transform old values to new values
   * Transform new values to old values (backward compatible)
   */
3203
  Properties tmp(true);
3204
  Properties::Iterator it(ctx.m_currentSection);
3205
  for (name = it.first(); name != NULL; name = it.next()) {
3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225
    const DepricationTransform * p = &f_deprication[0];
    while(p->m_section != 0){
      if(strcmp(p->m_section, ctx.fname) == 0){
	double mul = p->m_mul;
	double add = p->m_add;
	if(strcmp(name, p->m_oldName) == 0){
	  if(!transform(ctx, tmp, name, p->m_newName, add, mul)){
	    return false;
	  }
	} else if(strcmp(name, p->m_newName) == 0) {
	  if(!transform(ctx, tmp, name, p->m_oldName, -add/mul,1.0/mul)){
	    return false;
	  }
	}
      }
      p++;
    }
  }
  
  Properties::Iterator it2(&tmp);
3226
  for (name = it2.first(); name != NULL; name = it2.next()) {
3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255
    PropertiesType type;
    require(tmp.getTypeOf(name, &type));
    switch(type){
    case PropertiesType_Uint32:{
      Uint32 val;
      require(tmp.get(name, &val));
      ::require(ctx.m_currentSection->put(name, val));
      break;
    }
    case PropertiesType_char:{
      const char * val;
      require(tmp.get(name, &val));
      ::require(ctx.m_currentSection->put(name, val));
      break;
    }
    case PropertiesType_Uint64:{
      Uint64 val;
      require(tmp.get(name, &val));
      ::require(ctx.m_currentSection->put64(name, val));
      break;
    }
    case PropertiesType_Properties:
    default:
      abort();
    }
  }
  return true;
}

3256
static bool
3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269
saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
  const Properties * sec;
  if(!ctx.m_currentInfo->get(ctx.fname, &sec)){
    abort();
    return false;
  }
  
  do {
    const char *secName;
    Uint32 id, status, typeVal;
    require(sec->get("Fname", &secName));
    require(sec->get("Id", &id));
    require(sec->get("Status", &status));
3270
    require(sec->get("SectionType", &typeVal));
3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320
    
    if(id == KEY_INTERNAL || status == ConfigInfo::INTERNAL){
      ndbout_c("skipping section %s", ctx.fname);
      break;
    }
    
    Uint32 no = 0;
    ctx.m_userProperties.get("$Section", id, &no);
    ctx.m_userProperties.put("$Section", id, no+1, true);
    
    ctx.m_configValues.openSection(id, no);
    ctx.m_configValues.put(CFG_TYPE_OF_SECTION, typeVal);
    
    Properties::Iterator it(ctx.m_currentSection);
    for (const char* n = it.first(); n != NULL; n = it.next()) {
      const Properties * info;
      if(!ctx.m_currentInfo->get(n, &info))
	continue;

      Uint32 id = 0;
      info->get("Id", &id);
      
      if(id == KEY_INTERNAL)
	continue;

      bool ok = true;
      PropertiesType type;
      require(ctx.m_currentSection->getTypeOf(n, &type));
      switch(type){
      case PropertiesType_Uint32:{
	Uint32 val;
	require(ctx.m_currentSection->get(n, &val));
	ok = ctx.m_configValues.put(id, val);
	break;
      }
      case PropertiesType_Uint64:{
	Uint64 val;
	require(ctx.m_currentSection->get(n, &val));
	ok = ctx.m_configValues.put64(id, val);
	break;
      }
      case PropertiesType_char:{
	const char * val;
	require(ctx.m_currentSection->get(n, &val));
	ok = ctx.m_configValues.put(id, val);
	break;
      }
      default:
	abort();
      }
3321
      require(ok);
3322 3323 3324 3325 3326
    }
    ctx.m_configValues.closeSection();
  } while(0);
  return true;
}
3327

3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350
static bool
sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
	      struct InitConfigFileParser::Context &ctx, 
	      const char * rule_data)
{
  Uint32 db_nodes = 0;
  Uint32 mgm_nodes = 0;
  Uint32 api_nodes = 0;
  if (!ctx.m_userProperties.get("DB", &db_nodes)) {
    ctx.reportError("At least one database node should be defined in config file");
    return false;
  }
  if (!ctx.m_userProperties.get("MGM", &mgm_nodes)) {
    ctx.reportError("At least one management server node should be defined in config file");
    return false;
  }
  if (!ctx.m_userProperties.get("API", &api_nodes)) {
    ctx.reportError("At least one application node (for the mysqld) should be defined in config file");
    return false;
  }
  return true;
}

3351
static bool
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3352
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
3353
		   struct InitConfigFileParser::Context &ctx, 
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3354
		   const char * rule_data)
3355
{
3356
  Uint32 i;
3357
  Properties * props= ctx.m_config;
3358 3359
  Properties p_connections(true);
  Properties p_connections2(true);
3360

3361
  for (i = 0;; i++){
3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378
    const Properties * tmp;
    Uint32 nodeId1, nodeId2;

    if(!props->get("Connection", i, &tmp)) break;

    if(!tmp->get("NodeId1", &nodeId1)) continue;
    p_connections.put("", nodeId1, nodeId1);
    if(!tmp->get("NodeId2", &nodeId2)) continue;
    p_connections.put("", nodeId2, nodeId2);

    p_connections2.put("", nodeId1 + nodeId2<<16, nodeId1);
    p_connections2.put("", nodeId2 + nodeId1<<16, nodeId2);
  }

  Uint32 nNodes;
  ctx.m_userProperties.get("NoOfNodes", &nNodes);

3379 3380
  Properties p_db_nodes(true);
  Properties p_api_mgm_nodes(true);
3381

3382 3383
  Uint32 i_db= 0, i_api_mgm= 0, n;
  for (i= 0, n= 0; n < nNodes; i++){
3384 3385 3386 3387 3388 3389 3390
    const Properties * tmp;
    if(!props->get("Node", i, &tmp)) continue;
    n++;

    const char * type;
    if(!tmp->get("Type", &type)) continue;

3391
    if (strcmp(type,DB_TOKEN) == 0)
3392
      p_db_nodes.put("", i_db++, i);
3393 3394
    else if (strcmp(type,API_TOKEN) == 0 ||
	     strcmp(type,MGM_TOKEN) == 0)
3395 3396 3397 3398 3399
      p_api_mgm_nodes.put("", i_api_mgm++, i);
  }

  Uint32 nodeId1, nodeId2, dummy;

3400
  for (i= 0; p_db_nodes.get("", i, &nodeId1); i++){
3401 3402 3403 3404 3405
    for (Uint32 j= i+1;; j++){
      if(!p_db_nodes.get("", j, &nodeId2)) break;
      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
	ConfigInfo::ConfigRuleSection s;
	s.m_sectionType= BaseString("TCP");
3406
	s.m_sectionData= new Properties(true);
3407
	char buf[16];
3408
	BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1);
3409
	s.m_sectionData->put("NodeId1", buf);
3410
	BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2);
3411 3412 3413 3414 3415 3416
	s.m_sectionData->put("NodeId2", buf);
	sections.push_back(s);
      }
    }
  }

3417
  for (i= 0; p_api_mgm_nodes.get("", i, &nodeId1); i++){
3418 3419 3420 3421 3422
    if(!p_connections.get("", nodeId1, &dummy)) {
      for (Uint32 j= 0;; j++){
	if(!p_db_nodes.get("", j, &nodeId2)) break;
	ConfigInfo::ConfigRuleSection s;
	s.m_sectionType= BaseString("TCP");
3423
	s.m_sectionData= new Properties(true);
3424
	char buf[16];
3425
	BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1);
3426
	s.m_sectionData->put("NodeId1", buf);
3427
	BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2);
3428 3429 3430 3431 3432 3433 3434 3435
	s.m_sectionData->put("NodeId2", buf);
	sections.push_back(s);
      }
    }
  }

  return true;
}
3436

joreland@mysql.com's avatar
joreland@mysql.com committed
3437

3438
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3439 3440
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data)
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3441
{
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3442 3443
#if 0
  Properties * props= ctx.m_config;
3444
  Properties computers(true);
3445
  Uint32 port_base = NDB_BASE_PORT+2;
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466

  Uint32 nNodes;
  ctx.m_userProperties.get("NoOfNodes", &nNodes);

  for (Uint32 i= 0, n= 0; n < nNodes; i++){
    Properties * tmp;
    if(!props->get("Node", i, &tmp)) continue;
    n++;

    const char * type;
    if(!tmp->get("Type", &type)) continue;

    Uint32 port;
    if (tmp->get("ServerPort", &port)) continue;

    Uint32 computer;
    if (!tmp->get("ExecuteOnComputer", &computer)) continue;

    Uint32 adder= 0;
    computers.get("",computer, &adder);

3467
    if (strcmp(type,DB_TOKEN) == 0) {
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3468 3469 3470 3471 3472 3473
      adder++;
      tmp->put("ServerPort", port_base+adder);
      computers.put("",computer, adder);
    }
  }
#endif
tomas@poseidon.bredbandsbolaget.se's avatar
tomas@poseidon.bredbandsbolaget.se committed
3474 3475 3476
  return true;
}

3477
static bool
joreland@mysql.com's avatar
joreland@mysql.com committed
3478 3479 3480 3481
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		       struct InitConfigFileParser::Context &ctx, 
		       const char * rule_data)
{
3482 3483 3484
  Uint32 db_nodes= 0;
  Uint32 replicas= 0;
  Uint32 db_host_count= 0;
3485
  ctx.m_userProperties.get(DB_TOKEN, &db_nodes);
joreland@mysql.com's avatar
joreland@mysql.com committed
3486 3487 3488 3489 3490 3491
  ctx.m_userProperties.get("NoOfReplicas", &replicas);
  if((db_nodes % replicas) != 0){
    ctx.reportError("Invalid no of db nodes wrt no of replicas.\n"
		    "No of nodes must be dividable with no or replicas");
    return false;
  }
3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503
  // check that node groups and arbitrators are ok
  // just issue warning if not
  if(replicas > 1){
    Properties * props= ctx.m_config;
    Properties p_db_hosts(true); // store hosts which db nodes run on
    Properties p_arbitrators(true); // store hosts which arbitrators run on
    // arbitrator should not run together with db node on same host
    Uint32 i, n, group= 0, i_group= 0;
    Uint32 n_nodes;
    BaseString node_group_warning, arbitration_warning;
    const char *arbit_warn_fmt=
      "\n  arbitrator with id %d and db node with id %d on same host %s";
3504 3505
    const char *arbit_warn_fmt2=
      "\n  arbitrator with id %d has no hostname specified";
3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561

    ctx.m_userProperties.get("NoOfNodes", &n_nodes);
    for (i= 0, n= 0; n < n_nodes; i++){
      const Properties * tmp;
      if(!props->get("Node", i, &tmp)) continue;
      n++;

      const char * type;
      if(!tmp->get("Type", &type)) continue;

      const char* host= 0;
      tmp->get("HostName", &host);

      if (strcmp(type,DB_TOKEN) == 0)
      {
	{
	  Uint32 ii;
	  if (!p_db_hosts.get(host,&ii))
	    db_host_count++;
	  p_db_hosts.put(host,i);
	  if (p_arbitrators.get(host,&ii))
	  {
	    arbitration_warning.appfmt(arbit_warn_fmt, ii, i, host);
	    p_arbitrators.remove(host); // only one warning per db node
	  }
	}
	{
	  unsigned j;
	  BaseString str, str2;
	  str.assfmt("#group%d_",group);
	  p_db_hosts.put(str.c_str(),i_group,host);
	  str2.assfmt("##group%d_",group);
	  p_db_hosts.put(str2.c_str(),i_group,i);
	  for (j= 0; j < i_group; j++)
	  {
	    const char *other_host;
	    p_db_hosts.get(str.c_str(),j,&other_host);
	    if (strcmp(host,other_host) == 0) {
	      unsigned int other_i, c= 0;
	      p_db_hosts.get(str2.c_str(),j,&other_i);
	      p_db_hosts.get(str.c_str(),&c);
	      if (c == 0) // first warning in this node group
		node_group_warning.appfmt("  Node group %d", group);
	      c|= 1 << j;
	      p_db_hosts.put(str.c_str(),c);

	      node_group_warning.appfmt(",\n    db node with id %d and id %d "
					"on same host %s", other_i, i, host);
	    }
	  }
	  i_group++;
	  DBUG_ASSERT(i_group <= replicas);
	  if (i_group == replicas)
	  {
	    unsigned c= 0;
	    p_db_hosts.get(str.c_str(),&c);
3562
	    if (c+1 == (1u << (replicas-1))) // all nodes on same machine
3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587
	      node_group_warning.append(".\n    Host failure will "
					"cause complete cluster shutdown.");
	    else if (c > 0)
	      node_group_warning.append(".\n    Host failure may "
					"cause complete cluster shutdown.");
	    group++;
	    i_group= 0;
	  }
	}
      }
      else if (strcmp(type,API_TOKEN) == 0 ||
	       strcmp(type,MGM_TOKEN) == 0)
      {
	Uint32 rank;
	if(tmp->get("ArbitrationRank", &rank) && rank > 0)
	{
	  if(host && host[0] != 0)
	  {
	    Uint32 ii;
	    p_arbitrators.put(host,i);
	    if (p_db_hosts.get(host,&ii))
	    {
	      arbitration_warning.appfmt(arbit_warn_fmt, i, ii, host);
	    }
	  }
3588 3589 3590 3591
	  else
	  {
	    arbitration_warning.appfmt(arbit_warn_fmt2, i);
	  }
3592 3593 3594 3595 3596 3597
	}
      }
    }
    if (db_host_count > 1 && node_group_warning.length() > 0)
      ndbout_c("Cluster configuration warning:\n%s",node_group_warning.c_str());
    if (db_host_count > 1 && arbitration_warning.length() > 0)
3598 3599 3600
      ndbout_c("Cluster configuration warning:%s%s",arbitration_warning.c_str(),
	       "\n  Running arbitrator on the same host as a database node may"
	       "\n  cause complete cluster shutdown in case of host failure.");
3601
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
3602 3603 3604
  return true;
}

3605
template class Vector<ConfigInfo::ConfigRuleSection>;