From 192d562b29b4197caba3eb65a3a9240910577bc5 Mon Sep 17 00:00:00 2001
From: unknown <tomas@poseidon.(none)>
Date: Tue, 24 Aug 2004 22:27:33 +0000
Subject: [PATCH] ndb config ability/naming changes, see respective file

mysql-test/ndb/ndb_config_2_node.ini:
  using new naming capabilities
ndb/src/common/mgmcommon/ConfigInfo.cpp:
  fixes case insensitive
  + removed abort from config handling
ndb/src/common/mgmcommon/InitConfigFileParser.cpp:
  fixed alias handling
  some requires in config handling
ndb/src/mgmclient/CommandInterpreter.cpp:
  new printout to reflect new naming in config
---
 mysql-test/ndb/ndb_config_2_node.ini          | 52 +++++++++----------
 ndb/src/common/mgmcommon/ConfigInfo.cpp       |  8 +--
 .../common/mgmcommon/InitConfigFileParser.cpp | 22 ++++----
 ndb/src/mgmclient/CommandInterpreter.cpp      | 12 ++---
 4 files changed, 50 insertions(+), 44 deletions(-)

diff --git a/mysql-test/ndb/ndb_config_2_node.ini b/mysql-test/ndb/ndb_config_2_node.ini
index bf5c67cd1d6..7b3548ae303 100644
--- a/mysql-test/ndb/ndb_config_2_node.ini
+++ b/mysql-test/ndb/ndb_config_2_node.ini
@@ -1,36 +1,36 @@
-[DB DEFAULT]
-NoOfReplicas: 2
-MaxNoOfConcurrentOperations: CHOOSE_MaxNoOfConcurrentOperations
-DataMemory: CHOOSE_DataMemory
-IndexMemory: CHOOSE_IndexMemory
-Diskless: CHOOSE_Diskless
-TimeBetweenWatchDogCheck: 30000
-FileSystemPath: CHOOSE_FILESYSTEM
+[ndbd default]
+NoOfReplicas= 2
+MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations
+DataMemory= CHOOSE_DataMemory
+IndexMemory= CHOOSE_IndexMemory
+Diskless= CHOOSE_Diskless
+TimeBetweenWatchDogCheck= 30000
+FileSystemPath= CHOOSE_FILESYSTEM
 
-[COMPUTER]
-Id: 1
-HostName: CHOOSE_HOSTNAME_1
+[computer]
+Id= 1
+HostName= CHOOSE_HOSTNAME_1
 
-[COMPUTER]
-Id: 2
-HostName: CHOOSE_HOSTNAME_2
+[computer]
+Id= 2
+HostName= CHOOSE_HOSTNAME_2
 
-[DB]
-ExecuteOnComputer: 1
+[ndbd]
+ExecuteOnComputer= 1
 
-[DB]
-ExecuteOnComputer: 2
+[ndbd]
+ExecuteOnComputer= 2
 
-[MGM]
-PortNumber: CHOOSE_PORT_MGM
+[ndb_mgmd]
+PortNumber= CHOOSE_PORT_MGM
 
-[MYSQLD]
+[mysqld]
 
-[MYSQLD]
+[mysqld]
 
-[MYSQLD]
+[mysqld]
 
-[MYSQLD]
+[mysqld]
 
-[TCP DEFAULT]
-PortNumber: CHOOSE_PORT_TRANSPORTER
+[tcp default]
+PortNumber= CHOOSE_PORT_TRANSPORTER
diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp
index 552b49727fb..1c9edaf330e 100644
--- a/ndb/src/common/mgmcommon/ConfigInfo.cpp
+++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp
@@ -1989,7 +1989,8 @@ const Properties *
 ConfigInfo::getInfo(const char * section) const {
   const Properties * p;
   if(!m_info.get(section, &p)){
-    warning("getInfo", section);
+    return 0;
+    //    warning("getInfo", section);
   }
   return p;
 }
@@ -1998,7 +1999,8 @@ const Properties *
 ConfigInfo::getDefaults(const char * section) const {
   const Properties * p;
   if(!m_systemDefaults.get(section, &p)){
-    warning("getDefaults", section);
+    return 0;
+    //warning("getDefaults", section);
   }
   return p;
 }
@@ -2072,7 +2074,7 @@ ConfigInfo::isSection(const char * section) const {
 const char*
 ConfigInfo::getAlias(const char * section) const {
   for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
-    if(!strcmp(section, m_sectionNameAliases[i].alias))
+    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
       return m_sectionNameAliases[i].name;
   return 0;
 }
diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp
index 7c842508491..dab4e9a7c77 100644
--- a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp
+++ b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp
@@ -117,8 +117,8 @@ InitConfigFileParser::parseConfig(FILE * file) {
       ctx.m_sectionLineno  = ctx.m_lineno;
       ctx.m_currentSection = new Properties(true);
       ctx.m_userDefaults   = NULL;
-      ctx.m_currentInfo    = m_info->getInfo(ctx.fname);
-      ctx.m_systemDefaults = m_info->getDefaults(ctx.fname);
+      require((ctx.m_currentInfo = m_info->getInfo(ctx.fname)) != 0);
+      require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0);
       continue;
     }
     
