ConfigInfo.cpp 90.2 KB
Newer Older
1 2 3 4
/* 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
unknown's avatar
unknown committed
5
   the Free Software Foundation; version 2 of the License.
6 7 8 9 10 11 12 13 14 15

   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
16
#include <ndb_global.h>
17
#include <ndb_opt_defaults.h>
unknown's avatar
unknown committed
18

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

26
extern my_bool opt_ndb_shm;
27
extern my_bool opt_core;
28

29
#define MAX_LINE_LENGTH 255
30
#define KEY_INTERNAL 0
31
#define MAX_INT_RNIL 0xfffffeff
unknown's avatar
unknown committed
32
#define MAX_PORT_NO 65535
33

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

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

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

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

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

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

62 63 64
  DB_TOKEN,
  MGM_TOKEN,
  API_TOKEN,
65 66 67

  "TCP",
  "SCI",
unknown's avatar
unknown committed
68
  "SHM"
69 70 71 72 73 74 75 76
};
const int ConfigInfo::m_noOfSectionNames = 
sizeof(m_sectionNames)/sizeof(char*);


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

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

104 105 106
  { DB_TOKEN,   transformNode, 0 },
  { API_TOKEN,  transformNode, 0 },
  { MGM_TOKEN,  transformNode, 0 },
107

108 109
  { MGM_TOKEN,  fixShmUniqueId, 0 },

110 111 112 113
  { "TCP",  checkConnectionSupport, 0 },
  { "SHM",  checkConnectionSupport, 0 },
  { "SCI",  checkConnectionSupport, 0 },

114 115 116 117
  { "TCP",  transformConnection, 0 },
  { "SHM",  transformConnection, 0 },
  { "SCI",  transformConnection, 0 },

118 119 120
  { DB_TOKEN,   fixNodeHostname, 0 },
  { API_TOKEN,  fixNodeHostname, 0 },
  { MGM_TOKEN,  fixNodeHostname, 0 },
121 122 123 124 125 126 127

  { "TCP",  fixNodeId, "NodeId1" },
  { "TCP",  fixNodeId, "NodeId2" },
  { "SHM",  fixNodeId, "NodeId1" },
  { "SHM",  fixNodeId, "NodeId2" },
  { "SCI",  fixNodeId, "NodeId1" },
  { "SCI",  fixNodeId, "NodeId2" },
unknown's avatar
unknown committed
128

129 130
  { "TCP",  fixHostname, "HostName1" },
  { "TCP",  fixHostname, "HostName2" },
131 132
  { "SHM",  fixHostname, "HostName1" },
  { "SHM",  fixHostname, "HostName2" },
unknown's avatar
unknown committed
133 134
  { "SCI",  fixHostname, "HostName1" },
  { "SCI",  fixHostname, "HostName2" },
135 136
  { "SHM",  fixHostname, "HostName1" },
  { "SHM",  fixHostname, "HostName2" },
137

138
  { "TCP",  fixPortNumber, 0 }, // has to come after fixHostName
unknown's avatar
unknown committed
139
  { "SHM",  fixPortNumber, 0 }, // has to come after fixHostName
unknown's avatar
unknown committed
140
  { "SCI",  fixPortNumber, 0 }, // has to come after fixHostName
unknown's avatar
unknown committed
141

142 143 144 145
  { "*",    applyDefaultValues, "user" },
  { "*",    fixDepricated, 0 },
  { "*",    applyDefaultValues, "system" },

146 147
  { "SHM",  fixShmKey, 0 }, // has to come after apply default values

148 149 150 151
  { DB_TOKEN,   checkLocalhostHostnameMix, 0 },
  { API_TOKEN,  checkLocalhostHostnameMix, 0 },
  { MGM_TOKEN,  checkLocalhostHostnameMix, 0 },

152
  { DB_TOKEN,   fixFileSystemPath, 0 },
unknown's avatar
unknown committed
153
  { DB_TOKEN,   fixBackupDataDir, 0 },
154 155

  { DB_TOKEN,   checkDbConstraints, 0 },
156

157 158 159 160
  { "TCP",  checkConnectionConstraints, 0 },
  { "SHM",  checkConnectionConstraints, 0 },
  { "SCI",  checkConnectionConstraints, 0 },

161 162
  { "TCP",  checkTCPConstraints, "HostName1" },
  { "TCP",  checkTCPConstraints, "HostName2" },
unknown's avatar
unknown committed
163 164
  { "SCI",  checkTCPConstraints, "HostName1" },
  { "SCI",  checkTCPConstraints, "HostName2" },
165 166
  { "SHM",  checkTCPConstraints, "HostName1" },
  { "SHM",  checkTCPConstraints, "HostName2" },
167
  
168 169
  { "*",    checkMandatory, 0 },
  
170 171 172
  { DB_TOKEN,   saveInConfigValues, 0 },
  { API_TOKEN,  saveInConfigValues, 0 },
  { MGM_TOKEN,  saveInConfigValues, 0 },
173 174 175

  { "TCP",  saveInConfigValues, 0 },
  { "SHM",  saveInConfigValues, 0 },
unknown's avatar
unknown committed
176
  { "SCI",  saveInConfigValues, 0 }
177 178
};
const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);
179

180 181 182
/****************************************************************************
 * Config Rules declarations
 ****************************************************************************/
183
static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
184 185
			  struct InitConfigFileParser::Context &ctx, 
			  const char * rule_data);
186
static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
187 188
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
189 190 191
static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sections, 
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
192
static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
unknown's avatar
unknown committed
193 194
			    struct InitConfigFileParser::Context &ctx, 
			    const char * rule_data);
195 196 197

const ConfigInfo::ConfigRule 
ConfigInfo::m_ConfigRules[] = {
198
  { sanity_checks, 0 },
unknown's avatar
unknown committed
199
  { add_node_connections, 0 },
200
  { set_connection_priorities, 0 },
unknown's avatar
unknown committed
201
  { check_node_vs_replicas, 0 },
202 203 204
  { 0, 0 }
};
	  
205 206 207 208 209 210 211
struct DepricationTransform {
  const char * m_section;
  const char * m_oldName;
  const char * m_newName;
  double m_add;
  double m_mul;
};
212

213 214
static
const DepricationTransform f_deprication[] = {
215
  { DB_TOKEN, "Discless", "Diskless", 0, 1 },
216 217 218
  { DB_TOKEN, "Id", "NodeId", 0, 1 },
  { API_TOKEN, "Id", "NodeId", 0, 1 },
  { MGM_TOKEN, "Id", "NodeId", 0, 1 },
219
  { 0, 0, 0, 0, 0}
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
};

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

