ConfigInfo.cpp 93.7 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
#include <ndb_global.h>
18
#include <ndb_opt_defaults.h>
unknown's avatar
unknown committed
19

20
#include <NdbTCP.h>
21
#include "ConfigInfo.hpp"
22
#include <mgmapi_config_parameters.h>
23
#include <ndb_limits.h>
24
#include "InitConfigFileParser.hpp"
unknown's avatar
unknown committed
25
#include <m_string.h>
26

27 28
extern my_bool opt_ndb_shm;

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

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

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

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

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

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

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

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

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


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

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

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

116 117
  { MGM_TOKEN,  fixShmUniqueId, 0 },

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

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

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

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

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

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

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

  { DB_TOKEN,   checkDbConstraints, 0 },
175

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  {
unknown's avatar
unknown committed
876
    CFG_DB_MAX_OPEN_FILES,
877
    "MaxNoOfOpenFiles",
878
    DB_TOKEN,
879
    "Max number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)",
unknown's avatar
unknown committed
880
    ConfigInfo::CI_USED,
881
    false,
unknown's avatar
unknown committed
882
    ConfigInfo::CI_INT,
883 884
    "40",
    "20",
unknown's avatar
unknown committed
885
    STR_VALUE(MAX_INT_RNIL) },
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

unknown's avatar
unknown committed
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
  {
    CFG_LOGLEVEL_CONGESTION,
    "LogLevelCongestion",
    DB_TOKEN,
    "Congestion info printed on stdout",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "0",
    "0",
    "15" },

