diff options
Diffstat (limited to 'ndb/test/src/NdbConfig.cpp')
-rw-r--r-- | ndb/test/src/NdbConfig.cpp | 131 |
1 files changed, 27 insertions, 104 deletions
diff --git a/ndb/test/src/NdbConfig.cpp b/ndb/test/src/NdbConfig.cpp index 3a254bc1577..2fb466d1b8f 100644 --- a/ndb/test/src/NdbConfig.cpp +++ b/ndb/test/src/NdbConfig.cpp @@ -17,144 +17,67 @@ #include "NdbConfig.hpp" #include <NdbOut.hpp> #include <NDBT_Output.hpp> +#include <assert.h> #include <NdbConfig.h> #include <ConfigRetriever.hpp> #include <ndb_version.h> - - +#include <mgmapi.h> +#include <mgmapi_config_parameters.h> +#include <mgmapi_configuration.hpp> bool -NdbConfig::getPropsForNode(unsigned int node_id, - const char* type, - const Properties ** props) const { - - /** - * Fetch configuration from management server - */ - ConfigRetriever cr; - - - Properties * p = cr.getConfig(host, - port, - node_id, - NDB_VERSION); +NdbConfig::getHostName(unsigned int node_id, const char ** hostname) { + + ndb_mgm_configuration * p = getConfig(); if(p == 0){ - const char * s = cr.getErrorString(); - if(s == 0) - s = "No error given!"; - - ndbout << "Could not fetch configuration" << endl; - ndbout << s << endl; return false; - } + } /** * Setup cluster configuration data */ - if (!p->get("Node", node_id, props)) { - ndbout << "Invalid configuration fetched no info for nodeId = " - << node_id << endl; + ndb_mgm_configuration_iterator iter(* p, CFG_SECTION_NODE); + if (iter.find(CFG_NODE_ID, node_id)){ + ndbout << "Invalid configuration fetched, DB missing" << endl; return false; } - const char * str; - if(!((*props)->get("Type", &str) && strcmp(str, type) == 0)){ - ndbout <<"Invalid configuration fetched, type != " << type << endl; - return false; - } - return true; -} - -bool -NdbConfig::getProperty(unsigned int node_id, - const char* type, - const char* name, - const char ** value) const { - const Properties * db = 0; - - if(!getPropsForNode(node_id, type, &db)){ + if (iter.get(CFG_NODE_HOST, hostname)){ + ndbout << "Host not found" << endl; return false; } - if (!db->get(name, value)){ - ndbout << name << " not found" << endl; - return false; - } - return true; } bool -NdbConfig::getProperty(unsigned int node_id, - const char* type, - const char* name, - Uint32 * value) const { - const Properties * db = 0; - - if(!getPropsForNode(node_id, type, &db)){ - return false; - } - - if (!db->get(name, value)){ - ndbout << name << " not found" << endl; - return false; - } - - return true; -} - - -bool -NdbConfig::getHostName(unsigned int node_id, - const char ** hostname) const { - /** - * Fetch configuration from management server - */ - ConfigRetriever cr; - - - Properties * p = cr.getConfig(host, - port, - node_id, - NDB_VERSION); +NdbConfig::getProperty(unsigned nodeid, + unsigned type, unsigned key, Uint32 * val){ + ndb_mgm_configuration * p = getConfig(); if(p == 0){ - const char * s = cr.getErrorString(); - if(s == 0) - s = "No error given!"; - - ndbout << "Could not fetch configuration" << endl; - ndbout << s << endl; return false; - } + } /** * Setup cluster configuration data */ - const Properties * node_props; - if (!p->get("Node", node_id, &node_props)) { - ndbout << "Invalid configuration fetched no info for node = " - << node_id << endl; - return false; - } - const char* computer_id_str; - if (!node_props->get("ExecuteOnComputer", &computer_id_str)){ - ndbout << "ExecuteOnComputer not found" << endl; + ndb_mgm_configuration_iterator iter(* p, CFG_SECTION_NODE); + if (iter.find(CFG_NODE_ID, nodeid)){ + ndbout << "Invalid configuration fetched, DB missing" << endl; return false; } - - const Properties * comp_props; - if (!p->get("Computer", atoi(computer_id_str), &comp_props)) { - ndbout << "Invalid configuration fetched no info for computer = " - << node_id << endl; + unsigned _type; + if (iter.get(CFG_TYPE_OF_SECTION, &_type) || type != _type){ + ndbout << "No such node in configuration" << endl; return false; } - if (!comp_props->get("HostName", hostname)){ - ndbout << "HostName not found" << endl; + + if (iter.get(key, val)){ + ndbout << "No such key: " << key << " in configuration" << endl; return false; } - - + return true; } |