ConfigInfo.cpp 92.1 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 */

unknown's avatar
unknown committed
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"
unknown's avatar
unknown committed
24
#include <m_string.h>
25

26 27
extern my_bool opt_ndb_shm;

28
#define MAX_LINE_LENGTH 255
29
#define KEY_INTERNAL 0
30
#define MAX_INT_RNIL 0xfffffeff
31

unknown's avatar
unknown committed
32 33
#define _STR_VALUE(x) #x
#define STR_VALUE(x) _STR_VALUE(x)
34

35 36 37
/****************************************************************************
 * Section names
 ****************************************************************************/
unknown's avatar
unknown committed
38

39 40 41 42
#define DB_TOKEN_PRINT  "ndbd(DB)"
#define MGM_TOKEN_PRINT "ndb_mgmd(MGM)"
#define API_TOKEN_PRINT "mysqld(API)"

unknown's avatar
unknown committed
43 44 45
#define DB_TOKEN "DB"
#define MGM_TOKEN "MGM"
#define API_TOKEN "API"
46

unknown's avatar
unknown committed
47 48
const ConfigInfo::AliasPair
ConfigInfo::m_sectionNameAliases[]={
unknown's avatar
unknown committed
49 50 51
  {API_TOKEN, "MYSQLD"},
  {DB_TOKEN,  "NDBD"},
  {MGM_TOKEN, "NDB_MGMD"},
unknown's avatar
unknown committed
52 53 54
  {0, 0}
};

55 56 57 58 59 60
const char* 
ConfigInfo::m_sectionNames[]={
  "SYSTEM",
  "EXTERNAL SYSTEM",
  "COMPUTER",

61 62 63
  DB_TOKEN,
  MGM_TOKEN,
  API_TOKEN,
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
  "REP",
  "EXTERNAL REP",

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


/****************************************************************************
 * Section Rules declarations
 ****************************************************************************/
79 80 81 82 83
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 *);
84
static bool checkConnectionSupport(InitConfigFileParser::Context & ctx, const char *);
85 86 87 88
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 *);
89
static bool fixShmKey(InitConfigFileParser::Context & ctx, const char *);
90 91 92 93 94 95 96 97 98
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 *);
99
static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data);
unknown's avatar
unknown committed
100
static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data);
unknown's avatar
unknown committed
101
static bool fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data);
102 103 104 105 106 107 108

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

109 110 111
  { DB_TOKEN,   transformNode, 0 },
  { API_TOKEN,  transformNode, 0 },
  { MGM_TOKEN,  transformNode, 0 },
112 113 114
  { "REP",  transformNode, 0 },
  { "EXTERNAL REP",  transformExtNode, 0 },

unknown's avatar
unknown committed
115 116
  { MGM_TOKEN,  fixShmUniqueId, 0 },

117 118 119 120 121
  { "TCP",  checkConnectionSupport, 0 },
  { "SHM",  checkConnectionSupport, 0 },
  { "SCI",  checkConnectionSupport, 0 },
  { "OSE",  checkConnectionSupport, 0 },

122 123 124 125 126
  { "TCP",  transformConnection, 0 },
  { "SHM",  transformConnection, 0 },
  { "SCI",  transformConnection, 0 },
  { "OSE",  transformConnection, 0 },

127 128 129
  { DB_TOKEN,   fixNodeHostname, 0 },
  { API_TOKEN,  fixNodeHostname, 0 },
  { MGM_TOKEN,  fixNodeHostname, 0 },
130 131
  { "REP",  fixNodeHostname, 0 },
  //{ "EXTERNAL REP",  fixNodeHostname, 0 },
132 133 134 135 136 137 138 139 140

  { "TCP",  fixNodeId, "NodeId1" },
  { "TCP",  fixNodeId, "NodeId2" },
  { "SHM",  fixNodeId, "NodeId1" },
  { "SHM",  fixNodeId, "NodeId2" },
  { "SCI",  fixNodeId, "NodeId1" },
  { "SCI",  fixNodeId, "NodeId2" },
  { "OSE",  fixNodeId, "NodeId1" },
  { "OSE",  fixNodeId, "NodeId2" },
141 142 143
  
  { "TCP",  fixHostname, "HostName1" },
  { "TCP",  fixHostname, "HostName2" },
144 145
  { "SHM",  fixHostname, "HostName1" },
  { "SHM",  fixHostname, "HostName2" },
unknown's avatar
unknown committed
146 147
  { "SCI",  fixHostname, "HostName1" },
  { "SCI",  fixHostname, "HostName2" },
148 149
  { "SHM",  fixHostname, "HostName1" },
  { "SHM",  fixHostname, "HostName2" },
150 151
  { "OSE",  fixHostname, "HostName1" },
  { "OSE",  fixHostname, "HostName2" },
152

153
  { "TCP",  fixPortNumber, 0 }, // has to come after fixHostName
unknown's avatar
unknown committed
154
  { "SHM",  fixPortNumber, 0 }, // has to come after fixHostName
unknown's avatar
unknown committed
155
  { "SCI",  fixPortNumber, 0 }, // has to come after fixHostName
156
  { "SHM",  fixShmKey, 0 },
unknown's avatar
unknown committed
157

158 159 160 161 162 163 164 165
  /**
   * fixExtConnection must be after fixNodeId
   */
  { "TCP",  fixExtConnection, 0 },
  { "SHM",  fixExtConnection, 0 },
  { "SCI",  fixExtConnection, 0 },
  { "OSE",  fixExtConnection, 0 },
  
166 167 168 169
  { "*",    applyDefaultValues, "user" },
  { "*",    fixDepricated, 0 },
  { "*",    applyDefaultValues, "system" },

170
  { DB_TOKEN,   fixFileSystemPath, 0 },
unknown's avatar
unknown committed
171
  { DB_TOKEN,   fixBackupDataDir, 0 },
172 173

  { DB_TOKEN,   checkDbConstraints, 0 },
174

175 176 177 178 179 180 181 182
  /**
   * checkConnectionConstraints must be after fixExtConnection
   */
  { "TCP",  checkConnectionConstraints, 0 },
  { "SHM",  checkConnectionConstraints, 0 },
  { "SCI",  checkConnectionConstraints, 0 },
  { "OSE",  checkConnectionConstraints, 0 },

183 184
  { "TCP",  checkTCPConstraints, "HostName1" },
  { "TCP",  checkTCPConstraints, "HostName2" },
unknown's avatar
unknown committed
185 186
  { "SCI",  checkTCPConstraints, "HostName1" },
  { "SCI",  checkTCPConstraints, "HostName2" },
187 188
  { "SHM",  checkTCPConstraints, "HostName1" },
  { "SHM",  checkTCPConstraints, "HostName2" },
189
  
190 191
  { "*",    checkMandatory, 0 },
  
192 193 194
  { DB_TOKEN,   saveInConfigValues, 0 },
  { API_TOKEN,  saveInConfigValues, 0 },
  { MGM_TOKEN,  saveInConfigValues, 0 },
195 196 197 198 199 200 201 202
  { "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);
203

204 205 206
/****************************************************************************
 * Config Rules declarations
 ****************************************************************************/
207
static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
208 209
			  struct InitConfigFileParser::Context &ctx, 
			  const char * rule_data);
210
static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
211 212
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
213 214 215
static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sections, 
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
216
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
217 218
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data);
219
static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
220 221
			    struct InitConfigFileParser::Context &ctx, 
			    const char * rule_data);
222 223 224

const ConfigInfo::ConfigRule 
ConfigInfo::m_ConfigRules[] = {
225
  { sanity_checks, 0 },
unknown's avatar
unknown committed
226
  { add_node_connections, 0 },
227
  { set_connection_priorities, 0 },
unknown's avatar
unknown committed
228
  { add_server_ports, 0 },
unknown's avatar
unknown committed
229
  { check_node_vs_replicas, 0 },
230 231 232
  { 0, 0 }
};
	  
233 234 235 236 237 238 239
struct DepricationTransform {
  const char * m_section;
  const char * m_oldName;
  const char * m_newName;
  double m_add;
  double m_mul;
};
240

241 242
static
const DepricationTransform f_deprication[] = {
243
  { DB_TOKEN, "Discless", "Diskless", 0, 1 },
244
  { 0, 0, 0, 0, 0}
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
};

/**
 * 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"
 * *******************************************************************
 */
270