1123 1124 1125
  {
    CFG_LOGLEVEL_ERROR,
    "LogLevelError",
1126
    DB_TOKEN,
1127
    "Transporter, heartbeat errors 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

  {
    CFG_LOGLEVEL_INFO,
    "LogLevelInfo",
1138
    DB_TOKEN,
1139
    "Heartbeat and log info printed on stdout",
unknown's avatar
unknown committed
1140
    ConfigInfo::CI_USED,
1141
    false,
unknown's avatar
unknown committed
1142
    ConfigInfo::CI_INT,
1143 1144 1145
    "0",
    "0",
    "15" },
1146 1147 1148 1149 1150 1151 1152

  /**
   * Backup
   */
  { 
    CFG_DB_PARALLEL_BACKUPS,
    "ParallelBackups",
1153
    DB_TOKEN,
1154
    "Maximum number of parallel backups",
unknown's avatar
unknown committed
1155
    ConfigInfo::CI_NOTIMPLEMENTED,
1156
    false,
unknown's avatar
unknown committed
1157
    ConfigInfo::CI_INT,
1158 1159 1160
    "1",
    "1",
    "1" },
1161
  
1162
  { 
unknown's avatar
unknown committed
1163 1164
    CFG_DB_BACKUP_DATADIR,
    "BackupDataDir",
1165 1166
    DB_TOKEN,
    "Path to where to store backups",
unknown's avatar
unknown committed
1167
    ConfigInfo::CI_USED,
1168
    false,
unknown's avatar
unknown committed
1169
    ConfigInfo::CI_STRING,
1170 1171 1172
    UNDEFINED,
    0, 0 },
  
1173 1174 1175
  { 
    CFG_DB_BACKUP_MEM,
    "BackupMemory",
1176
    DB_TOKEN,
1177
    "Total memory allocated for backups per node (in bytes)",
unknown's avatar
unknown committed
1178
    ConfigInfo::CI_USED,
1179
    false,
unknown's avatar
unknown committed
1180
    ConfigInfo::CI_INT,
1181 1182
    "4M", // sum of BackupDataBufferSize and BackupLogBufferSize
    "0",
1183
    STR_VALUE(MAX_INT_RNIL) },
1184 1185 1186 1187
  
  { 
    CFG_DB_BACKUP_DATA_BUFFER_MEM,
    "BackupDataBufferSize",
1188
    DB_TOKEN,
1189
    "Default size of databuffer 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_LOG_BUFFER_MEM,
    "BackupLogBufferSize",
1200
    DB_TOKEN,
1201
    "Default size of logbuffer for a 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
    "2M", // remember to change BackupMemory
    "0",
1207
    STR_VALUE(MAX_INT_RNIL) },
1208 1209 1210 1211

  { 
    CFG_DB_BACKUP_WRITE_SIZE,
    "BackupWriteSize",
1212
    DB_TOKEN,
1213
    "Default size of filesystem writes made by backup (in bytes)",
unknown's avatar
unknown committed
1214
    ConfigInfo::CI_USED,
1215
    false,
unknown's avatar
unknown committed
1216
    ConfigInfo::CI_INT,
1217 1218
    "32K",
    "0",
1219
    STR_VALUE(MAX_INT_RNIL) },
1220 1221 1222 1223 1224 1225 1226 1227 1228

  /***************************************************************************
   * REP
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
    "REP",
    "REP",
    "Node section",
unknown's avatar
unknown committed
1229
    ConfigInfo::CI_USED,
1230
    false,
unknown's avatar
unknown committed
1231
    ConfigInfo::CI_SECTION,
1232 1233
    (const char *)NODE_TYPE_REP, 
    0, 0
1234 1235 1236 1237 1238 1239 1240
  },

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

  {
    CFG_NODE_SYSTEM,
    "System",
    "REP",
    "Name of system for this node",
unknown's avatar
unknown committed
1252
    ConfigInfo::CI_INTERNAL,
1253
    false,
unknown's avatar
unknown committed
1254
    ConfigInfo::CI_STRING,
1255
    UNDEFINED,
1256
    0, 0 },
1257 1258 1259 1260 1261 1262

  {
    CFG_NODE_ID,
    "Id",
    "REP",
    "Number identifying replication node (REP)",
unknown's avatar
unknown committed
1263
    ConfigInfo::CI_USED,
1264
    false,
unknown's avatar
unknown committed
1265
    ConfigInfo::CI_INT,
1266
    MANDATORY,
1267
    "1",
1268
    STR_VALUE(MAX_NODES) },
1269 1270 1271 1272 1273 1274

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
    "REP",
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1275
    ConfigInfo::CI_USED,
1276
    false,
unknown's avatar
unknown committed
1277
    ConfigInfo::CI_STRING,
1278
    MANDATORY,
1279
    0, 0 },
1280 1281 1282 1283 1284 1285

  {
    CFG_REP_HEARTBEAT_INTERVAL,
    "HeartbeatIntervalRepRep",
    "REP",
    "Time between REP-REP heartbeats. Connection closed after 3 missed HBs",
unknown's avatar
unknown committed
1286
    ConfigInfo::CI_USED,
1287
    true,
unknown's avatar
unknown committed
1288
    ConfigInfo::CI_INT,
1289 1290
    "3000",
    "100",
1291
    STR_VALUE(MAX_INT_RNIL) },
1292 1293 1294 1295 1296 1297

  /***************************************************************************
   * API
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1298 1299
    API_TOKEN,
    API_TOKEN,
1300
    "Node section",
unknown's avatar
unknown committed
1301
    ConfigInfo::CI_USED,
1302
    false,
unknown's avatar
unknown committed
1303
    ConfigInfo::CI_SECTION,
1304 1305
    (const char *)NODE_TYPE_API, 
    0, 0
1306 1307 1308 1309 1310
  },

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

  {
    CFG_NODE_SYSTEM,
    "System",
1322
    API_TOKEN,
1323
    "Name of system for this node",
unknown's avatar
unknown committed
1324
    ConfigInfo::CI_INTERNAL,
1325
    false,
unknown's avatar
unknown committed
1326
    ConfigInfo::CI_STRING,
1327
    UNDEFINED,
1328
    0, 0 },
1329 1330 1331 1332

  {
    CFG_NODE_ID,
    "Id",
1333
    API_TOKEN,
1334
    "Number identifying application node ("API_TOKEN_PRINT")",
unknown's avatar
unknown committed
1335
    ConfigInfo::CI_USED,
1336
    false,
unknown's avatar
unknown committed
1337
    ConfigInfo::CI_INT,
1338
    MANDATORY,
1339
    "1",
1340
    STR_VALUE(MAX_NODES) },
1341 1342 1343 1344

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1345
    API_TOKEN,
1346
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1347
    ConfigInfo::CI_USED,
1348
    false,
unknown's avatar
unknown committed
1349
    ConfigInfo::CI_STRING,
1350 1351
    UNDEFINED,
    0, 0 },
1352 1353 1354 1355

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1356
    API_TOKEN,
1357
    "If 0, then "API_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1358
    ConfigInfo::CI_USED,
1359
    false,
unknown's avatar
unknown committed
1360
    ConfigInfo::CI_INT,
1361 1362 1363
    "0",
    "0",
    "2" },
1364 1365 1366 1367

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1368
    API_TOKEN,
1369
    "When asked to arbitrate, arbitrator waits this long before voting (msec)",
unknown's avatar
unknown committed
1370
    ConfigInfo::CI_USED,
1371
    false,
unknown's avatar
unknown committed
1372
    ConfigInfo::CI_INT,
1373 1374
    "0",
    "0",
1375
    STR_VALUE(MAX_INT_RNIL) },
1376

1377 1378 1379 1380 1381
  {
    CFG_MAX_SCAN_BATCH_SIZE,
    "MaxScanBatchSize",
    "API",
    "The maximum collective batch size for one scan",
unknown's avatar
unknown committed
1382
    ConfigInfo::CI_USED,
1383
    false,
unknown's avatar
unknown committed
1384
    ConfigInfo::CI_INT,
1385 1386 1387 1388
    STR_VALUE(MAX_SCAN_BATCH_SIZE),
    "32k",
    "16M" },
  
1389 1390 1391 1392 1393
  {
    CFG_BATCH_BYTE_SIZE,
    "BatchByteSize",
    "API",
    "The default batch size in bytes",
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(SCAN_BATCH_SIZE),
    "1k",
    "1M" },
1400 1401 1402 1403 1404 1405

  {
    CFG_BATCH_SIZE,
    "BatchSize",
    "API",
    "The default batch size in number of records",
unknown's avatar
unknown committed
1406
    ConfigInfo::CI_USED,
1407
    false,
unknown's avatar
unknown committed
1408
    ConfigInfo::CI_INT,
1409 1410 1411
    STR_VALUE(DEF_BATCH_SIZE),
    "1",
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
1412

1413 1414 1415 1416 1417
  /****************************************************************************
   * MGM
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1418 1419
    MGM_TOKEN,
    MGM_TOKEN,
1420
    "Node section",
unknown's avatar
unknown committed
1421
    ConfigInfo::CI_USED,
1422
    false,
unknown's avatar
unknown committed
1423
    ConfigInfo::CI_SECTION,
1424 1425
    (const char *)NODE_TYPE_MGM, 
    0, 0
1426 1427 1428 1429 1430
  },

  {
    CFG_NODE_HOST,
    "HostName",
1431
    MGM_TOKEN,
1432
    "Name of computer for this node",
unknown's avatar
unknown committed
1433
    ConfigInfo::CI_INTERNAL,
1434
    false,
unknown's avatar
unknown committed
1435
    ConfigInfo::CI_STRING,
1436
    UNDEFINED,
1437
    0, 0 },
1438

1439 1440 1441 1442 1443
  {
    CFG_NODE_DATADIR,
    "DataDir",
    MGM_TOKEN,
    "Data directory for this node",
unknown's avatar
unknown committed
1444
    ConfigInfo::CI_USED,
1445
    false,
unknown's avatar
unknown committed
1446
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1447
    MYSQLCLUSTERDIR,
1448 1449
    0, 0 },

1450 1451 1452
  {
    CFG_NODE_SYSTEM,
    "System",
1453
    MGM_TOKEN,
1454
    "Name of system for this node",
unknown's avatar
unknown committed
1455
    ConfigInfo::CI_INTERNAL,
1456
    false,
unknown's avatar
unknown committed
1457
    ConfigInfo::CI_STRING,
1458
    UNDEFINED,
1459
    0, 0 },
1460 1461 1462 1463

  {
    CFG_NODE_ID,
    "Id",
1464
    MGM_TOKEN,
1465
    "Number identifying the management server node ("MGM_TOKEN_PRINT")",
unknown's avatar
unknown committed
1466
    ConfigInfo::CI_USED,
1467
    false,
unknown's avatar
unknown committed
1468
    ConfigInfo::CI_INT,
1469
    MANDATORY,
1470
    "1",
1471
    STR_VALUE(MAX_NODES) },
1472 1473 1474 1475
  
  {
    CFG_LOG_DESTINATION,
    "LogDestination",
1476
    MGM_TOKEN,
1477
    "String describing where logmessages are sent",
unknown's avatar
unknown committed
1478
    ConfigInfo::CI_USED,
1479
    false,
unknown's avatar
unknown committed
1480
    ConfigInfo::CI_STRING,
1481
    0,
1482
    0, 0 },
1483 1484 1485 1486
  
  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1487
    MGM_TOKEN,
1488
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1489
    ConfigInfo::CI_USED,
1490
    false,
unknown's avatar
unknown committed
1491
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1492
    0,
1493 1494
    0, 0 },

1495 1496 1497
  {
    KEY_INTERNAL,
    "MaxNoOfSavedEvents",
1498
    MGM_TOKEN,
1499
    "",
unknown's avatar
unknown committed
1500
    ConfigInfo::CI_USED,
1501
    false,
unknown's avatar
unknown committed
1502
    ConfigInfo::CI_INT,
1503 1504
    "100",
    "0",
1505
    STR_VALUE(MAX_INT_RNIL) },
1506 1507 1508 1509

  {
    CFG_MGM_PORT,
    "PortNumber",
1510
    MGM_TOKEN,
1511
    "Port number to give commands to/fetch configurations from management server",
unknown's avatar
unknown committed
1512
    ConfigInfo::CI_USED,
1513
    false,
unknown's avatar
unknown committed
1514
    ConfigInfo::CI_INT,
1515
    NDB_PORT,
1516
    "0",
1517
    STR_VALUE(MAX_INT_RNIL) },
1518 1519 1520 1521

  {
    KEY_INTERNAL,
    "PortNumberStats",
1522
    MGM_TOKEN,
1523
    "Port number used to get statistical information from a management server",
unknown's avatar
unknown committed
1524
    ConfigInfo::CI_USED,
1525
    false,
unknown's avatar
unknown committed
1526
    ConfigInfo::CI_INT,
1527
    UNDEFINED,
1528
    "0",
1529
    STR_VALUE(MAX_INT_RNIL) },
1530 1531 1532 1533

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1534
    MGM_TOKEN,
1535
    "If 0, then "MGM_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1536
    ConfigInfo::CI_USED,
1537
    false,
unknown's avatar
unknown committed
1538
    ConfigInfo::CI_INT,
1539 1540 1541
    "1",
    "0",
    "2" },
1542 1543 1544 1545

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1546
    MGM_TOKEN,
1547
    "",
unknown's avatar
unknown committed
1548
    ConfigInfo::CI_USED,
1549
    false,
unknown's avatar
unknown committed
1550
    ConfigInfo::CI_INT,
1551 1552
    "0",
    "0",
1553
    STR_VALUE(MAX_INT_RNIL) },
1554 1555 1556 1557 1558 1559 1560 1561 1562

  /****************************************************************************
   * TCP
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "TCP",
    "TCP",
    "Connection section",
unknown's avatar
unknown committed
1563
    ConfigInfo::CI_USED,
1564
    false,
unknown's avatar
unknown committed
1565
    ConfigInfo::CI_SECTION,
1566 1567
    (const char *)CONNECTION_TYPE_TCP, 
    0, 0
1568 1569 1570
  },

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

  {
1582
    CFG_CONNECTION_HOSTNAME_2,
1583 1584 1585
    "HostName2",
    "TCP",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1586
    ConfigInfo::CI_INTERNAL,
1587
    false,
unknown's avatar
unknown committed
1588
    ConfigInfo::CI_STRING,
1589
    UNDEFINED,
1590
    0, 0 },
1591 1592 1593 1594 1595

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "TCP",
1596
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1597
    ConfigInfo::CI_USED,
1598
    false,
unknown's avatar
unknown committed
1599
    ConfigInfo::CI_STRING,
1600
    MANDATORY,
1601
    0, 0 },
1602 1603 1604 1605 1606

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "TCP",
1607
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1608
    ConfigInfo::CI_USED,
1609
    false,
unknown's avatar
unknown committed
1610
    ConfigInfo::CI_STRING,
1611
    MANDATORY,
1612
    0, 0 },
1613

1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "TCP",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "55",
    "0", "200" },

1625 1626 1627 1628 1629
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "TCP",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1630
    ConfigInfo::CI_USED,
1631
    false,
unknown's avatar
unknown committed
1632
    ConfigInfo::CI_BOOL,
1633 1634 1635
    "true",
    "false",
    "true" },
1636 1637 1638 1639 1640 1641 1642


  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "TCP",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1643
    ConfigInfo::CI_USED,
1644
    false,
unknown's avatar
unknown committed
1645
    ConfigInfo::CI_BOOL,
1646 1647 1648
    "false",
    "false",
    "true" },
1649 1650

  {
unknown's avatar
unknown committed
1651
    CFG_CONNECTION_SERVER_PORT,
1652 1653 1654
    "PortNumber",
    "TCP",
    "Port used for this transporter",
unknown's avatar
unknown committed
1655
    ConfigInfo::CI_USED,
1656
    false,
unknown's avatar
unknown committed
1657
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1658
    MANDATORY,
1659
    "0",
1660
    STR_VALUE(MAX_INT_RNIL) },
1661 1662 1663 1664 1665 1666

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

  {
    CFG_TCP_RECEIVE_BUFFER_SIZE,
    "ReceiveBufferMemory",
    "TCP",
    "Bytes of buffer for signals received by this node",
unknown's avatar
unknown committed
1679
    ConfigInfo::CI_USED,
1680
    false,
unknown's avatar
unknown committed
1681
    ConfigInfo::CI_INT,
1682 1683
    "64K",
    "16K",
1684
    STR_VALUE(MAX_INT_RNIL) },
1685 1686 1687 1688 1689 1690

  {
    CFG_TCP_PROXY,
    "Proxy",
    "TCP",
    "",
unknown's avatar
unknown committed
1691
    ConfigInfo::CI_USED,
1692
    false,
unknown's avatar
unknown committed
1693
    ConfigInfo::CI_STRING,
1694
    UNDEFINED,
1695
    0, 0 },
1696 1697 1698 1699 1700 1701

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "TCP",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1702
    ConfigInfo::CI_INTERNAL,
1703
    false,
unknown's avatar
unknown committed
1704
    ConfigInfo::CI_STRING,
1705
    UNDEFINED,
1706
    0, 0 },
1707 1708 1709 1710 1711 1712

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "TCP",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1713
    ConfigInfo::CI_INTERNAL,
1714
    false,
unknown's avatar
unknown committed
1715
    ConfigInfo::CI_STRING,
1716
    UNDEFINED,
1717
    0, 0 },
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727
  

  /****************************************************************************
   * SHM
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SHM",
    "SHM",
    "Connection section",
unknown's avatar
unknown committed
1728
    ConfigInfo::CI_USED,
1729
    false,
unknown's avatar
unknown committed
1730
    ConfigInfo::CI_SECTION,
1731 1732
    (const char *)CONNECTION_TYPE_SHM, 
    0, 0 },
1733 1734

  {
1735 1736
    CFG_CONNECTION_HOSTNAME_1,
    "HostName1",
1737
    "SHM",
1738
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1739
    ConfigInfo::CI_INTERNAL,
1740
    false,
unknown's avatar
unknown committed
1741
    ConfigInfo::CI_STRING,
1742
    UNDEFINED,
1743
    0, 0 },
1744 1745 1746 1747 1748 1749

  {
    CFG_CONNECTION_HOSTNAME_2,
    "HostName2",
    "SHM",
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1750
    ConfigInfo::CI_INTERNAL,
1751
    false,
unknown's avatar
merge  
unknown committed
1752
    ConfigInfo::CI_STRING,
1753 1754 1755
    UNDEFINED,
    0, 0 },

unknown's avatar
unknown committed
1756 1757 1758 1759 1760
  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
    "SHM",
    "Port used for this transporter",
unknown's avatar
unknown committed
1761
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1762
    false,
unknown's avatar
unknown committed
1763
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1764
    MANDATORY,
1765
    "0", 
1766
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
1767

1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
  {
    CFG_SHM_SIGNUM,
    "Signum",
    "SHM",
    "Signum to be used for signalling",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    UNDEFINED,
    "0", 
    STR_VALUE(MAX_INT_RNIL) },

1780 1781 1782 1783 1784
  {
    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
1785
    ConfigInfo::CI_USED,
1786
    false,
unknown's avatar
merge  
unknown committed
1787
    ConfigInfo::CI_STRING,
1788 1789 1790
    MANDATORY,
    0, 0 },
  
1791 1792 1793 1794
  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SHM",
1795
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1796
    ConfigInfo::CI_USED,
1797
    false,
unknown's avatar
unknown committed
1798
    ConfigInfo::CI_STRING,
1799
    MANDATORY,
1800
    0, 0 },
1801
  
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SHM",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "35",
    "0", "200" },

1813 1814 1815 1816 1817
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SHM",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1818
    ConfigInfo::CI_USED,
1819
    false,
unknown's avatar
unknown committed
1820
    ConfigInfo::CI_BOOL,
1821 1822 1823
    "false",
    "false",
    "true" },
1824 1825 1826 1827 1828 1829 1830
  
  
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SHM",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1831
    ConfigInfo::CI_USED,
1832
    false,
unknown's avatar
unknown committed
1833
    ConfigInfo::CI_BOOL,
1834 1835 1836
    "true",
    "false",
    "true" },
1837 1838 1839 1840 1841 1842
  
  {
    CFG_SHM_KEY,
    "ShmKey",
    "SHM",
    "A shared memory key",
unknown's avatar
unknown committed
1843
    ConfigInfo::CI_USED,
1844
    false,
unknown's avatar
unknown committed
1845
    ConfigInfo::CI_INT,
1846
    "0",
1847
    "0",
1848
    STR_VALUE(MAX_INT_RNIL) },
1849 1850 1851 1852 1853 1854
  
  {
    CFG_SHM_BUFFER_MEM,
    "ShmSize",
    "SHM",
    "Size of shared memory segment",
unknown's avatar
unknown committed
1855
    ConfigInfo::CI_USED,
1856
    false,
unknown's avatar
unknown committed
1857
    ConfigInfo::CI_INT,
1858
    "1M",
1859
    "64K",
1860
    STR_VALUE(MAX_INT_RNIL) },
1861

1862 1863 1864 1865 1866
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SHM",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1867
    ConfigInfo::CI_INTERNAL,
1868
    false,
unknown's avatar
unknown committed
1869
    ConfigInfo::CI_STRING,
1870
    UNDEFINED,
1871
    0, 0 },
1872 1873 1874 1875 1876 1877

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SHM",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1878
    ConfigInfo::CI_INTERNAL,
1879
    false,
unknown's avatar
unknown committed
1880
    ConfigInfo::CI_STRING,
1881
    UNDEFINED,
1882
    0, 0 },
1883 1884 1885 1886 1887 1888 1889 1890 1891

  /****************************************************************************
   * SCI
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SCI",
    "SCI",
    "Connection section",
unknown's avatar
unknown committed
1892
    ConfigInfo::CI_USED,
1893
    false,
unknown's avatar
unknown committed
1894
    ConfigInfo::CI_SECTION,
1895
    (const char *)CONNECTION_TYPE_SCI, 
1896 1897 1898 1899 1900 1901 1902
    0, 0 
  },

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SCI",
1903
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1904
    ConfigInfo::CI_USED,
1905
    false,
unknown's avatar
unknown committed
1906
    ConfigInfo::CI_STRING,
1907
    MANDATORY,
1908
    "0",
1909
    STR_VALUE(MAX_INT_RNIL) },
1910 1911 1912 1913 1914

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SCI",
1915
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1916
    ConfigInfo::CI_USED,
1917
    false,
unknown's avatar
unknown committed
1918
    ConfigInfo::CI_STRING,
1919
    MANDATORY,
1920
    "0",
1921
    STR_VALUE(MAX_INT_RNIL) },
1922

1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SCI",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "15",
    "0", "200" },

1934
  {
unknown's avatar
unknown committed
1935
    CFG_CONNECTION_HOSTNAME_1,
unknown's avatar
unknown committed
1936 1937 1938
    "HostName1",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1939
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
1940
    false,
unknown's avatar
unknown committed
1941
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1942 1943 1944 1945
    UNDEFINED,
    0, 0 },

  {
unknown's avatar
unknown committed
1946
    CFG_CONNECTION_HOSTNAME_2,
unknown's avatar
unknown committed
1947 1948 1949
    "HostName2",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1950
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
1951
    false,
unknown's avatar
unknown committed
1952
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1953 1954 1955 1956 1957 1958
    UNDEFINED,
    0, 0 },

  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
1959
    "SCI",
unknown's avatar
unknown committed
1960
    "Port used for this transporter",
unknown's avatar
unknown committed
1961
    ConfigInfo::CI_USED,
1962
    false,
unknown's avatar
unknown committed
1963
    ConfigInfo::CI_INT,
1964
    MANDATORY,
unknown's avatar
unknown committed
1965 1966 1967 1968 1969 1970 1971 1972
    "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
1973
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1974
    false,
unknown's avatar
unknown committed
1975
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1976 1977 1978 1979 1980 1981 1982 1983 1984
    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
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
    "0",
1989
    "0",
1990
    STR_VALUE(MAX_INT_RNIL) },
1991 1992

  {
unknown's avatar
unknown committed
1993 1994
    CFG_SCI_HOST2_ID_0,
    "Host2SciId0",
1995
    "SCI",
unknown's avatar
unknown committed
1996
    "SCI-node id for adapter 0 on Host2 (a computer can have two adapters)",
unknown's avatar
unknown committed
1997
    ConfigInfo::CI_USED,
1998
    false,
unknown's avatar
unknown committed
1999
    ConfigInfo::CI_INT,
2000
    MANDATORY,
2001
    "0",
2002
    STR_VALUE(MAX_INT_RNIL) },
2003

unknown's avatar
unknown committed
2004 2005 2006 2007 2008
  {
    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
2009
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
2010
    false,
unknown's avatar
unknown committed
2011
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
2012 2013 2014 2015
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },

2016 2017 2018 2019 2020
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SCI",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
2021
    ConfigInfo::CI_USED,
2022
    false,
unknown's avatar
unknown committed
2023
    ConfigInfo::CI_BOOL,
2024 2025 2026
    "true",
    "false",
    "true" },
2027 2028 2029 2030 2031 2032

  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SCI",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
2033
    ConfigInfo::CI_USED,
2034
    false,
unknown's avatar
unknown committed
2035
    ConfigInfo::CI_BOOL,
2036 2037 2038
    "false",
    "false",
    "true" },
2039 2040 2041 2042 2043 2044

  {
    CFG_SCI_SEND_LIMIT,
    "SendLimit",
    "SCI",
    "Transporter send buffer contents are sent when this no of bytes is buffered",
unknown's avatar
unknown committed
2045
    ConfigInfo::CI_USED,
2046
    false,
unknown's avatar
unknown committed
2047
    ConfigInfo::CI_INT,
2048
    "8K",
unknown's avatar
unknown committed
2049 2050
    "128",
    "32K" },
2051 2052 2053 2054 2055 2056

  {
    CFG_SCI_BUFFER_MEM,
    "SharedBufferSize",
    "SCI",
    "Size of shared memory segment",
unknown's avatar
unknown committed
2057
    ConfigInfo::CI_USED,
2058
    false,
unknown's avatar
unknown committed
2059
    ConfigInfo::CI_INT,
2060
    "1M",
unknown's avatar
unknown committed
2061
    "64K",
2062
    STR_VALUE(MAX_INT_RNIL) },
2063 2064 2065 2066 2067 2068

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SCI",
    "System for node 1 in connection",
unknown's avatar
unknown committed
2069
    ConfigInfo::CI_INTERNAL,
2070
    false,
unknown's avatar
unknown committed
2071
    ConfigInfo::CI_STRING,
2072
    UNDEFINED,
2073
    0, 0 },
2074 2075 2076 2077 2078 2079

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SCI",
    "System for node 2 in connection",
unknown's avatar
unknown committed
2080
    ConfigInfo::CI_INTERNAL,
2081
    false,
unknown's avatar
unknown committed
2082
    ConfigInfo::CI_STRING,
2083
    UNDEFINED,
2084
    0, 0 },
2085 2086

  /****************************************************************************
2087 2088 2089 2090 2091 2092 2093
   * OSE
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "OSE",
    "OSE",
    "Connection section",
unknown's avatar
unknown committed
2094
    ConfigInfo::CI_USED,
2095
    false,
unknown's avatar
unknown committed
2096
    ConfigInfo::CI_SECTION,
2097
    (const char *)CONNECTION_TYPE_OSE, 
2098
    0, 0 
2099 2100
  },

2101
  {
2102
    CFG_CONNECTION_HOSTNAME_1,
2103 2104 2105
    "HostName1",
    "OSE",
    "Name of computer on one side of the connection",
unknown's avatar
unknown committed
2106
    ConfigInfo::CI_USED,
2107
    false,
unknown's avatar
unknown committed
2108
    ConfigInfo::CI_STRING,
2109
    UNDEFINED,
2110
    0, 0 },
2111 2112

  {
2113
    CFG_CONNECTION_HOSTNAME_2,
2114 2115 2116
    "HostName2",
    "OSE",
    "Name of computer on one side of the connection",
unknown's avatar
unknown committed
2117
    ConfigInfo::CI_USED,
2118
    false,
unknown's avatar
unknown committed
2119
    ConfigInfo::CI_STRING,
2120
    UNDEFINED,
2121
    0, 0 },
2122 2123 2124 2125 2126

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "OSE",
2127
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
2128
    ConfigInfo::CI_USED,
2129
    false,
unknown's avatar
unknown committed
2130
    ConfigInfo::CI_INT,
2131
    MANDATORY,
2132
    "0",
2133
    STR_VALUE(MAX_INT_RNIL) },
2134 2135 2136 2137 2138

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "OSE",
2139
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
2140
    ConfigInfo::CI_USED,
2141
    false,
unknown's avatar
unknown committed
2142
    ConfigInfo::CI_INT,
2143
    UNDEFINED,
2144
    "0",
2145
    STR_VALUE(MAX_INT_RNIL) },
2146

2147 2148 2149 2150 2151
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "OSE",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
2152
    ConfigInfo::CI_USED,
2153
    false,
unknown's avatar
unknown committed
2154
    ConfigInfo::CI_BOOL,
2155 2156 2157
    "true",
    "false",
    "true" },
2158

2159 2160 2161 2162 2163
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "OSE",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
2164
    ConfigInfo::CI_USED,
2165
    false,
unknown's avatar
unknown committed
2166
    ConfigInfo::CI_BOOL,
2167 2168 2169
    "false",
    "false",
    "true" },
2170 2171 2172 2173 2174 2175

  {
    CFG_OSE_PRIO_A_SIZE,
    "PrioASignalSize",
    "OSE",
    "Size of priority A signals (in bytes)",
unknown's avatar
unknown committed
2176
    ConfigInfo::CI_USED,
2177
    false,
unknown's avatar
unknown committed
2178
    ConfigInfo::CI_INT,
2179 2180
    "1000",
    "0",
2181
    STR_VALUE(MAX_INT_RNIL) },
2182

2183 2184 2185 2186 2187
  {
    CFG_OSE_PRIO_B_SIZE,
    "PrioBSignalSize",
    "OSE",
    "Size of priority B signals (in bytes)",
unknown's avatar
unknown committed
2188
    ConfigInfo::CI_USED,
2189
    false,
unknown's avatar
unknown committed
2190
    ConfigInfo::CI_INT,
2191 2192
    "1000",
    "0",
2193
    STR_VALUE(MAX_INT_RNIL) },
2194 2195 2196 2197 2198 2199
  
  {
    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
2200
    ConfigInfo::CI_USED,
2201
    false,
unknown's avatar
unknown committed
2202
    ConfigInfo::CI_INT,
2203 2204
    "10",
    "0",
2205
    STR_VALUE(MAX_INT_RNIL) },
2206

2207 2208 2209 2210 2211
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "OSE",
    "System for node 1 in connection",
unknown's avatar
unknown committed
2212
    ConfigInfo::CI_INTERNAL,
2213
    false,
unknown's avatar
unknown committed
2214
    ConfigInfo::CI_STRING,
2215
    UNDEFINED,
2216
    0, 0 },
2217

2218 2219 2220 2221 2222
  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "OSE",
    "System for node 2 in connection",
unknown's avatar
unknown committed
2223
    ConfigInfo::CI_INTERNAL,
2224
    false,
unknown's avatar
unknown committed
2225
    ConfigInfo::CI_STRING,
2226
    UNDEFINED,
2227
    0, 0 },
2228 2229 2230 2231 2232 2233 2234 2235
};

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


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

2238 2239 2240
ConfigInfo::ConfigInfo()
  : m_info(true), m_systemDefaults(true)
{
unknown's avatar
unknown committed
2241
  int i;
2242 2243 2244
  Properties *section;
  const Properties *oldpinfo;

unknown's avatar
unknown committed
2245
  for (i=0; i<m_NoOfParams; i++) {
2246
    const ParamInfo & param = m_ParamInfo[i];
2247 2248
    Uint64 default_uint64;
    bool   default_bool;
2249 2250 2251
    
    // Create new section if it did not exist
    if (!m_info.getCopy(param._section, &section)) {
2252
      Properties newsection(true);
2253 2254
      m_info.put(param._section, &newsection);
    }
2255
    
2256 2257 2258 2259
    // Get copy of section
    m_info.getCopy(param._section, &section);
    
    // Create pinfo (parameter info) entry 
2260
    Properties pinfo(true); 
2261
    pinfo.put("Id",          param._paramId);
2262 2263 2264 2265 2266
    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);
2267 2268 2269 2270 2271 2272

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

    switch (param._type) {
unknown's avatar
unknown committed
2273
      case CI_BOOL:
2274 2275 2276 2277 2278 2279 2280 2281
      {
	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
2282 2283
      case CI_INT:
      case CI_INT64:
2284 2285 2286 2287 2288 2289 2290 2291
      {
	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
2292
      case CI_SECTION:
unknown's avatar
unknown committed
2293
	pinfo.put("SectionType", (Uint32)UintPtr(param._default));
2294
	break;
unknown's avatar
unknown committed
2295
      case CI_STRING:
2296 2297
	break;
    }
2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311

    // 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);
2312
    
unknown's avatar
unknown committed
2313
    if(param._type != ConfigInfo::CI_SECTION){
2314 2315
      Properties * p;
      if(!m_systemDefaults.getCopy(param._section, &p)){
2316
	p = new Properties(true);
2317
      }
2318
      if(param._default != UNDEFINED &&
2319
	 param._default != MANDATORY){
2320 2321
	switch (param._type)
        {
unknown's avatar
unknown committed
2322
	  case CI_SECTION:
2323
	    break;
unknown's avatar
unknown committed
2324
	  case CI_STRING:
2325 2326
	    require(p->put(param._fname, param._default));
	    break;
unknown's avatar
unknown committed
2327
	  case CI_BOOL:
2328 2329 2330 2331 2332 2333
	    {
	      bool tmp_bool;
	      require(InitConfigFileParser::convertStringToBool(param._default, default_bool));
	      require(p->put(param._fname, default_bool));
	      break;
	    }
unknown's avatar
unknown committed
2334 2335
	  case CI_INT:
	  case CI_INT64:
2336 2337 2338 2339 2340 2341 2342
	    {
	      Uint64 tmp_uint64;
	      require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64));
	      require(p->put(param._fname, default_uint64));
	      break;
	    }
	}
2343 2344 2345 2346 2347
      }
      require(m_systemDefaults.put(param._section, p, true));
      delete p;
    }
  }
2348
  
unknown's avatar
unknown committed
2349
  for (i=0; i<m_NoOfParams; i++) {
2350
    if(m_ParamInfo[i]._section == NULL){
2351 2352
      ndbout << "Check that each entry has a section failed." << endl;
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname << endl; 
2353 2354 2355
      ndbout << "Edit file " << __FILE__ << "." << endl;
      exit(-1);
    }
2356
    
unknown's avatar
unknown committed
2357
    if(m_ParamInfo[i]._type == ConfigInfo::CI_SECTION)
2358 2359
      continue;

2360
    const Properties * p = getInfo(m_ParamInfo[i]._section);
2361
    if (!p || !p->contains(m_ParamInfo[i]._fname)) {
2362
      ndbout << "Check that each pname has an fname failed." << endl;
2363
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname 
2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383
	     << "\" 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)){
2384 2385
    return 0;
    //    warning("getInfo", section);
2386 2387 2388 2389 2390 2391 2392 2393
  }
  return p;
}

const Properties * 
ConfigInfo::getDefaults(const char * section) const {
  const Properties * p;
  if(!m_systemDefaults.get(section, &p)){
2394 2395
    return 0;
    //warning("getDefaults", section);
2396 2397 2398 2399 2400
  }
  return p;
}

static
2401
Uint64
2402 2403
getInfoInt(const Properties * section, 
	   const char* fname, const char * type){
2404
  Uint32 val32;
2405
  const Properties * p;
2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417
  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();
2418
  }
2419

2420
  warning(type, fname);
2421
  return 0;
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436
}

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

2437
Uint64
2438 2439 2440 2441
ConfigInfo::getMax(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Max");
}

2442
Uint64
2443 2444 2445 2446
ConfigInfo::getMin(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Min");
}

2447
Uint64
2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460
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++) {
2461
    if(!strcasecmp(section, m_sectionNames[i])) return true;
2462 2463 2464 2465
  }
  return false;
}

unknown's avatar
unknown committed
2466 2467 2468
const char*
ConfigInfo::getAlias(const char * section) const {
  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
2469
    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
unknown's avatar
unknown committed
2470 2471 2472 2473
      return m_sectionNameAliases[i].name;
  return 0;
}

2474 2475
bool
ConfigInfo::verify(const Properties * section, const char* fname, 
2476
		   Uint64 value) const {
2477
  Uint64 min, max;
2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516

  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
2517 2518 2519
    if (getStatus(sec, n) == ConfigInfo::CI_INTERNAL) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_DEPRICATED) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_NOTIMPLEMENTED) continue;
2520 2521 2522 2523 2524 2525
    print(sec, n);
  }
}

void ConfigInfo::print(const Properties * section, 
		       const char* parameter) const {
2526
  ndbout << parameter;
2527 2528
  //  ndbout << getDescription(section, parameter) << endl;
  switch (getType(section, parameter)) {
unknown's avatar
unknown committed
2529
  case ConfigInfo::CI_BOOL:
2530 2531 2532 2533 2534 2535
    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;
2536
    } else if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2537 2538 2539 2540 2541 2542 2543
      ndbout << "MANDATORY (Legal values: Y, N)" << endl;
    } else {
      ndbout << "UNKNOWN" << endl;
    }
    ndbout << endl;
    break;    
    
unknown's avatar
unknown committed
2544 2545
  case ConfigInfo::CI_INT:
  case ConfigInfo::CI_INT64:
2546 2547
    ndbout << " (Non-negative Integer)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2548
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2549
      ndbout << "MANDATORY (";
2550
    } else if (getDefault(section, parameter) == (UintPtr)UNDEFINED) {
2551 2552 2553 2554 2555 2556 2557 2558 2559
      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
2560
  case ConfigInfo::CI_STRING:
2561 2562
    ndbout << " (String)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2563
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2564 2565 2566 2567 2568 2569
      ndbout << "MANDATORY" << endl;
    } else {
      ndbout << "No default value" << endl;
    }
    ndbout << endl;
    break;
unknown's avatar
unknown committed
2570
  case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2571
    break;
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
  }
}

/****************************************************************************
 * 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)){
2587 2588 2589 2590 2591 2592 2593 2594
    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
2595 2596 2597 2598
    ctx.reportError("Mandatory parameter Id missing from section "
		    "[%s] starting at line: %d",
		    ctx.fname, ctx.m_sectionLineno);
    return false;
2599 2600 2601 2602 2603 2604
#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;
2605
  }
2606 2607

  ctx.m_userProperties.put("AllocatedNodeId_", id, id);
2608
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
2609 2610 2611 2612 2613 2614 2615
  
  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
2616 2617 2618 2619 2620 2621 2622
  /**
   * Update count (per type)
   */
  nodes = 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  ctx.m_userProperties.put(ctx.fname, ++nodes, true);

2623 2624 2625
  return true;
}

