mariadb/ndb/include/mgmcommon/ConfigRetriever.hpp
unknown 9bc6ed86cc Fixes for: use initial mgm connection as transporter connection
ndb/include/mgmapi/mgmapi.h:
  ndb_mgm_convert_to_transporter may destroy the handle, now takes a pointer.
ndb/include/mgmcommon/ConfigRetriever.hpp:
  If outside code is going to manipulate the NdbMgmHandle, allow it to do it
  via a get_mgmHandlePtr() call
ndb/include/transporter/TransporterRegistry.hpp:
  connect_client and connect_ndb_mgmd may destroy the handle, now they take a pointer.
ndb/src/common/transporter/TransporterRegistry.cpp:
  When start_service is binding to ports, report back the port numbers.
  
  We need this here now, as we re-use the initial mgm connection as a transporter, which
  is connected *before* start_service has allocated the dynamic port numbers. So the creation
  of this early transporter cannot be used to send the dynamic ports to the mgmd.
  
  We connect to the mgm server (using the handle that will be used in the client_Connect thread)
  if needed. This is thread safe as start_service is only ever called once, before
  the client connect thread starts.
  
  connect_client,connect_ndb_mgmd may destroy the NdbMgmHandle. It now accepts a pointer to it.
ndb/src/kernel/vm/Configuration.cpp:
  Copy the m_mgmd_host string from the config_retreiver as the NdbMgmHandle in the
  ConfigRetreiver will be destroyed later (along with the host string).
  
  globalTransporterRegistry.connect_client will destroy the mgm handle, use a pointer to the handle.
ndb/src/kernel/vm/Configuration.hpp:
  allow the dynamic allocation of m_mgmd_host.
ndb/src/mgmapi/mgmapi.cpp:
  accept a pointer for ndb_mgm_convert_to_transporter as we destroy the handle.
2005-02-24 17:57:22 +11:00

106 lines
2.9 KiB
C++

/* 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>
/**
* @class ConfigRetriever
* @brief Used by nodes (DB, MGM, API) to get their config from MGM server.
*/
class ConfigRetriever {
public:
ConfigRetriever(const char * _connect_string,
Uint32 version, Uint32 nodeType);
~ConfigRetriever();
int do_connect(int no_retries, int retry_delay_in_seconds, int verbose);
/**
* Get configuration for current 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();
void resetError();
int hasError();
const char * getErrorString();
/**
* @return Node id of this node (as stated in local config or connectString)
*/
Uint32 allocNodeId(int no_retries, int retry_delay_in_seconds);
int setNodeId(Uint32 nodeid);
/**
* 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);
Uint32 get_mgmd_port() const;
const char *get_mgmd_host() const;
const char *get_connectstring(char *buf, int buf_sz) const;
NdbMgmHandle get_mgmHandle() { return m_handle; };
NdbMgmHandle* get_mgmHandlePtr() { return &m_handle; };
Uint32 get_configuration_nodeid() const;
private:
BaseString errorString;
enum ErrorType {
CR_NO_ERROR = 0,
CR_ERROR = 1,
CR_RETRY = 2
};
ErrorType latestErrorType;
void setError(ErrorType, const char * errorMsg);
Uint32 _ownNodeId;
/*
Uint32 m_mgmd_port;
const char *m_mgmd_host;
*/
Uint32 m_version;
Uint32 m_node_type;
NdbMgmHandle m_handle;
};
#endif