271 272
const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {

273 274 275 276 277 278 279 280
  /****************************************************************************
   * COMPUTER
   ***************************************************************************/
  {
    KEY_INTERNAL,
    "COMPUTER",
    "COMPUTER",
    "Computer section",
unknown's avatar
unknown committed
281
    ConfigInfo::CI_INTERNAL,
282
    false,
unknown's avatar
unknown committed
283
    ConfigInfo::CI_SECTION,
284 285 286 287 288 289 290 291
    0,
    0, 0 },
  
  {
    KEY_INTERNAL,
    "Id",
    "COMPUTER",
    "Name of computer",
unknown's avatar
unknown committed
292
    ConfigInfo::CI_USED,
293
    false,
unknown's avatar
unknown committed
294
    ConfigInfo::CI_STRING,
295
    MANDATORY,
296
    0, 0 },
297 298 299 300 301

  {
    KEY_INTERNAL,
    "HostName",
    "COMPUTER",
unknown's avatar
unknown committed
302
    "Hostname of computer (e.g. mysql.com)",
unknown's avatar
unknown committed
303
    ConfigInfo::CI_USED,
304
    false,
unknown's avatar
unknown committed
305
    ConfigInfo::CI_STRING,
306
    MANDATORY,
307
    0, 0 },
308 309 310 311 312 313

  {
    KEY_INTERNAL,
    "ByteOrder",
    "COMPUTER",
    0,
unknown's avatar
unknown committed
314
    ConfigInfo::CI_DEPRICATED,
315
    false,
unknown's avatar
unknown committed
316
    ConfigInfo::CI_STRING,
317 318 319
    UNDEFINED,
    0,
    0 },
320 321 322 323 324 325 326 327 328
  
  /****************************************************************************
   * SYSTEM
   ***************************************************************************/
  {
    CFG_SECTION_SYSTEM,
    "SYSTEM",
    "SYSTEM",
    "System section",
unknown's avatar
unknown committed
329
    ConfigInfo::CI_USED,
330
    false,
unknown's avatar
unknown committed
331
    ConfigInfo::CI_SECTION,
332 333
    (const char *)CFG_SECTION_SYSTEM,
    0, 0 },
334 335 336 337 338 339

  {
    CFG_SYS_NAME,
    "Name",
    "SYSTEM",
    "Name of system (NDB Cluster)",
unknown's avatar
unknown committed
340
    ConfigInfo::CI_USED,
341
    false,
unknown's avatar
unknown committed
342
    ConfigInfo::CI_STRING,
343
    MANDATORY,
344
    0, 0 },
345 346 347 348 349 350
  
  {
    CFG_SYS_REPLICATION_ROLE,
    "ReplicationRole",
    "SYSTEM",
    "Role in Global Replication (None, Primary, or Standby)",
unknown's avatar
unknown committed
351
    ConfigInfo::CI_USED,
352
    false,
unknown's avatar
unknown committed
353
    ConfigInfo::CI_STRING,
354
    UNDEFINED,
355
    0, 0 },
356 357 358 359 360
  
  {
    CFG_SYS_PRIMARY_MGM_NODE,
    "PrimaryMGMNode",
    "SYSTEM",
361
    "Node id of Primary "MGM_TOKEN_PRINT" node",
unknown's avatar
unknown committed
362
    ConfigInfo::CI_USED,
363
    false,
unknown's avatar
unknown committed
364
    ConfigInfo::CI_INT,
365 366
    "0",
    "0",
367
    STR_VALUE(MAX_INT_RNIL) },
368 369 370 371 372 373

  {
    CFG_SYS_CONFIG_GENERATION,
    "ConfigGenerationNumber",
    "SYSTEM",
    "Configuration generation number",
unknown's avatar
unknown committed
374
    ConfigInfo::CI_USED,
375
    false,
unknown's avatar
unknown committed
376
    ConfigInfo::CI_INT,
377 378
    "0",
    "0",
379
    STR_VALUE(MAX_INT_RNIL) },
380 381 382 383 384 385

  /***************************************************************************
   * DB
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
386 387
    DB_TOKEN,
    DB_TOKEN,
388
    "Node section",
unknown's avatar
unknown committed
389
    ConfigInfo::CI_USED,
390
    false,
unknown's avatar
unknown committed
391
    ConfigInfo::CI_SECTION,
392 393
    (const char *)NODE_TYPE_DB, 
    0, 0
394 395 396 397 398
  },

  {
    CFG_NODE_HOST,
    "HostName",
399
    DB_TOKEN,
400
    "Name of computer for this node",
unknown's avatar
unknown committed
401
    ConfigInfo::CI_INTERNAL,
402
    false,
unknown's avatar
unknown committed
403
    ConfigInfo::CI_STRING,
404
    UNDEFINED,
405
    0, 0 },
406 407 408 409

  {
    CFG_NODE_SYSTEM,
    "System",
410
    DB_TOKEN,
411
    "Name of system for this node",
unknown's avatar
unknown committed
412
    ConfigInfo::CI_INTERNAL,
413
    false,
unknown's avatar
unknown committed
414
    ConfigInfo::CI_STRING,
415
    UNDEFINED,
416
    0, 0 },
417 418 419 420

  {
    CFG_NODE_ID,
    "Id",
421
    DB_TOKEN,
422
    "Number identifying the database node ("DB_TOKEN_PRINT")",
unknown's avatar
unknown committed
423
    ConfigInfo::CI_USED,
424
    false,
unknown's avatar
unknown committed
425
    ConfigInfo::CI_INT,
426
    MANDATORY,
427
    "1",
428
    STR_VALUE(MAX_NODES) },
429

unknown's avatar
unknown committed
430
  {
unknown's avatar
unknown committed
431
    KEY_INTERNAL,
unknown's avatar
unknown committed
432
    "ServerPort",
433
    DB_TOKEN,
unknown's avatar
unknown committed
434
    "Port used to setup transporter",
unknown's avatar
unknown committed
435
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
436
    false,
unknown's avatar
unknown committed
437
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
438
    UNDEFINED,
439
    "1",
440
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
441

442 443 444
  {
    CFG_DB_NO_REPLICAS,
    "NoOfReplicas",
445
    DB_TOKEN,
446
    "Number of copies of all data in the database (1-4)",
unknown's avatar
unknown committed
447
    ConfigInfo::CI_USED,
448
    false,
unknown's avatar
unknown committed
449
    ConfigInfo::CI_INT,
450
    MANDATORY,
451 452
    "1",
    "4" },
453 454 455 456

  {
    CFG_DB_NO_ATTRIBUTES,
    "MaxNoOfAttributes",
457
    DB_TOKEN,
458
    "Total number of attributes stored in database. I.e. sum over all tables",
unknown's avatar
unknown committed
459
    ConfigInfo::CI_USED,
460
    false,
unknown's avatar
unknown committed
461
    ConfigInfo::CI_INT,
462 463
    "1000",
    "32",
464
    STR_VALUE(MAX_INT_RNIL) },
465 466 467 468
  
  {
    CFG_DB_NO_TABLES,
    "MaxNoOfTables",
469
    DB_TOKEN,
470
    "Total number of tables stored in the database",
unknown's avatar
unknown committed
471
    ConfigInfo::CI_USED,
472
    false,
unknown's avatar
unknown committed
473
    ConfigInfo::CI_INT,
474 475
    "128",
    "8",
476
    STR_VALUE(MAX_INT_RNIL) },
477
  
unknown's avatar
unknown committed
478 479 480
  {
    CFG_DB_NO_ORDERED_INDEXES,
    "MaxNoOfOrderedIndexes",
481
    DB_TOKEN,
unknown's avatar
unknown committed
482
    "Total number of ordered indexes that can be defined in the system",
unknown's avatar
unknown committed
483
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
484
    false,
unknown's avatar
unknown committed
485
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
486 487
    "128",
    "0",
unknown's avatar
unknown committed
488
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
489 490 491 492

  {
    CFG_DB_NO_UNIQUE_HASH_INDEXES,
    "MaxNoOfUniqueHashIndexes",
493
    DB_TOKEN,
unknown's avatar
unknown committed
494
    "Total number of unique hash indexes that can be defined in the system",
unknown's avatar
unknown committed
495
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
496
    false,
unknown's avatar
unknown committed
497
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
498 499
    "64",
    "0",
unknown's avatar
unknown committed
500
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
501

502 503 504
  {
    CFG_DB_NO_INDEXES,
    "MaxNoOfIndexes",
505
    DB_TOKEN,
506
    "Total number of indexes that can be defined in the system",
unknown's avatar
unknown committed
507
    ConfigInfo::CI_DEPRICATED,
508
    false,
unknown's avatar
unknown committed
509
    ConfigInfo::CI_INT,
510 511
    "128",
    "0",
512
    STR_VALUE(MAX_INT_RNIL) },
513 514 515 516

  {
    CFG_DB_NO_INDEX_OPS,
    "MaxNoOfConcurrentIndexOperations",
517
    DB_TOKEN,
518
    "Total number of index operations that can execute simultaneously on one "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
519
    ConfigInfo::CI_USED,
520
    false,
unknown's avatar
unknown committed
521
    ConfigInfo::CI_INT,
522 523
    "8K",
    "0",
524
    STR_VALUE(MAX_INT_RNIL) 
525 526 527 528 529
   },

  {
    CFG_DB_NO_TRIGGERS,
    "MaxNoOfTriggers",
530
    DB_TOKEN,
531
    "Total number of triggers that can be defined in the system",
unknown's avatar
unknown committed
532
    ConfigInfo::CI_USED,
533
    false,
unknown's avatar
unknown committed
534
    ConfigInfo::CI_INT,
535 536
    "768",
    "0",
537
    STR_VALUE(MAX_INT_RNIL) },
538 539 540 541

  {
    CFG_DB_NO_TRIGGER_OPS,
    "MaxNoOfFiredTriggers",
542
    DB_TOKEN,
543
    "Total number of triggers that can fire simultaneously in one "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
544
    ConfigInfo::CI_USED,
545
    false,
unknown's avatar
unknown committed
546
    ConfigInfo::CI_INT,
547 548
    "4000",
    "0",
549
    STR_VALUE(MAX_INT_RNIL) },
550 551 552 553

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
554
    DB_TOKEN,
555
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
556
    ConfigInfo::CI_USED,
557
    false,
unknown's avatar
unknown committed
558
    ConfigInfo::CI_STRING,
559 560
    UNDEFINED,
    0, 0 },
561 562 563 564
  
  {
    CFG_DB_NO_SAVE_MSGS,
    "MaxNoOfSavedMessages",
565
    DB_TOKEN,
566
    "Max number of error messages in error log and max number of trace files",
unknown's avatar
unknown committed
567
    ConfigInfo::CI_USED,
568
    true,
unknown's avatar
unknown committed
569
    ConfigInfo::CI_INT,
570 571
    "25",
    "0",
572
    STR_VALUE(MAX_INT_RNIL) },
573 574 575 576

  {
    CFG_DB_MEMLOCK,
    "LockPagesInMainMemory",
577
    DB_TOKEN,
578
    "If set to yes, then NDB Cluster data will not be swapped out to disk",
unknown's avatar
unknown committed
579
    ConfigInfo::CI_USED,
580
    true,
unknown's avatar
unknown committed
581
    ConfigInfo::CI_BOOL,
582 583 584
    "false",
    "false",
    "true" },
585 586 587 588

  {
    CFG_DB_WATCHDOG_INTERVAL,
    "TimeBetweenWatchDogCheck",
589
    DB_TOKEN,
590
    "Time between execution checks inside a database node",
unknown's avatar
unknown committed
591
    ConfigInfo::CI_USED,
592
    true,
unknown's avatar
unknown committed
593
    ConfigInfo::CI_INT,
594 595
    "6000",
    "70",
596
    STR_VALUE(MAX_INT_RNIL) },
597 598 599 600

  {
    CFG_DB_STOP_ON_ERROR,
    "StopOnError",
601
    DB_TOKEN,
602
    "If set to N, "DB_TOKEN_PRINT" automatically restarts/recovers in case of node failure",
unknown's avatar
unknown committed
603
    ConfigInfo::CI_USED,
604
    true,
unknown's avatar
unknown committed
605
    ConfigInfo::CI_BOOL,
606 607 608
    "true",
    "false",
    "true" },
609 610 611 612

  { 
    CFG_DB_STOP_ON_ERROR_INSERT,
    "RestartOnErrorInsert",
613
    DB_TOKEN,
614
    "See src/kernel/vm/Emulator.hpp NdbRestartType for details",
unknown's avatar
unknown committed
615
    ConfigInfo::CI_INTERNAL,
616
    true,
unknown's avatar
unknown committed
617
    ConfigInfo::CI_INT,
618 619 620
    "2",
    "0",
    "4" },
621 622 623 624
  
  {
    CFG_DB_NO_OPS,
    "MaxNoOfConcurrentOperations",
625
    DB_TOKEN,
unknown's avatar
unknown committed
626
    "Max number of operation records in transaction coordinator",
unknown's avatar
unknown committed
627
    ConfigInfo::CI_USED,
628
    false,
unknown's avatar
unknown committed
629
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
630
    "32k",
631
    "32",
unknown's avatar
unknown committed
632
    STR_VALUE(MAX_INT_RNIL) },
633

unknown's avatar
unknown committed
634 635 636
  {
    CFG_DB_NO_LOCAL_OPS,
    "MaxNoOfLocalOperations",
637
    DB_TOKEN,
unknown's avatar
unknown committed
638
    "Max number of operation records defined in the local storage node",
unknown's avatar
unknown committed
639
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
640
    false,
unknown's avatar
unknown committed
641
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
642 643
    UNDEFINED,
    "32",
unknown's avatar
unknown committed
644
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
645 646 647 648

  {
    CFG_DB_NO_LOCAL_SCANS,
    "MaxNoOfLocalScans",
649
    DB_TOKEN,
unknown's avatar
unknown committed
650
    "Max number of fragment scans in parallel in the local storage node",
unknown's avatar
unknown committed
651
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
652
    false,
unknown's avatar
unknown committed
653
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
654 655
    UNDEFINED,
    "32",
unknown's avatar
unknown committed
656
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
657 658 659 660

  {
    CFG_DB_BATCH_SIZE,
    "BatchSizePerLocalScan",
661
    DB_TOKEN,
unknown's avatar
unknown committed
662
    "Used to calculate the number of lock records for scan with hold lock",
unknown's avatar
unknown committed
663
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
664
    false,
unknown's avatar
unknown committed
665
    ConfigInfo::CI_INT,
unknown's avatar
merge  
unknown committed
666
    STR_VALUE(DEF_BATCH_SIZE),
unknown's avatar
unknown committed
667
    "1",
unknown's avatar
merge  
unknown committed
668
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
669 670 671 672

  {
    CFG_DB_NO_TRANSACTIONS,
    "MaxNoOfConcurrentTransactions",
673
    DB_TOKEN,
674
    "Max number of transaction executing concurrently on the "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
675
    ConfigInfo::CI_USED,
676
    false,
unknown's avatar
unknown committed
677
    ConfigInfo::CI_INT,
678 679
    "4096",
    "32",
680
    STR_VALUE(MAX_INT_RNIL) },
681 682 683 684

  {
    CFG_DB_NO_SCANS,
    "MaxNoOfConcurrentScans",
685
    DB_TOKEN,
686
    "Max number of scans executing concurrently on the "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
687
    ConfigInfo::CI_USED,
688
    false,
unknown's avatar
unknown committed
689
    ConfigInfo::CI_INT,
690 691 692
    "256",
    "2",
    "500" },
693 694 695 696

  {
    CFG_DB_TRANS_BUFFER_MEM,
    "TransactionBufferMemory",
697
    DB_TOKEN,
698
    "Dynamic buffer space (in bytes) for key and attribute data allocated for each "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
699
    ConfigInfo::CI_USED,
700
    false,
unknown's avatar
unknown committed
701
    ConfigInfo::CI_INT,
702 703
    "1M",
    "1K",
704
    STR_VALUE(MAX_INT_RNIL) },
705 706 707 708
 
  {
    CFG_DB_INDEX_MEM,
    "IndexMemory",
709
    DB_TOKEN,
710
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing indexes",
unknown's avatar
unknown committed
711
    ConfigInfo::CI_USED,
712
    false,
unknown's avatar
unknown committed
713
    ConfigInfo::CI_INT64,
714 715 716
    "18M",
    "1M",
    "1024G" },
717 718 719 720

  {
    CFG_DB_DATA_MEM,
    "DataMemory",
721
    DB_TOKEN,
722
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing data",
unknown's avatar
unknown committed
723
    ConfigInfo::CI_USED,
724
    false,
unknown's avatar
unknown committed
725
    ConfigInfo::CI_INT64,
726 727 728
    "80M",
    "1M",
    "1024G" },
729

730 731 732
  {
    CFG_DB_UNDO_INDEX_BUFFER,
    "UndoIndexBuffer",
733
    DB_TOKEN,
734
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for index part",
unknown's avatar
unknown committed
735
    ConfigInfo::CI_USED,
736
    false,
unknown's avatar
unknown committed
737
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
738 739
    "2M",
    "1M",
unknown's avatar
unknown committed
740
    STR_VALUE(MAX_INT_RNIL)},
741 742 743 744

  {
    CFG_DB_UNDO_DATA_BUFFER,
    "UndoDataBuffer",
745
    DB_TOKEN,
746
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for data part",
unknown's avatar
unknown committed
747
    ConfigInfo::CI_USED,
748
    false,
unknown's avatar
unknown committed
749
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
750 751
    "16M",
    "1M",
unknown's avatar
unknown committed
752
    STR_VALUE(MAX_INT_RNIL)},
753 754 755 756

  {
    CFG_DB_REDO_BUFFER,
    "RedoBuffer",
757
    DB_TOKEN,
758
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing REDO logs",
unknown's avatar
unknown committed
759
    ConfigInfo::CI_USED,
760
    false,
unknown's avatar
unknown committed
761
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
762 763
    "8M",
    "1M",
unknown's avatar
unknown committed
764
    STR_VALUE(MAX_INT_RNIL)},
765

766 767 768
  {
    CFG_DB_LONG_SIGNAL_BUFFER,
    "LongMessageBuffer",
769
    DB_TOKEN,
770
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for internal long messages",
unknown's avatar
unknown committed
771
    ConfigInfo::CI_USED,
772
    false,
unknown's avatar
unknown committed
773
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
774 775
    "1M",
    "512k",
unknown's avatar
unknown committed
776
    STR_VALUE(MAX_INT_RNIL)},
777

778 779 780
  {
    CFG_DB_START_PARTIAL_TIMEOUT,
    "StartPartialTimeout",
781
    DB_TOKEN,
782
    "Time to wait before trying to start wo/ all nodes. 0=Wait forever",
unknown's avatar
unknown committed
783
    ConfigInfo::CI_USED,
784
    true,
unknown's avatar
unknown committed
785
    ConfigInfo::CI_INT,
786 787
    "30000",
    "0",
788
    STR_VALUE(MAX_INT_RNIL) },
789 790 791 792

  {
    CFG_DB_START_PARTITION_TIMEOUT,
    "StartPartitionedTimeout",
793
    DB_TOKEN,
794
    "Time to wait before trying to start partitioned. 0=Wait forever",
unknown's avatar
unknown committed
795
    ConfigInfo::CI_USED,
796
    true,
unknown's avatar
unknown committed
797
    ConfigInfo::CI_INT,
798 799
    "60000",
    "0",
800
    STR_VALUE(MAX_INT_RNIL) },
801 802 803 804
  
  {
    CFG_DB_START_FAILURE_TIMEOUT,
    "StartFailureTimeout",
805
    DB_TOKEN,
806
    "Time to wait before terminating. 0=Wait forever",
unknown's avatar
unknown committed
807
    ConfigInfo::CI_USED,
808
    true,
unknown's avatar
unknown committed
809
    ConfigInfo::CI_INT,
810 811
    "0",
    "0",
812
    STR_VALUE(MAX_INT_RNIL) },
813 814 815 816
  
  {
    CFG_DB_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalDbDb",
817
    DB_TOKEN,
818
    "Time between "DB_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "DB_TOKEN_PRINT" considered dead after 3 missed HBs",
unknown's avatar
unknown committed
819
    ConfigInfo::CI_USED,
820
    true,
unknown's avatar
unknown committed
821
    ConfigInfo::CI_INT,
822 823
    "1500",
    "10",
824
    STR_VALUE(MAX_INT_RNIL) },
825 826 827 828

  {
    CFG_DB_API_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalDbApi",
829
    DB_TOKEN,
830
    "Time between "API_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "API_TOKEN_PRINT" connection closed after 3 missed HBs",
unknown's avatar
unknown committed
831
    ConfigInfo::CI_USED,
832
    true,
unknown's avatar
unknown committed
833
    ConfigInfo::CI_INT,
834 835
    "1500",
    "100",
836
    STR_VALUE(MAX_INT_RNIL) },
837 838 839 840

  {
    CFG_DB_LCP_INTERVAL,
    "TimeBetweenLocalCheckpoints",
841
    DB_TOKEN,
842
    "Time between taking snapshots of the database (expressed in 2log of bytes)",
unknown's avatar
unknown committed
843
    ConfigInfo::CI_USED,
844
    true,
unknown's avatar
unknown committed
845
    ConfigInfo::CI_INT,
846 847 848
    "20",
    "0",
    "31" },
849 850 851 852

  {
    CFG_DB_GCP_INTERVAL,
    "TimeBetweenGlobalCheckpoints",
853
    DB_TOKEN,
854
    "Time between doing group commit of transactions to disk",
unknown's avatar
unknown committed
855
    ConfigInfo::CI_USED,
856
    true,
unknown's avatar
unknown committed
857
    ConfigInfo::CI_INT,
858 859 860
    "2000",
    "10",
    "32000" },
861 862 863 864

  {
    CFG_DB_NO_REDOLOG_FILES,
    "NoOfFragmentLogFiles",
865
    DB_TOKEN,
866
    "No of 16 Mbyte Redo log files in each of 4 file sets belonging to "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
867
    ConfigInfo::CI_USED,
868
    false,
unknown's avatar
unknown committed
869
    ConfigInfo::CI_INT,
870 871
    "8",
    "1",
872
    STR_VALUE(MAX_INT_RNIL) },
873 874 875 876

  {
    KEY_INTERNAL,
    "MaxNoOfOpenFiles",
877
    DB_TOKEN,
878
    "Max number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)",
unknown's avatar
unknown committed
879
    ConfigInfo::CI_USED,
880
    false,
unknown's avatar
unknown committed
881
    ConfigInfo::CI_INT,
882 883 884
    "40",
    "20",
    "256" },
885 886 887 888 889

  
  {
    CFG_DB_TRANSACTION_CHECK_INTERVAL,
    "TimeBetweenInactiveTransactionAbortCheck",
890
    DB_TOKEN,
891
    "Time between inactive transaction checks",
unknown's avatar
unknown committed
892
    ConfigInfo::CI_USED,
893
    true,
unknown's avatar
unknown committed
894
    ConfigInfo::CI_INT,
895 896
    "1000",
    "1000",
897
    STR_VALUE(MAX_INT_RNIL) },
898 899 900 901
  
  {
    CFG_DB_TRANSACTION_INACTIVE_TIMEOUT,
    "TransactionInactiveTimeout",
902
    DB_TOKEN,
903 904 905 906 907
    "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.",
unknown's avatar
unknown committed
908
    ConfigInfo::CI_USED,
909
    true,
unknown's avatar
unknown committed
910
    ConfigInfo::CI_INT,
911
    STR_VALUE(MAX_INT_RNIL),
912
    "0",
913
    STR_VALUE(MAX_INT_RNIL) },
914 915 916 917

  {
    CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
    "TransactionDeadlockDetectionTimeout",
918
    DB_TOKEN,
919 920 921 922
    "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.",
unknown's avatar
unknown committed
923
    ConfigInfo::CI_USED,
924
    true,
unknown's avatar
unknown committed
925
    ConfigInfo::CI_INT,
926 927
    "1200",
    "50",
928
    STR_VALUE(MAX_INT_RNIL) },
929 930 931 932

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskDuringRestartTUP",
933
    DB_TOKEN,
934
    "?",
unknown's avatar
unknown committed
935
    ConfigInfo::CI_USED,
936
    true,
unknown's avatar
unknown committed
937
    ConfigInfo::CI_INT,
938 939
    "40",
    "1",
940
    STR_VALUE(MAX_INT_RNIL) },
941 942 943 944

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskAfterRestartTUP",
945
    DB_TOKEN,
946
    "?",
unknown's avatar
unknown committed
947
    ConfigInfo::CI_USED,
948
    true,
unknown's avatar
unknown committed
949
    ConfigInfo::CI_INT,
950 951
    "40",
    "1",
952
    STR_VALUE(MAX_INT_RNIL) },
953 954 955 956

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskDuringRestartACC",
957
    DB_TOKEN,
958
    "?",
unknown's avatar
unknown committed
959
    ConfigInfo::CI_USED,
960
    true,
unknown's avatar
unknown committed
961
    ConfigInfo::CI_INT,
962 963
    "20",
    "1",
964
    STR_VALUE(MAX_INT_RNIL) },
965 966 967 968

  {
    KEY_INTERNAL,
    "NoOfDiskPagesToDiskAfterRestartACC",
969
    DB_TOKEN,
970
    "?",
unknown's avatar
unknown committed
971
    ConfigInfo::CI_USED,
972
    true,
unknown's avatar
unknown committed
973
    ConfigInfo::CI_INT,
974 975
    "20",
    "1",
976
    STR_VALUE(MAX_INT_RNIL) },
977
  
978 979 980

  {
    CFG_DB_DISCLESS,
unknown's avatar
unknown committed
981
    "Diskless",
982
    DB_TOKEN,
983
    "Run wo/ disk",
unknown's avatar
unknown committed
984
    ConfigInfo::CI_USED,
985
    true,
unknown's avatar
unknown committed
986
    ConfigInfo::CI_BOOL,
987 988 989
    "false",
    "false",
    "true"},
unknown's avatar
unknown committed
990 991

  {
992
    KEY_INTERNAL,
unknown's avatar
unknown committed
993
    "Discless",
994
    DB_TOKEN,
unknown's avatar
unknown committed
995
    "Diskless",
unknown's avatar
unknown committed
996
    ConfigInfo::CI_DEPRICATED,
unknown's avatar
unknown committed
997
    true,
unknown's avatar
unknown committed
998
    ConfigInfo::CI_BOOL,
999 1000 1001
    "false",
    "false",
    "true"},
unknown's avatar
unknown committed
1002 1003
  

1004
  
1005 1006 1007
  {
    CFG_DB_ARBIT_TIMEOUT,
    "ArbitrationTimeout",
1008
    DB_TOKEN,
1009
    "Max time (milliseconds) database partion waits for arbitration signal",
unknown's avatar
unknown committed
1010
    ConfigInfo::CI_USED,
1011
    false,
unknown's avatar
unknown committed
1012
    ConfigInfo::CI_INT,
1013 1014
    "3000",
    "10",
1015
    STR_VALUE(MAX_INT_RNIL) },
1016

1017 1018 1019 1020 1021
  {
    CFG_NODE_DATADIR,
    "DataDir",
    DB_TOKEN,
    "Data directory for this node",
unknown's avatar
unknown committed
1022
    ConfigInfo::CI_USED,
1023
    false,
unknown's avatar
unknown committed
1024
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1025
    MYSQLCLUSTERDIR,
1026 1027
    0, 0 },

1028 1029 1030
  {
    CFG_DB_FILESYSTEM_PATH,
    "FileSystemPath",
1031
    DB_TOKEN,
1032
    "Path to directory where the "DB_TOKEN_PRINT" node stores its data (directory must exist)",
unknown's avatar
unknown committed
1033
    ConfigInfo::CI_USED,
1034
    false,
unknown's avatar
unknown committed
1035
    ConfigInfo::CI_STRING,
1036
    UNDEFINED,
1037
    0, 0 },
1038 1039 1040 1041

  {
    CFG_LOGLEVEL_STARTUP,
    "LogLevelStartup",
1042
    DB_TOKEN,
1043
    "Node startup info printed on stdout",
unknown's avatar
unknown committed
1044
    ConfigInfo::CI_USED,
1045
    false,
unknown's avatar
unknown committed
1046
    ConfigInfo::CI_INT,
1047 1048 1049
    "1",
    "0",
    "15" },
1050 1051 1052 1053
  
  {
    CFG_LOGLEVEL_SHUTDOWN,
    "LogLevelShutdown",
1054
    DB_TOKEN,
1055
    "Node shutdown info printed on stdout",
unknown's avatar
unknown committed
1056
    ConfigInfo::CI_USED,
1057
    false,
unknown's avatar
unknown committed
1058
    ConfigInfo::CI_INT,
1059 1060 1061
    "0",
    "0",
    "15" },
1062 1063 1064 1065

  {
    CFG_LOGLEVEL_STATISTICS,
    "LogLevelStatistic",
1066
    DB_TOKEN,
1067
    "Transaction, operation, transporter info printed on stdout",
unknown's avatar
unknown committed
1068
    ConfigInfo::CI_USED,
1069
    false,
unknown's avatar
unknown committed
1070
    ConfigInfo::CI_INT,
1071 1072 1073
    "0",
    "0",
    "15" },
1074 1075 1076 1077

  {
    CFG_LOGLEVEL_CHECKPOINT,
    "LogLevelCheckpoint",
1078
    DB_TOKEN,
1079
    "Local and Global checkpoint info printed on stdout",
unknown's avatar
unknown committed
1080
    ConfigInfo::CI_USED,
1081
    false,
unknown's avatar
unknown committed
1082
    ConfigInfo::CI_INT,
1083 1084 1085
    "0",
    "0",
    "15" },
1086 1087 1088 1089

  {
    CFG_LOGLEVEL_NODERESTART,
    "LogLevelNodeRestart",
1090
    DB_TOKEN,
1091
    "Node restart, node failure info printed on stdout",
unknown's avatar
unknown committed
1092
    ConfigInfo::CI_USED,
1093
    false,
unknown's avatar
unknown committed
1094
    ConfigInfo::CI_INT,
1095 1096 1097
    "0",
    "0",
    "15" },
1098 1099 1100 1101

  {
    CFG_LOGLEVEL_CONNECTION,
    "LogLevelConnection",
1102
    DB_TOKEN,
1103
    "Node connect/disconnect info printed on stdout",
unknown's avatar
unknown committed
1104
    ConfigInfo::CI_USED,
1105
    false,
unknown's avatar
unknown committed
1106
    ConfigInfo::CI_INT,
1107 1108 1109
    "0",
    "0",
    "15" },
1110 1111 1112 1113

  {
    CFG_LOGLEVEL_ERROR,
    "LogLevelError",
1114
    DB_TOKEN,
1115
    "Transporter, heartbeat errors printed on stdout",
unknown's avatar
unknown committed
1116
    ConfigInfo::CI_USED,
1117
    false,
unknown's avatar
unknown committed
1118
    ConfigInfo::CI_INT,
1119 1120 1121
    "0",
    "0",
    "15" },
1122 1123 1124 1125

  {
    CFG_LOGLEVEL_INFO,
    "LogLevelInfo",
1126
    DB_TOKEN,
1127
    "Heartbeat and log info printed on stdout",
unknown's avatar
unknown committed
1128
    ConfigInfo::CI_USED,
1129
    false,
unknown's avatar
unknown committed
1130
    ConfigInfo::CI_INT,
1131 1132 1133
    "0",
    "0",
    "15" },
1134 1135 1136 1137 1138 1139 1140

  /**
   * Backup
   */
  { 
    CFG_DB_PARALLEL_BACKUPS,
    "ParallelBackups",
1141
    DB_TOKEN,
1142
    "Maximum number of parallel backups",
unknown's avatar
unknown committed
1143
    ConfigInfo::CI_NOTIMPLEMENTED,
1144
    false,
unknown's avatar
unknown committed
1145
    ConfigInfo::CI_INT,
1146 1147 1148
    "1",
    "1",
    "1" },
1149
  
1150
  { 
unknown's avatar
unknown committed
1151 1152
    CFG_DB_BACKUP_DATADIR,
    "BackupDataDir",
1153 1154
    DB_TOKEN,
    "Path to where to store backups",
unknown's avatar
unknown committed
1155
    ConfigInfo::CI_USED,
1156
    false,
unknown's avatar
unknown committed
1157
    ConfigInfo::CI_STRING,
1158 1159 1160
    UNDEFINED,
    0, 0 },
  
1161 1162 1163
  { 
    CFG_DB_BACKUP_MEM,
    "BackupMemory",
1164
    DB_TOKEN,
1165
    "Total memory allocated for backups per node (in bytes)",
unknown's avatar
unknown committed
1166
    ConfigInfo::CI_USED,
1167
    false,
unknown's avatar
unknown committed
1168
    ConfigInfo::CI_INT,
1169 1170
    "4M", // sum of BackupDataBufferSize and BackupLogBufferSize
    "0",
1171
    STR_VALUE(MAX_INT_RNIL) },
1172 1173 1174 1175
  
  { 
    CFG_DB_BACKUP_DATA_BUFFER_MEM,
    "BackupDataBufferSize",
1176
    DB_TOKEN,
1177
    "Default size of databuffer for a backup (in bytes)",
unknown's avatar
unknown committed
1178
    ConfigInfo::CI_USED,
1179
    false,
unknown's avatar
unknown committed
1180
    ConfigInfo::CI_INT,
1181 1182
    "2M", // remember to change BackupMemory
    "0",
1183
    STR_VALUE(MAX_INT_RNIL) },
1184 1185 1186 1187

  { 
    CFG_DB_BACKUP_LOG_BUFFER_MEM,
    "BackupLogBufferSize",
1188
    DB_TOKEN,
1189
    "Default size of logbuffer for a backup (in bytes)",
unknown's avatar
unknown committed
1190
    ConfigInfo::CI_USED,
1191
    false,
unknown's avatar
unknown committed
1192
    ConfigInfo::CI_INT,
1193 1194
    "2M", // remember to change BackupMemory
    "0",
1195
    STR_VALUE(MAX_INT_RNIL) },
1196 1197 1198 1199

  { 
    CFG_DB_BACKUP_WRITE_SIZE,
    "BackupWriteSize",
1200
    DB_TOKEN,
1201
    "Default size of filesystem writes made by backup (in bytes)",
unknown's avatar
unknown committed
1202
    ConfigInfo::CI_USED,
1203
    false,
unknown's avatar
unknown committed
1204
    ConfigInfo::CI_INT,
1205 1206
    "32K",
    "0",
1207
    STR_VALUE(MAX_INT_RNIL) },
1208 1209 1210 1211 1212 1213 1214 1215 1216

  /***************************************************************************
   * REP
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
    "REP",
    "REP",
    "Node section",
unknown's avatar
unknown committed
1217
    ConfigInfo::CI_USED,
1218
    false,
unknown's avatar
unknown committed
1219
    ConfigInfo::CI_SECTION,
1220 1221
    (const char *)NODE_TYPE_REP, 
    0, 0
1222 1223 1224 1225 1226 1227 1228
  },

  {
    CFG_NODE_HOST,
    "HostName",
    "REP",
    "Name of computer for this node",
unknown's avatar
unknown committed
1229
    ConfigInfo::CI_INTERNAL,
1230
    false,
unknown's avatar
unknown committed
1231
    ConfigInfo::CI_STRING,
1232
    UNDEFINED,
1233
    0, 0 },
1234 1235 1236 1237 1238 1239

  {
    CFG_NODE_SYSTEM,
    "System",
    "REP",
    "Name of system for this node",
unknown's avatar
unknown committed
1240
    ConfigInfo::CI_INTERNAL,
1241
    false,
unknown's avatar
unknown committed
1242
    ConfigInfo::CI_STRING,
1243
    UNDEFINED,
1244
    0, 0 },
1245 1246 1247 1248 1249 1250

  {
    CFG_NODE_ID,
    "Id",
    "REP",
    "Number identifying replication node (REP)",
unknown's avatar
unknown committed
1251
    ConfigInfo::CI_USED,
1252
    false,
unknown's avatar
unknown committed
1253
    ConfigInfo::CI_INT,
1254
    MANDATORY,
1255
    "1",
1256
    STR_VALUE(MAX_NODES) },
1257 1258 1259 1260 1261 1262

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
    "REP",
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1263
    ConfigInfo::CI_USED,
1264
    false,
unknown's avatar
unknown committed
1265
    ConfigInfo::CI_STRING,
1266
    MANDATORY,
1267
    0, 0 },
1268 1269 1270 1271 1272 1273

  {
    CFG_REP_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalRepRep",
    "REP",
    "Time between REP-REP heartbeats. Connection closed after 3 missed HBs",
unknown's avatar
unknown committed
1274
    ConfigInfo::CI_USED,
1275
    true,
unknown's avatar
unknown committed
1276
    ConfigInfo::CI_INT,
1277 1278
    "3000",
    "100",
1279
    STR_VALUE(MAX_INT_RNIL) },
1280 1281 1282 1283 1284 1285

  /***************************************************************************
   * API
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1286 1287
    API_TOKEN,
    API_TOKEN,
1288
    "Node section",
unknown's avatar
unknown committed
1289
    ConfigInfo::CI_USED,
1290
    false,
unknown's avatar
unknown committed
1291
    ConfigInfo::CI_SECTION,
1292 1293
    (const char *)NODE_TYPE_API, 
    0, 0
1294 1295 1296 1297 1298
  },

  {
    CFG_NODE_HOST,
    "HostName",
1299
    API_TOKEN,
1300
    "Name of computer for this node",
unknown's avatar
unknown committed
1301
    ConfigInfo::CI_INTERNAL,
1302
    false,
unknown's avatar
unknown committed
1303
    ConfigInfo::CI_STRING,
1304
    UNDEFINED,
1305
    0, 0 },
1306 1307 1308 1309

  {
    CFG_NODE_SYSTEM,
    "System",
1310
    API_TOKEN,
1311
    "Name of system for this node",
unknown's avatar
unknown committed
1312
    ConfigInfo::CI_INTERNAL,
1313
    false,
unknown's avatar
unknown committed
1314
    ConfigInfo::CI_STRING,
1315
    UNDEFINED,
1316
    0, 0 },
1317 1318 1319 1320

  {
    CFG_NODE_ID,
    "Id",
1321
    API_TOKEN,
1322
    "Number identifying application node ("API_TOKEN_PRINT")",
unknown's avatar
unknown committed
1323
    ConfigInfo::CI_USED,
1324
    false,
unknown's avatar
unknown committed
1325
    ConfigInfo::CI_INT,
1326
    MANDATORY,
1327
    "1",
1328
    STR_VALUE(MAX_NODES) },
1329 1330 1331 1332

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1333
    API_TOKEN,
1334
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1335
    ConfigInfo::CI_USED,
1336
    false,
unknown's avatar
unknown committed
1337
    ConfigInfo::CI_STRING,
1338 1339
    UNDEFINED,
    0, 0 },
1340 1341 1342 1343

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1344
    API_TOKEN,
1345
    "If 0, then "API_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1346
    ConfigInfo::CI_USED,
1347
    false,
unknown's avatar
unknown committed
1348
    ConfigInfo::CI_INT,
1349 1350 1351
    "0",
    "0",
    "2" },
1352 1353 1354 1355

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1356
    API_TOKEN,
1357
    "When asked to arbitrate, arbitrator waits this long before voting (msec)",
unknown's avatar
unknown committed
1358
    ConfigInfo::CI_USED,
1359
    false,
unknown's avatar
unknown committed
1360
    ConfigInfo::CI_INT,
1361 1362
    "0",
    "0",
1363
    STR_VALUE(MAX_INT_RNIL) },
1364

1365 1366 1367 1368 1369
  {
    CFG_MAX_SCAN_BATCH_SIZE,
    "MaxScanBatchSize",
    "API",
    "The maximum collective batch size for one scan",
unknown's avatar
unknown committed
1370
    ConfigInfo::CI_USED,
1371
    false,
unknown's avatar
unknown committed
1372
    ConfigInfo::CI_INT,
1373 1374 1375 1376
    STR_VALUE(MAX_SCAN_BATCH_SIZE),
    "32k",
    "16M" },
  
1377 1378 1379 1380 1381
  {
    CFG_BATCH_BYTE_SIZE,
    "BatchByteSize",
    "API",
    "The default batch size in bytes",
unknown's avatar
unknown committed
1382
    ConfigInfo::CI_USED,
1383
    false,
unknown's avatar
unknown committed
1384
    ConfigInfo::CI_INT,
1385 1386 1387
    STR_VALUE(SCAN_BATCH_SIZE),
    "1k",
    "1M" },
1388 1389 1390 1391 1392 1393

  {
    CFG_BATCH_SIZE,
    "BatchSize",
    "API",
    "The default batch size in number of records",
unknown's avatar
unknown committed
1394
    ConfigInfo::CI_USED,
1395
    false,
unknown's avatar
unknown committed
1396
    ConfigInfo::CI_INT,
1397 1398 1399
    STR_VALUE(DEF_BATCH_SIZE),
    "1",
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
1400

1401 1402 1403 1404 1405
  /****************************************************************************
   * MGM
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1406 1407
    MGM_TOKEN,
    MGM_TOKEN,
1408
    "Node section",
unknown's avatar
unknown committed
1409
    ConfigInfo::CI_USED,
1410
    false,
unknown's avatar
unknown committed
1411
    ConfigInfo::CI_SECTION,
1412 1413
    (const char *)NODE_TYPE_MGM, 
    0, 0
1414 1415 1416 1417 1418
  },

  {
    CFG_NODE_HOST,
    "HostName",
1419
    MGM_TOKEN,
1420
    "Name of computer for this node",
unknown's avatar
unknown committed
1421
    ConfigInfo::CI_INTERNAL,
1422
    false,
unknown's avatar
unknown committed
1423
    ConfigInfo::CI_STRING,
1424
    UNDEFINED,
1425
    0, 0 },
1426

1427 1428 1429 1430 1431
  {
    CFG_NODE_DATADIR,
    "DataDir",
    MGM_TOKEN,
    "Data directory for this node",
unknown's avatar
unknown committed
1432
    ConfigInfo::CI_USED,
1433
    false,
unknown's avatar
unknown committed
1434
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1435
    MYSQLCLUSTERDIR,
1436 1437
    0, 0 },

1438 1439 1440
  {
    CFG_NODE_SYSTEM,
    "System",
1441
    MGM_TOKEN,
1442
    "Name of system for this node",
unknown's avatar
unknown committed
1443
    ConfigInfo::CI_INTERNAL,
1444
    false,
unknown's avatar
unknown committed
1445
    ConfigInfo::CI_STRING,
1446
    UNDEFINED,
1447
    0, 0 },
1448 1449 1450 1451

  {
    CFG_NODE_ID,
    "Id",
1452
    MGM_TOKEN,
1453
    "Number identifying the management server node ("MGM_TOKEN_PRINT")",
unknown's avatar
unknown committed
1454
    ConfigInfo::CI_USED,
1455
    false,
unknown's avatar
unknown committed
1456
    ConfigInfo::CI_INT,
1457
    MANDATORY,
1458
    "1",
1459
    STR_VALUE(MAX_NODES) },
1460 1461 1462 1463
  
  {
    CFG_LOG_DESTINATION,
    "LogDestination",
1464
    MGM_TOKEN,
1465
    "String describing where logmessages are sent",
unknown's avatar
unknown committed
1466
    ConfigInfo::CI_USED,
1467
    false,
unknown's avatar
unknown committed
1468
    ConfigInfo::CI_STRING,
1469
    0,
1470
    0, 0 },
1471 1472 1473 1474
  
  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1475
    MGM_TOKEN,
1476
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1477
    ConfigInfo::CI_USED,
1478
    false,
unknown's avatar
unknown committed
1479
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1480
    0,
1481 1482
    0, 0 },

1483 1484 1485
  {
    KEY_INTERNAL,
    "MaxNoOfSavedEvents",
1486
    MGM_TOKEN,
1487
    "",
unknown's avatar
unknown committed
1488
    ConfigInfo::CI_USED,
1489
    false,
unknown's avatar
unknown committed
1490
    ConfigInfo::CI_INT,
1491 1492
    "100",
    "0",
1493
    STR_VALUE(MAX_INT_RNIL) },
1494 1495 1496 1497

  {
    CFG_MGM_PORT,
    "PortNumber",
1498
    MGM_TOKEN,
1499
    "Port number to give commands to/fetch configurations from management server",
unknown's avatar
unknown committed
1500
    ConfigInfo::CI_USED,
1501
    false,
unknown's avatar
unknown committed
1502
    ConfigInfo::CI_INT,
1503
    NDB_PORT,
1504
    "0",
1505
    STR_VALUE(MAX_INT_RNIL) },
1506 1507 1508 1509

  {
    KEY_INTERNAL,
    "PortNumberStats",
1510
    MGM_TOKEN,
1511
    "Port number used to get statistical information from a management server",
unknown's avatar
unknown committed
1512
    ConfigInfo::CI_USED,
1513
    false,
unknown's avatar
unknown committed
1514
    ConfigInfo::CI_INT,
1515
    UNDEFINED,
1516
    "0",
1517
    STR_VALUE(MAX_INT_RNIL) },
1518 1519 1520 1521

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1522
    MGM_TOKEN,
1523
    "If 0, then "MGM_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1524
    ConfigInfo::CI_USED,
1525
    false,
unknown's avatar
unknown committed
1526
    ConfigInfo::CI_INT,
1527 1528 1529
    "1",
    "0",
    "2" },
1530 1531 1532 1533

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1534
    MGM_TOKEN,
1535
    "",
unknown's avatar
unknown committed
1536
    ConfigInfo::CI_USED,
1537
    false,
unknown's avatar
unknown committed
1538
    ConfigInfo::CI_INT,
1539 1540
    "0",
    "0",
1541
    STR_VALUE(MAX_INT_RNIL) },
1542 1543 1544 1545 1546 1547 1548 1549 1550

  /****************************************************************************
   * TCP
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "TCP",
    "TCP",
    "Connection section",
unknown's avatar
unknown committed
1551
    ConfigInfo::CI_USED,
1552
    false,
unknown's avatar
unknown committed
1553
    ConfigInfo::CI_SECTION,
1554 1555
    (const char *)CONNECTION_TYPE_TCP, 
    0, 0
1556 1557 1558
  },

  {
1559
    CFG_CONNECTION_HOSTNAME_1,
1560 1561 1562
    "HostName1",
    "TCP",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1563
    ConfigInfo::CI_INTERNAL,
1564
    false,
unknown's avatar
unknown committed
1565
    ConfigInfo::CI_STRING,
1566
    UNDEFINED,
1567
    0, 0 },
1568 1569

  {
1570
    CFG_CONNECTION_HOSTNAME_2,
1571 1572 1573
    "HostName2",
    "TCP",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1574
    ConfigInfo::CI_INTERNAL,
1575
    false,
unknown's avatar
unknown committed
1576
    ConfigInfo::CI_STRING,
1577
    UNDEFINED,
1578
    0, 0 },
1579 1580 1581 1582 1583

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "TCP",
1584
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1585
    ConfigInfo::CI_USED,
1586
    false,
unknown's avatar
unknown committed
1587
    ConfigInfo::CI_STRING,
1588
    MANDATORY,
1589
    0, 0 },
1590 1591 1592 1593 1594

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "TCP",
1595
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1596
    ConfigInfo::CI_USED,
1597
    false,
unknown's avatar
unknown committed
1598
    ConfigInfo::CI_STRING,
1599
    MANDATORY,
1600
    0, 0 },
1601

1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "TCP",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "55",
    "0", "200" },

1613 1614 1615 1616 1617
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "TCP",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1618
    ConfigInfo::CI_USED,
1619
    false,
unknown's avatar
unknown committed
1620
    ConfigInfo::CI_BOOL,
1621 1622 1623
    "true",
    "false",
    "true" },
1624 1625 1626 1627 1628 1629 1630


  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "TCP",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1631
    ConfigInfo::CI_USED,
1632
    false,
unknown's avatar
unknown committed
1633
    ConfigInfo::CI_BOOL,
1634 1635 1636
    "false",
    "false",
    "true" },
1637 1638

  {
unknown's avatar
unknown committed
1639
    CFG_CONNECTION_SERVER_PORT,
1640 1641 1642
    "PortNumber",
    "TCP",
    "Port used for this transporter",
unknown's avatar
unknown committed
1643
    ConfigInfo::CI_USED,
1644
    false,
unknown's avatar
unknown committed
1645
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1646
    MANDATORY,
1647
    "0",
1648
    STR_VALUE(MAX_INT_RNIL) },
1649 1650 1651 1652 1653 1654

  {
    CFG_TCP_SEND_BUFFER_SIZE,
    "SendBufferMemory",
    "TCP",
    "Bytes of buffer for signals sent from this node",
unknown's avatar
unknown committed
1655
    ConfigInfo::CI_USED,
1656
    false,
unknown's avatar
unknown committed
1657
    ConfigInfo::CI_INT,
1658 1659
    "256K",
    "16K",
1660
    STR_VALUE(MAX_INT_RNIL) },
1661 1662 1663 1664 1665 1666

  {
    CFG_TCP_RECEIVE_BUFFER_SIZE,
    "ReceiveBufferMemory",
    "TCP",
    "Bytes of buffer for signals received by this node",
unknown's avatar
unknown committed
1667
    ConfigInfo::CI_USED,
1668
    false,
unknown's avatar
unknown committed
1669
    ConfigInfo::CI_INT,
1670 1671
    "64K",
    "16K",
1672
    STR_VALUE(MAX_INT_RNIL) },
1673 1674 1675 1676 1677 1678

  {
    CFG_TCP_PROXY,
    "Proxy",
    "TCP",
    "",
unknown's avatar
unknown committed
1679
    ConfigInfo::CI_USED,
1680
    false,
unknown's avatar
unknown committed
1681
    ConfigInfo::CI_STRING,
1682
    UNDEFINED,
1683
    0, 0 },
1684 1685 1686 1687 1688 1689

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "TCP",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1690
    ConfigInfo::CI_INTERNAL,
1691
    false,
unknown's avatar
unknown committed
1692
    ConfigInfo::CI_STRING,
1693
    UNDEFINED,
1694
    0, 0 },
1695 1696 1697 1698 1699 1700

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "TCP",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1701
    ConfigInfo::CI_INTERNAL,
1702
    false,
unknown's avatar
unknown committed
1703
    ConfigInfo::CI_STRING,
1704
    UNDEFINED,
1705
    0, 0 },
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
  

  /****************************************************************************
   * SHM
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SHM",
    "SHM",
    "Connection section",
unknown's avatar
unknown committed
1716
    ConfigInfo::CI_USED,
1717
    false,
unknown's avatar
unknown committed
1718
    ConfigInfo::CI_SECTION,
1719 1720
    (const char *)CONNECTION_TYPE_SHM, 
    0, 0 },
1721 1722

  {
1723 1724
    CFG_CONNECTION_HOSTNAME_1,
    "HostName1",
1725
    "SHM",
1726
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1727
    ConfigInfo::CI_INTERNAL,
1728
    false,
unknown's avatar
unknown committed
1729
    ConfigInfo::CI_STRING,
1730
    UNDEFINED,
1731
    0, 0 },
1732 1733 1734 1735 1736 1737

  {
    CFG_CONNECTION_HOSTNAME_2,
    "HostName2",
    "SHM",
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1738
    ConfigInfo::CI_INTERNAL,
1739
    false,
unknown's avatar
merge  
unknown committed
1740
    ConfigInfo::CI_STRING,
1741 1742 1743
    UNDEFINED,
    0, 0 },

unknown's avatar
unknown committed
1744 1745 1746 1747 1748
  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
    "SHM",
    "Port used for this transporter",
unknown's avatar
unknown committed
1749
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1750
    false,
unknown's avatar
unknown committed
1751
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1752
    MANDATORY,
1753
    "0", 
1754
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
1755

1756 1757 1758 1759 1760
  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SHM",
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
merge  
unknown committed
1761
    ConfigInfo::CI_USED,
1762
    false,
unknown's avatar
merge  
unknown committed
1763
    ConfigInfo::CI_STRING,
1764 1765 1766
    MANDATORY,
    0, 0 },
  
1767 1768 1769 1770
  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SHM",
1771
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1772
    ConfigInfo::CI_USED,
1773
    false,
unknown's avatar
unknown committed
1774
    ConfigInfo::CI_STRING,
1775
    MANDATORY,
1776
    0, 0 },
1777
  
1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SHM",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "35",
    "0", "200" },

1789 1790 1791 1792 1793
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SHM",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1794
    ConfigInfo::CI_USED,
1795
    false,
unknown's avatar
unknown committed
1796
    ConfigInfo::CI_BOOL,
1797 1798 1799
    "false",
    "false",
    "true" },
1800 1801 1802 1803 1804 1805 1806
  
  
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SHM",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1807
    ConfigInfo::CI_USED,
1808
    false,
unknown's avatar
unknown committed
1809
    ConfigInfo::CI_BOOL,
1810 1811 1812
    "true",
    "false",
    "true" },
1813 1814 1815 1816 1817 1818
  
  {
    CFG_SHM_KEY,
    "ShmKey",
    "SHM",
    "A shared memory key",
unknown's avatar
unknown committed
1819
    ConfigInfo::CI_USED,
1820
    false,
unknown's avatar
unknown committed
1821
    ConfigInfo::CI_INT,
1822
    "0",
1823
    "0",
1824
    STR_VALUE(MAX_INT_RNIL) },
1825 1826 1827 1828 1829 1830
  
  {
    CFG_SHM_BUFFER_MEM,
    "ShmSize",
    "SHM",
    "Size of shared memory segment",
unknown's avatar
unknown committed
1831
    ConfigInfo::CI_USED,
1832
    false,
unknown's avatar
unknown committed
1833
    ConfigInfo::CI_INT,
1834 1835
    "1M",
    "4K",
1836
    STR_VALUE(MAX_INT_RNIL) },
1837

1838 1839 1840 1841 1842
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SHM",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1843
    ConfigInfo::CI_INTERNAL,
1844
    false,
unknown's avatar
unknown committed
1845
    ConfigInfo::CI_STRING,
1846
    UNDEFINED,
1847
    0, 0 },
1848 1849 1850 1851 1852 1853

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SHM",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1854
    ConfigInfo::CI_INTERNAL,
1855
    false,
unknown's avatar
unknown committed
1856
    ConfigInfo::CI_STRING,
1857
    UNDEFINED,
1858
    0, 0 },
1859 1860 1861 1862 1863 1864 1865 1866 1867

  /****************************************************************************
   * SCI
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SCI",
    "SCI",
    "Connection section",
unknown's avatar
unknown committed
1868
    ConfigInfo::CI_USED,
1869
    false,
unknown's avatar
unknown committed
1870
    ConfigInfo::CI_SECTION,
1871
    (const char *)CONNECTION_TYPE_SCI, 
1872 1873 1874 1875 1876 1877 1878
    0, 0 
  },

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SCI",
1879
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1880
    ConfigInfo::CI_USED,
1881
    false,
unknown's avatar
unknown committed
1882
    ConfigInfo::CI_STRING,
1883
    MANDATORY,
1884
    "0",
1885
    STR_VALUE(MAX_INT_RNIL) },
1886 1887 1888 1889 1890

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SCI",
1891
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1892
    ConfigInfo::CI_USED,
1893
    false,
unknown's avatar
unknown committed
1894
    ConfigInfo::CI_STRING,
1895
    MANDATORY,
1896
    "0",
1897
    STR_VALUE(MAX_INT_RNIL) },
1898

1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SCI",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "15",
    "0", "200" },

1910
  {
unknown's avatar
unknown committed
1911
    CFG_CONNECTION_HOSTNAME_1,
unknown's avatar
unknown committed
1912 1913 1914
    "HostName1",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1915
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
1916
    false,
unknown's avatar
unknown committed
1917
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1918 1919 1920 1921
    UNDEFINED,
    0, 0 },

  {
unknown's avatar
unknown committed
1922
    CFG_CONNECTION_HOSTNAME_2,
unknown's avatar
unknown committed
1923 1924 1925
    "HostName2",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1926
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
1927
    false,
unknown's avatar
unknown committed
1928
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1929 1930 1931 1932 1933 1934
    UNDEFINED,
    0, 0 },

  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
1935
    "SCI",
unknown's avatar
unknown committed
1936
    "Port used for this transporter",
unknown's avatar
unknown committed
1937
    ConfigInfo::CI_USED,
1938
    false,
unknown's avatar
unknown committed
1939
    ConfigInfo::CI_INT,
1940
    MANDATORY,
unknown's avatar
unknown committed
1941 1942 1943 1944 1945 1946 1947 1948
    "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)",
unknown's avatar
unknown committed
1949
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1950
    false,
unknown's avatar
unknown committed
1951
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1952 1953 1954 1955 1956 1957 1958 1959 1960
    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)",
unknown's avatar
unknown committed
1961
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1962
    false,
unknown's avatar
unknown committed
1963
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1964
    "0",
1965
    "0",
1966
    STR_VALUE(MAX_INT_RNIL) },
1967 1968

  {
unknown's avatar
unknown committed
1969 1970
    CFG_SCI_HOST2_ID_0,
    "Host2SciId0",
1971
    "SCI",
unknown's avatar
unknown committed
1972
    "SCI-node id for adapter 0 on Host2 (a computer can have two adapters)",
unknown's avatar
unknown committed
1973
    ConfigInfo::CI_USED,
1974
    false,
unknown's avatar
unknown committed
1975
    ConfigInfo::CI_INT,
1976
    MANDATORY,
1977
    "0",
1978
    STR_VALUE(MAX_INT_RNIL) },
1979

unknown's avatar
unknown committed
1980 1981 1982 1983 1984
  {
    CFG_SCI_HOST2_ID_1,
    "Host2SciId1",
    "SCI",
    "SCI-node id for adapter 1 on Host2 (a computer can have two adapters)",
unknown's avatar
unknown committed
1985
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1986
    false,
unknown's avatar
unknown committed
1987
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1988 1989 1990 1991
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },

1992 1993 1994 1995 1996
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SCI",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1997
    ConfigInfo::CI_USED,
1998
    false,
unknown's avatar
unknown committed
1999
    ConfigInfo::CI_BOOL,
2000 2001 2002
    "true",
    "false",
    "true" },
2003 2004 2005 2006 2007 2008

  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SCI",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
2009
    ConfigInfo::CI_USED,
2010
    false,
unknown's avatar
unknown committed
2011
    ConfigInfo::CI_BOOL,
2012 2013 2014
    "false",
    "false",
    "true" },
2015 2016 2017 2018 2019 2020

  {
    CFG_SCI_SEND_LIMIT,
    "SendLimit",
    "SCI",
    "Transporter send buffer contents are sent when this no of bytes is buffered",
unknown's avatar
unknown committed
2021
    ConfigInfo::CI_USED,
2022
    false,
unknown's avatar
unknown committed
2023
    ConfigInfo::CI_INT,
2024
    "8K",
unknown's avatar
unknown committed
2025 2026
    "128",
    "32K" },
2027 2028 2029 2030 2031 2032

  {
    CFG_SCI_BUFFER_MEM,
    "SharedBufferSize",
    "SCI",
    "Size of shared memory segment",
unknown's avatar
unknown committed
2033
    ConfigInfo::CI_USED,
2034
    false,
unknown's avatar
unknown committed
2035
    ConfigInfo::CI_INT,
2036
    "1M",
unknown's avatar
unknown committed
2037
    "64K",
2038
    STR_VALUE(MAX_INT_RNIL) },
2039 2040 2041 2042 2043 2044

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SCI",
    "System for node 1 in connection",
unknown's avatar
unknown committed
2045
    ConfigInfo::CI_INTERNAL,
2046
    false,
unknown's avatar
unknown committed
2047
    ConfigInfo::CI_STRING,
2048
    UNDEFINED,
2049
    0, 0 },
2050 2051 2052 2053 2054 2055

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SCI",
    "System for node 2 in connection",
unknown's avatar
unknown committed
2056
    ConfigInfo::CI_INTERNAL,
2057
    false,
unknown's avatar
unknown committed
2058
    ConfigInfo::CI_STRING,
2059
    UNDEFINED,
2060
    0, 0 },
2061 2062

  /****************************************************************************
2063 2064 2065 2066 2067 2068 2069
   * OSE
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "OSE",
    "OSE",
    "Connection section",
unknown's avatar
unknown committed
2070
    ConfigInfo::CI_USED,
2071
    false,
unknown's avatar
unknown committed
2072
    ConfigInfo::CI_SECTION,
2073
    (const char *)CONNECTION_TYPE_OSE, 
2074
    0, 0 
2075 2076
  },

2077
  {
2078
    CFG_CONNECTION_HOSTNAME_1,
2079 2080 2081
    "HostName1",
    "OSE",
    "Name of computer on one side of the connection",
unknown's avatar
unknown committed
2082
    ConfigInfo::CI_USED,
2083
    false,
unknown's avatar
unknown committed
2084
    ConfigInfo::CI_STRING,
2085
    UNDEFINED,
2086
    0, 0 },
2087 2088

  {
2089
    CFG_CONNECTION_HOSTNAME_2,
2090 2091 2092
    "HostName2",
    "OSE",
    "Name of computer on one side of the connection",
unknown's avatar
unknown committed
2093
    ConfigInfo::CI_USED,
2094
    false,
unknown's avatar
unknown committed
2095
    ConfigInfo::CI_STRING,
2096
    UNDEFINED,
2097
    0, 0 },
2098 2099 2100 2101 2102

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "OSE",
2103
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
2104
    ConfigInfo::CI_USED,
2105
    false,
unknown's avatar
unknown committed
2106
    ConfigInfo::CI_INT,
2107
    MANDATORY,
2108
    "0",
2109
    STR_VALUE(MAX_INT_RNIL) },
2110 2111 2112 2113 2114

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "OSE",
2115
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
2116
    ConfigInfo::CI_USED,
2117
    false,
unknown's avatar
unknown committed
2118
    ConfigInfo::CI_INT,
2119
    UNDEFINED,
2120
    "0",
2121
    STR_VALUE(MAX_INT_RNIL) },
2122

2123 2124 2125 2126 2127
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "OSE",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
2128
    ConfigInfo::CI_USED,
2129
    false,
unknown's avatar
unknown committed
2130
    ConfigInfo::CI_BOOL,
2131 2132 2133
    "true",
    "false",
    "true" },
2134

2135 2136 2137 2138 2139
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "OSE",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
2140
    ConfigInfo::CI_USED,
2141
    false,
unknown's avatar
unknown committed
2142
    ConfigInfo::CI_BOOL,
2143 2144 2145
    "false",
    "false",
    "true" },
2146 2147 2148 2149 2150 2151

  {
    CFG_OSE_PRIO_A_SIZE,
    "PrioASignalSize",
    "OSE",
    "Size of priority A signals (in bytes)",
unknown's avatar
unknown committed
2152
    ConfigInfo::CI_USED,
2153
    false,
unknown's avatar
unknown committed
2154
    ConfigInfo::CI_INT,
2155 2156
    "1000",
    "0",
2157
    STR_VALUE(MAX_INT_RNIL) },
2158

2159 2160 2161 2162 2163
  {
    CFG_OSE_PRIO_B_SIZE,
    "PrioBSignalSize",
    "OSE",
    "Size of priority B signals (in bytes)",
unknown's avatar
unknown committed
2164
    ConfigInfo::CI_USED,
2165
    false,
unknown's avatar
unknown committed
2166
    ConfigInfo::CI_INT,
2167 2168
    "1000",
    "0",
2169
    STR_VALUE(MAX_INT_RNIL) },
2170 2171 2172 2173 2174 2175
  
  {
    CFG_OSE_RECEIVE_ARRAY_SIZE,
    "ReceiveArraySize",
    "OSE",
    "Number of OSE signals checked for correct ordering (in no of OSE signals)",
unknown's avatar
unknown committed
2176
    ConfigInfo::CI_USED,
2177
    false,
unknown's avatar
unknown committed
2178
    ConfigInfo::CI_INT,
2179 2180
    "10",
    "0",
2181
    STR_VALUE(MAX_INT_RNIL) },
2182

2183 2184 2185 2186 2187
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "OSE",
    "System for node 1 in connection",
unknown's avatar
unknown committed
2188
    ConfigInfo::CI_INTERNAL,
2189
    false,
unknown's avatar
unknown committed
2190
    ConfigInfo::CI_STRING,
2191
    UNDEFINED,
2192
    0, 0 },
2193

2194 2195 2196 2197 2198
  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "OSE",
    "System for node 2 in connection",
unknown's avatar
unknown committed
2199
    ConfigInfo::CI_INTERNAL,
2200
    false,
unknown's avatar
unknown committed
2201
    ConfigInfo::CI_STRING,
2202
    UNDEFINED,
2203
    0, 0 },
2204 2205 2206 2207 2208 2209 2210 2211
};

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


/****************************************************************************
 * Ctor
 ****************************************************************************/
unknown's avatar
unknown committed
2212
static void require(bool v) { if(!v) abort();}
2213

2214 2215 2216
ConfigInfo::ConfigInfo()
  : m_info(true), m_systemDefaults(true)
{
unknown's avatar
unknown committed
2217
  int i;
2218 2219 2220
  Properties *section;
  const Properties *oldpinfo;

unknown's avatar
unknown committed
2221
  for (i=0; i<m_NoOfParams; i++) {
2222
    const ParamInfo & param = m_ParamInfo[i];
2223 2224
    Uint64 default_uint64;
    bool   default_bool;
2225 2226 2227
    
    // Create new section if it did not exist
    if (!m_info.getCopy(param._section, &section)) {
2228
      Properties newsection(true);
2229 2230
      m_info.put(param._section, &newsection);
    }
2231
    
2232 2233 2234 2235
    // Get copy of section
    m_info.getCopy(param._section, &section);
    
    // Create pinfo (parameter info) entry 
2236
    Properties pinfo(true); 
2237
    pinfo.put("Id",          param._paramId);
2238 2239 2240 2241 2242
    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);
2243 2244 2245 2246 2247 2248

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

    switch (param._type) {
unknown's avatar
unknown committed
2249
      case CI_BOOL:
2250 2251 2252 2253 2254 2255 2256 2257
      {
	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;
      }
unknown's avatar
unknown committed
2258 2259
      case CI_INT:
      case CI_INT64:
2260 2261 2262 2263 2264 2265 2266 2267
      {
	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;
      }
unknown's avatar
unknown committed
2268
      case CI_SECTION:
unknown's avatar
unknown committed
2269
	pinfo.put("SectionType", (Uint32)UintPtr(param._default));
2270
	break;
unknown's avatar
unknown committed
2271
      case CI_STRING:
2272 2273
	break;
    }
2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287

    // 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);
2288
    
unknown's avatar
unknown committed
2289
    if(param._type != ConfigInfo::CI_SECTION){
2290 2291
      Properties * p;
      if(!m_systemDefaults.getCopy(param._section, &p)){
2292
	p = new Properties(true);
2293
      }
2294
      if(param._default != UNDEFINED &&
2295
	 param._default != MANDATORY){
2296 2297
	switch (param._type)
        {
unknown's avatar
unknown committed
2298
	  case CI_SECTION:
2299
	    break;
unknown's avatar
unknown committed
2300
	  case CI_STRING:
2301 2302
	    require(p->put(param._fname, param._default));
	    break;
unknown's avatar
unknown committed
2303
	  case CI_BOOL:
2304 2305 2306 2307 2308 2309
	    {
	      bool tmp_bool;
	      require(InitConfigFileParser::convertStringToBool(param._default, default_bool));
	      require(p->put(param._fname, default_bool));
	      break;
	    }
unknown's avatar
unknown committed
2310 2311
	  case CI_INT:
	  case CI_INT64:
2312 2313 2314 2315 2316 2317 2318
	    {
	      Uint64 tmp_uint64;
	      require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64));
	      require(p->put(param._fname, default_uint64));
	      break;
	    }
	}
2319 2320 2321 2322 2323
      }
      require(m_systemDefaults.put(param._section, p, true));
      delete p;
    }
  }