unknown's avatar
unknown committed
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653
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);
}

2654 2655 2656
bool
fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){
  
2657 2658
  const char * hostname;
  if (ctx.m_currentSection->get("HostName", &hostname))
unknown's avatar
unknown committed
2659
    return checkLocalhostHostnameMix(ctx);
2660

2661 2662
  const char * compId;
  if(!ctx.m_currentSection->get("ExecuteOnComputer", &compId)){
unknown's avatar
unknown committed
2663
    const char * type;
2664
    if(ctx.m_currentSection->get("Type", &type) && strcmp(type,DB_TOKEN) == 0)
2665 2666 2667
      require(ctx.m_currentSection->put("HostName", "localhost"));
    else
      require(ctx.m_currentSection->put("HostName", ""));
unknown's avatar
unknown committed
2668
    return checkLocalhostHostnameMix(ctx);
2669 2670 2671 2672
  }
  
  const Properties * computer;
  char tmp[255];
2673
  BaseString::snprintf(tmp, sizeof(tmp), "Computer_%s", compId);
2674 2675 2676 2677
  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
2678
    return false;
2679 2680 2681
  }
  
  if(!computer->get("HostName", &hostname)){
unknown's avatar
unknown committed
2682 2683
    ctx.reportError("HostName missing in [COMPUTER] (Id: %d) "
		    " - [%s] starting at line: %d",
2684
		    compId, ctx.fname, ctx.m_sectionLineno);
unknown's avatar
unknown committed
2685
    return false;
2686 2687 2688
  }
  
  require(ctx.m_currentSection->put("HostName", hostname));