246 247
const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {

248 249 250 251 252 253 254 255
  /****************************************************************************
   * COMPUTER
   ***************************************************************************/
  {
    KEY_INTERNAL,
    "COMPUTER",
    "COMPUTER",
    "Computer section",
unknown's avatar
unknown committed
256
    ConfigInfo::CI_INTERNAL,
257
    false,
unknown's avatar
unknown committed
258
    ConfigInfo::CI_SECTION,
259 260 261 262 263 264 265 266
    0,
    0, 0 },
  
  {
    KEY_INTERNAL,
    "Id",
    "COMPUTER",
    "Name of computer",
unknown's avatar
unknown committed
267
    ConfigInfo::CI_USED,
268
    false,
unknown's avatar
unknown committed
269
    ConfigInfo::CI_STRING,
270
    MANDATORY,
271
    0, 0 },
272 273 274 275 276

  {
    KEY_INTERNAL,
    "HostName",
    "COMPUTER",
unknown's avatar
unknown committed
277
    "Hostname of computer (e.g. mysql.com)",
unknown's avatar
unknown committed
278
    ConfigInfo::CI_USED,
279
    false,
unknown's avatar
unknown committed
280
    ConfigInfo::CI_STRING,
281
    MANDATORY,
282
    0, 0 },
283 284 285 286 287 288

  {
    KEY_INTERNAL,
    "ByteOrder",
    "COMPUTER",
    0,
unknown's avatar
unknown committed
289
    ConfigInfo::CI_DEPRICATED,
290
    false,
unknown's avatar
unknown committed
291
    ConfigInfo::CI_STRING,
292 293 294
    UNDEFINED,
    0,
    0 },
295 296 297 298 299 300 301 302 303
  
  /****************************************************************************
   * SYSTEM
   ***************************************************************************/
  {
    CFG_SECTION_SYSTEM,
    "SYSTEM",
    "SYSTEM",
    "System section",
unknown's avatar
unknown committed
304
    ConfigInfo::CI_USED,
305
    false,
unknown's avatar
unknown committed
306
    ConfigInfo::CI_SECTION,
307 308
    (const char *)CFG_SECTION_SYSTEM,
    0, 0 },
309 310 311 312 313 314

  {
    CFG_SYS_NAME,
    "Name",
    "SYSTEM",
    "Name of system (NDB Cluster)",
unknown's avatar
unknown committed
315
    ConfigInfo::CI_USED,
316
    false,
unknown's avatar
unknown committed
317
    ConfigInfo::CI_STRING,
318
    MANDATORY,
319
    0, 0 },
320 321 322 323 324
  
  {
    CFG_SYS_PRIMARY_MGM_NODE,
    "PrimaryMGMNode",
    "SYSTEM",
325
    "Node id of Primary "MGM_TOKEN_PRINT" node",
unknown's avatar
unknown committed
326
    ConfigInfo::CI_USED,
327
    false,
unknown's avatar
unknown committed
328
    ConfigInfo::CI_INT,
329 330
    "0",
    "0",
331
    STR_VALUE(MAX_INT_RNIL) },
332 333 334 335 336 337

  {
    CFG_SYS_CONFIG_GENERATION,
    "ConfigGenerationNumber",
    "SYSTEM",
    "Configuration generation number",
unknown's avatar
unknown committed
338
    ConfigInfo::CI_USED,
339
    false,
unknown's avatar
unknown committed
340
    ConfigInfo::CI_INT,
341 342
    "0",
    "0",
343
    STR_VALUE(MAX_INT_RNIL) },
344 345 346 347 348 349

  /***************************************************************************
   * DB
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
350 351
    DB_TOKEN,
    DB_TOKEN,
352
    "Node section",
unknown's avatar
unknown committed
353
    ConfigInfo::CI_USED,
354
    false,
unknown's avatar
unknown committed
355
    ConfigInfo::CI_SECTION,
356 357
    (const char *)NODE_TYPE_DB, 
    0, 0
358 359 360 361 362
  },

  {
    CFG_NODE_HOST,
    "HostName",
363
    DB_TOKEN,
364
    "Name of computer for this node",
unknown's avatar
unknown committed
365
    ConfigInfo::CI_INTERNAL,
366
    false,
unknown's avatar
unknown committed
367
    ConfigInfo::CI_STRING,
368
    "localhost",
369
    0, 0 },
370 371 372 373

  {
    CFG_NODE_SYSTEM,
    "System",
374
    DB_TOKEN,
375
    "Name of system for this node",
unknown's avatar
unknown committed
376
    ConfigInfo::CI_INTERNAL,
377
    false,
unknown's avatar
unknown committed
378
    ConfigInfo::CI_STRING,
379
    UNDEFINED,
380
    0, 0 },
381 382

  {
unknown's avatar
unknown committed
383
    KEY_INTERNAL,
384
    "Id",
385
    DB_TOKEN,
unknown's avatar
unknown committed
386 387 388 389 390 391 392 393 394 395
    "",
    ConfigInfo::CI_DEPRICATED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1",
    STR_VALUE(MAX_NODES) },

  {
    CFG_NODE_ID,
396
    "NodeId",
unknown's avatar
unknown committed
397
    DB_TOKEN,
398
    "Number identifying the database node ("DB_TOKEN_PRINT")",
unknown's avatar
unknown committed
399
    ConfigInfo::CI_USED,
400
    false,
unknown's avatar
unknown committed
401
    ConfigInfo::CI_INT,
402
    MANDATORY,
403
    "1",
404
    STR_VALUE(MAX_NODES) },
405

unknown's avatar
unknown committed
406
  {
unknown's avatar
unknown committed
407
    KEY_INTERNAL,
unknown's avatar
unknown committed
408
    "ServerPort",
409
    DB_TOKEN,
unknown's avatar
unknown committed
410
    "Port used to setup transporter",
unknown's avatar
unknown committed
411
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
412
    false,
unknown's avatar
unknown committed
413
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
414
    UNDEFINED,
415
    "1",
unknown's avatar
unknown committed
416
    STR_VALUE(MAX_PORT_NO) },
unknown's avatar
unknown committed
417

418 419 420
  {
    CFG_DB_NO_REPLICAS,
    "NoOfReplicas",
421
    DB_TOKEN,
422
    "Number of copies of all data in the database (1-4)",
unknown's avatar
unknown committed
423
    ConfigInfo::CI_USED,
424
    false,
unknown's avatar
unknown committed
425
    ConfigInfo::CI_INT,
426
    MANDATORY,
427 428
    "1",
    "4" },
429 430 431 432

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

  {
    CFG_DB_NO_UNIQUE_HASH_INDEXES,
    "MaxNoOfUniqueHashIndexes",
469
    DB_TOKEN,
unknown's avatar
unknown committed
470
    "Total number of unique hash indexes that can be defined in the system",
unknown's avatar
unknown committed
471
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
472
    false,
unknown's avatar
unknown committed
473
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
474 475
    "64",
    "0",
unknown's avatar
unknown committed
476
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
477

478 479 480
  {
    CFG_DB_NO_INDEXES,
    "MaxNoOfIndexes",
481
    DB_TOKEN,
482
    "Total number of indexes that can be defined in the system",
unknown's avatar
unknown committed
483
    ConfigInfo::CI_DEPRICATED,
484
    false,
unknown's avatar
unknown committed
485
    ConfigInfo::CI_INT,
486 487
    "128",
    "0",
488
    STR_VALUE(MAX_INT_RNIL) },
489 490 491 492

  {
    CFG_DB_NO_INDEX_OPS,
    "MaxNoOfConcurrentIndexOperations",
493
    DB_TOKEN,
494
    "Total number of index operations that can execute simultaneously on one "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
495
    ConfigInfo::CI_USED,
496
    false,
unknown's avatar
unknown committed
497
    ConfigInfo::CI_INT,
498 499
    "8K",
    "0",
500
    STR_VALUE(MAX_INT_RNIL) 
501 502 503 504 505
   },

  {
    CFG_DB_NO_TRIGGERS,
    "MaxNoOfTriggers",
506
    DB_TOKEN,
507
    "Total number of triggers that can be defined in the system",
unknown's avatar
unknown committed
508
    ConfigInfo::CI_USED,
509
    false,
unknown's avatar
unknown committed
510
    ConfigInfo::CI_INT,
511 512
    "768",
    "0",
513
    STR_VALUE(MAX_INT_RNIL) },
514 515 516 517

  {
    CFG_DB_NO_TRIGGER_OPS,
    "MaxNoOfFiredTriggers",
518
    DB_TOKEN,
519
    "Total number of triggers that can fire simultaneously in 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
    "4000",
    "0",
525
    STR_VALUE(MAX_INT_RNIL) },
526 527 528 529

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
530
    DB_TOKEN,
531
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
532
    ConfigInfo::CI_USED,
533
    false,
unknown's avatar
unknown committed
534
    ConfigInfo::CI_STRING,
535 536
    UNDEFINED,
    0, 0 },
537 538 539 540
  
  {
    CFG_DB_NO_SAVE_MSGS,
    "MaxNoOfSavedMessages",
541
    DB_TOKEN,
542
    "Max number of error messages in error log and max number of trace files",
unknown's avatar
unknown committed
543
    ConfigInfo::CI_USED,
544
    true,
unknown's avatar
unknown committed
545
    ConfigInfo::CI_INT,
546 547
    "25",
    "0",
548
    STR_VALUE(MAX_INT_RNIL) },
549 550 551 552

  {
    CFG_DB_MEMLOCK,
    "LockPagesInMainMemory",
553
    DB_TOKEN,
554
    "If set to yes, then NDB Cluster data will not be swapped out to disk",
unknown's avatar
unknown committed
555
    ConfigInfo::CI_USED,
556
    true,
unknown's avatar
unknown committed
557 558 559 560
    ConfigInfo::CI_INT,
    "0",
    "1",
    "2" },
561 562 563 564

  {
    CFG_DB_WATCHDOG_INTERVAL,
    "TimeBetweenWatchDogCheck",
565
    DB_TOKEN,
566
    "Time between execution checks inside a database node",
unknown's avatar
unknown committed
567
    ConfigInfo::CI_USED,
568
    true,
unknown's avatar
unknown committed
569
    ConfigInfo::CI_INT,
570 571
    "6000",
    "70",
572
    STR_VALUE(MAX_INT_RNIL) },
573 574 575 576

  {
    CFG_DB_STOP_ON_ERROR,
    "StopOnError",
577
    DB_TOKEN,
578
    "If set to N, "DB_TOKEN_PRINT" automatically restarts/recovers in case of node failure",
unknown's avatar
unknown committed
579
    ConfigInfo::CI_USED,
580
    true,
unknown's avatar
unknown committed
581
    ConfigInfo::CI_BOOL,
582 583 584
    "true",
    "false",
    "true" },
585 586 587 588

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

unknown's avatar
unknown committed
610 611 612
  {
    CFG_DB_NO_LOCAL_OPS,
    "MaxNoOfLocalOperations",
613
    DB_TOKEN,
unknown's avatar
unknown committed
614
    "Max number of operation records defined in the local storage node",
unknown's avatar
unknown committed
615
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
616
    false,
unknown's avatar
unknown committed
617
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
618 619
    UNDEFINED,
    "32",
unknown's avatar
unknown committed
620
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
621 622 623 624

  {
    CFG_DB_NO_LOCAL_SCANS,
    "MaxNoOfLocalScans",
625
    DB_TOKEN,
unknown's avatar
unknown committed
626
    "Max number of fragment scans in parallel in the local storage node",
unknown's avatar
unknown committed
627
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
628
    false,
unknown's avatar
unknown committed
629
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
630 631
    UNDEFINED,
    "32",
unknown's avatar
unknown committed
632
    STR_VALUE(MAX_INT_RNIL) },
unknown's avatar
unknown committed
633 634 635 636

  {
    CFG_DB_BATCH_SIZE,
    "BatchSizePerLocalScan",
637
    DB_TOKEN,
unknown's avatar
unknown committed
638
    "Used to calculate the number of lock records for scan with hold lock",
unknown's avatar
unknown committed
639
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
640
    false,
unknown's avatar
unknown committed
641
    ConfigInfo::CI_INT,
unknown's avatar
merge  
unknown committed
642
    STR_VALUE(DEF_BATCH_SIZE),
unknown's avatar
unknown committed
643
    "1",
unknown's avatar
merge  
unknown committed
644
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
645 646 647 648

  {
    CFG_DB_NO_TRANSACTIONS,
    "MaxNoOfConcurrentTransactions",
649
    DB_TOKEN,
650
    "Max number of transaction executing concurrently on the "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
651
    ConfigInfo::CI_USED,
652
    false,
unknown's avatar
unknown committed
653
    ConfigInfo::CI_INT,
654 655
    "4096",
    "32",
656
    STR_VALUE(MAX_INT_RNIL) },
657 658 659 660

  {
    CFG_DB_NO_SCANS,
    "MaxNoOfConcurrentScans",
661
    DB_TOKEN,
662
    "Max number of scans executing concurrently on the "DB_TOKEN_PRINT" node",
unknown's avatar
unknown committed
663
    ConfigInfo::CI_USED,
664
    false,
unknown's avatar
unknown committed
665
    ConfigInfo::CI_INT,
666 667 668
    "256",
    "2",
    "500" },
669 670 671 672

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

  {
    CFG_DB_DATA_MEM,
    "DataMemory",
697
    DB_TOKEN,
698
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing data",
unknown's avatar
unknown committed
699
    ConfigInfo::CI_USED,
700
    false,
unknown's avatar
unknown committed
701
    ConfigInfo::CI_INT64,
702 703 704
    "80M",
    "1M",
    "1024G" },
705

706 707 708
  {
    CFG_DB_UNDO_INDEX_BUFFER,
    "UndoIndexBuffer",
709
    DB_TOKEN,
710
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for index part",
unknown's avatar
unknown committed
711
    ConfigInfo::CI_USED,
712
    false,
unknown's avatar
unknown committed
713
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
714 715
    "2M",
    "1M",
unknown's avatar
unknown committed
716
    STR_VALUE(MAX_INT_RNIL)},
717 718 719 720

  {
    CFG_DB_UNDO_DATA_BUFFER,
    "UndoDataBuffer",
721
    DB_TOKEN,
722
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for data part",
unknown's avatar
unknown committed
723
    ConfigInfo::CI_USED,
724
    false,
unknown's avatar
unknown committed
725
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
726 727
    "16M",
    "1M",
unknown's avatar
unknown committed
728
    STR_VALUE(MAX_INT_RNIL)},
729 730 731 732

  {
    CFG_DB_REDO_BUFFER,
    "RedoBuffer",
733
    DB_TOKEN,
734
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing REDO logs",
unknown's avatar
unknown committed
735
    ConfigInfo::CI_USED,
736
    false,
unknown's avatar
unknown committed
737
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
738 739
    "8M",
    "1M",
unknown's avatar
unknown committed
740
    STR_VALUE(MAX_INT_RNIL)},
741

742 743 744
  {
    CFG_DB_LONG_SIGNAL_BUFFER,
    "LongMessageBuffer",
745
    DB_TOKEN,
746
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for internal long messages",
unknown's avatar
unknown committed
747
    ConfigInfo::CI_USED,
748
    false,
unknown's avatar
unknown committed
749
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
750 751
    "1M",
    "512k",
unknown's avatar
unknown committed
752
    STR_VALUE(MAX_INT_RNIL)},
753

unknown's avatar
unknown committed
754 755 756 757 758 759 760 761 762 763 764
  {
    CFG_DB_DISK_PAGE_BUFFER_MEMORY,
    "DiskPageBufferMemory",
    DB_TOKEN,
    "Number bytes on each "DB_TOKEN_PRINT" node allocated for disk page buffer cache",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT64,
    "64M",
    "4M",
    "1024G" },
765 766 767 768 769 770 771 772 773 774 775 776

  {
    CFG_DB_SGA,
    "SharedGlobalMemory",
    DB_TOKEN,
    "Total number bytes on each "DB_TOKEN_PRINT" node allocated for any use",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT64,
    "20M",
    "0",
    "65536G" }, // 32k pages * 32-bit i value
unknown's avatar
unknown committed
777
  
778 779 780
  {
    CFG_DB_START_PARTIAL_TIMEOUT,
    "StartPartialTimeout",
781
    DB_TOKEN,
782
    "Time to wait before trying to start wo/ all nodes. 0=Wait forever",
unknown's avatar
unknown committed
783
    ConfigInfo::CI_USED,
784
    true,
unknown's avatar
unknown committed
785
    ConfigInfo::CI_INT,
786 787
    "30000",
    "0",
788
    STR_VALUE(MAX_INT_RNIL) },
789 790 791 792

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

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

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

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

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

  {
unknown's avatar
unknown committed
875
    CFG_DB_MAX_OPEN_FILES,
876
    "MaxNoOfOpenFiles",
877
    DB_TOKEN,
878
    "Max number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)",
unknown's avatar
unknown committed
879
    ConfigInfo::CI_USED,
880
    false,
unknown's avatar
unknown committed
881
    ConfigInfo::CI_INT,
882 883
    "40",
    "20",
unknown's avatar
unknown committed
884
    STR_VALUE(MAX_INT_RNIL) },
885
  
886
  {
unknown's avatar
unknown committed
887
    CFG_DB_INITIAL_OPEN_FILES,
888 889 890 891 892 893 894 895 896 897
    "InitialNoOfOpenFiles",
    DB_TOKEN,
    "Initial number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "27",
    "20",
    STR_VALUE(MAX_INT_RNIL) },
  
898 899 900
  {
    CFG_DB_TRANSACTION_CHECK_INTERVAL,
    "TimeBetweenInactiveTransactionAbortCheck",
901
    DB_TOKEN,
902
    "Time between inactive transaction checks",
unknown's avatar
unknown committed
903
    ConfigInfo::CI_USED,
904
    true,
unknown's avatar
unknown committed
905
    ConfigInfo::CI_INT,
906 907
    "1000",
    "1000",
908
    STR_VALUE(MAX_INT_RNIL) },
909 910 911 912
  
  {
    CFG_DB_TRANSACTION_INACTIVE_TIMEOUT,
    "TransactionInactiveTimeout",
913
    DB_TOKEN,
914 915 916 917 918
    "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
919
    ConfigInfo::CI_USED,
920
    true,
unknown's avatar
unknown committed
921
    ConfigInfo::CI_INT,
922
    STR_VALUE(MAX_INT_RNIL),
923
    "0",
924
    STR_VALUE(MAX_INT_RNIL) },
925 926 927 928

  {
    CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
    "TransactionDeadlockDetectionTimeout",
929
    DB_TOKEN,
930 931 932 933
    "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
934
    ConfigInfo::CI_USED,
935
    true,
unknown's avatar
unknown committed
936
    ConfigInfo::CI_INT,
937 938
    "1200",
    "50",
939
    STR_VALUE(MAX_INT_RNIL) },
940 941

  {
unknown's avatar
unknown committed
942
    CFG_DB_LCP_DISC_PAGES_TUP_SR,
943
    "NoOfDiskPagesToDiskDuringRestartTUP",
944
    DB_TOKEN,
945 946
    "DiskCheckpointSpeedSr",
    ConfigInfo::CI_DEPRICATED,
947
    true,
unknown's avatar
unknown committed
948
    ConfigInfo::CI_INT,
949 950
    "40",
    "1",
951
    STR_VALUE(MAX_INT_RNIL) },
952 953

  {
unknown's avatar
unknown committed
954
    CFG_DB_LCP_DISC_PAGES_TUP,
955
    "NoOfDiskPagesToDiskAfterRestartTUP",
956
    DB_TOKEN,
957 958
    "DiskCheckpointSpeed",
    ConfigInfo::CI_DEPRICATED,
959
    true,
unknown's avatar
unknown committed
960
    ConfigInfo::CI_INT,
961 962
    "40",
    "1",
963
    STR_VALUE(MAX_INT_RNIL) },
964 965

  {
unknown's avatar
unknown committed
966
    CFG_DB_LCP_DISC_PAGES_ACC_SR,
967
    "NoOfDiskPagesToDiskDuringRestartACC",
968
    DB_TOKEN,
969 970
    "DiskCheckpointSpeedSr",
    ConfigInfo::CI_DEPRICATED,
971
    true,
unknown's avatar
unknown committed
972
    ConfigInfo::CI_INT,
973 974
    "20",
    "1",
975
    STR_VALUE(MAX_INT_RNIL) },
976 977

  {
unknown's avatar
unknown committed
978
    CFG_DB_LCP_DISC_PAGES_ACC,
979
    "NoOfDiskPagesToDiskAfterRestartACC",
980
    DB_TOKEN,
981 982
    "DiskCheckpointSpeed",
    ConfigInfo::CI_DEPRICATED,
983
    true,
unknown's avatar
unknown committed
984
    ConfigInfo::CI_INT,
985 986
    "20",
    "1",
987
    STR_VALUE(MAX_INT_RNIL) },
988
  
989 990 991

  {
    CFG_DB_DISCLESS,
unknown's avatar
unknown committed
992
    "Diskless",
993
    DB_TOKEN,
994
    "Run wo/ disk",
unknown's avatar
unknown committed
995
    ConfigInfo::CI_USED,
996
    true,
unknown's avatar
unknown committed
997
    ConfigInfo::CI_BOOL,
998 999 1000
    "false",
    "false",
    "true"},
unknown's avatar
unknown committed
1001 1002

  {
1003
    KEY_INTERNAL,
unknown's avatar
unknown committed
1004
    "Discless",
1005
    DB_TOKEN,
unknown's avatar
unknown committed
1006
    "Diskless",
unknown's avatar
unknown committed
1007
    ConfigInfo::CI_DEPRICATED,
unknown's avatar
unknown committed
1008
    true,
unknown's avatar
unknown committed
1009
    ConfigInfo::CI_BOOL,
1010 1011 1012
    "false",
    "false",
    "true"},
unknown's avatar
unknown committed
1013 1014
  

1015
  
1016 1017 1018
  {
    CFG_DB_ARBIT_TIMEOUT,
    "ArbitrationTimeout",
1019
    DB_TOKEN,
1020
    "Max time (milliseconds) database partion waits for arbitration signal",
unknown's avatar
unknown committed
1021
    ConfigInfo::CI_USED,
1022
    false,
unknown's avatar
unknown committed
1023
    ConfigInfo::CI_INT,
1024 1025
    "3000",
    "10",
1026
    STR_VALUE(MAX_INT_RNIL) },
1027

1028 1029 1030 1031 1032
  {
    CFG_NODE_DATADIR,
    "DataDir",
    DB_TOKEN,
    "Data directory for this node",
unknown's avatar
unknown committed
1033
    ConfigInfo::CI_USED,
1034
    false,
unknown's avatar
unknown committed
1035
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1036
    MYSQLCLUSTERDIR,
1037 1038
    0, 0 },

1039 1040 1041
  {
    CFG_DB_FILESYSTEM_PATH,
    "FileSystemPath",
1042
    DB_TOKEN,
1043
    "Path to directory where the "DB_TOKEN_PRINT" node stores its data (directory must exist)",
unknown's avatar
unknown committed
1044
    ConfigInfo::CI_USED,
1045
    false,
unknown's avatar
unknown committed
1046
    ConfigInfo::CI_STRING,
1047
    UNDEFINED,
1048
    0, 0 },
1049 1050 1051 1052

  {
    CFG_LOGLEVEL_STARTUP,
    "LogLevelStartup",
1053
    DB_TOKEN,
1054
    "Node startup info printed on stdout",
unknown's avatar
unknown committed
1055
    ConfigInfo::CI_USED,
1056
    false,
unknown's avatar
unknown committed
1057
    ConfigInfo::CI_INT,
1058 1059 1060
    "1",
    "0",
    "15" },
1061 1062 1063 1064
  
  {
    CFG_LOGLEVEL_SHUTDOWN,
    "LogLevelShutdown",
1065
    DB_TOKEN,
1066
    "Node shutdown info printed on stdout",
unknown's avatar
unknown committed
1067
    ConfigInfo::CI_USED,
1068
    false,
unknown's avatar
unknown committed
1069
    ConfigInfo::CI_INT,
1070 1071 1072
    "0",
    "0",
    "15" },
1073 1074 1075 1076

  {
    CFG_LOGLEVEL_STATISTICS,
    "LogLevelStatistic",
1077
    DB_TOKEN,
1078
    "Transaction, operation, transporter info printed on stdout",
unknown's avatar
unknown committed
1079
    ConfigInfo::CI_USED,
1080
    false,
unknown's avatar
unknown committed
1081
    ConfigInfo::CI_INT,
1082 1083 1084
    "0",
    "0",
    "15" },
1085 1086 1087 1088

  {
    CFG_LOGLEVEL_CHECKPOINT,
    "LogLevelCheckpoint",
1089
    DB_TOKEN,
1090
    "Local and Global checkpoint info printed on stdout",
unknown's avatar
unknown committed
1091
    ConfigInfo::CI_USED,
1092
    false,
unknown's avatar
unknown committed
1093
    ConfigInfo::CI_INT,
1094 1095 1096
    "0",
    "0",
    "15" },
1097 1098 1099 1100

  {
    CFG_LOGLEVEL_NODERESTART,
    "LogLevelNodeRestart",
1101
    DB_TOKEN,
1102
    "Node restart, node failure info printed on stdout",
unknown's avatar
unknown committed
1103
    ConfigInfo::CI_USED,
1104
    false,
unknown's avatar
unknown committed
1105
    ConfigInfo::CI_INT,
1106 1107 1108
    "0",
    "0",
    "15" },
1109 1110 1111 1112

  {
    CFG_LOGLEVEL_CONNECTION,
    "LogLevelConnection",
1113
    DB_TOKEN,
1114
    "Node connect/disconnect info printed on stdout",
unknown's avatar
unknown committed
1115
    ConfigInfo::CI_USED,
1116
    false,
unknown's avatar
unknown committed
1117
    ConfigInfo::CI_INT,
1118 1119 1120
    "0",
    "0",
    "15" },
1121

unknown's avatar
unknown committed
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
  {
    CFG_LOGLEVEL_CONGESTION,
    "LogLevelCongestion",
    DB_TOKEN,
    "Congestion info printed on stdout",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "0",
    "0",
    "15" },

1134 1135 1136
  {
    CFG_LOGLEVEL_ERROR,
    "LogLevelError",
1137
    DB_TOKEN,
1138
    "Transporter, heartbeat errors printed on stdout",
unknown's avatar
unknown committed
1139
    ConfigInfo::CI_USED,
1140
    false,
unknown's avatar
unknown committed
1141
    ConfigInfo::CI_INT,
1142 1143 1144
    "0",
    "0",
    "15" },
1145 1146 1147 1148

  {
    CFG_LOGLEVEL_INFO,
    "LogLevelInfo",
1149
    DB_TOKEN,
1150
    "Heartbeat and log info printed on stdout",
unknown's avatar
unknown committed
1151
    ConfigInfo::CI_USED,
1152
    false,
unknown's avatar
unknown committed
1153
    ConfigInfo::CI_INT,
1154 1155 1156
    "0",
    "0",
    "15" },
1157 1158 1159 1160 1161 1162 1163

  /**
   * Backup
   */
  { 
    CFG_DB_PARALLEL_BACKUPS,
    "ParallelBackups",
1164
    DB_TOKEN,
1165
    "Maximum number of parallel backups",
unknown's avatar
unknown committed
1166
    ConfigInfo::CI_NOTIMPLEMENTED,
1167
    false,
unknown's avatar
unknown committed
1168
    ConfigInfo::CI_INT,
1169 1170 1171
    "1",
    "1",
    "1" },
1172
  
1173
  { 
unknown's avatar
unknown committed
1174 1175
    CFG_DB_BACKUP_DATADIR,
    "BackupDataDir",
1176 1177
    DB_TOKEN,
    "Path to where to store backups",
unknown's avatar
unknown committed
1178
    ConfigInfo::CI_USED,
1179
    false,
unknown's avatar
unknown committed
1180
    ConfigInfo::CI_STRING,
1181 1182 1183
    UNDEFINED,
    0, 0 },
  
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
  { 
    CFG_DB_DISK_SYNCH_SIZE,
    "DiskSyncSize",
    DB_TOKEN,
    "Data written to a file before a synch is forced",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "4M",
    "32k",
    STR_VALUE(MAX_INT_RNIL) },
  
  { 
    CFG_DB_CHECKPOINT_SPEED,
    "DiskCheckpointSpeed",
    DB_TOKEN,
    "Bytes per second allowed to be written by checkpoint",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "10M",
    "1M",
    STR_VALUE(MAX_INT_RNIL) },
  
  { 
    CFG_DB_CHECKPOINT_SPEED_SR,
    "DiskCheckpointSpeedInRestart",
    DB_TOKEN,
    "Bytes per second allowed to be written by checkpoint during restart",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "100M",
    "1M",
    STR_VALUE(MAX_INT_RNIL) },
  
1220 1221 1222
  { 
    CFG_DB_BACKUP_MEM,
    "BackupMemory",
1223
    DB_TOKEN,
1224
    "Total memory allocated for backups per node (in bytes)",
unknown's avatar
unknown committed
1225
    ConfigInfo::CI_USED,
1226
    false,
unknown's avatar
unknown committed
1227
    ConfigInfo::CI_INT,
1228 1229
    "4M", // sum of BackupDataBufferSize and BackupLogBufferSize
    "0",
1230
    STR_VALUE(MAX_INT_RNIL) },
1231 1232 1233 1234
  
  { 
    CFG_DB_BACKUP_DATA_BUFFER_MEM,
    "BackupDataBufferSize",
1235
    DB_TOKEN,
1236
    "Default size of databuffer for a backup (in bytes)",
unknown's avatar
unknown committed
1237
    ConfigInfo::CI_USED,
1238
    false,
unknown's avatar
unknown committed
1239
    ConfigInfo::CI_INT,
1240 1241
    "2M", // remember to change BackupMemory
    "0",
1242
    STR_VALUE(MAX_INT_RNIL) },
1243 1244 1245 1246

  { 
    CFG_DB_BACKUP_LOG_BUFFER_MEM,
    "BackupLogBufferSize",
1247
    DB_TOKEN,
1248
    "Default size of logbuffer for a backup (in bytes)",
unknown's avatar
unknown committed
1249
    ConfigInfo::CI_USED,
1250
    false,
unknown's avatar
unknown committed
1251
    ConfigInfo::CI_INT,
1252 1253
    "2M", // remember to change BackupMemory
    "0",
1254
    STR_VALUE(MAX_INT_RNIL) },
1255 1256 1257 1258

  { 
    CFG_DB_BACKUP_WRITE_SIZE,
    "BackupWriteSize",
1259
    DB_TOKEN,
1260
    "Default size of filesystem writes made by backup (in bytes)",
unknown's avatar
unknown committed
1261
    ConfigInfo::CI_USED,
1262
    false,
unknown's avatar
unknown committed
1263
    ConfigInfo::CI_INT,
1264
    "32K",
unknown's avatar
ndb -  
unknown committed
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
    "2K",
    STR_VALUE(MAX_INT_RNIL) },

  { 
    CFG_DB_BACKUP_MAX_WRITE_SIZE,
    "BackupMaxWriteSize",
    DB_TOKEN,
    "Max size of filesystem writes made by backup (in bytes)",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "256K",
    "2K",
1278
    STR_VALUE(MAX_INT_RNIL) },
1279

1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290
  { 
    CFG_DB_STRING_MEMORY,
    "StringMemory",
    DB_TOKEN,
    "Default size of string memory (0 -> 5% of max 1-100 -> %of max, >100 -> actual bytes)",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302

  { 
    CFG_DB_MEMREPORT_FREQUENCY,
    "MemReportFrequency",
    DB_TOKEN,
    "Frequency of mem reports in seconds, 0 = only when passing %-limits",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },
1303
  
1304 1305 1306 1307 1308
  /***************************************************************************
   * API
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1309 1310
    API_TOKEN,
    API_TOKEN,
1311
    "Node section",
unknown's avatar
unknown committed
1312
    ConfigInfo::CI_USED,
1313
    false,
unknown's avatar
unknown committed
1314
    ConfigInfo::CI_SECTION,
1315 1316
    (const char *)NODE_TYPE_API, 
    0, 0
1317 1318 1319 1320 1321
  },

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

  {
    CFG_NODE_SYSTEM,
    "System",
1333
    API_TOKEN,
1334
    "Name of system for this node",
unknown's avatar
unknown committed
1335
    ConfigInfo::CI_INTERNAL,
1336
    false,
unknown's avatar
unknown committed
1337
    ConfigInfo::CI_STRING,
1338
    UNDEFINED,
1339
    0, 0 },
1340 1341

  {
unknown's avatar
unknown committed
1342
    KEY_INTERNAL,
1343
    "Id",
1344
    API_TOKEN,
unknown's avatar
unknown committed
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
    "",
    ConfigInfo::CI_DEPRICATED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1",
    STR_VALUE(MAX_NODES) },

  {
    CFG_NODE_ID,
1355
    "NodeId",
unknown's avatar
unknown committed
1356
    API_TOKEN,
1357
    "Number identifying application node ("API_TOKEN_PRINT")",
unknown's avatar
unknown committed
1358
    ConfigInfo::CI_USED,
1359
    false,
unknown's avatar
unknown committed
1360
    ConfigInfo::CI_INT,
1361
    MANDATORY,
1362
    "1",
1363
    STR_VALUE(MAX_NODES) },
1364 1365 1366 1367

  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1368
    API_TOKEN,
1369
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1370
    ConfigInfo::CI_USED,
1371
    false,
unknown's avatar
unknown committed
1372
    ConfigInfo::CI_STRING,
1373 1374
    UNDEFINED,
    0, 0 },
1375 1376 1377 1378

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1379
    API_TOKEN,
1380
    "If 0, then "API_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1381
    ConfigInfo::CI_USED,
1382
    false,
unknown's avatar
unknown committed
1383
    ConfigInfo::CI_INT,
1384 1385 1386
    "0",
    "0",
    "2" },
1387 1388 1389 1390

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1391
    API_TOKEN,
1392
    "When asked to arbitrate, arbitrator waits this long before voting (msec)",
unknown's avatar
unknown committed
1393
    ConfigInfo::CI_USED,
1394
    false,
unknown's avatar
unknown committed
1395
    ConfigInfo::CI_INT,
1396 1397
    "0",
    "0",
1398
    STR_VALUE(MAX_INT_RNIL) },
1399

1400 1401 1402 1403 1404
  {
    CFG_MAX_SCAN_BATCH_SIZE,
    "MaxScanBatchSize",
    "API",
    "The maximum collective batch size for one scan",
unknown's avatar
unknown committed
1405
    ConfigInfo::CI_USED,
1406
    false,
unknown's avatar
unknown committed
1407
    ConfigInfo::CI_INT,
1408 1409 1410 1411
    STR_VALUE(MAX_SCAN_BATCH_SIZE),
    "32k",
    "16M" },
  
1412 1413 1414 1415 1416
  {
    CFG_BATCH_BYTE_SIZE,
    "BatchByteSize",
    "API",
    "The default batch size in bytes",
unknown's avatar
unknown committed
1417
    ConfigInfo::CI_USED,
1418
    false,
unknown's avatar
unknown committed
1419
    ConfigInfo::CI_INT,
1420 1421 1422
    STR_VALUE(SCAN_BATCH_SIZE),
    "1k",
    "1M" },
1423 1424 1425 1426 1427 1428

  {
    CFG_BATCH_SIZE,
    "BatchSize",
    "API",
    "The default batch size in number of records",
unknown's avatar
unknown committed
1429
    ConfigInfo::CI_USED,
1430
    false,
unknown's avatar
unknown committed
1431
    ConfigInfo::CI_INT,
1432 1433 1434
    STR_VALUE(DEF_BATCH_SIZE),
    "1",
    STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
1435

1436 1437 1438 1439 1440
  /****************************************************************************
   * MGM
   ***************************************************************************/
  {
    CFG_SECTION_NODE,
1441 1442
    MGM_TOKEN,
    MGM_TOKEN,
1443
    "Node section",
unknown's avatar
unknown committed
1444
    ConfigInfo::CI_USED,
1445
    false,
unknown's avatar
unknown committed
1446
    ConfigInfo::CI_SECTION,
1447 1448
    (const char *)NODE_TYPE_MGM, 
    0, 0
1449 1450 1451 1452 1453
  },

  {
    CFG_NODE_HOST,
    "HostName",
1454
    MGM_TOKEN,
1455
    "Name of computer for this node",
unknown's avatar
unknown committed
1456
    ConfigInfo::CI_INTERNAL,
1457
    false,
unknown's avatar
unknown committed
1458
    ConfigInfo::CI_STRING,
1459
    "",
1460
    0, 0 },
1461

1462 1463 1464 1465 1466
  {
    CFG_NODE_DATADIR,
    "DataDir",
    MGM_TOKEN,
    "Data directory for this node",
unknown's avatar
unknown committed
1467
    ConfigInfo::CI_USED,
1468
    false,
unknown's avatar
unknown committed
1469
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1470
    MYSQLCLUSTERDIR,
1471 1472
    0, 0 },

1473 1474 1475
  {
    CFG_NODE_SYSTEM,
    "System",
1476
    MGM_TOKEN,
1477
    "Name of system for this node",
unknown's avatar
unknown committed
1478
    ConfigInfo::CI_INTERNAL,
1479
    false,
unknown's avatar
unknown committed
1480
    ConfigInfo::CI_STRING,
1481
    UNDEFINED,
1482
    0, 0 },
1483 1484

  {
unknown's avatar
unknown committed
1485
    KEY_INTERNAL,
1486
    "Id",
1487
    MGM_TOKEN,
unknown's avatar
unknown committed
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
    "",
    ConfigInfo::CI_DEPRICATED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1",
    STR_VALUE(MAX_NODES) },
  
  {
    CFG_NODE_ID,
1498
    "NodeId",
unknown's avatar
unknown committed
1499
    MGM_TOKEN,
1500
    "Number identifying the management server node ("MGM_TOKEN_PRINT")",
unknown's avatar
unknown committed
1501
    ConfigInfo::CI_USED,
1502
    false,
unknown's avatar
unknown committed
1503
    ConfigInfo::CI_INT,
1504
    MANDATORY,
1505
    "1",
1506
    STR_VALUE(MAX_NODES) },
1507 1508 1509 1510
  
  {
    CFG_LOG_DESTINATION,
    "LogDestination",
1511
    MGM_TOKEN,
1512
    "String describing where logmessages are sent",
unknown's avatar
unknown committed
1513
    ConfigInfo::CI_USED,
1514
    false,
unknown's avatar
unknown committed
1515
    ConfigInfo::CI_STRING,
1516
    0,
1517
    0, 0 },
1518 1519 1520 1521
  
  {
    KEY_INTERNAL,
    "ExecuteOnComputer",
1522
    MGM_TOKEN,
1523
    "String referencing an earlier defined COMPUTER",
unknown's avatar
unknown committed
1524
    ConfigInfo::CI_USED,
1525
    false,
unknown's avatar
unknown committed
1526
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
1527
    0,
1528 1529
    0, 0 },

1530 1531 1532
  {
    KEY_INTERNAL,
    "MaxNoOfSavedEvents",
1533
    MGM_TOKEN,
1534
    "",
unknown's avatar
unknown committed
1535
    ConfigInfo::CI_USED,
1536
    false,
unknown's avatar
unknown committed
1537
    ConfigInfo::CI_INT,
1538 1539
    "100",
    "0",
1540
    STR_VALUE(MAX_INT_RNIL) },
1541 1542 1543 1544

  {
    CFG_MGM_PORT,
    "PortNumber",
1545
    MGM_TOKEN,
1546
    "Port number to give commands to/fetch configurations from management server",
unknown's avatar
unknown committed
1547
    ConfigInfo::CI_USED,
1548
    false,
unknown's avatar
unknown committed
1549
    ConfigInfo::CI_INT,
1550
    NDB_PORT,
1551
    "0",
unknown's avatar
unknown committed
1552
    STR_VALUE(MAX_PORT_NO) },
1553 1554 1555 1556

  {
    KEY_INTERNAL,
    "PortNumberStats",
1557
    MGM_TOKEN,
1558
    "Port number used to get statistical information from a management server",
unknown's avatar
unknown committed
1559
    ConfigInfo::CI_USED,
1560
    false,
unknown's avatar
unknown committed
1561
    ConfigInfo::CI_INT,
1562
    UNDEFINED,
1563
    "0",
unknown's avatar
unknown committed
1564
    STR_VALUE(MAX_PORT_NO) },
1565 1566 1567 1568

  {
    CFG_NODE_ARBIT_RANK,
    "ArbitrationRank",
1569
    MGM_TOKEN,
1570
    "If 0, then "MGM_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2",
unknown's avatar
unknown committed
1571
    ConfigInfo::CI_USED,
1572
    false,
unknown's avatar
unknown committed
1573
    ConfigInfo::CI_INT,
1574 1575 1576
    "1",
    "0",
    "2" },
1577 1578 1579 1580

  {
    CFG_NODE_ARBIT_DELAY,
    "ArbitrationDelay",
1581
    MGM_TOKEN,
1582
    "",
unknown's avatar
unknown committed
1583
    ConfigInfo::CI_USED,
1584
    false,
unknown's avatar
unknown committed
1585
    ConfigInfo::CI_INT,
1586 1587
    "0",
    "0",
1588
    STR_VALUE(MAX_INT_RNIL) },
1589 1590 1591 1592 1593 1594 1595 1596 1597

  /****************************************************************************
   * TCP
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "TCP",
    "TCP",
    "Connection section",
unknown's avatar
unknown committed
1598
    ConfigInfo::CI_USED,
1599
    false,
unknown's avatar
unknown committed
1600
    ConfigInfo::CI_SECTION,
1601 1602
    (const char *)CONNECTION_TYPE_TCP, 
    0, 0
1603 1604 1605
  },

  {
1606
    CFG_CONNECTION_HOSTNAME_1,
1607 1608 1609
    "HostName1",
    "TCP",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1610
    ConfigInfo::CI_INTERNAL,
1611
    false,
unknown's avatar
unknown committed
1612
    ConfigInfo::CI_STRING,
1613
    UNDEFINED,
1614
    0, 0 },
1615 1616

  {
1617
    CFG_CONNECTION_HOSTNAME_2,
1618 1619 1620
    "HostName2",
    "TCP",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
1621
    ConfigInfo::CI_INTERNAL,
1622
    false,
unknown's avatar
unknown committed
1623
    ConfigInfo::CI_STRING,
1624
    UNDEFINED,
1625
    0, 0 },
1626 1627 1628 1629 1630

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "TCP",
1631
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1632
    ConfigInfo::CI_USED,
1633
    false,
unknown's avatar
unknown committed
1634
    ConfigInfo::CI_STRING,
1635
    MANDATORY,
1636
    0, 0 },
1637 1638 1639 1640 1641

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "TCP",
1642
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1643
    ConfigInfo::CI_USED,
1644
    false,
unknown's avatar
unknown committed
1645
    ConfigInfo::CI_STRING,
1646
    MANDATORY,
1647
    0, 0 },
1648

1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "TCP",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "55",
    "0", "200" },

1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670
  {
    CFG_CONNECTION_NODE_ID_SERVER,
    "NodeIdServer",
    "TCP",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1", "63" },

1671 1672 1673 1674 1675
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "TCP",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1676
    ConfigInfo::CI_USED,
1677
    false,
unknown's avatar
unknown committed
1678
    ConfigInfo::CI_BOOL,
1679 1680 1681
    "true",
    "false",
    "true" },
1682 1683 1684 1685 1686 1687 1688


  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "TCP",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1689
    ConfigInfo::CI_USED,
1690
    false,
unknown's avatar
unknown committed
1691
    ConfigInfo::CI_BOOL,
1692 1693 1694
    "false",
    "false",
    "true" },
1695 1696

  {
unknown's avatar
unknown committed
1697
    CFG_CONNECTION_SERVER_PORT,
1698 1699 1700
    "PortNumber",
    "TCP",
    "Port used for this transporter",
unknown's avatar
unknown committed
1701
    ConfigInfo::CI_USED,
1702
    false,
unknown's avatar
unknown committed
1703
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1704
    MANDATORY,
1705
    "0",
unknown's avatar
unknown committed
1706
    STR_VALUE(MAX_PORT_NO) },
1707 1708 1709 1710 1711 1712

  {
    CFG_TCP_SEND_BUFFER_SIZE,
    "SendBufferMemory",
    "TCP",
    "Bytes of buffer for signals sent from this node",
unknown's avatar
unknown committed
1713
    ConfigInfo::CI_USED,
1714
    false,
unknown's avatar
unknown committed
1715
    ConfigInfo::CI_INT,
1716
    "256K",
1717
    "64K",
1718
    STR_VALUE(MAX_INT_RNIL) },
1719 1720 1721 1722 1723 1724

  {
    CFG_TCP_RECEIVE_BUFFER_SIZE,
    "ReceiveBufferMemory",
    "TCP",
    "Bytes of buffer for signals received by this node",
unknown's avatar
unknown committed
1725
    ConfigInfo::CI_USED,
1726
    false,
unknown's avatar
unknown committed
1727
    ConfigInfo::CI_INT,
1728 1729
    "64K",
    "16K",
1730
    STR_VALUE(MAX_INT_RNIL) },
1731 1732 1733 1734 1735 1736

  {
    CFG_TCP_PROXY,
    "Proxy",
    "TCP",
    "",
unknown's avatar
unknown committed
1737
    ConfigInfo::CI_USED,
1738
    false,
unknown's avatar
unknown committed
1739
    ConfigInfo::CI_STRING,
1740
    UNDEFINED,
1741
    0, 0 },
1742 1743 1744 1745 1746 1747

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "TCP",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1748
    ConfigInfo::CI_INTERNAL,
1749
    false,
unknown's avatar
unknown committed
1750
    ConfigInfo::CI_STRING,
1751
    UNDEFINED,
1752
    0, 0 },
1753 1754 1755 1756 1757 1758

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "TCP",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1759
    ConfigInfo::CI_INTERNAL,
1760
    false,
unknown's avatar
unknown committed
1761
    ConfigInfo::CI_STRING,
1762
    UNDEFINED,
1763
    0, 0 },
1764 1765 1766 1767 1768 1769 1770 1771 1772 1773
  

  /****************************************************************************
   * SHM
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SHM",
    "SHM",
    "Connection section",
unknown's avatar
unknown committed
1774
    ConfigInfo::CI_USED,
1775
    false,
unknown's avatar
unknown committed
1776
    ConfigInfo::CI_SECTION,
1777 1778
    (const char *)CONNECTION_TYPE_SHM, 
    0, 0 },
1779 1780

  {
1781 1782
    CFG_CONNECTION_HOSTNAME_1,
    "HostName1",
1783
    "SHM",
1784
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1785
    ConfigInfo::CI_INTERNAL,
1786
    false,
unknown's avatar
unknown committed
1787
    ConfigInfo::CI_STRING,
1788
    UNDEFINED,
1789
    0, 0 },
1790 1791 1792 1793 1794 1795

  {
    CFG_CONNECTION_HOSTNAME_2,
    "HostName2",
    "SHM",
    "Name/IP of computer on one side of the connection",
unknown's avatar
merge  
unknown committed
1796
    ConfigInfo::CI_INTERNAL,
1797
    false,
unknown's avatar
merge  
unknown committed
1798
    ConfigInfo::CI_STRING,
1799 1800 1801
    UNDEFINED,
    0, 0 },

unknown's avatar
unknown committed
1802 1803 1804 1805 1806
  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
    "SHM",
    "Port used for this transporter",
unknown's avatar
unknown committed
1807
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
1808
    false,
unknown's avatar
unknown committed
1809
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
1810
    MANDATORY,
1811
    "0", 
unknown's avatar
unknown committed
1812
    STR_VALUE(MAX_PORT_NO) },
unknown's avatar
unknown committed
1813

1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825
  {
    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) },

1826 1827 1828 1829 1830
  {
    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
1831
    ConfigInfo::CI_USED,
1832
    false,
unknown's avatar
merge  
unknown committed
1833
    ConfigInfo::CI_STRING,
1834 1835 1836
    MANDATORY,
    0, 0 },
  
1837 1838 1839 1840
  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SHM",
1841
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1842
    ConfigInfo::CI_USED,
1843
    false,
unknown's avatar
unknown committed
1844
    ConfigInfo::CI_STRING,
1845
    MANDATORY,
1846
    0, 0 },
1847
  
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SHM",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "35",
    "0", "200" },

1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869
  {
    CFG_CONNECTION_NODE_ID_SERVER,
    "NodeIdServer",
    "SHM",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1", "63" },

1870 1871 1872 1873 1874
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SHM",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
1875
    ConfigInfo::CI_USED,
1876
    false,
unknown's avatar
unknown committed
1877
    ConfigInfo::CI_BOOL,
1878 1879 1880
    "false",
    "false",
    "true" },
1881 1882 1883 1884 1885 1886 1887
  
  
  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SHM",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
1888
    ConfigInfo::CI_USED,
1889
    false,
unknown's avatar
unknown committed
1890
    ConfigInfo::CI_BOOL,
1891 1892 1893
    "true",
    "false",
    "true" },
1894 1895 1896 1897 1898 1899
  
  {
    CFG_SHM_KEY,
    "ShmKey",
    "SHM",
    "A shared memory key",
unknown's avatar
unknown committed
1900
    ConfigInfo::CI_USED,
1901
    false,
unknown's avatar
unknown committed
1902
    ConfigInfo::CI_INT,
1903
    UNDEFINED,
1904
    "0",
1905
    STR_VALUE(MAX_INT_RNIL) },
1906 1907 1908 1909 1910 1911
  
  {
    CFG_SHM_BUFFER_MEM,
    "ShmSize",
    "SHM",
    "Size of shared memory segment",
unknown's avatar
unknown committed
1912
    ConfigInfo::CI_USED,
1913
    false,
unknown's avatar
unknown committed
1914
    ConfigInfo::CI_INT,
1915
    "1M",
1916
    "64K",
1917
    STR_VALUE(MAX_INT_RNIL) },
1918

1919 1920 1921 1922 1923
  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SHM",
    "System for node 1 in connection",
unknown's avatar
unknown committed
1924
    ConfigInfo::CI_INTERNAL,
1925
    false,
unknown's avatar
unknown committed
1926
    ConfigInfo::CI_STRING,
1927
    UNDEFINED,
1928
    0, 0 },
1929 1930 1931 1932 1933 1934

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SHM",
    "System for node 2 in connection",
unknown's avatar
unknown committed
1935
    ConfigInfo::CI_INTERNAL,
1936
    false,
unknown's avatar
unknown committed
1937
    ConfigInfo::CI_STRING,
1938
    UNDEFINED,
1939
    0, 0 },
1940 1941 1942 1943 1944 1945 1946 1947 1948

  /****************************************************************************
   * SCI
   ***************************************************************************/
  {
    CFG_SECTION_CONNECTION,
    "SCI",
    "SCI",
    "Connection section",
unknown's avatar
unknown committed
1949
    ConfigInfo::CI_USED,
1950
    false,
unknown's avatar
unknown committed
1951
    ConfigInfo::CI_SECTION,
1952
    (const char *)CONNECTION_TYPE_SCI, 
1953 1954 1955 1956 1957 1958 1959
    0, 0 
  },

  {
    CFG_CONNECTION_NODE_1,
    "NodeId1",
    "SCI",
1960
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1961
    ConfigInfo::CI_USED,
1962
    false,
unknown's avatar
unknown committed
1963
    ConfigInfo::CI_STRING,
1964
    MANDATORY,
1965
    "0",
1966
    STR_VALUE(MAX_INT_RNIL) },
1967 1968 1969 1970 1971

  {
    CFG_CONNECTION_NODE_2,
    "NodeId2",
    "SCI",
1972
    "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection",
unknown's avatar
unknown committed
1973
    ConfigInfo::CI_USED,
1974
    false,
unknown's avatar
unknown committed
1975
    ConfigInfo::CI_STRING,
1976
    MANDATORY,
1977
    "0",
1978
    STR_VALUE(MAX_INT_RNIL) },
1979

1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
  {
    CFG_CONNECTION_GROUP,
    "Group",
    "SCI",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    "15",
    "0", "200" },

1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001
  {
    CFG_CONNECTION_NODE_ID_SERVER,
    "NodeIdServer",
    "SCI",
    "",
    ConfigInfo::CI_USED,
    false,
    ConfigInfo::CI_INT,
    MANDATORY,
    "1", "63" },

2002
  {
unknown's avatar
unknown committed
2003
    CFG_CONNECTION_HOSTNAME_1,
unknown's avatar
unknown committed
2004 2005 2006
    "HostName1",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
2007
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
2008
    false,
unknown's avatar
unknown committed
2009
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
2010 2011 2012 2013
    UNDEFINED,
    0, 0 },

  {
unknown's avatar
unknown committed
2014
    CFG_CONNECTION_HOSTNAME_2,
unknown's avatar
unknown committed
2015 2016 2017
    "HostName2",
    "SCI",
    "Name/IP of computer on one side of the connection",
unknown's avatar
unknown committed
2018
    ConfigInfo::CI_INTERNAL,
unknown's avatar
unknown committed
2019
    false,
unknown's avatar
unknown committed
2020
    ConfigInfo::CI_STRING,
unknown's avatar
unknown committed
2021 2022 2023 2024 2025 2026
    UNDEFINED,
    0, 0 },

  {
    CFG_CONNECTION_SERVER_PORT,
    "PortNumber",
2027
    "SCI",
unknown's avatar
unknown committed
2028
    "Port used for this transporter",
unknown's avatar
unknown committed
2029
    ConfigInfo::CI_USED,
2030
    false,
unknown's avatar
unknown committed
2031
    ConfigInfo::CI_INT,
2032
    MANDATORY,
unknown's avatar
unknown committed
2033
    "0", 
unknown's avatar
unknown committed
2034
    STR_VALUE(MAX_PORT_NO) },
unknown's avatar
unknown committed
2035 2036 2037 2038 2039 2040

  {
    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
2041
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
2042
    false,
unknown's avatar
unknown committed
2043
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
2044 2045 2046 2047 2048 2049 2050 2051 2052
    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
2053
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
2054
    false,
unknown's avatar
unknown committed
2055
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
2056
    "0",
2057
    "0",
2058
    STR_VALUE(MAX_INT_RNIL) },
2059 2060

  {
unknown's avatar
unknown committed
2061 2062
    CFG_SCI_HOST2_ID_0,
    "Host2SciId0",
2063
    "SCI",
unknown's avatar
unknown committed
2064
    "SCI-node id for adapter 0 on Host2 (a computer can have two adapters)",
unknown's avatar
unknown committed
2065
    ConfigInfo::CI_USED,
2066
    false,
unknown's avatar
unknown committed
2067
    ConfigInfo::CI_INT,
2068
    MANDATORY,
2069
    "0",
2070
    STR_VALUE(MAX_INT_RNIL) },
2071

unknown's avatar
unknown committed
2072 2073 2074 2075 2076
  {
    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
2077
    ConfigInfo::CI_USED,
unknown's avatar
unknown committed
2078
    false,
unknown's avatar
unknown committed
2079
    ConfigInfo::CI_INT,
unknown's avatar
unknown committed
2080 2081 2082 2083
    "0",
    "0",
    STR_VALUE(MAX_INT_RNIL) },

2084 2085 2086 2087 2088
  {
    CFG_CONNECTION_SEND_SIGNAL_ID,
    "SendSignalId",
    "SCI",
    "Sends id in each signal.  Used in trace files.",
unknown's avatar
unknown committed
2089
    ConfigInfo::CI_USED,
2090
    false,
unknown's avatar
unknown committed
2091
    ConfigInfo::CI_BOOL,
2092 2093 2094
    "true",
    "false",
    "true" },
2095 2096 2097 2098 2099 2100

  {
    CFG_CONNECTION_CHECKSUM,
    "Checksum",
    "SCI",
    "If checksum is enabled, all signals between nodes are checked for errors",
unknown's avatar
unknown committed
2101
    ConfigInfo::CI_USED,
2102
    false,
unknown's avatar
unknown committed
2103
    ConfigInfo::CI_BOOL,
2104 2105 2106
    "false",
    "false",
    "true" },
2107 2108 2109 2110 2111 2112

  {
    CFG_SCI_SEND_LIMIT,
    "SendLimit",
    "SCI",
    "Transporter send buffer contents are sent when this no of bytes is buffered",
unknown's avatar
unknown committed
2113
    ConfigInfo::CI_USED,
2114
    false,
unknown's avatar
unknown committed
2115
    ConfigInfo::CI_INT,
2116
    "8K",
unknown's avatar
unknown committed
2117 2118
    "128",
    "32K" },
2119 2120 2121 2122 2123 2124

  {
    CFG_SCI_BUFFER_MEM,
    "SharedBufferSize",
    "SCI",
    "Size of shared memory segment",
unknown's avatar
unknown committed
2125
    ConfigInfo::CI_USED,
2126
    false,
unknown's avatar
unknown committed
2127
    ConfigInfo::CI_INT,
2128
    "1M",
unknown's avatar
unknown committed
2129
    "64K",
2130
    STR_VALUE(MAX_INT_RNIL) },
2131 2132 2133 2134 2135 2136

  {
    CFG_CONNECTION_NODE_1_SYSTEM,
    "NodeId1_System",
    "SCI",
    "System for node 1 in connection",
unknown's avatar
unknown committed
2137
    ConfigInfo::CI_INTERNAL,
2138
    false,
unknown's avatar
unknown committed
2139
    ConfigInfo::CI_STRING,
2140
    UNDEFINED,
2141
    0, 0 },
2142 2143 2144 2145 2146 2147

  {
    CFG_CONNECTION_NODE_2_SYSTEM,
    "NodeId2_System",
    "SCI",
    "System for node 2 in connection",
unknown's avatar
unknown committed
2148
    ConfigInfo::CI_INTERNAL,
2149
    false,
unknown's avatar
unknown committed
2150
    ConfigInfo::CI_STRING,
2151
    UNDEFINED,
unknown's avatar
unknown committed
2152
    0, 0 }
2153 2154 2155 2156 2157 2158 2159 2160
};

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


/****************************************************************************
 * Ctor
 ****************************************************************************/
2161 2162 2163 2164
static void require(bool v)
{
  if(!v)
  {
2165 2166 2167 2168
    if (opt_core)
      abort();
    else
      exit(-1);
2169 2170
  }
}
2171

2172 2173 2174
ConfigInfo::ConfigInfo()
  : m_info(true), m_systemDefaults(true)
{
unknown's avatar
unknown committed
2175
  int i;
2176 2177 2178
  Properties *section;
  const Properties *oldpinfo;

unknown's avatar
unknown committed
2179
  for (i=0; i<m_NoOfParams; i++) {
2180
    const ParamInfo & param = m_ParamInfo[i];
2181 2182
    Uint64 default_uint64;
    bool   default_bool;
2183 2184 2185
    
    // Create new section if it did not exist
    if (!m_info.getCopy(param._section, &section)) {
2186
      Properties newsection(true);
2187
      m_info.put(param._section, &newsection);
2188 2189 2190

      // Get copy of section
      m_info.getCopy(param._section, &section);
2191
    }
2192

2193
    // Create pinfo (parameter info) entry 
2194
    Properties pinfo(true); 
2195
    pinfo.put("Id",          param._paramId);
2196 2197 2198 2199 2200
    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);
2201 2202 2203 2204 2205 2206

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

    switch (param._type) {
unknown's avatar
unknown committed
2207
      case CI_BOOL:
2208 2209 2210 2211 2212 2213 2214 2215
      {
	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
2216 2217
      case CI_INT:
      case CI_INT64:
2218 2219 2220 2221 2222 2223 2224 2225
      {
	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
2226
      case CI_SECTION:
unknown's avatar
unknown committed
2227
	pinfo.put("SectionType", (Uint32)UintPtr(param._default));
2228
	break;
unknown's avatar
unknown committed
2229
      case CI_STRING:
2230 2231
	break;
    }
2232 2233 2234 2235 2236 2237

    // Check that pinfo is really new
    if (section->get(param._fname, &oldpinfo)) {
      ndbout << "Error: Parameter " << param._fname
	     << " defined twice in section " << param._section
	     << "." << endl;
2238
      require(false);
2239 2240 2241 2242 2243 2244 2245
    }
    
    // Add new pinfo to section
    section->put(param._fname, &pinfo);

    // Replace section with modified section
    m_info.put(param._section, section, true);
2246
    delete section;
2247
    
unknown's avatar
unknown committed
2248
    if(param._type != ConfigInfo::CI_SECTION){
2249 2250
      Properties * p;
      if(!m_systemDefaults.getCopy(param._section, &p)){
2251
	p = new Properties(true);
2252
      }
2253
      if(param._default != UNDEFINED &&
2254
	 param._default != MANDATORY){
2255 2256
	switch (param._type)
        {
unknown's avatar
unknown committed
2257
	  case CI_SECTION:
2258
	    break;
unknown's avatar
unknown committed
2259
	  case CI_STRING:
2260 2261
	    require(p->put(param._fname, param._default));
	    break;
unknown's avatar
unknown committed
2262
	  case CI_BOOL:
2263 2264 2265 2266 2267 2268
	    {
	      bool tmp_bool;
	      require(InitConfigFileParser::convertStringToBool(param._default, default_bool));
	      require(p->put(param._fname, default_bool));
	      break;
	    }
unknown's avatar
unknown committed
2269 2270
	  case CI_INT:
	  case CI_INT64:
2271 2272 2273 2274 2275 2276 2277
	    {
	      Uint64 tmp_uint64;
	      require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64));
	      require(p->put(param._fname, default_uint64));
	      break;
	    }
	}
2278 2279 2280 2281 2282
      }
      require(m_systemDefaults.put(param._section, p, true));
      delete p;
    }
  }
2283
  
unknown's avatar
unknown committed
2284
  for (i=0; i<m_NoOfParams; i++) {
2285
    if(m_ParamInfo[i]._section == NULL){
2286 2287
      ndbout << "Check that each entry has a section failed." << endl;
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname << endl; 
2288
      ndbout << "Edit file " << __FILE__ << "." << endl;
2289
      require(false);
2290
    }
2291
    
unknown's avatar
unknown committed
2292
    if(m_ParamInfo[i]._type == ConfigInfo::CI_SECTION)
2293 2294
      continue;

2295
    const Properties * p = getInfo(m_ParamInfo[i]._section);
2296
    if (!p || !p->contains(m_ParamInfo[i]._fname)) {
2297
      ndbout << "Check that each pname has an fname failed." << endl;
2298
      ndbout << "Parameter \"" << m_ParamInfo[i]._fname 
2299 2300 2301
	     << "\" does not exist in section \"" 
	     << m_ParamInfo[i]._section << "\"." << endl;
      ndbout << "Edit file " << __FILE__ << "." << endl;
2302
      require(false);
2303 2304 2305 2306 2307 2308 2309 2310 2311
    }
  }
}