2324
  
unknown's avatar
unknown committed
2325
  for (i=0; i<m_NoOfParams; i++) {
2326
    if(m_ParamInfo[i]._section == NULL){
2327 2328
      ndbout << "Check that each entry has a section failed." << endl;
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname << endl; 
2329 2330 2331
      ndbout << "Edit file " << __FILE__ << "." << endl;
      exit(-1);
    }
2332
    
unknown's avatar
unknown committed
2333
    if(m_ParamInfo[i]._type == ConfigInfo::CI_SECTION)
2334 2335
      continue;

2336
    const Properties * p = getInfo(m_ParamInfo[i]._section);
2337
    if (!p || !p->contains(m_ParamInfo[i]._fname)) {
2338
      ndbout << "Check that each pname has an fname failed." << endl;
2339
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname 
2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359
	     << "\" 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)){
2360 2361
    return 0;
    //    warning("getInfo", section);
2362 2363 2364 2365 2366 2367 2368 2369
  }
  return p;
}

const Properties * 
ConfigInfo::getDefaults(const char * section) const {
  const Properties * p;
  if(!m_systemDefaults.get(section, &p)){
2370 2371
    return 0;
    //warning("getDefaults", section);
2372 2373 2374 2375 2376
  }
  return p;
}

static
2377
Uint64
2378 2379
getInfoInt(const Properties * section, 
	   const char* fname, const char * type){
2380
  Uint32 val32;
2381
  const Properties * p;
2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393
  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();
2394
  }