unknown's avatar
unknown committed
2689
  return checkLocalhostHostnameMix(ctx);
2690 2691
}

2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709
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
2710
fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
2711 2712
  
  const char * path;
unknown's avatar
unknown committed
2713
  if (ctx.m_currentSection->get("BackupDataDir", &path))
2714 2715 2716
    return true;

  if (ctx.m_currentSection->get("FileSystemPath", &path)) {
unknown's avatar
unknown committed
2717
    require(ctx.m_currentSection->put("BackupDataDir", path));
2718 2719 2720 2721 2722 2723 2724
    return true;
  }

  require(false);
  return false;
}

2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750
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));

2751
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s:Node_%d", 
2752 2753 2754 2755 2756 2757
	   systemName, id);

  return true;
}

/**
2758
 * Connection rule: Check support of connection
2759 2760
 */
bool
2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794
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;
}
2795

2796 2797 2798 2799 2800 2801
/**
 * Connection rule: Update "NoOfConnections"
 */
bool
transformConnection(InitConfigFileParser::Context & ctx, const char * data)
{
2802 2803
  Uint32 connections = 0;
  ctx.m_userProperties.get("NoOfConnections", &connections);
2804
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Connection_%d", connections);
2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
  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
2824 2825 2826

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

2827
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "SYSTEM_%s", name);
2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843
  
  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;
  }