/****************************************************************************
 * Getters
 ****************************************************************************/
inline void warning(const char * src, const char * arg){
  ndbout << "Illegal call to ConfigInfo::" << src << "() - " << arg << endl;
2312
  require(false);
2313 2314 2315 2316 2317 2318
}

const Properties * 
ConfigInfo::getInfo(const char * section) const {
  const Properties * p;
  if(!m_info.get(section, &p)){
2319 2320
    return 0;
    //    warning("getInfo", section);
2321 2322 2323 2324 2325 2326 2327 2328
  }
  return p;
}

const Properties * 
ConfigInfo::getDefaults(const char * section) const {
  const Properties * p;
  if(!m_systemDefaults.get(section, &p)){
2329 2330
    return 0;
    //warning("getDefaults", section);
2331 2332 2333 2334 2335
  }
  return p;
}

static
2336
Uint64
2337 2338
getInfoInt(const Properties * section, 
	   const char* fname, const char * type){
2339
  Uint32 val32;
2340
  const Properties * p;
2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352
  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();
2353
  }
2354

2355
  warning(type, fname);
2356
  return 0;
2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371
}

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

2372
Uint64
2373 2374 2375 2376
ConfigInfo::getMax(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Max");
}

2377
Uint64
2378 2379 2380 2381
ConfigInfo::getMin(const Properties * section, const char* fname) const {
  return getInfoInt(section, fname, "Min");
}