2395

2396
  warning(type, fname);
2397
  return 0;
2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412
}

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;
}

2413
Uint64
2414 2415 2416 2417
ConfigInfo::getMax(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Max");
}

2418
Uint64
2419 2420 2421 2422
ConfigInfo::getMin(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Min");
}

2423
Uint64
2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436
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++) {
2437
    if(!strcasecmp(section, m_sectionNames[i])) return true;
2438 2439 2440 2441
  }
  return false;
}

unknown's avatar
unknown committed
2442 2443 2444
const char*
ConfigInfo::getAlias(const char * section) const {
  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
2445
    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
unknown's avatar
unknown committed
2446 2447 2448 2449
      return m_sectionNameAliases[i].name;
  return 0;
}

2450 2451
bool
ConfigInfo::verify(const Properties * section, const char* fname, 
2452
		   Uint64 value) const {
2453
  Uint64 min, max;
2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492

  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
unknown's avatar
unknown committed
2493 2494 2495
    if (getStatus(sec, n) == ConfigInfo::CI_INTERNAL) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_DEPRICATED) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_NOTIMPLEMENTED) continue;
2496 2497 2498 2499 2500 2501
    print(sec, n);
  }
}

void ConfigInfo::print(const Properties * section, 
		       const char* parameter) const {
2502
  ndbout << parameter;
2503 2504
  //  ndbout << getDescription(section, parameter) << endl;
  switch (getType(section, parameter)) {
unknown's avatar
unknown committed
2505
  case ConfigInfo::CI_BOOL:
2506 2507 2508 2509 2510 2511
    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;
2512
    } else if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2513 2514 2515 2516 2517 2518 2519
      ndbout << "MANDATORY (Legal values: Y, N)" << endl;
    } else {
      ndbout << "UNKNOWN" << endl;
    }
    ndbout << endl;
    break;    
    
