List:Commits« Previous MessageNext Message »
From:Magnus Svensson Date:July 25 2008 1:21pm
Subject:bzr commit into mysql-5.1-telco-6.4 branch (msvensson:2680)
View as plain text  
#At file:///data/msvensson/mysql/5.1-telco-6.4/

 2680 Magnus Svensson	2008-07-25 [merge]
      Merge
modified:
  storage/ndb/src/mgmsrv/Config.cpp
  storage/ndb/src/mgmsrv/Config.hpp
  storage/ndb/src/mgmsrv/ConfigInfo.cpp
  storage/ndb/src/mgmsrv/ConfigInfo.hpp
  storage/ndb/src/mgmsrv/MgmtSrvr.hpp
  storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp
  storage/ndb/src/mgmsrv/main.cpp

=== modified file 'storage/ndb/src/mgmsrv/Config.cpp'
--- a/storage/ndb/src/mgmsrv/Config.cpp	2008-06-10 20:06:47 +0000
+++ b/storage/ndb/src/mgmsrv/Config.cpp	2008-07-25 10:02:59 +0000
@@ -15,9 +15,10 @@
 
 #include "Config.hpp"
 
-//*****************************************************************************
-//  Ctor / Dtor
-//*****************************************************************************
+#include <mgmapi_config_parameters.h>
+#include <NdbOut.hpp>
+#include "ConfigInfo.hpp"
+
 
 Config::Config(struct ndb_mgm_configuration *config_values) :
   m_configValues(config_values)
@@ -31,146 +32,51 @@ Config::~Config() {
   }
 }
 