2382
Uint64
2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395
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++) {
2396
    if(!strcasecmp(section, m_sectionNames[i])) return true;
2397 2398 2399 2400
  }
  return false;
}

unknown's avatar
unknown committed
2401
const char*
2402 2403 2404 2405 2406 2407 2408 2409 2410
ConfigInfo::nameToAlias(const char * name) {
  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
    if(!strcasecmp(name, m_sectionNameAliases[i].name))
      return m_sectionNameAliases[i].alias;
  return 0;
}

const char*
ConfigInfo::getAlias(const char * section) {
unknown's avatar
unknown committed
2411
  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
2412
    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
unknown's avatar
unknown committed
2413 2414 2415 2416
      return m_sectionNameAliases[i].name;
  return 0;
}

2417 2418
bool
ConfigInfo::verify(const Properties * section, const char* fname, 
2419
		   Uint64 value) const {
2420
  Uint64 min, max;
2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459

  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
2460 2461 2462
    if (getStatus(sec, n) == ConfigInfo::CI_INTERNAL) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_DEPRICATED) continue;
    if (getStatus(sec, n) == ConfigInfo::CI_NOTIMPLEMENTED) continue;
2463 2464 2465 2466 2467 2468
    print(sec, n);
  }
}

void ConfigInfo::print(const Properties * section, 
		       const char* parameter) const {
2469
  ndbout << parameter;
2470 2471
  //  ndbout << getDescription(section, parameter) << endl;
  switch (getType(section, parameter)) {
unknown's avatar
unknown committed
2472
  case ConfigInfo::CI_BOOL:
2473 2474 2475 2476 2477 2478
    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;
2479
    } else if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2480 2481 2482 2483 2484 2485 2486
      ndbout << "MANDATORY (Legal values: Y, N)" << endl;
    } else {
      ndbout << "UNKNOWN" << endl;
    }
    ndbout << endl;
    break;    
    