unknown's avatar
unknown committed
2520 2521
  case ConfigInfo::CI_INT:
  case ConfigInfo::CI_INT64:
2522 2523
    ndbout << " (Non-negative Integer)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2524
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2525
      ndbout << "MANDATORY (";
2526
    } else if (getDefault(section, parameter) == (UintPtr)UNDEFINED) {
2527 2528 2529 2530 2531 2532 2533 2534 2535
      ndbout << "UNDEFINED (";
    } else {
      ndbout << "Default: " << getDefault(section, parameter) << " (";
    }
    ndbout << "Min: " << getMin(section, parameter) << ", ";
    ndbout << "Max: " << getMax(section, parameter) << ")" << endl;
    ndbout << endl;
    break;
    
unknown's avatar
unknown committed
2536
  case ConfigInfo::CI_STRING:
2537 2538
    ndbout << " (String)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2539
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2540 2541 2542 2543 2544 2545
      ndbout << "MANDATORY" << endl;
    } else {
      ndbout << "No default value" << endl;
    }
    ndbout << endl;
    break;
unknown's avatar
unknown committed
2546
  case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2547
    break;
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562
  }
}

/****************************************************************************
 * 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)){
2563 2564 2565 2566 2567 2568 2569 2570
    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
2571 2572 2573 2574
    ctx.reportError("Mandatory parameter Id missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
2575 2576 2577 2578 2579 2580
#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;
2581
  }
2582 2583

  ctx.m_userProperties.put("AllocatedNodeId_", id, id);
2584
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
2585 2586 2587 2588 2589 2590 2591
  
  ctx.m_currentSection->put("Type", ctx.fname);

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

unknown's avatar
unknown committed
2592 2593 2594 2595 2596 2597 2598
  /**
   * Update count (per type)
   */
  nodes = 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  ctx.m_userProperties.put(ctx.fname, ++nodes, true);