-/*****************************************************************************/
-
-void 
-Config::printAllNameValuePairs(NdbOut &out,
-			       const Properties *prop,
-			       const char* s) const {
-#if 0
-  Properties::Iterator it(prop);
-  const Properties * section = m_info.getInfo(s);
-  for (const char* n = it.first(); n != NULL; n = it.next()) {
-    Uint32 int_value;
-    const char* str_value;
-    Uint64 int_64;
+unsigned sections[]=
+{
+  CFG_SECTION_SYSTEM,
+  CFG_SECTION_NODE,
+  CFG_SECTION_CONNECTION
+};
+const size_t num_sections= sizeof(sections)/sizeof(unsigned);
+
+static const ConfigInfo g_info;
+
+void
+Config::print() const {
+
+  for(unsigned i= 0; i < num_sections; i++) {
+    unsigned section= sections[i];
+    ndb_mgm_configuration_iterator it(*m_configValues, section);
 
-    if(!section->contains(n))
-      continue;
-    if (m_info.getStatus(section, n) == ConfigInfo::CI_INTERNAL) 
-      continue;
-    if (m_info.getStatus(section, n) == ConfigInfo::CI_DEPRICATED)
-      continue;
-    if (m_info.getStatus(section, n) == ConfigInfo::CI_NOTIMPLEMENTED)
+    if (it.first())
       continue;
 
-    out << n << ": ";
+    for(;it.valid();it.next()) {
 
-    switch (m_info.getType(section, n)) {
-    case ConfigInfo::CI_INT:
-      MGM_REQUIRE(prop->get(n, &int_value)); 
-      out << int_value;
-      break;
-
-    case ConfigInfo::CI_INT64:
-      MGM_REQUIRE(prop->get(n, &int_64)); 
-      out << int_64;
-      break;
-      
-    case ConfigInfo::CI_BOOL:
-      MGM_REQUIRE(prop->get(n, &int_value)); 
-      if (int_value) {
-	out << "Y";
-      } else {
-	out << "N";
-      }
-      break;
-    case ConfigInfo::CI_STRING:
-      MGM_REQUIRE(prop->get(n, &str_value)); 
-      out << str_value;
-      break;
-    case ConfigInfo::CI_SECTION:
-      out << "SECTION";
-      break;
-    }      
-    out << endl;
-  }
-#endif
-}
+      Uint32 section_type;
+      assert(it.get(CFG_TYPE_OF_SECTION, &section_type) == 0);
 
-/*****************************************************************************/
-   
-void Config::printConfigFile(NdbOut &out) const {
-#if 0
-  Uint32 noOfNodes, noOfConnections, noOfComputers;
-  MGM_REQUIRE(get("NoOfNodes", &noOfNodes));
-  MGM_REQUIRE(get("NoOfConnections", &noOfConnections));
-  MGM_REQUIRE(get("NoOfComputers", &noOfComputers));
-
-  out << 
-    "######################################################################" <<
-    endl <<
-    "#" << endl <<
-    "#  NDB Cluster  System configuration" << endl <<
-    "#" << endl <<
-    "######################################################################" <<
-    endl << 
-    "# No of nodes (DB, API or MGM):  " << noOfNodes << endl <<
-    "# No of connections:             " << noOfConnections << endl <<
-    "######################################################################" <<
-    endl;
-
-  /**************************
-   * Print COMPUTER configs *
-   **************************/
-  const char * name;
-  Properties::Iterator it(this);
-  for(name = it.first(); name != NULL; name = it.next()){
-    if(strncasecmp("Computer_", name, 9) == 0){ 
-      
-      const Properties *prop;
-      out << endl << "[COMPUTER]" << endl;
-      MGM_REQUIRE(get(name, &prop));
-      printAllNameValuePairs(out, prop, "COMPUTER");
-      
-      out << endl <<
-	"###################################################################" <<
-	endl;
-
-    } else if(strncasecmp("Node_", name, 5) == 0){
-      /**********************
-       * Print NODE configs *
-       **********************/
-      const Properties *prop;
-      const char *s;
-
-      MGM_REQUIRE(get(name, &prop));
-      MGM_REQUIRE(prop->get("Type", &s));
-      out << endl << "[" << s << "]" << endl;
-      printAllNameValuePairs(out, prop, s);
-
-      out << endl <<
-	"###################################################################" <<
-	endl;
-    } else if(strncasecmp("Connection_", name, 11) == 0){
-      /****************************
-       * Print CONNECTION configs *
-       ****************************/
-      const Properties *prop;
-      const char *s;
-
-      MGM_REQUIRE(get(name, &prop));
-      MGM_REQUIRE(prop->get("Type", &s));
-      out << endl << "[" << s << "]" << endl;
-      printAllNameValuePairs(out, prop, s);
-      
-      out << endl <<
-	"###################################################################" <<
-	endl;
-    } else if(strncasecmp("SYSTEM", name, strlen("SYSTEM")) == 0) {
-      /************************
-       * Print SYSTEM configs *
-       ************************/
-      const Properties *prop;
-
-      MGM_REQUIRE(get(name, &prop));
-      out << endl << "[SYSTEM]" << endl;
-      printAllNameValuePairs(out, prop, "SYSTEM");
-      
-      out << endl <<
-	"###################################################################" <<
-	endl;
+      const ConfigInfo::ParamInfo* pinfo= NULL;
+      ConfigInfo::ParamInfoIter param_iter(g_info,
+                                           section,
+                                           section_type);
+
+      ndbout_c("[%s]", g_info.sectionName(section, section_type));
+
+      /*  Loop through the section and print those values that exist */
+      Uint32 val;
+      Uint64 val64;
+      const char* val_str;
+      while((pinfo= param_iter.next())){
+
+        if (!it.get(pinfo->_paramId, &val))
+          ndbout_c("%s=%u", pinfo->_fname, val);
+        else if (!it.get(pinfo->_paramId, &val64))
+          ndbout_c("%s=%llu", pinfo->_fname, val64);
+        else if (!it.get(pinfo->_paramId, &val_str))
+          ndbout_c("%s=%s", pinfo->_fname, val_str);
+      }
     }
   }
-#endif
 }

=== modified file 'storage/ndb/src/mgmsrv/Config.hpp'
--- a/storage/ndb/src/mgmsrv/Config.hpp	2008-06-09 10:52:24 +0000
+++ b/storage/ndb/src/mgmsrv/Config.hpp	2008-07-25 10:02:59 +0000
@@ -22,16 +22,10 @@
 
 /**
  * @class Config
- * @brief Cluster Configuration  (corresponds to initial configuration file)
+ * @brief Cluster Configuration Wrapper
  *
- * Contains all cluster configuration parameters.
- *
- * The information includes all configurable parameters for a NDB cluster:
- * - DB, API and MGM nodes with all their properties, 
- * - Connections between nodes and computers the nodes will execute on.
- *
- * The following categories (sections) of configuration parameters exists:
- * - COMPUTER, DB, MGM, API, TCP, SCI, SHM
+ * Adds a C++ wrapper around 'ndb_mgm_configuration' which is
+ * exposed from mgmapi_configuration
  *
  */
 
@@ -40,30 +34,8 @@ public:
   Config(struct ndb_mgm_configuration *config_values = NULL);
   virtual ~Config();
 
-  /**
-   *   Prints the configuration in configfile format
-   */
-  void printConfigFile(NdbOut &out = ndbout) const;
-  void printConfigFile(OutputStream &out) const {
-    NdbOut ndb(out);
-    printConfigFile(ndb);
-  }
-
-  /**
-   * Info
-   */
-  const ConfigInfo * getConfigInfo() const { return &m_info;}
-private:
-  ConfigInfo m_info;
+  void print() const;
 
-  void printAllNameValuePairs(NdbOut &out,
-			      const Properties *prop,
-			      const char* section) const;
-
-  /**
-   *   Information about parameters (min, max values etc)
-   */
-public:
   struct ndb_mgm_configuration * m_configValues;
 };
 

=== modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2008-06-10 09:21:15 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2008-07-25 10:02:59 +0000
@@ -2832,6 +2832,55 @@ ConfigInfo::getAlias(const char * sectio
   return 0;
 }
 
+
+const char*
+ConfigInfo::sectionName(Uint32 section_type, Uint32 type) const {
+
+  switch (section_type){
+  case CFG_SECTION_SYSTEM:
+    return "SYSTEM";
+    break;
+
+  case CFG_SECTION_NODE:
+    switch(type){
+    case NODE_TYPE_DB:
+      return DB_TOKEN_PRINT;
+      break;
+    case NODE_TYPE_MGM:
+      return MGM_TOKEN_PRINT;
+      break;
+    case NODE_TYPE_API:
+      return API_TOKEN_PRINT;
+      break;
+    default:
+      assert(false);
+      break;
+    }
+    break;
+
+  case CFG_SECTION_CONNECTION:
+    switch(type){
+    case CONNECTION_TYPE_TCP:
+      return "TCP";
+      break;
+    case CONNECTION_TYPE_SHM:
+      return "SHM";
+      break;
+    case CONNECTION_TYPE_SCI:
+      return "SCI";
+      break;
+    default:
+      assert(false);
+      break;
+    }
+    break;
+
+  default:
+    assert(false);
+    break;
+  }
+}
+
 bool
 ConfigInfo::verify(const Properties * section, const char* fname, 
 		   Uint64 value) const {
@@ -3819,8 +3868,6 @@ fixDepricated(InitConfigFileParser::Cont
   return true;
 }
 
-extern int g_print_full_config;
-
 static bool
 saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
   const Properties * sec;
@@ -3841,12 +3888,6 @@ saveInConfigValues(InitConfigFileParser:
       ndbout_c("skipping section %s", ctx.fname);
       break;
     }
-    
-    if (g_print_full_config)
-    {
-      const char *alias= ConfigInfo::nameToAlias(ctx.fname);
-      printf("[%s]\n", alias ? alias : ctx.fname);
-    }
 
     Uint32 no = 0;
     ctx.m_userProperties.get("$Section", id, &no);
@@ -3875,24 +3916,18 @@ saveInConfigValues(InitConfigFileParser:
 	Uint32 val;
 	require(ctx.m_currentSection->get(n, &val));
 	ok = ctx.m_configValues.put(id, val);
-	if (g_print_full_config)
-	  printf("%s=%u\n", n, val);
 	break;
       }
       case PropertiesType_Uint64:{
 	Uint64 val;
 	require(ctx.m_currentSection->get(n, &val));
 	ok = ctx.m_configValues.put64(id, val);
-	if (g_print_full_config)
-	  printf("%s=%llu\n", n, val);
 	break;
       }
       case PropertiesType_char:{
 	const char * val;
 	require(ctx.m_currentSection->get(n, &val));
 	ok = ctx.m_configValues.put(id, val);
-	if (g_print_full_config)
-	  printf("%s=%s\n", n, val);
 	break;
       }
       default:
@@ -4270,5 +4305,43 @@ check_node_vs_replicas(Vector<ConfigInfo
   return true;
 }
 
+
+ConfigInfo::ParamInfoIter::ParamInfoIter(const ConfigInfo& info,
+                                         Uint32 section,
+                                         Uint32 section_type) :
+  m_info(info),
+  m_curr_param(0)
+{
+  /* Find the section's name */
+  for (int j=0; j<info.m_NoOfParams; j++) {
+    const ConfigInfo::ParamInfo & param = info.m_ParamInfo[j];
+    if (param._type == ConfigInfo::CI_SECTION &&
+        param._paramId == section &&
+        (section_type == (Uint32)~0 || param._section_type == section_type))
+    {
+      m_section_name= param._section;
+      break;
+    }
+  }
+  assert(m_section_name);
+}
+
+
+const ConfigInfo::ParamInfo*
+ConfigInfo::ParamInfoIter::next(void) {
+  assert(m_curr_param < m_info.m_NoOfParams);
+  do {
+    /*  Loop through the parameter and return a pointer to the next found */
+    const ConfigInfo::ParamInfo* param = &m_info.m_ParamInfo[m_curr_param++];
+    if (strcmp(param->_section, m_section_name) == 0 &&
+        param->_type != ConfigInfo::CI_SECTION)
+      return param;
+  }
+  while (m_curr_param<m_info.m_NoOfParams);
+
+  return NULL;
+}
+
+
 template class Vector<ConfigInfo::ConfigRuleSection>;
 #endif /* NDB_MGMAPI */

=== modified file 'storage/ndb/src/mgmsrv/ConfigInfo.hpp'
--- a/storage/ndb/src/mgmsrv/ConfigInfo.hpp	2008-05-29 15:06:11 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.hpp	2008-07-25 10:02:59 +0000
@@ -81,11 +81,26 @@ public:
      * For section entries, instead the _default member gives the internal id
      * of that kind of section (CONNECTION_TYPE_TCP, NODE_TYPE_MGM, etc.)
      */
-    const char*    _default;
+    union {
+      const char*  _default;
+      Uint32       _section_type; // if _type = CI_SECTION
+    };
     const char*    _min;
     const char*    _max;
   };
 
+  class ParamInfoIter {
+    const ConfigInfo& m_info;
+    const char* m_section_name;
+    int m_curr_param;
+  public:
+    ParamInfoIter(const ConfigInfo& info,
+                  Uint32 section,
+                  Uint32 section_type = ~0);
+
+    const ParamInfo* next(void);
+  };
+
 #ifndef NDB_MGMAPI
   struct AliasPair{
     const char * name;
@@ -149,6 +164,8 @@ public:
   void print(const char* section) const;
   void print(const Properties * section, const char* parameter) const;
 
+  const char* sectionName(Uint32 section, Uint32 type) const;
+
 private:
   Properties               m_info;
   Properties               m_systemDefaults;

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.hpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2008-06-10 12:41:07 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2008-07-25 10:02:59 +0000
@@ -137,6 +137,8 @@ public:
 
   ~MgmtSrvr();
 
+  void print_config(void) { _config->print(); };
+
   /**
    * Get status on a node.
    * address may point to a common area (e.g. from inet_addr)
@@ -159,18 +161,6 @@ public:
   // COULD_NOT_ALLOCATE_MEMORY, SEND_OR_RECEIVE_FAILED
 
   /**
-   * Save a configuration to permanent storage
-   */
-  int saveConfig(const Config *);
-
-  /**
-   * Save the running configuration
-   */
-  int saveConfig() {
-    return saveConfig(_config);
-  };
-
-  /**
    * Read configuration from file, or from another MGM server
    */
   Config *readConfig();

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp	2008-06-09 10:52:24 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp	2008-07-25 10:02:59 +0000
@@ -21,31 +21,6 @@
 #include <ConfigRetriever.hpp>
 #include <ndb_version.h>
 
-/**
- * Save a configuration to the running configuration file
- */
-int
-MgmtSrvr::saveConfig(const Config *conf) {
-  BaseString newfile;
-  newfile.appfmt("%s.new", m_configFilename.c_str());
-  
-  /* Open and write to the new config file */
-  FILE *f = fopen(newfile.c_str(), "w");
-  if(f == NULL) {
-    /** @todo Send something apropriate to the log */
-    return -1;
-  }
-  FileOutputStream stream(f);
-  conf->printConfigFile(stream);
-
-  fclose(f);
-
-  /* Rename file to real name */
-  rename(newfile.c_str(), m_configFilename.c_str());
-
-  return 0;
-}
-
 Config *
 MgmtSrvr::readConfig() {
   Config *conf;

=== modified file 'storage/ndb/src/mgmsrv/main.cpp'
--- a/storage/ndb/src/mgmsrv/main.cpp	2008-06-09 10:52:24 +0000
+++ b/storage/ndb/src/mgmsrv/main.cpp	2008-07-25 10:02:59 +0000
@@ -233,8 +233,10 @@ start:
 				 opt_config_filename,
 				 opt_connect_str);
 
-  if (g_print_full_config)
+  if (g_print_full_config){
+    glob->mgmObject->print_config();
     goto the_end;
+  }
 
   my_setwd(NdbConfig_get_path(0), MYF(0));
 

Thread
bzr commit into mysql-5.1-telco-6.4 branch (msvensson:2680) Magnus Svensson25 Jul