unknown's avatar
unknown committed
2487 2488
  case ConfigInfo::CI_INT:
  case ConfigInfo::CI_INT64:
2489 2490
    ndbout << " (Non-negative Integer)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2491
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2492
      ndbout << "MANDATORY (";
2493
    } else if (getDefault(section, parameter) == (UintPtr)UNDEFINED) {
2494 2495 2496 2497 2498 2499 2500 2501 2502
      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
2503
  case ConfigInfo::CI_STRING:
2504 2505
    ndbout << " (String)" << endl;
    ndbout << getDescription(section, parameter) << endl;
2506
    if (getDefault(section, parameter) == (UintPtr)MANDATORY) {
2507 2508 2509 2510 2511 2512
      ndbout << "MANDATORY" << endl;
    } else {
      ndbout << "No default value" << endl;
    }
    ndbout << endl;
    break;
unknown's avatar
unknown committed
2513
  case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2514
    break;
2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527
  }
}

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

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

2528 2529
  Uint32 id, line;
  if(!ctx.m_currentSection->get("NodeId", &id) && !ctx.m_currentSection->get("Id", &id)){
2530 2531 2532
    Uint32 nextNodeId= 1;
    ctx.m_userProperties.get("NextNodeId", &nextNodeId);
    id= nextNodeId;
2533
    while (ctx.m_userProperties.get("AllocatedNodeId_", id, &line))
2534
      id++;
2535 2536
    if (id != nextNodeId)
    {
unknown's avatar
unknown committed
2537
      fprintf(stderr,"Cluster configuration warning line %d: "
2538
	       "Could not use next node id %d for section [%s], "
unknown's avatar
unknown committed
2539
	       "using next unused node id %d.\n",
2540 2541 2542 2543
	       ctx.m_sectionLineno, nextNodeId, ctx.fname, id);
    }
    ctx.m_currentSection->put("NodeId", id);
  } else if(ctx.m_userProperties.get("AllocatedNodeId_", id, &line)) {
unknown's avatar
unknown committed
2544
    ctx.reportError("Duplicate nodeid in section "
2545 2546
		    "[%s] starting at line: %d. Previously used on line %d.",
		    ctx.fname, ctx.m_sectionLineno, line);
2547
    return false;
2548
  }
