mariadb/ndb/include/mgmcommon/ConfigRetriever.hpp

97 lines
2.6 KiB
C++
Raw Normal View History

/* 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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 */
#ifndef ConfigRetriever_H
#define ConfigRetriever_H
#include <ndb_types.h>
#include <mgmapi.h>
#include <BaseString.hpp>
#include <LocalConfig.hpp>
/**
* @class ConfigRetriever
* @brief Used by nodes (DB, MGM, API) to get their config from MGM server.
*/
class ConfigRetriever {
public:
ConfigRetriever(LocalConfig &local_config, Uint32 version, Uint32 nodeType);
~ConfigRetriever();
/**
* Read local config
* @return Own node id, -1 means fail
*/
int init();
int do_connect(int exit_on_connect_failure= false);
/**
* Get configuration for current (nodeId given in local config file) node.
*
* Configuration is fetched from one MGM server configured in local config
* file. The method loops over all the configured MGM servers and tries
* to establish a connection. This is repeated until a connection is
* established, so the function hangs until a connection is established.
*
* @return ndb_mgm_configuration object if succeeded,
* NULL if erroneous local config file or configuration error.
*/
struct ndb_mgm_configuration * getConfig();
const char * getErrorString();
/**
* @return Node id of this node (as stated in local config or connectString)
*/
Uint32 allocNodeId();
/**
* Get config using socket
*/
struct ndb_mgm_configuration * getConfig(NdbMgmHandle handle);
/**
* Get config from file
*/
struct ndb_mgm_configuration * getConfig(const char * file);
/**
* Verify config
*/
bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid);
private:
BaseString errorString;
enum ErrorType {
CR_ERROR = 0,
CR_RETRY = 1
};
ErrorType latestErrorType;
void setError(ErrorType, const char * errorMsg);
struct LocalConfig& _localConfig;
2004-09-11 20:53:57 +02:00
Uint32 _ownNodeId;
Uint32 m_version;
Uint32 m_node_type;
several config fixes for ndb, see respective file ndb/include/debugger/EventLogger.hpp: removed unused method ndb/include/mgmcommon/ConfigRetriever.hpp: put NdbMgmHandle in ConfigRetriever to enable holding connection open until setup complete ndb/include/mgmcommon/NdbConfig.h: moved naming of all "ndb" file into NdbConfig.c ndb/include/ndb_global.h: introduced define NDB_BASE_PORT to control default port for ndb ndb/src/common/debugger/EventLogger.cpp: removed unused method ndb/src/common/mgmcommon/ConfigInfo.cpp: introduced define NDB_BASE_PORT to control default port for ndb + added setting default Id's on nodes ndb/src/common/mgmcommon/ConfigRetriever.cpp: put NdbMgmHandle in ConfigRetriever to enable holding connection open until setup complete ndb/src/common/mgmcommon/IPCConfig.cpp: changed error message ndb/src/common/mgmcommon/LocalConfig.cpp: introduced define NDB_BASE_PORT to control default port for ndb ndb/src/common/mgmcommon/NdbConfig.c: moved naming of all "ndb" file into NdbConfig.c ndb/src/common/transporter/TransporterRegistry.cpp: spelling errors ndb/src/kernel/error/ErrorReporter.cpp: moved naming of all "ndb" file into NdbConfig.c ndb/src/kernel/error/ErrorReporter.hpp: moved naming of all "ndb" file into NdbConfig.c ndb/src/kernel/main.cpp: moved naming of all "ndb" file into NdbConfig.c ndb/src/kernel/vm/Configuration.cpp: moved allocation of ConfigRetriever object to Configuration to enable holing "config" open until setup finished ndb/src/kernel/vm/Configuration.hpp: moved allocation of ConfigRetriever object to Configuration to enable holing "config" open until setup finished ndb/src/mgmclient/main.cpp: fix default port number ndb/src/mgmsrv/MgmtSrvr.cpp: fix default port ndb/src/mgmsrv/Services.cpp: added spec of transporter in get_nodeid ndb/src/mgmsrv/main.cpp: moved naming of all "ndb" file into NdbConfig.c ndb/src/ndbapi/TransporterFacade.cpp: moved allocation of ConfigRetriever object to TransporterFacade to enable holing "config" open until setup finished ndb/src/ndbapi/TransporterFacade.hpp: moved allocation of ConfigRetriever object to TransporterFacade to enable holing "config" open until setup finished
2004-06-28 17:29:58 +00:00
NdbMgmHandle m_handle;
};
#endif