2599 2600 2601
  return true;
}

unknown's avatar
unknown committed
2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629
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);
}

2630 2631 2632
bool
fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){
  
2633 2634
  const char * hostname;
  if (ctx.m_currentSection->get("HostName", &hostname))
unknown's avatar
unknown committed
2635
    return checkLocalhostHostnameMix(ctx);
2636

2637 2638
  const char * compId;
  if(!ctx.m_currentSection->get("ExecuteOnComputer", &compId)){
unknown's avatar
unknown committed
2639
    const char * type;
2640
    if(ctx.m_currentSection->get("Type", &type) && strcmp(type,DB_TOKEN) == 0)
2641 2642 2643
      require(ctx.m_currentSection->put("HostName", "localhost"));
    else
      require(ctx.m_currentSection->put("HostName", ""));
unknown's avatar
unknown committed
2644
    return checkLocalhostHostnameMix(ctx);
2645 2646 2647 2648
  }
  
  const Properties * computer;
  char tmp[255];
2649
  BaseString::snprintf(tmp, sizeof(tmp), "Computer_%s", compId);
2650 2651 2652 2653
  if(!ctx.m_config->get(tmp, &computer)){
    ctx.reportError("Computer \"%s\" not declared"
		    "- [%s] starting at line: %d",
		    compId, ctx.fname, ctx.m_sectionLineno);
unknown's avatar
unknown committed
2654
    return false;
2655 2656 2657
  }
  
  if(!computer->get("HostName", &hostname)){
unknown's avatar
unknown committed
2658 2659
    ctx.reportError("HostName missing in [COMPUTER] (Id: %d) "
		    " - [%s] starting at line: %d",
2660
		    compId, ctx.fname, ctx.m_sectionLineno);
unknown's avatar
unknown committed
2661
    return false;
2662 2663 2664
  }
  
  require(ctx.m_currentSection->put("HostName", hostname));
unknown's avatar
unknown committed
2665
  return checkLocalhostHostnameMix(ctx);
2666 2667
}