2549

2550 2551 2552 2553 2554 2555 2556
  if(id >= MAX_NODES)
  {
    ctx.reportError("too many nodes configured, only up to %d nodes supported.",
            MAX_NODES);
    return false;
  } 

2557 2558 2559 2560
  // next node id _always_ next numbers after last used id
  ctx.m_userProperties.put("NextNodeId", id+1, true);

  ctx.m_userProperties.put("AllocatedNodeId_", id, ctx.m_sectionLineno);
2561
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
2562 2563 2564 2565 2566 2567 2568
  
  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
2569 2570 2571 2572 2573 2574 2575
  /**
   * Update count (per type)
   */
  nodes = 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  ctx.m_userProperties.put(ctx.fname, ++nodes, true);

2576 2577 2578
  return true;
}

2579
static bool checkLocalhostHostnameMix(InitConfigFileParser::Context & ctx, const char * data)
unknown's avatar
unknown committed
2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598
{
  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) {
unknown's avatar
unknown committed
2599
    ctx.reportError("Mixing of localhost (default for [NDBD]HostName) with other hostname(%s) is illegal",
unknown's avatar
unknown committed
2600 2601 2602 2603 2604 2605 2606
		    hostname);
    DBUG_RETURN(false);
  }

  DBUG_RETURN(true);
}

