diff options
author | unknown <joreland@mysql.com> | 2004-05-26 10:56:32 +0200 |
---|---|---|
committer | unknown <joreland@mysql.com> | 2004-05-26 10:56:32 +0200 |
commit | 1a9eb476f185d94ec13ed4f13dbfbdb14f9217c1 (patch) | |
tree | 32b839686028c5bc61304dbd566705a3bc085f6d /ndb/src/mgmsrv | |
parent | 3cfddc421d53e28f398a2db98002cab2be15fc9e (diff) | |
download | mariadb-git-1a9eb476f185d94ec13ed4f13dbfbdb14f9217c1.tar.gz |
WL1371 - Cleanup configuration handling
WL1356 - Discless db node
WL1357 - sp 1-2
Diffstat (limited to 'ndb/src/mgmsrv')
-rw-r--r-- | ndb/src/mgmsrv/CommandInterpreter.cpp | 9 | ||||
-rw-r--r-- | ndb/src/mgmsrv/Makefile | 5 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.cpp | 151 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.hpp | 12 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvrConfig.cpp | 27 | ||||
-rw-r--r-- | ndb/src/mgmsrv/Services.cpp | 184 | ||||
-rw-r--r-- | ndb/src/mgmsrv/main.cpp | 57 | ||||
-rw-r--r-- | ndb/src/mgmsrv/mkconfig/Makefile | 5 | ||||
-rw-r--r-- | ndb/src/mgmsrv/mkconfig/mkconfig.cpp | 20 |
9 files changed, 292 insertions, 178 deletions
diff --git a/ndb/src/mgmsrv/CommandInterpreter.cpp b/ndb/src/mgmsrv/CommandInterpreter.cpp index 8a7293b8434..cda613a5ef2 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.cpp +++ b/ndb/src/mgmsrv/CommandInterpreter.cpp @@ -453,14 +453,15 @@ void CommandInterpreter::executeShow(char* parameters) { return; } else if (strcmp(parameters, "PROPERTIES") == 0 || strcmp(parameters, "PROP") == 0) { - _mgmtSrvr.getConfig()->print(); + ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */ } else if (strcmp(parameters, "CONFIGURATION") == 0 || strcmp(parameters, "CONFIG") == 0){ + ndbout << "_mgmtSrvr.getConfigFile()->print();" << endl; /* XXX */ _mgmtSrvr.getConfig()->printConfigFile(); } else if (strcmp(parameters, "PARAMETERS") == 0 || strcmp(parameters, "PARAMS") == 0 || strcmp(parameters, "PARAM") == 0) { - _mgmtSrvr.getConfig()->getConfigInfo()->print(); + ndbout << "_mgmtSrvr.getConfigInfo()->print();" << endl; /* XXX */ } else { ndbout << "Invalid argument." << endl; } @@ -773,11 +774,11 @@ void CommandInterpreter::executeStatus(int processId, } ndb_mgm_node_status status; - Uint32 startPhase, version, dynamicId, nodeGroup; + Uint32 startPhase, version, dynamicId, nodeGroup, connectCount; bool system; int result = _mgmtSrvr.status(processId, &status, &version, &startPhase, &system, - &dynamicId, &nodeGroup); + &dynamicId, &nodeGroup, &connectCount); if(result != 0){ ndbout << _mgmtSrvr.getErrorText(result) << endl; return; diff --git a/ndb/src/mgmsrv/Makefile b/ndb/src/mgmsrv/Makefile index b10bdb64d30..c99875ae8b6 100644 --- a/ndb/src/mgmsrv/Makefile +++ b/ndb/src/mgmsrv/Makefile @@ -1,10 +1,10 @@ include .defs.mk -TYPE := ndbapi +TYPE := ndbapi mgmapiclient BIN_TARGET := mgmtsrvr BIN_TARGET_LIBS := -BIN_TARGET_ARCHIVES := mgmapi NDB_API mgmsrvcommon +BIN_TARGET_ARCHIVES := NDB_API mgmsrvcommon mgmapi general ifneq ($(USE_EDITLINE), N) BIN_TARGET_ARCHIVES += editline @@ -31,6 +31,7 @@ SOURCES += CommandInterpreter.cpp endif CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/src/ndbapi) \ + -I$(call fixpath,$(NDB_TOP)/src/mgmapi) \ -I$(call fixpath,$(NDB_TOP)/include/mgmapi) \ -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 7c2d94c6b7f..f3bd967c5e0 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -29,7 +29,6 @@ #include <GlobalSignalNumbers.h> #include <signaldata/TestOrd.hpp> #include <signaldata/TamperOrd.hpp> -#include <signaldata/SetVarReq.hpp> #include <signaldata/StartOrd.hpp> #include <signaldata/ApiVersion.hpp> #include <signaldata/ResumeReq.hpp> @@ -49,6 +48,10 @@ #include "NodeLogLevel.hpp" #include <NdbConfig.h> +#include <mgmapi.h> +#include <mgmapi_configuration.hpp> +#include <mgmapi_config_parameters.h> + //#define MGM_SRV_DEBUG #ifdef MGM_SRV_DEBUG #define DEBUG(x) do ndbout << x << endl; while(0) @@ -225,19 +228,33 @@ void MgmtSrvr::startEventLog() { g_EventLogger.setCategory("MgmSrvr"); - const Properties *mgmProps; - _config->get("Node", _ownNodeId, &mgmProps); + + ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator + ((ndb_mgm_configuration*)_config->m_configValues, CFG_SECTION_NODE); + if(iter == 0) + return ; + + if(ndb_mgm_find(iter, CFG_NODE_ID, _ownNodeId) != 0){ + ndb_mgm_destroy_iterator(iter); + return ; + } + + const char * tmp; BaseString logdest; char clusterLog[MAXPATHLEN]; - NdbConfig_ClusterLogFileName(clusterLog, sizeof(clusterLog)); - - mgmProps->get("LogDestination", logdest); - + + + if(ndb_mgm_get_string_parameter(iter, CFG_LOG_DESTINATION, &tmp) == 0){ + logdest.assign(tmp); + } + ndb_mgm_destroy_iterator(iter); + if(logdest.length()==0) { - logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6", clusterLog); + logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6", + clusterLog); } - + if(!g_EventLogger.addHandler(logdest)) { ndbout << "ERROR: cannot parse \"" << logdest << "\"" << endl; exit(1); @@ -375,8 +392,8 @@ MgmtSrvr::getNodeCount(enum ndb_mgm_node_type type) const } int -MgmtSrvr::getStatPort() const -{ +MgmtSrvr::getStatPort() const { +#if 0 const Properties *mgmProps; if(!getConfig()->get("Node", _ownNodeId, &mgmProps)) return -1; @@ -386,12 +403,16 @@ MgmtSrvr::getStatPort() const return -1; return tmp; +#else + return -1; +#endif } /* Constructor */ MgmtSrvr::MgmtSrvr(NodeId nodeId, const BaseString &configFilename, - const BaseString &ndb_config_filename): + const BaseString &ndb_config_filename, + Config * config): _blockNumber(1), // Hard coded block number since it makes it easy to send // signals to other management servers. _ownReference(0), @@ -416,8 +437,8 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, m_nextConfigGenerationNumber = 0; - _config = readConfig(); - + _config = (config == 0 ? readConfig() : config); + theMgmtWaitForResponseCondPtr = NdbCondition_Create(); m_configMutex = NdbMutex_Create(); @@ -428,31 +449,38 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, for(Uint32 i = 0; i<MAX_NODES; i++) nodeTypes[i] = (enum ndb_mgm_node_type)-1; - Properties::Iterator it(_config); - const char * name; - for(name = it.first(); name != NULL; name = it.next()){ - if(strncmp(name, "Node_", strlen("Node_")) == 0){ - const Properties * tmp; + ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator + (config->m_configValues, CFG_SECTION_NODE); + for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){ + unsigned type, id; + if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0) + continue; - _config->get(name, &tmp); - - Uint32 nodeId; - BaseString type; - MGM_REQUIRE(tmp->get("Id", &nodeId)); - MGM_REQUIRE(tmp->get("Type", type)); - MGM_REQUIRE(nodeId < MAX_NODES); + if(ndb_mgm_get_int_parameter(iter, CFG_NODE_ID, &id) != 0) + continue; + + MGM_REQUIRE(id < MAX_NODES); - if(type == "MGM") - nodeTypes[nodeId] = NDB_MGM_NODE_TYPE_MGM; - if(type == "API") - nodeTypes[nodeId] = NDB_MGM_NODE_TYPE_API; - if(type == "DB") - nodeTypes[nodeId] = NDB_MGM_NODE_TYPE_NDB; - if(type == "REP") - nodeTypes[nodeId] = NDB_MGM_NODE_TYPE_API; + switch(type){ + case NODE_TYPE_DB: + nodeTypes[id] = NDB_MGM_NODE_TYPE_NDB; + break; + case NODE_TYPE_API: + nodeTypes[id] = NDB_MGM_NODE_TYPE_API; + break; + case NODE_TYPE_MGM: + nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM; + break; + case NODE_TYPE_REP: + nodeTypes[id] = NDB_MGM_NODE_TYPE_REP; + break; + case NODE_TYPE_EXT_REP: + default: + break; } } - + ndb_mgm_destroy_iterator(iter); + m_statisticsListner = NULL; _nodeLogLevelList = new NodeLogLevelList(); @@ -472,13 +500,6 @@ MgmtSrvr::check_start() return false; } - _props = new Config(* _config); - if (_props == 0) { - DEBUG("MgmtSrvr.cpp: Object props is NULL."); - return false; - } - MGM_REQUIRE(_props->put("LocalNodeId", _ownNodeId, true)); - return true; } @@ -489,11 +510,10 @@ MgmtSrvr::start() if (!check_start()) return false; } + theFacade = TransporterFacade::start_instance + (_ownNodeId, + (ndb_mgm_configuration*)_config->m_configValues); - theFacade = TransporterFacade::start_instance(_props, NULL); - delete _props; - _props = NULL; - if(theFacade == 0) { DEBUG("MgmtSrvr.cpp: theFacade is NULL."); return false; @@ -506,14 +526,14 @@ MgmtSrvr::start() _blockNumber = theFacade->open(this, signalReceivedNotification, nodeStatusNotification); - + if(_blockNumber == -1){ DEBUG("MgmtSrvr.cpp: _blockNumber is -1."); theFacade->stop_instance(); theFacade = 0; return false; } - + _ownReference = numberToRef(_blockNumber, _ownNodeId); startEventLog(); @@ -558,7 +578,11 @@ MgmtSrvr::~MgmtSrvr() NdbMutex_Destroy(m_configMutex); if(m_newConfig != NULL) - delete m_newConfig; + free(m_newConfig); + + if(_config != NULL) + delete _config; + delete _nodeLogLevelList; delete _clusterLogLevelList; @@ -813,9 +837,10 @@ MgmtSrvr::restart(bool nostart, bool initalStart, bool abort, s = NDB_MGM_NODE_STATUS_NO_CONTACT; while (s == NDB_MGM_NODE_STATUS_NO_CONTACT && waitTime > 0) { Uint32 startPhase = 0, version = 0, dynamicId = 0, nodeGroup = 0; + Uint32 connectCount = 0; bool system; status(nodeId, &s, &version, &startPhase, - &system, &dynamicId, &nodeGroup); + &system, &dynamicId, &nodeGroup, &connectCount); NdbSleep_MilliSleep(100); waitTime = (maxTime - NdbTick_CurrentMillisecond()); } @@ -1298,7 +1323,8 @@ MgmtSrvr::status(int processId, Uint32 * _phase, bool * _system, Uint32 * dynamic, - Uint32 * nodegroup) + Uint32 * nodegroup, + Uint32 * connectCount) { if (getNodeType(processId) == NDB_MGM_NODE_TYPE_API) { if(versionNode(processId, false,0,0) ==0) @@ -1325,7 +1351,8 @@ MgmtSrvr::status(int processId, * dynamic = node.m_state.dynamicId; * nodegroup = node.m_state.nodeGroup; - + * connectCount = node.m_info.m_connectCount; + switch(node.m_state.startLevel){ case NodeState::SL_CMVMI: * _status = NDB_MGM_NODE_STATUS_NOT_STARTED; @@ -1376,11 +1403,11 @@ MgmtSrvr::status(int processId, * _phase = 0; return 0; } - + return -1; } - - + + //**************************************************************************** //**************************************************************************** int @@ -1950,7 +1977,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) BackupEvent event; event.Event = BackupEvent::BackupStarted; event.Started.BackupId = conf->backupId; - event.Started.Nodes = conf->nodes; + event.Nodes = conf->nodes; #ifdef VM_TRACE ndbout_c("Backup master is %d", refToNode(signal->theSendersBlockRef)); #endif @@ -2013,7 +2040,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) event.Completed.stopGCP = rep->stopGCP; event.Completed.startGCP = rep->startGCP; - event.Completed.Nodes = rep->nodes; + event.Nodes = rep->nodes; backupCallback(event); } @@ -2170,8 +2197,9 @@ MgmtSrvr::getNextNodeId(NodeId * nodeId, enum ndb_mgm_node_type type) const while(nodeTypes[tmp] != type && tmp < MAX_NODES) tmp++; - if(tmp == MAX_NODES) + if(tmp == MAX_NODES){ return false; + } * nodeId = tmp; return true; @@ -2530,8 +2558,8 @@ MgmtSrvr::getStuff() } NodeId -MgmtSrvr::getPrimaryNode() const -{ +MgmtSrvr::getPrimaryNode() const { +#if 0 Uint32 tmp; const Properties *prop = NULL; @@ -2542,4 +2570,7 @@ MgmtSrvr::getPrimaryNode() const prop->get("PrimaryMGMNode", &tmp); return tmp; +#else + return 0; +#endif } diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index ce8765d6c73..1d394a14857 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -27,6 +27,7 @@ #include <NodeBitmask.hpp> #include <signaldata/ManagementServer.hpp> #include "SignalQueue.hpp" +#include <ndb_version.h> #include "NodeLogLevelList.hpp" @@ -151,7 +152,8 @@ public: /* Constructor */ MgmtSrvr(NodeId nodeId, /* Local nodeid */ const BaseString &config_filename, /* Where to save config */ - const BaseString &ndb_config_filename); /* Ndb.cfg filename */ + const BaseString &ndb_config_filename, /* Ndb.cfg filename */ + Config * config); /** * Read (initial) config file, create TransporterFacade, @@ -169,7 +171,8 @@ public: Uint32 * phase, bool * systemShutdown, Uint32 * dynamicId, - Uint32 * nodeGroup); + Uint32 * nodeGroup, + Uint32 * connectCount); // All the functions below may return any of this error codes: // NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE, @@ -307,10 +310,10 @@ public: BackupAborted = 4 } Event; + NdbNodeBitmask Nodes; union { struct { Uint32 BackupId; - NdbNodeBitmask Nodes; } Started ; struct { Uint32 ErrorCode; @@ -321,7 +324,6 @@ public: Uint32 NoOfRecords; Uint32 NoOfLogBytes; Uint32 NoOfLogRecords; - NdbNodeBitmask Nodes; Uint32 startGCP; Uint32 stopGCP; } Completed ; @@ -522,7 +524,7 @@ private: int _blockNumber; NodeId _ownNodeId; BlockReference _ownReference; - NdbMutex *m_configMutex; + NdbMutex *m_configMutex; const Config * _config; Config * m_newConfig; BaseString m_configFilename; diff --git a/ndb/src/mgmsrv/MgmtSrvrConfig.cpp b/ndb/src/mgmsrv/MgmtSrvrConfig.cpp index f4e53409b30..10316bd2851 100644 --- a/ndb/src/mgmsrv/MgmtSrvrConfig.cpp +++ b/ndb/src/mgmsrv/MgmtSrvrConfig.cpp @@ -275,31 +275,30 @@ MgmtSrvr::readConfig() { Config *conf = NULL; if(m_configFilename.length() != 0) { /* Use config file */ - InitConfigFileParser parser(m_configFilename.c_str()); - - if(!parser.readConfigFile()) { + InitConfigFileParser parser; + conf = parser.parseConfig(m_configFilename.c_str()); + + if(conf == NULL) { /* Try to get configuration from other MGM server */ - ConfigRetriever cr; - cr.setLocalConfigFileName(m_localNdbConfigFilename.c_str()); - conf = new Config(*cr.getConfig("MGM", NDB_VERSION)); - } else { - conf = new Config(*parser.getConfig()); + return fetchConfig(); } - - if(conf == NULL) - return NULL; } return conf; } Config * MgmtSrvr::fetchConfig() { - Config *conf = NULL; ConfigRetriever cr; cr.setLocalConfigFileName(m_localNdbConfigFilename.c_str()); - conf = new Config(*cr.getConfig("MGM", NDB_VERSION)); + struct ndb_mgm_configuration * tmp = cr.getConfig(NDB_VERSION, + NODE_TYPE_MGM); + if(tmp != 0){ + Config * conf = new Config(); + conf->m_configValues = tmp; + return conf; + } - return conf; + return 0; } bool diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 24f41fe64bf..739eef90c52 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -26,6 +26,9 @@ #include <BaseString.hpp> #include <Base64.hpp> +#include <ConfigValues.hpp> +#include <mgmapi_configuration.hpp> + #include "Services.hpp" static const unsigned int MAX_READ_TIMEOUT = 1000 ; @@ -275,12 +278,60 @@ MgmApiSession::getConfig_old(Parser_t::Context &ctx) { } #endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */ +inline void require(bool b){ if(!b) abort(); } + void MgmApiSession::getConfig(Parser_t::Context &ctx, const class Properties &args) { getConfig_common(ctx, args); } +static Properties * +backward(const char * base, const Properties* reply){ + Properties * ret = new Properties(); + Properties::Iterator it(reply); + for(const char * name = it.first(); name != 0; name=it.next()){ + PropertiesType type; + reply->getTypeOf(name, &type); + switch(type){ + case PropertiesType_Uint32:{ + Uint32 val; + reply->get(name, &val); + ret->put(name, val); + } + break; + case PropertiesType_char: + { + const char * val; + reply->get(name, &val); + ret->put(name, val); + if(!strcmp(name, "Type") && !strcmp(val, "DB")){ + ret->put("NoOfDiskBufferPages", (unsigned)0); + ret->put("NoOfDiskFiles", (unsigned)0); + ret->put("NoOfDiskClusters", (unsigned)0); + ret->put("NoOfFreeDiskClusters", (unsigned)0); + ret->put("NoOfDiskClustersPerDiskFile", (unsigned)0); + ret->put("NoOfConcurrentCheckpointsDuringRestart", (unsigned)1); + ret->put("NoOfConcurrentCheckpointsAfterRestart", (unsigned)1); + ret->put("NoOfConcurrentProcessesHandleTakeover", (unsigned)1); + } + } + break; + case PropertiesType_Properties: + { + const Properties * recurse; + reply->get(name, &recurse); + Properties * val = backward(name, recurse); + ret->put(name, val); + } + break; + case PropertiesType_Uint64: + break; + } + } + return ret; +} + void MgmApiSession::getConfig_common(Parser_t::Context &, const class Properties &args, @@ -290,92 +341,100 @@ MgmApiSession::getConfig_common(Parser_t::Context &, args.get("version", &version); args.get("node", &node); -#if 0 - if(version != 0) { - m_output->println("get config"); - m_output->println("result: Invalid version number"); - m_output->println(""); - return; - } -#endif - const Config *conf = m_mgmsrv.getConfig(); if(conf == NULL) { - m_output->println("get config"); + m_output->println("get config reply"); m_output->println("result: Could not fetch configuration"); m_output->println(""); return; } - bool compatible; - switch (m_mgmsrv.getNodeType(node)) { - case NDB_MGM_NODE_TYPE_NDB: - compatible = ndbCompatible_mgmt_ndb(NDB_VERSION, version); - break; - case NDB_MGM_NODE_TYPE_API: - case NDB_MGM_NODE_TYPE_MGM: - compatible = ndbCompatible_mgmt_api(NDB_VERSION, version); - break; - default: - m_output->println("get config"); - m_output->println("result: unrecognignized node type"); - m_output->println(""); - return; - } - - if (!compatible){ - m_output->println("get config"); - m_output->println("result: incompatible version mgmt 0x%x and node 0x%x", - NDB_VERSION, version); - m_output->println(""); - return; - } - - Properties *reply = new Properties(*conf); - reply->put("Version", NDB_VERSION); // reply->put("Version", version); - reply->put("LocalNodeId", node); + if(version > 0 && version < makeVersion(3, 5, 0) && compat){ + Properties *reply = backward("", conf->m_oldConfig); + reply->put("Version", version); + reply->put("LocalNodeId", node); -#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT - if(compat) { + backward("", reply); + //reply->print(); + const Uint32 size = reply->getPackedSize(); Uint32 *buffer = new Uint32[size/4+1]; reply->pack(buffer); delete reply; - + const int uurows = (size + 44)/45; char * uubuf = new char[uurows * 62+5]; - + const int uusz = uuencode_mem(uubuf, (char *)buffer, size); delete[] buffer; - + m_output->println("GET CONFIG %d %d %d %d %d", - 0, NDB_VERSION, node, size, uusz);// 0, version, node, size, uusz); - + 0, version, node, size, uusz); + m_output->println("begin 664 Ndb_cfg.bin"); - + /* XXX Need to write directly to the socket, because the uubuf is not * NUL-terminated. This could/should probably be done in a nicer way. */ write_socket(m_socket, MAX_WRITE_TIMEOUT, uubuf, uusz); delete[] uubuf; - + m_output->println("end"); m_output->println(""); - } else { -#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */ - - UtilBuffer buffer; - BaseString str; - reply->pack(buffer); - delete reply; - base64_encode(buffer, str); + return; + } - m_output->println("config: %s", str.c_str()); - m_output->println(""); -#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT + if(compat){ + m_output->println("GET CONFIG %d %d %d %d %d",1, version, 0, 0, 0); + return; } -#endif /* MGM_GET_CONFIG_BACKWARDS_COMPAT */ + + if(node != 0){ + bool compatible; + switch (m_mgmsrv.getNodeType(node)) { + case NDB_MGM_NODE_TYPE_NDB: + compatible = ndbCompatible_mgmt_ndb(NDB_VERSION, version); + break; + case NDB_MGM_NODE_TYPE_API: + case NDB_MGM_NODE_TYPE_MGM: + compatible = ndbCompatible_mgmt_api(NDB_VERSION, version); + break; + default: + m_output->println("get config"); + m_output->println("result: unrecognignized node type"); + m_output->println(""); + return; + } + + if (!compatible){ + m_output->println("get config"); + m_output->println("result: incompatible version mgmt 0x%x and node 0x%x", + NDB_VERSION, version); + m_output->println(""); + return; + } + } + + const ConfigValues * cfg = &conf->m_configValues->m_config; + const Uint32 size = cfg->getPackedSize(); + + UtilBuffer src; + cfg->pack(src); + + BaseString str; + int res = base64_encode(src, str); + + m_output->println("get config reply"); + m_output->println("result: Ok"); + m_output->println("Content-Length: %d", str.length()); + m_output->println("Content-Type: ndbconfig/octet-stream"); + m_output->println("Content-Transfer-Encoding: base64"); + m_output->println(""); + m_output->println(str.c_str()); + m_output->println(""); + + return; } void @@ -756,10 +815,14 @@ printNodeStatus(OutputStream *output, NodeId nodeId = 0; while(mgmsrv.getNextNodeId(&nodeId, type)) { enum ndb_mgm_node_status status; - Uint32 startPhase = 0, version = 0, dynamicId = 0, nodeGroup = 0; + Uint32 startPhase = 0, + version = 0, + dynamicId = 0, + nodeGroup = 0, + connectCount = 0; bool system; mgmsrv.status(nodeId, &status, &version, &startPhase, - &system, &dynamicId, &nodeGroup); + &system, &dynamicId, &nodeGroup, &connectCount); output->println("node.%d.type: %s", nodeId, ndb_mgm_get_node_type_string(type)); @@ -770,6 +833,7 @@ printNodeStatus(OutputStream *output, output->println("node.%d.startphase: %d", nodeId, startPhase); output->println("node.%d.dynamic_id: %d", nodeId, dynamicId); output->println("node.%d.node_group: %d", nodeId, nodeGroup); + output->println("node.%d.connect_count: %d", nodeId, connectCount); } } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 91b443f61a2..d9eb0001c44 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -34,6 +34,7 @@ #include <NdbHost.h> #include <ndb_version.h> #include <ConfigRetriever.hpp> +#include <mgmapi_config_parameters.h> #include <getarg.h> #if defined NDB_OSE || defined NDB_SOFTOSE @@ -191,7 +192,10 @@ NDB_MAIN(mgmsrv){ glob.mgmObject = new MgmtSrvr(glob.localNodeId, BaseString(glob.config_filename), - BaseString(glob.local_config_filename == 0 ? "" : glob.local_config_filename)); + BaseString(glob.local_config_filename == 0 ? "" : glob.local_config_filename), + glob.cluster_config); + + glob.cluster_config = 0; if(!glob.mgmObject->check_start()){ ndbout_c("Unable to start management server."); @@ -321,18 +325,21 @@ readGlobalConfig() { return false; /* Use config file */ - InitConfigFileParser parser(glob.config_filename); - - if(parser.readConfigFile()) { - glob.cluster_config = new Config(*parser.getConfig()); - } else { - /* Try to get configuration from other MGM server */ + InitConfigFileParser parser; + glob.cluster_config = parser.parseConfig(glob.config_filename); + if(glob.cluster_config == 0){ + /** + * Try to get configuration from other MGM server + * Note: Only new format + */ + glob.cluster_config = new Config(); + ConfigRetriever cr; cr.setLocalConfigFileName(glob.local_config_filename); - Properties* mgmconf = cr.getConfig("MGM", NDB_VERSION); - if (mgmconf == NULL) + glob.cluster_config->m_configValues = cr.getConfig(NDB_VERSION, + NODE_TYPE_MGM); + if (glob.cluster_config->m_configValues == NULL) return false; - glob.cluster_config = new Config(*mgmconf); } return true; } @@ -350,15 +357,23 @@ static bool setPortNo(){ const Properties *mgmProps; - if(!glob.cluster_config->get("Node", glob.localNodeId, &mgmProps)){ + ndb_mgm_configuration_iterator * iter = + ndb_mgm_create_configuration_iterator(glob.cluster_config->m_configValues, + CFG_SECTION_NODE); + if(iter == 0) + return false; + + if(ndb_mgm_find(iter, CFG_NODE_ID, glob.localNodeId) != 0){ ndbout << "Could not retrieve configuration for Node " << glob.localNodeId << " in config file." << endl << "Have you set correct NodeId for this node?" << endl; + ndb_mgm_destroy_iterator(iter); return false; } - BaseString type; - if(!mgmProps->get("Type", type) || strcasecmp(type.c_str(), "MGM") != 0){ + unsigned type; + if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0 || + type != NODE_TYPE_MGM){ ndbout << "Local node id " << glob.localNodeId << " is not defined as management server" << endl << "Have you set correct NodeId for this node?" << endl; @@ -369,7 +384,7 @@ setPortNo(){ * Set Port * ************/ Uint32 tmp = 0; - if (!mgmProps->get("PortNumber", &tmp)){ + if(ndb_mgm_get_int_parameter(iter, CFG_MGM_PORT, &tmp) != 0){ ndbout << "Could not find PortNumber in the configuration file." << endl; return false; } @@ -378,15 +393,18 @@ setPortNo(){ /***************** * Set Stat Port * *****************/ +#if 0 if (!mgmProps->get("PortNumberStats", &tmp)){ ndbout << "Could not find PortNumberStats in the configuration file." << endl; return false; } glob.port_stats = tmp; +#endif - BaseString host; - if(!mgmProps->get("ExecuteOnComputer", host)){ +#if 0 + const char * host; + if(ndb_mgm_get_string_parameter(iter, mgmProps->get("ExecuteOnComputer", host)){ ndbout << "Failed to find \"ExecuteOnComputer\" for my node" << endl; ndbout << "Unable to verify own hostname" << endl; return false; @@ -422,8 +440,11 @@ setPortNo(){ return true; } - glob.use_specific_ip = false; glob.interface_name = strdup(hostname); - +#endif + + glob.interface_name = 0; + glob.use_specific_ip = false; + return true; } diff --git a/ndb/src/mgmsrv/mkconfig/Makefile b/ndb/src/mgmsrv/mkconfig/Makefile index d35f68a5648..43574eefbd1 100644 --- a/ndb/src/mgmsrv/mkconfig/Makefile +++ b/ndb/src/mgmsrv/mkconfig/Makefile @@ -3,12 +3,11 @@ include .defs.mk TYPE := ndbapi BIN_TARGET := mkconfig -BIN_TARGET_ARCHIVES := logger general trace mgmsrvcommon portlib +BIN_TARGET_ARCHIVES := logger trace mgmsrvcommon portlib general SOURCES := mkconfig.cpp CCFLAGS_LOC += -I.. -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) - -OBJECTS_LOC := ../convertStrToInt.o +CFLAGS_mkconfig.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/mgmsrv/mkconfig/mkconfig.cpp b/ndb/src/mgmsrv/mkconfig/mkconfig.cpp index 224c82aa8a1..3b2046d7b49 100644 --- a/ndb/src/mgmsrv/mkconfig/mkconfig.cpp +++ b/ndb/src/mgmsrv/mkconfig/mkconfig.cpp @@ -16,6 +16,7 @@ #include <ndb_global.h> #include <ndb_version.h> +#include <mgmapi_configuration.hpp> #include <NdbMain.h> #include <Properties.hpp> @@ -36,25 +37,20 @@ NDB_COMMAND(mkconfig, return 0; } - InitConfigFileParser parser(argv[1]); - Config* cp; + InitConfigFileParser parser; + Config* _cp; - if (!parser.readConfigFile()) + if ((_cp = parser.parseConfig(argv[1])) == 0) return false; - cp = (Config *) parser.getConfig(); - if (cp == NULL) - return false; - - cp->put("VersionId", (Uint32)NDB_VERSION); - + ConfigValues* cp = &_cp->m_configValues->m_config; Uint32 sz = cp->getPackedSize(); - Uint32 * buf = new Uint32[sz]; + UtilBuffer buf; if(!cp->pack(buf)) return -1; - + FILE * f = fopen(argv[2], "w"); - if(fwrite(buf, 1, sz, f) != sz){ + if(fwrite(buf.get_data(), 1, buf.length(), f) != sz){ fclose(f); unlink(argv[2]); return -1; |