2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685
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
unknown's avatar
unknown committed
2686
fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
2687 2688
  
  const char * path;
unknown's avatar
unknown committed
2689
  if (ctx.m_currentSection->get("BackupDataDir", &path))
2690 2691 2692
    return true;

  if (ctx.m_currentSection->get("FileSystemPath", &path)) {
unknown's avatar
unknown committed
2693
    require(ctx.m_currentSection->put("BackupDataDir", path));
2694 2695 2696 2697 2698 2699 2700
    return true;
  }

  require(false);
  return false;
}

2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726
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));

2727
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s:Node_%d", 
2728 2729 2730 2731 2732 2733
	   systemName, id);

  return true;
}

/**
2734
 * Connection rule: Check support of connection
2735 2736
 */
bool
2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770
checkConnectionSupport(InitConfigFileParser::Context & ctx, const char * data)
{
  int error= 0;
  if (strcasecmp("TCP",ctx.fname) == 0)
  {
    // always enabled
  }
  else if (strcasecmp("SHM",ctx.fname) == 0)
  {
#ifndef NDB_SHM_TRANSPORTER
    error= 1;
#endif
  }
  else if (strcasecmp("SCI",ctx.fname) == 0)
  {
#ifndef NDB_SCI_TRANSPORTER
    error= 1;
#endif
  }
  else if (strcasecmp("OSE",ctx.fname) == 0)
  {
#ifndef NDB_OSE_TRANSPORTER
    error= 1;
#endif
  }
  if (error)
  {
    ctx.reportError("Binary not compiled with this connection support, "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
  }
  return true;
}
2771

2772 2773 2774 2775 2776 2777
/**
 * Connection rule: Update "NoOfConnections"
 */
bool
transformConnection(InitConfigFileParser::Context & ctx, const char * data)
{
2778 2779
  Uint32 connections = 0;
  ctx.m_userProperties.get("NoOfConnections", &connections);
2780
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Connection_%d", connections);
2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799
  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;
  }
unknown's avatar
unknown committed
2800 2801 2802

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

2803
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "SYSTEM_%s", name);
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819
  
  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;
  }
2820
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s", name);
2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836
  
  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;
  }
2837
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Computer_%s", id);
2838 2839 2840 2841 2842
  
  Uint32 computers = 0;
  ctx.m_userProperties.get("NoOfComputers", &computers);
  ctx.m_userProperties.put("NoOfComputers", ++computers, true);
  
2843 2844 2845 2846 2847 2848
  const char * hostname = 0;
  ctx.m_currentSection->get("HostName", &hostname);
  if(!hostname){
    return true;
  }
  
unknown's avatar
unknown committed
2849
  return checkLocalhostHostnameMix(ctx);
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861
}

/**
 * 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()){
2862
      ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name);
2863 2864
      if(!ctx.m_currentSection->contains(name)){
	switch (ctx.m_info->getType(ctx.m_currentInfo, name)){
unknown's avatar
unknown committed
2865 2866
	case ConfigInfo::CI_INT:
	case ConfigInfo::CI_BOOL:{
2867 2868 2869 2870 2871
	  Uint32 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
unknown's avatar
unknown committed
2872
	case ConfigInfo::CI_INT64:{
2873 2874 2875 2876 2877
	  Uint64 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put64(name, val);
	  break;
	}
unknown's avatar
unknown committed
2878
	case ConfigInfo::CI_STRING:{
2879 2880 2881 2882 2883
	  const char * val;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
unknown's avatar
unknown committed
2884
	case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2885
	  break;
2886 2887 2888 2889 2890 2891 2892 2893 2894
	}
      }
    }
  }
}

bool
applyDefaultValues(InitConfigFileParser::Context & ctx, const char * data){
  
2895 2896 2897 2898 2899 2900 2901
  if(strcmp(data, "user") == 0)
    applyDefaultValues(ctx, ctx.m_userDefaults);
  else if (strcmp(data, "system") == 0)
    applyDefaultValues(ctx, ctx.m_systemDefaults);
  else 
    return false;

2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915
  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;
2916
    if(info->get("Mandatory", &val)){
2917 2918
      const char * fname;
      ::require(info->get("Fname", &fname));
2919
      if(!ctx.m_currentSection->contains(fname)){
2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935
	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").
 */
2936
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
2937
{
2938 2939 2940 2941
  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));
2942

2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971
  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.
 */
2972
static bool 
2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999
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).
 */
3000
static bool
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012
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];
3013
    BaseString::snprintf(tmpLine1, MAX_LINE_LENGTH, "Connection_%d", connections-1);
3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054

    /**
     *  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
 */
3055
static bool
3056 3057 3058 3059 3060 3061 3062 3063
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));
3064
    
3065
    const Properties * node;
3066 3067 3068 3069 3070 3071 3072
    if(!ctx.m_config->get("Node", id, &node))
    {
      ctx.reportError("Unknown node: \"%d\" specified in connection "
		      "[%s] starting at line: %d",
		      id, ctx.fname, ctx.m_sectionLineno);
      return false;
    }
3073 3074
    
    const char * hostname;
3075
    require(node->get("HostName", &hostname));
3076 3077 3078 3079 3080 3081 3082 3083
    require(ctx.m_currentSection->put(data, hostname));
  }
  return true;
}

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

3087 3088
  DBUG_ENTER("fixPortNumber");

unknown's avatar
unknown committed
3089
  Uint32 id1= 0, id2= 0;
3090 3091
  const char *hostName1;
  const char *hostName2;