2607
bool
2608 2609
fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data)
{
2610
  const char * hostname;
2611 2612
  DBUG_ENTER("fixNodeHostname");

2613
  if (ctx.m_currentSection->get("HostName", &hostname))
2614
    DBUG_RETURN(checkLocalhostHostnameMix(ctx,0));
2615

2616
  const char * compId;
2617 2618
  if(!ctx.m_currentSection->get("ExecuteOnComputer", &compId))
    DBUG_RETURN(true);
2619 2620 2621
  
  const Properties * computer;
  char tmp[255];
2622
  BaseString::snprintf(tmp, sizeof(tmp), "Computer_%s", compId);
2623 2624 2625 2626
  if(!ctx.m_config->get(tmp, &computer)){
    ctx.reportError("Computer \"%s\" not declared"
		    "- [%s] starting at line: %d",
		    compId, ctx.fname, ctx.m_sectionLineno);
2627
    DBUG_RETURN(false);
2628 2629 2630
  }
  
  if(!computer->get("HostName", &hostname)){
unknown's avatar
unknown committed
2631 2632
    ctx.reportError("HostName missing in [COMPUTER] (Id: %d) "
		    " - [%s] starting at line: %d",
2633
		    compId, ctx.fname, ctx.m_sectionLineno);
2634
    DBUG_RETURN(false);
2635 2636 2637
  }
  
  require(ctx.m_currentSection->put("HostName", hostname));
2638
  DBUG_RETURN(checkLocalhostHostnameMix(ctx,0));
2639 2640
}

2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658
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
2659
fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
2660 2661
  
  const char * path;
unknown's avatar
unknown committed
2662
  if (ctx.m_currentSection->get("BackupDataDir", &path))
2663 2664 2665
    return true;

  if (ctx.m_currentSection->get("FileSystemPath", &path)) {
unknown's avatar
unknown committed
2666
    require(ctx.m_currentSection->put("BackupDataDir", path));
2667 2668 2669 2670 2671 2672 2673
    return true;
  }

  require(false);
  return false;
}

2674
/**
2675
 * Connection rule: Check support of connection
2676 2677
 */
bool
2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696
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
  }
unknown's avatar
unknown committed
2697

2698 2699 2700 2701 2702 2703 2704 2705 2706
  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;
}
2707

2708 2709 2710 2711 2712 2713
/**
 * Connection rule: Update "NoOfConnections"
 */
bool
transformConnection(InitConfigFileParser::Context & ctx, const char * data)
{
2714 2715
  Uint32 connections = 0;
  ctx.m_userProperties.get("NoOfConnections", &connections);
2716
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Connection_%d", connections);
2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735
  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
2736 2737 2738

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

2739
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "SYSTEM_%s", name);
2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755
  
  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;
  }
2756
  BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Computer_%s", id);
2757 2758 2759 2760 2761
  
  Uint32 computers = 0;
  ctx.m_userProperties.get("NoOfComputers", &computers);
  ctx.m_userProperties.put("NoOfComputers", ++computers, true);
  
2762 2763 2764 2765 2766 2767
  const char * hostname = 0;
  ctx.m_currentSection->get("HostName", &hostname);
  if(!hostname){
    return true;
  }
  
2768
  return checkLocalhostHostnameMix(ctx,0);
2769 2770 2771 2772 2773 2774 2775
}

/**
 * Apply default values
 */
void 
applyDefaultValues(InitConfigFileParser::Context & ctx,
2776 2777 2778
		   const Properties * defaults)
{
  DBUG_ENTER("applyDefaultValues");
2779 2780 2781 2782
  if(defaults != NULL){
    Properties::Iterator it(defaults);

    for(const char * name = it.first(); name != NULL; name = it.next()){
2783
      ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name);
2784 2785
      if(!ctx.m_currentSection->contains(name)){
	switch (ctx.m_info->getType(ctx.m_currentInfo, name)){
unknown's avatar
unknown committed
2786 2787
	case ConfigInfo::CI_INT:
	case ConfigInfo::CI_BOOL:{
2788 2789 2790
	  Uint32 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
2791
          DBUG_PRINT("info",("%s=%d #default",name,val));
2792 2793
	  break;
	}
unknown's avatar
unknown committed
2794
	case ConfigInfo::CI_INT64:{
2795 2796 2797
	  Uint64 val = 0;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put64(name, val);
2798
          DBUG_PRINT("info",("%s=%lld #default",name,val));
2799 2800
	  break;
	}
unknown's avatar
unknown committed
2801
	case ConfigInfo::CI_STRING:{
2802 2803 2804
	  const char * val;
	  ::require(defaults->get(name, &val));
	  ctx.m_currentSection->put(name, val);
2805
          DBUG_PRINT("info",("%s=%s #default",name,val));
2806 2807
	  break;
	}
unknown's avatar
unknown committed
2808
	case ConfigInfo::CI_SECTION:
unknown's avatar
unknown committed
2809
	  break;
2810 2811
	}
      }
2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839
#ifndef DBUG_OFF
      else
      {
        switch (ctx.m_info->getType(ctx.m_currentInfo, name)){
        case ConfigInfo::CI_INT:
        case ConfigInfo::CI_BOOL:{
          Uint32 val = 0;
          ::require(ctx.m_currentSection->get(name, &val));
          DBUG_PRINT("info",("%s=%d",name,val));
          break;
        }
        case ConfigInfo::CI_INT64:{
          Uint64 val = 0;
          ::require(ctx.m_currentSection->get(name, &val));
          DBUG_PRINT("info",("%s=%lld",name,val));
          break;
        }
        case ConfigInfo::CI_STRING:{
          const char * val;
          ::require(ctx.m_currentSection->get(name, &val));
          DBUG_PRINT("info",("%s=%s",name,val));
          break;
        }
        case ConfigInfo::CI_SECTION:
          break;
        }
      }
#endif
2840 2841
    }
  }
2842
  DBUG_VOID_RETURN;
2843 2844 2845 2846 2847
}

bool
applyDefaultValues(InitConfigFileParser::Context & ctx, const char * data){
  
2848 2849 2850 2851 2852 2853 2854
  if(strcmp(data, "user") == 0)
    applyDefaultValues(ctx, ctx.m_userDefaults);
  else if (strcmp(data, "system") == 0)
    applyDefaultValues(ctx, ctx.m_systemDefaults);
  else 
    return false;

2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868
  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;
2869
    if(info->get("Mandatory", &val)){
2870 2871
      const char * fname;
      ::require(info->get("Fname", &fname));
2872
      if(!ctx.m_currentSection->contains(fname)){
2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888
	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").
 */
2889
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
2890
{
2891 2892 2893 2894
  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));
2895

2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926
  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;
}

/**
 * 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
 */
2927
static bool
2928 2929 2930 2931 2932 2933 2934 2935
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));
2936
    
2937
    const Properties * node;
2938 2939 2940 2941 2942 2943 2944
    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;
    }
2945 2946
    
    const char * hostname;
2947
    require(node->get("HostName", &hostname));
2948 2949 2950 2951 2952 2953 2954 2955
    require(ctx.m_currentSection->put(data, hostname));
  }
  return true;
}

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

2959 2960
  DBUG_ENTER("fixPortNumber");

2961
  Uint32 id1, id2;
2962 2963
  const char *hostName1;
  const char *hostName2;
unknown's avatar
unknown committed
2964 2965
  require(ctx.m_currentSection->get("NodeId1", &id1));
  require(ctx.m_currentSection->get("NodeId2", &id2));
2966 2967 2968 2969 2970
  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));

2971 2972 2973
  const Properties *node1, *node2;
  require(ctx.m_config->get("Node", id1, &node1));
  require(ctx.m_config->get("Node", id2, &node2));
unknown's avatar
unknown committed
2974

2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010
  const char *type1, *type2;
  require(node1->get("Type", &type1));
  require(node2->get("Type", &type2));

  /* add NodeIdServer info */
  {
    Uint32 nodeIdServer = id1 < id2 ? id1 : id2;
    if(strcmp(type1, API_TOKEN) == 0 || strcmp(type2, MGM_TOKEN) == 0)
      nodeIdServer = id2;
    else if(strcmp(type2, API_TOKEN) == 0 || strcmp(type1, MGM_TOKEN) == 0)
      nodeIdServer = id1;
    ctx.m_currentSection->put("NodeIdServer", nodeIdServer);

    if (id2 == nodeIdServer) {
      {
	const char *tmp= hostName1;
	hostName1= hostName2;
	hostName2= tmp;
      }
      {
	Uint32 tmp= id1;
	id1= id2;
	id2= tmp;
      }
      {
	const Properties *tmp= node1;
	node1= node2;
	node2= tmp;
      }
      {
	const char *tmp= type1;
	type1= type2;
	type2= tmp;
      }
    }
  }