2844
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s", name);
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860
  
  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;
  }
2861
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Computer_%s", id);
2862 2863 2864 2865 2866
  
  Uint32 computers = 0;
  ctx.m_userProperties.get("NoOfComputers", &computers);
  ctx.m_userProperties.put("NoOfComputers", ++computers, true);
  
2867 2868 2869 2870 2871 2872
  const char * hostname = 0;
  ctx.m_currentSection->get("HostName", &hostname);
  if(!hostname){
    return true;
  }
  
unknown's avatar
unknown committed
2873
  return checkLocalhostHostnameMix(ctx);
2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885
}

/**
 * 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()){
2886
      ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name);
2887 2888
      if(!ctx.m_currentSection->contains(name)){
	switch (ctx.m_info->getType(ctx.m_currentInfo, name)){
unknown's avatar
unknown committed
2889 2890
	case ConfigInfo::CI_INT:
	case ConfigInfo::CI_BOOL:{
2891 2892 2893 2894 2895
	  Uint32 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
unknown's avatar
unknown committed
2896
	case ConfigInfo::CI_INT64:{
2897 2898 2899 2900 2901
	  Uint64 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put64(name, val);
	  break;
	}
unknown's avatar
unknown committed
2902
	case ConfigInfo::CI_STRING:{
2903 2904 2905 2906 2907
	  const char * val;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
	  break;
	}
unknown's avatar
unknown committed
2908
	case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2909
	  break;
2910 2911 2912 2913 2914 2915 2916 2917 2918
	}
      }
    }
  }
}

bool
applyDefaultValues(InitConfigFileParser::Context & ctx, const char * data){
  
2919 2920 2921 2922 2923 2924 2925
  if(strcmp(data, "user") == 0)
    applyDefaultValues(ctx, ctx.m_userDefaults);
  else if (strcmp(data, "system") == 0)
    applyDefaultValues(ctx, ctx.m_systemDefaults);
  else 
    return false;

2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939
  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;
2940
    if(info->get("Mandatory", &val)){
2941 2942
      const char * fname;
      ::require(info->get("Fname", &fname));
2943
      if(!ctx.m_currentSection->contains(fname)){
2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959
	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").
 */