unknown's avatar
unknown committed
3092 3093
  require(ctx.m_currentSection->get("NodeId1", &id1));
  require(ctx.m_currentSection->get("NodeId2", &id2));
3094 3095 3096 3097 3098
  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));

3099 3100
  if (id1 > id2) {
    Uint32 tmp= id1;
3101 3102
    const char *tmp_name= hostName1;
    hostName1= hostName2;
3103
    id1= id2;
3104
    hostName2= tmp_name;
3105 3106
    id2= tmp;
  }
unknown's avatar
unknown committed
3107 3108 3109

  const Properties * node;
  require(ctx.m_config->get("Node", id1, &node));
3110 3111
  BaseString hostname(hostName1);
  //  require(node->get("HostName", hostname));
unknown's avatar
unknown committed
3112 3113
  
  if (hostname.c_str()[0] == 0) {
3114 3115
    ctx.reportError("Hostname required on nodeid %d since it will "
		    "act as server.", id1);
3116
    DBUG_RETURN(false);
unknown's avatar
unknown committed
3117 3118 3119
  }

  Uint32 port= 0;
3120 3121
  if (!node->get("ServerPort", &port) &&
      !ctx.m_userProperties.get("ServerPort_", id1, &port)) {
unknown's avatar
unknown committed
3122
    Uint32 adder= 0;
unknown's avatar
unknown committed
3123 3124 3125 3126 3127 3128 3129 3130
    {
      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;
unknown's avatar
unknown committed
3131
    if (!ctx.m_userProperties.get("ServerPortBase", &base)){
3132 3133
      if(!(ctx.m_userDefaults &&
	   ctx.m_userDefaults->get("PortNumber", &base)) &&
unknown's avatar
unknown committed
3134
	 !ctx.m_systemDefaults->get("PortNumber", &base)) {
unknown's avatar
unknown committed
3135
	base= strtoll(NDB_TCP_BASE_PORT,0,0);
unknown's avatar
unknown committed
3136 3137 3138 3139
      //      ctx.reportError("Cannot retrieve base port number");
      //      return false;
      }
      ctx.m_userProperties.put("ServerPortBase", base);
3140
    }
unknown's avatar
unknown committed
3141 3142 3143 3144 3145
    port= base + adder;
    ctx.m_userProperties.put("ServerPort_", id1, port);
  }

  if(ctx.m_currentSection->contains("PortNumber")) {
3146 3147 3148
    ndbout << "PortNumber should no longer be specificied "
	   << "per connection, please remove from config. "
	   << "Will be changed to " << port << endl;
unknown's avatar
unknown committed
3149
    ctx.m_currentSection->put("PortNumber", port, true);
3150 3151 3152
  } 
  else
  {
unknown's avatar
unknown committed
3153
    ctx.m_currentSection->put("PortNumber", port);
3154
  }
3155 3156
  DBUG_PRINT("info", ("connection %d-%d port %d host %s",
		      id1, id2, port, hostname.c_str()));
3157 3158

  DBUG_RETURN(true);
3159 3160
}

unknown's avatar
unknown committed
3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175
static bool 
fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data)
{
  DBUG_ENTER("fixShmUniqueId");
  Uint32 nodes= 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  if (nodes == 1) // first management server
  {
    Uint32 portno= atoi(NDB_PORT);
    ctx.m_currentSection->get("PortNumber", &portno);
    ctx.m_userProperties.put("ShmUniqueId", portno);
  }
  DBUG_RETURN(true);
}

3176 3177 3178 3179
static 
bool 
fixShmKey(InitConfigFileParser::Context & ctx, const char *)
{
unknown's avatar
unknown committed
3180
  DBUG_ENTER("fixShmKey");
3181 3182 3183 3184
  Uint32 id1= 0, id2= 0, key= 0;
  require(ctx.m_currentSection->get("NodeId1", &id1));
  require(ctx.m_currentSection->get("NodeId2", &id2));
  if(ctx.m_currentSection->get("ShmKey", &key))
unknown's avatar
unknown committed
3185 3186 3187
  {
    DBUG_RETURN(true);
  }
3188

unknown's avatar
unknown committed
3189 3190
  require(ctx.m_userProperties.get("ShmUniqueId", &key));
  key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1);
3191
  ctx.m_currentSection->put("ShmKey", key);
unknown's avatar
unknown committed
3192 3193
  DBUG_PRINT("info",("Added ShmKey=0x%x", key));
  DBUG_RETURN(true);
3194 3195
}

3196 3197 3198
/**
 * DB Node rule: Check various constraints
 */
3199
static bool
3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231
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
 */
3232
static bool
3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277
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
   */
3278 3279
  if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) &&
     !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0) &&
3280 3281 3282 3283 3284 3285 3286 3287
     !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;
  }
3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303

  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;
  }
3304 3305
  return true;
}
3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326

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) 
unknown's avatar
unknown committed
3327
       && (newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_INT64 || newType == ConfigInfo::CI_BOOL))){
unknown's avatar
unknown committed
3328
    ndbout << "oldType: " << (int)oldType << ", newType: " << (int)newType << endl;
3329 3330 3331 3332 3333 3334 3335 3336 3337
    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));

unknown's avatar
unknown committed
3338
  Uint64 newVal = (Uint64)((Int64)oldVal * mul + add);
3339 3340 3341 3342 3343 3344 3345 3346
  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;
  }

unknown's avatar
unknown committed
3347
  if(newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_BOOL){
3348
    require(dst.put(newName, (Uint32)newVal));
unknown's avatar
unknown committed
3349
  } else if(newType == ConfigInfo::CI_INT64) {
3350 3351 3352 3353 3354
    require(dst.put64(newName, newVal));    
  }
  return true;
}

3355
static bool
3356
fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
unknown's avatar
unknown committed
3357
  const char * name;
3358 3359 3360 3361
  /**
   * Transform old values to new values
   * Transform new values to old values (backward compatible)
   */
3362
  Properties tmp(true);
3363
  Properties::Iterator it(ctx.m_currentSection);
unknown's avatar
unknown committed
3364
  for (name = it.first(); name != NULL; name = it.next()) {
3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384
    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);
unknown's avatar
unknown committed
3385
  for (name = it2.first(); name != NULL; name = it2.next()) {
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414
    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;
}

3415
static bool
3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428
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));
3429
    require(sec->get("SectionType", &typeVal));
3430
    
unknown's avatar
unknown committed
3431
    if(id == KEY_INTERNAL || status == ConfigInfo::CI_INTERNAL){
3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479
      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();
      }
3480
      require(ok);
3481 3482 3483 3484 3485
    }
    ctx.m_configValues.closeSection();
  } while(0);
  return true;
}
3486

3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509
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;
}

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
static void
add_a_connection(Vector<ConfigInfo::ConfigRuleSection>&sections,
		 struct InitConfigFileParser::Context &ctx,
		 Uint32 nodeId1, Uint32 nodeId2, bool use_shm)
{
  ConfigInfo::ConfigRuleSection s;
  const char *hostname1= 0, *hostname2= 0;
  const Properties *tmp;
  
  require(ctx.m_config->get("Node", nodeId1, &tmp));
  tmp->get("HostName", &hostname1);
  
  require(ctx.m_config->get("Node", nodeId2, &tmp));
  tmp->get("HostName", &hostname2);
  
  char buf[16];
  s.m_sectionData= new Properties(true);
  BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1);
  s.m_sectionData->put("NodeId1", buf);
  BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2);
  s.m_sectionData->put("NodeId2", buf);

  if (use_shm &&
      hostname1 && hostname1[0] &&
      hostname2 && hostname2[0] &&
      strcmp(hostname1,hostname2) == 0)
  {
    s.m_sectionType= BaseString("SHM");
    DBUG_PRINT("info",("adding SHM connection %d %d",nodeId1,nodeId2));
  }
  else
  {
    s.m_sectionType= BaseString("TCP");
    DBUG_PRINT("info",("adding TCP connection %d %d",nodeId1,nodeId2));
  }

  sections.push_back(s);
}

3549
static bool
unknown's avatar
unknown committed
3550
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
3551
		   struct InitConfigFileParser::Context &ctx, 
unknown's avatar
unknown committed
3552
		   const char * rule_data)
3553
{
3554
  DBUG_ENTER("add_node_connections");
unknown's avatar
unknown committed
3555
  Uint32 i;
3556
  Properties * props= ctx.m_config;
3557 3558
  Properties p_connections(true);
  Properties p_connections2(true);
3559

unknown's avatar
unknown committed
3560
  for (i = 0;; i++){
3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577
    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);

3578
  Properties p_db_nodes(true);
3579 3580
  Properties p_api_nodes(true);
  Properties p_mgm_nodes(true);
3581

3582
  Uint32 i_db= 0, i_api= 0, i_mgm= 0, n;
unknown's avatar
unknown committed
3583
  for (i= 0, n= 0; n < nNodes; i++){
3584 3585 3586 3587 3588 3589 3590
    const Properties * tmp;
    if(!props->get("Node", i, &tmp)) continue;
    n++;

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

3591
    if (strcmp(type,DB_TOKEN) == 0)
3592
      p_db_nodes.put("", i_db++, i);
3593 3594 3595 3596
    else if (strcmp(type,API_TOKEN) == 0)
      p_api_nodes.put("", i_api++, i);
    else if (strcmp(type,MGM_TOKEN) == 0)
      p_mgm_nodes.put("", i_mgm++, i);
3597 3598 3599 3600
  }

  Uint32 nodeId1, nodeId2, dummy;

unknown's avatar
unknown committed
3601
  for (i= 0; p_db_nodes.get("", i, &nodeId1); i++){
3602 3603 3604
    for (Uint32 j= i+1;; j++){
      if(!p_db_nodes.get("", j, &nodeId2)) break;
      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
3605
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3606 3607 3608 3609
      }
    }
  }

3610
  for (i= 0; p_api_nodes.get("", i, &nodeId1); i++){
3611 3612 3613
    if(!p_connections.get("", nodeId1, &dummy)) {
      for (Uint32 j= 0;; j++){
	if(!p_db_nodes.get("", j, &nodeId2)) break;
3614
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3615 3616 3617 3618
      }
    }
  }

3619 3620 3621 3622 3623 3624 3625 3626 3627 3628
  for (i= 0; p_mgm_nodes.get("", i, &nodeId1); i++){
    if(!p_connections.get("", nodeId1, &dummy)) {
      for (Uint32 j= 0;; j++){
	if(!p_db_nodes.get("", j, &nodeId2)) break;
	add_a_connection(sections,ctx,nodeId1,nodeId2,0);
      }
    }
  }

  DBUG_RETURN(true);
3629
}
unknown's avatar
unknown committed
3630

3631 3632 3633 3634 3635 3636 3637
static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sections, 
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data)
{
  DBUG_ENTER("set_connection_priorities");
  DBUG_RETURN(true);
}
unknown's avatar
unknown committed
3638

3639
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
3640 3641
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data)
unknown's avatar
unknown committed
3642
{
unknown's avatar
unknown committed
3643 3644
#if 0
  Properties * props= ctx.m_config;
3645
  Properties computers(true);
unknown's avatar
unknown committed
3646
  Uint32 port_base = NDB_TCP_BASE_PORT;
unknown's avatar
unknown committed
3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667

  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);

3668
    if (strcmp(type,DB_TOKEN) == 0) {
unknown's avatar
unknown committed
3669 3670 3671 3672 3673 3674
      adder++;
      tmp->put("ServerPort", port_base+adder);
      computers.put("",computer, adder);
    }
  }
#endif
unknown's avatar
unknown committed
3675 3676 3677
  return true;
}

3678
static bool
unknown's avatar
unknown committed
3679 3680 3681 3682
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		       struct InitConfigFileParser::Context &ctx, 
		       const char * rule_data)
{
3683 3684 3685
  Uint32 db_nodes= 0;
  Uint32 replicas= 0;
  Uint32 db_host_count= 0;
3686
  ctx.m_userProperties.get(DB_TOKEN, &db_nodes);
unknown's avatar
unknown committed
3687 3688 3689 3690 3691 3692
  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;
  }
3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704
  // 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";
3705 3706
    const char *arbit_warn_fmt2=
      "\n  arbitrator with id %d has no hostname specified";
3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762

    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);
unknown's avatar
unknown committed
3763
	    if (c+1 == (1u << (replicas-1))) // all nodes on same machine
3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788
	      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);
	    }
	  }
3789 3790 3791 3792
	  else
	  {
	    arbitration_warning.appfmt(arbit_warn_fmt2, i);
	  }
3793 3794 3795 3796 3797 3798
	}
      }
    }
    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)
3799 3800 3801
      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.");
3802
  }
unknown's avatar
unknown committed
3803 3804 3805
  return true;
}

unknown's avatar
unknown committed
3806
template class Vector<ConfigInfo::ConfigRuleSection>;