@@ -139,8 +139,8 @@ InitConfigFileParser::parseConfig(FILE * file) {
       ctx.m_sectionLineno  = ctx.m_lineno;      
       ctx.m_currentSection = new Properties(true);
       ctx.m_userDefaults   = getSection(ctx.fname, ctx.m_defaults);
-      ctx.m_currentInfo    = m_info->getInfo(ctx.fname);
-      ctx.m_systemDefaults = m_info->getDefaults(ctx.fname);
+      require((ctx.m_currentInfo    = m_info->getInfo(ctx.fname)) != 0);
+      require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0);
       continue;
     }
     
@@ -180,8 +180,8 @@ InitConfigFileParser::parseConfig(FILE * file) {
       ctx.type             = InitConfigFileParser::Section;
       ctx.m_currentSection = tmp[j].m_sectionData;
       ctx.m_userDefaults   = getSection(ctx.fname, ctx.m_defaults);
-      ctx.m_currentInfo    = m_info->getInfo(ctx.fname);
-      ctx.m_systemDefaults = m_info->getDefaults(ctx.fname);
+      require((ctx.m_currentInfo    = m_info->getInfo(ctx.fname)) != 0);
+      require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0);
       if(!storeSection(ctx))
 	return 0;
     }
@@ -516,7 +516,7 @@ char*
 InitConfigFileParser::parseDefaultSectionHeader(const char* line) const {
   static char token1[MAX_LINE_LENGTH], token2[MAX_LINE_LENGTH];
 
-  int no = sscanf(line, "[%120[A-Za-z] %120[A-Za-z]]", token1, token2);
+  int no = sscanf(line, "[%120[A-Z_a-z] %120[A-Z_a-z]]", token1, token2);
 
   // Not correct no of tokens 
   if (no != 2) return NULL;
@@ -524,8 +524,12 @@ InitConfigFileParser::parseDefaultSectionHeader(const char* line) const {
   // Not correct keyword at end
   if (!strcasecmp(token2, "DEFAULT") == 0) return NULL;
 
-  if(m_info->getInfo(token1)){
-    return strdup(token1);
+  const char *token1_alias= m_info->getAlias(token1);
+  if (token1_alias == 0)
+    token1_alias= token1;
+
+  if(m_info->getInfo(token1_alias)){
+    return strdup(token1_alias);
   }
   
   // Did not find section
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp
index 141a0be0eff..c90ed1822f1 100644
--- a/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -682,12 +682,12 @@ CommandInterpreter::executeShow(char* parameters)
     }
 
     ndbout << ndb_nodes
-	   << " NDB Node(s)" 
+	   << " [ndbd] node(s)" 
 	   << endl;
 
     for(i=0; i < state->no_of_nodes; i++) {
       if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_NDB) {
-	ndbout << "DB node:\t" << state->node_states[i].node_id;
+	ndbout << "[ndbd]\t\tid=" << state->node_states[i].node_id;
 	if(state->node_states[i].version != 0) {
 	  ndbout << "  (Version: "
 		 << getMajor(state->node_states[i].version) << "."
@@ -707,12 +707,12 @@ CommandInterpreter::executeShow(char* parameters)
     ndbout << endl;
     
     ndbout << mgm_nodes
-	   << " MGM Node(s)" 
+	   << " [ndb_mgmd] node(s)" 
 	   << endl;
 
     for(i=0; i < state->no_of_nodes; i++) {
       if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_MGM) {
-	ndbout << "MGM node:\t" << state->node_states[i].node_id;
+	ndbout << "[ndb_mgmd]\tid=" << state->node_states[i].node_id;
 	if(state->node_states[i].version != 0) {
 	  ndbout << "  (Version: "
 		 << getMajor(state->node_states[i].version) << "."
@@ -728,12 +728,12 @@ CommandInterpreter::executeShow(char* parameters)
     ndbout << endl;
 
     ndbout << api_nodes
-	   << " API Node(s)" 
+	   << " [mysqld] node(s)" 
 	   << endl;
 
     for(i=0; i < state->no_of_nodes; i++) {
       if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_API) {
-	ndbout << "API node:\t" << state->node_states[i].node_id;
+	ndbout << "[mysqld]\tid=" << state->node_states[i].node_id;
 	if(state->node_states[i].version != 0) {
 	  ndbout << "  (Version: "
 		 << getMajor(state->node_states[i].version) << "."
-- 
2.30.9