2960
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
2961
{
2962 2963 2964 2965
  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));
2966

2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995
  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.
 */
2996
static bool 
2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023
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).
 */
3024
static bool
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036
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];
3037
    BaseString::snprintf(tmpLine1, MAX_LINE_LENGTH, "Connection_%d", connections-1);
3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078

    /**
     *  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
 */
3079
static bool
3080 3081 3082 3083 3084 3085 3086 3087
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));
3088
    
3089
    const Properties * node;
3090 3091 3092 3093 3094 3095 3096
    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;
    }
3097 3098
    
    const char * hostname;
3099
    require(node->get("HostName", &hostname));
3100 3101 3102 3103 3104 3105 3106 3107
    require(ctx.m_currentSection->put(data, hostname));
  }
  return true;
}

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

3111 3112
  DBUG_ENTER("fixPortNumber");

unknown's avatar
unknown committed
3113
  Uint32 id1= 0, id2= 0;
3114 3115
  const char *hostName1;
  const char *hostName2;
unknown's avatar
unknown committed
3116 3117
  require(ctx.m_currentSection->get("NodeId1", &id1));
  require(ctx.m_currentSection->get("NodeId2", &id2));
3118 3119 3120 3121 3122
  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));

3123 3124
  if (id1 > id2) {
    Uint32 tmp= id1;
3125 3126
    const char *tmp_name= hostName1;
    hostName1= hostName2;
3127
    id1= id2;
3128
    hostName2= tmp_name;
3129 3130
    id2= tmp;
  }