3011

3012
  BaseString hostname(hostName1);
unknown's avatar
unknown committed
3013 3014
  
  if (hostname.c_str()[0] == 0) {
3015 3016
    ctx.reportError("Hostname required on nodeid %d since it will "
		    "act as server.", id1);
3017
    DBUG_RETURN(false);
unknown's avatar
unknown committed
3018 3019 3020
  }

  Uint32 port= 0;
3021
  if(strcmp(type1, MGM_TOKEN)==0)
3022
    node1->get("PortNumber",&port);
3023 3024
  else if(strcmp(type2, MGM_TOKEN)==0)
    node2->get("PortNumber",&port);
3025

3026
  if (!port && 
3027
      !node1->get("ServerPort", &port) &&
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053
      !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);
      }
3054

3055 3056 3057
      port= base + adder;
      ctx.m_userProperties.put("ServerPort_", id1, port);
    }
3058
  }
3059

3060 3061 3062 3063 3064 3065 3066 3067 3068 3069
  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);
  }
3070

3071 3072
  DBUG_PRINT("info", ("connection %d-%d port %d host %s",
		      id1, id2, port, hostname.c_str()));
3073 3074

  DBUG_RETURN(true);
3075 3076
}

3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091
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);
}

3092 3093 3094 3095
static 
bool 
fixShmKey(InitConfigFileParser::Context & ctx, const char *)
{
3096 3097
  DBUG_ENTER("fixShmKey");
  {
3098
    static int last_signum= -1;
3099 3100 3101 3102
    Uint32 signum;
    if(!ctx.m_currentSection->get("Signum", &signum))
    {
      signum= OPT_NDB_SHM_SIGNUM_DEFAULT;
3103 3104 3105 3106 3107 3108
      if (signum <= 0)
      {
	  ctx.reportError("Unable to set default parameter for [SHM]Signum"
			  " please specify [SHM DEFAULT]Signum");
	  return false;
      }
3109 3110 3111
      ctx.m_currentSection->put("Signum", signum);
      DBUG_PRINT("info",("Added Signum=%u", signum));
    }
3112 3113 3114 3115 3116 3117 3118
    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;
3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130
  }
  {
    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));
    }
3131 3132
  }
  DBUG_RETURN(true);
3133 3134
}

3135 3136 3137
/**
 * DB Node rule: Check various constraints
 */
3138
static bool
3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163
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);
  }
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179

  /**
   * In kernel, will calculate the MaxNoOfMeataTables use the following sum:
   * Uint32 noOfMetaTables = noOfTables + noOfOrderedIndexes + 
   *                         noOfUniqueHashIndexes + 2
   * 2 is the number of the SysTables.
   * So must check that the sum does't exceed the max value of Uint32.
   */
  Uint32 noOfTables = 0,
         noOfOrderedIndexes = 0,
         noOfUniqueHashIndexes = 0;
  ctx.m_currentSection->get("MaxNoOfTables", &noOfTables);
  ctx.m_currentSection->get("MaxNoOfOrderedIndexes", &noOfOrderedIndexes);
  ctx.m_currentSection->get("MaxNoOfUniqueHashIndexes", &noOfUniqueHashIndexes);

  Uint64 sum= (Uint64)noOfTables + noOfOrderedIndexes + noOfUniqueHashIndexes;
3180
  
3181 3182 3183 3184 3185 3186 3187 3188
  if (sum > ((Uint32)~0 - 2)) {
    ctx.reportError("The sum of MaxNoOfTables, MaxNoOfOrderedIndexes and"
		    " MaxNoOfUniqueHashIndexes must not exceed %u - [%s]"
                    " starting at line: %d",
		    ((Uint32)~0 - 2), ctx.fname, ctx.m_sectionLineno);
    return false;
  } 

3189 3190 3191 3192 3193 3194
  return true;
}

/**
 * Connection rule: Check varius constraints
 */
3195
static bool
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234
checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){

  Uint32 id1 = 0, id2 = 0;
  ctx.m_currentSection->get("NodeId1", &id1);
  ctx.m_currentSection->get("NodeId2", &id2);
  
  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
   */
3235
  if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) &&
3236 3237
     !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0))
  {
3238 3239 3240 3241 3242 3243
    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;
  }
3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259

  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;
  }
3260 3261
  return true;
}
3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281

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);  
unknown's avatar
unknown committed
3282

3283
  if(!((oldType == PropertiesType_Uint32 || oldType == PropertiesType_Uint64) 
unknown's avatar
unknown committed
3284
       && (newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_INT64 || newType == ConfigInfo::CI_BOOL))){
unknown's avatar
unknown committed
3285
    ndbout << "oldType: " << (int)oldType << ", newType: " << (int)newType << endl;
3286 3287 3288 3289 3290 3291 3292 3293 3294
    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
3295
  Uint64 newVal = (Uint64)((Int64)oldVal * mul + add);
3296 3297 3298 3299 3300 3301 3302 3303
  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
3304
  if(newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_BOOL){
3305
    require(dst.put(newName, (Uint32)newVal));
unknown's avatar
unknown committed
3306
  } else if(newType == ConfigInfo::CI_INT64) {
3307 3308 3309 3310 3311
    require(dst.put64(newName, newVal));    
  }
  return true;
}

3312
static bool
3313
fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
unknown's avatar
unknown committed
3314
  const char * name;
3315 3316 3317 3318
  /**
   * Transform old values to new values
   * Transform new values to old values (backward compatible)
   */
3319
  Properties tmp(true);
3320
  Properties::Iterator it(ctx.m_currentSection);
unknown's avatar
unknown committed
3321
  for (name = it.first(); name != NULL; name = it.next()) {
3322 3323 3324 3325 3326
    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;
3327
	if(strcasecmp(name, p->m_oldName) == 0){
3328 3329 3330
	  if(!transform(ctx, tmp, name, p->m_newName, add, mul)){
	    return false;
	  }
3331
	} else if(strcasecmp(name, p->m_newName) == 0) {
3332 3333 3334 3335 3336 3337 3338 3339 3340 3341
	  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
3342
  for (name = it2.first(); name != NULL; name = it2.next()) {
3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365
    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:
3366
      ::require(false);
3367 3368 3369 3370 3371
    }
  }
  return true;
}

3372 3373
extern int g_print_full_config;

3374
static bool
3375 3376 3377
saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
  const Properties * sec;
  if(!ctx.m_currentInfo->get(ctx.fname, &sec)){
3378
    require(false);
3379 3380 3381 3382 3383 3384 3385 3386 3387
    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));
3388
    require(sec->get("SectionType", &typeVal));
3389
    
unknown's avatar
unknown committed
3390
    if(id == KEY_INTERNAL || status == ConfigInfo::CI_INTERNAL){
3391 3392 3393 3394
      ndbout_c("skipping section %s", ctx.fname);
      break;
    }
    
3395
    if (g_print_full_config)
3396 3397 3398 3399
    {
      const char *alias= ConfigInfo::nameToAlias(ctx.fname);
      printf("[%s]\n", alias ? alias : ctx.fname);
    }
3400

3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427
    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);
3428 3429
	if (g_print_full_config)
	  printf("%s=%u\n", n, val);
3430 3431 3432 3433 3434 3435
	break;
      }
      case PropertiesType_Uint64:{
	Uint64 val;
	require(ctx.m_currentSection->get(n, &val));
	ok = ctx.m_configValues.put64(id, val);
3436 3437
	if (g_print_full_config)
	  printf("%s=%llu\n", n, val);
3438 3439 3440 3441 3442 3443
	break;
      }
      case PropertiesType_char:{
	const char * val;
	require(ctx.m_currentSection->get(n, &val));
	ok = ctx.m_configValues.put(id, val);
3444 3445
	if (g_print_full_config)
	  printf("%s=%s\n", n, val);
3446 3447 3448
	break;
      }
      default:
3449
	require(false);
3450
      }
3451
      require(ok);
3452 3453 3454 3455 3456
    }
    ctx.m_configValues.closeSection();
  } while(0);
  return true;
}
3457

3458 3459 3460 3461 3462 3463 3464 3465 3466
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)) {
3467
    ctx.reportError("At least one database node (ndbd) should be defined in config file");
3468 3469 3470
    return false;
  }
  if (!ctx.m_userProperties.get("MGM", &mgm_nodes)) {
3471
    ctx.reportError("At least one management server node (ndb_mgmd) should be defined in config file");
3472 3473 3474 3475 3476 3477 3478 3479 3480
    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;
}

3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519
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);
}

3520
static bool
unknown's avatar
unknown committed
3521
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
3522
		   struct InitConfigFileParser::Context &ctx, 
unknown's avatar
unknown committed
3523
		   const char * rule_data)
3524
{
3525
  DBUG_ENTER("add_node_connections");
unknown's avatar
unknown committed
3526
  Uint32 i;
3527
  Properties * props= ctx.m_config;
3528 3529
  Properties p_connections(true);
  Properties p_connections2(true);
3530

unknown's avatar
unknown committed
3531
  for (i = 0;; i++){
3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548
    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);

3549
  Properties p_db_nodes(true);
3550 3551
  Properties p_api_nodes(true);
  Properties p_mgm_nodes(true);
3552

3553
  Uint32 i_db= 0, i_api= 0, i_mgm= 0, n;
unknown's avatar
unknown committed
3554
  for (i= 0, n= 0; n < nNodes; i++){
3555 3556 3557 3558 3559 3560 3561
    const Properties * tmp;
    if(!props->get("Node", i, &tmp)) continue;
    n++;

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

3562
    if (strcmp(type,DB_TOKEN) == 0)
3563
      p_db_nodes.put("", i_db++, i);
3564 3565 3566 3567
    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);
3568 3569 3570 3571
  }

  Uint32 nodeId1, nodeId2, dummy;

unknown's avatar
unknown committed
3572
  for (i= 0; p_db_nodes.get("", i, &nodeId1); i++){
3573 3574 3575
    for (Uint32 j= i+1;; j++){
      if(!p_db_nodes.get("", j, &nodeId2)) break;
      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
3576
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3577 3578 3579 3580
      }
    }
  }

3581
  for (i= 0; p_api_nodes.get("", i, &nodeId1); i++){
3582 3583 3584
    if(!p_connections.get("", nodeId1, &dummy)) {
      for (Uint32 j= 0;; j++){
	if(!p_db_nodes.get("", j, &nodeId2)) break;
3585
	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
3586 3587 3588 3589
      }
    }
  }

3590 3591 3592 3593 3594 3595 3596 3597 3598 3599
  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);
3600
}
unknown's avatar
unknown committed
3601

3602 3603 3604 3605 3606 3607 3608
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
3609

3610
static bool
unknown's avatar
unknown committed
3611 3612 3613 3614
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		       struct InitConfigFileParser::Context &ctx, 
		       const char * rule_data)
{
3615 3616 3617
  Uint32 db_nodes= 0;
  Uint32 replicas= 0;
  Uint32 db_host_count= 0;
3618
  ctx.m_userProperties.get(DB_TOKEN, &db_nodes);
unknown's avatar
unknown committed
3619 3620 3621 3622 3623 3624
  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;
  }
3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636
  // 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";
3637 3638
    const char *arbit_warn_fmt2=
      "\n  arbitrator with id %d has no hostname specified";
3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694

    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
3695
	    if (c+1 == (1u << (replicas-1))) // all nodes on same machine
3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720
	      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);
	    }
	  }
3721 3722 3723 3724
	  else
	  {
	    arbitration_warning.appfmt(arbit_warn_fmt2, i);
	  }
3725 3726 3727 3728 3729 3730
	}
      }
    }
    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)
3731 3732 3733
      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.");
3734
  }
unknown's avatar
unknown committed
3735 3736 3737
  return true;
}

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