unknown's avatar
unknown committed
3131 3132 3133

  const Properties * node;
  require(ctx.m_config->get("Node", id1, &node));
3134

3135
  BaseString hostname(hostName1);
unknown's avatar
unknown committed
3136 3137
  
  if (hostname.c_str()[0] == 0) {
3138 3139
    ctx.reportError("Hostname required on nodeid %d since it will "
		    "act as server.", id1);
3140
    DBUG_RETURN(false);
unknown's avatar
unknown committed
3141 3142 3143
  }

  Uint32 port= 0;
3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155
  const char * type1;
  const char * type2;
  const Properties * node2;

  node->get("Type", &type1);
  ctx.m_config->get("Node", id2, &node2);
  node2->get("Type", &type2);

  if(strcmp(type1, MGM_TOKEN)==0)
    node->get("PortNumber",&port);
  else if(strcmp(type2, MGM_TOKEN)==0)
    node2->get("PortNumber",&port);
3156

3157
  if (!port && 
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184
      !node->get("ServerPort", &port) &&
      !ctx.m_userProperties.get("ServerPort_", id1, &port))
  {
    Uint32 base= 0;
    /*
     * If the connection doesn't involve an mgm server,
     * and a default port number has been set, behave the old
     * way of allocating port numbers for transporters.
     */
    if(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base))
    {
      Uint32 adder= 0;
      {
	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);
      }
      
      if (!ctx.m_userProperties.get("ServerPortBase", &base)){
	if(!(ctx.m_userDefaults &&
	   ctx.m_userDefaults->get("PortNumber", &base)) &&
	   !ctx.m_systemDefaults->get("PortNumber", &base)) {
	  base= strtoll(NDB_TCP_BASE_PORT,0,0);
	}
	ctx.m_userProperties.put("ServerPortBase", base);
      }
3185

3186 3187 3188
      port= base + adder;
      ctx.m_userProperties.put("ServerPort_", id1, port);
    }
3189
  }
3190

3191 3192 3193 3194 3195 3196 3197 3198 3199 3200
  if(ctx.m_currentSection->contains("PortNumber")) {
    ndbout << "PortNumber should no longer be specificied "
	   << "per connection, please remove from config. "
	   << "Will be changed to " << port << endl;
    ctx.m_currentSection->put("PortNumber", port, true);
  } 
  else
  {
    ctx.m_currentSection->put("PortNumber", port);
  }
3201

3202 3203
  DBUG_PRINT("info", ("connection %d-%d port %d host %s",
		      id1, id2, port, hostname.c_str()));
3204 3205

  DBUG_RETURN(true);
3206 3207
}

3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222
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);
}

3223 3224 3225 3226
static 
bool 
fixShmKey(InitConfigFileParser::Context & ctx, const char *)
{
3227 3228
  DBUG_ENTER("fixShmKey");
  {
3229
    static int last_signum= -1;
3230 3231 3232 3233
    Uint32 signum;
    if(!ctx.m_currentSection->get("Signum", &signum))
    {
      signum= OPT_NDB_SHM_SIGNUM_DEFAULT;
3234 3235 3236 3237 3238 3239
      if (signum <= 0)
      {
	  ctx.reportError("Unable to set default parameter for [SHM]Signum"
			  " please specify [SHM DEFAULT]Signum");
	  return false;
      }
3240 3241 3242
      ctx.m_currentSection->put("Signum", signum);
      DBUG_PRINT("info",("Added Signum=%u", signum));
    }
3243 3244 3245 3246 3247 3248 3249
    if ( last_signum != (int)signum && last_signum >= 0 )
    {
      ctx.reportError("All shared memory transporters must have same [SHM]Signum defined."
		      " Use [SHM DEFAULT]Signum");
      return false;
    }
    last_signum= (int)signum;
3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261
  }
  {
    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))
    {
      require(ctx.m_userProperties.get("ShmUniqueId", &key));
      key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1);
      ctx.m_currentSection->put("ShmKey", key);
      DBUG_PRINT("info",("Added ShmKey=0x%x", key));
    }
3262 3263
  }
  DBUG_RETURN(true);
3264 3265
}

3266 3267 3268
/**
 * DB Node rule: Check various constraints
 */
3269
static bool
3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301
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
 */
3302
static bool
3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347
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
   */
3348 3349
  if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) &&
     !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0) &&
3350 3351 3352 3353 3354 3355 3356 3357
     !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;
  }
3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373

  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;
  }
3374 3375
  return true;
}
3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396

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
3397
       && (newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_INT64 || newType == ConfigInfo::CI_BOOL))){
unknown's avatar
unknown committed
3398
    ndbout << "oldType: " << (int)oldType << ", newType: " << (int)newType << endl;
3399 3400 3401 3402 3403 3404 3405 3406 3407
    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
3408
  Uint64 newVal = (Uint64)((Int64)oldVal * mul + add);
3409 3410 3411 3412 3413 3414 3415 3416
  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
3417
  if(newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_BOOL){
3418
    require(dst.put(newName, (Uint32)newVal));
unknown's avatar
unknown committed
3419
  } else if(newType == ConfigInfo::CI_INT64) {
3420 3421 3422 3423 3424
    require(dst.put64(newName, newVal));    
  }
  return true;
}

3425
static bool
3426
fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
unknown's avatar
unknown committed
3427
  const char * name;
3428 3429 3430 3431
  /**
   * Transform old values to new values
   * Transform new values to old values (backward compatible)
   */
3432
  Properties tmp(true);
3433
  Properties::Iterator it(ctx.m_currentSection);
unknown's avatar
unknown committed
3434
  for (name = it.first(); name != NULL; name = it.next()) {
3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454
    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
3455
  for (name = it2.first(); name != NULL; name = it2.next()) {
3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484
    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;
}

3485
static bool
3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498
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));
3499
    require(sec->get("SectionType", &typeVal));
3500
    
unknown's avatar
unknown committed
3501
    if(id == KEY_INTERNAL || status == ConfigInfo::CI_INTERNAL){
3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549
      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();
      }
3550
      require(ok);
3551 3552 3553 3554 3555
    }
    ctx.m_configValues.closeSection();
  } while(0);
  return true;
}
3556

3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579
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;
}

3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618
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);
}

3619
static bool
unknown's avatar
unknown committed
3620
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
3621
		   struct InitConfigFileParser::Context &ctx, 
unknown's avatar
unknown committed
3622
		   const char * rule_data)
3623
{
3624
  DBUG_ENTER("add_node_connections");
unknown's avatar
unknown committed
3625
  Uint32 i;
3626
  Properties * props= ctx.m_config;
3627 3628
  Properties p_connections(true);
  Properties p_connections2(true);
3629

unknown's avatar
unknown committed
3630
  for (i = 0;; i++){
3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647
    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);

3648
  Properties p_db_nodes(true);
3649 3650
  Properties p_api_nodes(true);
  Properties p_mgm_nodes(true);
3651

3652
  Uint32 i_db= 0, i_api= 0, i_mgm= 0, n;
unknown's avatar
unknown committed
3653
  for (i= 0, n= 0; n < nNodes; i++){
3654 3655 3656 3657 3658 3659 3660
    const Properties * tmp;
    if(!props->get("Node", i, &tmp)) continue;
    n++;

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

3661
    if (strcmp(type,DB_TOKEN) == 0)
3662
      p_db_nodes.put("", i_db++, i);
3663 3664 3665 3666
    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);
3667 3668 3669 3670
  }

  Uint32 nodeId1, nodeId2, dummy;

unknown's avatar
unknown committed
3671
  for (i= 0; p_db_nodes.get("", i, &nodeId1); i++){
3672 3673 3674
    for (Uint32 j= i+1;; j++){
      if(!p_db_nodes.get("", j, &nodeId2)) break;
      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
3675
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3676 3677 3678 3679
      }
    }
  }

3680
  for (i= 0; p_api_nodes.get("", i, &nodeId1); i++){
3681 3682 3683
    if(!p_connections.get("", nodeId1, &dummy)) {
      for (Uint32 j= 0;; j++){
	if(!p_db_nodes.get("", j, &nodeId2)) break;
3684
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3685 3686 3687 3688
      }
    }
  }

3689 3690 3691 3692 3693 3694 3695 3696 3697 3698
  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);
3699
}
unknown's avatar
unknown committed
3700

3701 3702 3703 3704 3705 3706 3707
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
3708

3709
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
3710 3711
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data)
unknown's avatar
unknown committed
3712
{
unknown's avatar
unknown committed
3713 3714
#if 0
  Properties * props= ctx.m_config;
3715
  Properties computers(true);
unknown's avatar
unknown committed
3716
  Uint32 port_base = NDB_TCP_BASE_PORT;
unknown's avatar
unknown committed
3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737

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

3738
    if (strcmp(type,DB_TOKEN) == 0) {
unknown's avatar
unknown committed
3739 3740 3741 3742 3743 3744
      adder++;
      tmp->put("ServerPort", port_base+adder);
      computers.put("",computer, adder);
    }
  }
#endif
unknown's avatar
unknown committed
3745 3746 3747
  return true;
}

3748
static bool
unknown's avatar
unknown committed
3749 3750 3751 3752
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		       struct InitConfigFileParser::Context &ctx, 
		       const char * rule_data)
{
3753 3754 3755
  Uint32 db_nodes= 0;
  Uint32 replicas= 0;
  Uint32 db_host_count= 0;
3756
  ctx.m_userProperties.get(DB_TOKEN, &db_nodes);
unknown's avatar
unknown committed
3757 3758 3759 3760 3761 3762
  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;
  }
3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774
  // 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";
3775 3776
    const char *arbit_warn_fmt2=
      "\n  arbitrator with id %d has no hostname specified";
3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832

    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
3833
	    if (c+1 == (1u << (replicas-1))) // all nodes on same machine
3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858
	      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);
	    }
	  }
3859 3860 3861 3862
	  else
	  {
	    arbitration_warning.appfmt(arbit_warn_fmt2, i);
	  }
3863 3864 3865 3866 3867 3868
	}
      }
    }
    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)
3869 3870 3871
      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.");
3872
  }
unknown's avatar
unknown committed
3873 3874 3875
  return true;
}

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