mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Initial revision of NDB Cluster files
BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
parent
0ba6cb48d8
commit
6386c55cee
1835 changed files with 500032 additions and 0 deletions
116
ndb/include/mgmcommon/ConfigRetriever.hpp
Normal file
116
ndb/include/mgmcommon/ConfigRetriever.hpp
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/* 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 <Properties.hpp>
|
||||
|
||||
/**
|
||||
* @class ConfigRetriever
|
||||
* @brief Used by nodes (DB, MGM, API) to get their config from MGM server.
|
||||
*/
|
||||
class ConfigRetriever {
|
||||
public:
|
||||
ConfigRetriever();
|
||||
ConfigRetriever(const int id, const char* remoteHost, const int port);
|
||||
~ConfigRetriever();
|
||||
|
||||
/**
|
||||
* Read local config
|
||||
* @return Own node id, -1 means fail
|
||||
*/
|
||||
int init(bool onlyNodeId = 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 Properties object if succeeded,
|
||||
* NULL if erroneous local config file or configuration error.
|
||||
*/
|
||||
class Properties * getConfig(const char * nodeType, int versionId);
|
||||
|
||||
const char * getErrorString();
|
||||
|
||||
/**
|
||||
* Sets connectstring which can be used instead of local config file
|
||||
*/
|
||||
void setConnectString(const char * connectString);
|
||||
|
||||
/**
|
||||
* Sets name of local config file (usually not needed)
|
||||
*/
|
||||
void setLocalConfigFileName(const char * connectString);
|
||||
|
||||
/**
|
||||
* Sets connectstring which can be used instead of local config file
|
||||
* environment variables and Ndb.cfg has precidence over this
|
||||
*/
|
||||
void setDefaultConnectString(const char * defaultConnectString);
|
||||
|
||||
/**
|
||||
* @return Node id of this node (as stated in local config or connectString)
|
||||
*/
|
||||
inline Uint32 getOwnNodeId() { return _ownNodeId; }
|
||||
|
||||
/**
|
||||
* Get configuration object
|
||||
*/
|
||||
class Properties * getConfig(int versionId);
|
||||
|
||||
/**
|
||||
* Get config using socket
|
||||
*/
|
||||
class Properties * getConfig(const char * mgmhost, unsigned int port,
|
||||
Uint32 nodeId, int versionId);
|
||||
/**
|
||||
* Get config from file
|
||||
*/
|
||||
class Properties * getConfig(const char * filename, Uint32 nodeId,
|
||||
int versionId);
|
||||
private:
|
||||
char * errorString;
|
||||
enum ErrorType {
|
||||
CR_ERROR = 0,
|
||||
CR_RETRY = 1
|
||||
};
|
||||
ErrorType latestErrorType;
|
||||
|
||||
void setError(ErrorType, const char * errorMsg);
|
||||
|
||||
/**
|
||||
* Verifies that received configuration is correct
|
||||
*/
|
||||
bool verifyProperties(const char* nodeType, Properties *p,
|
||||
Uint32 nodeId, int versionId);
|
||||
|
||||
char * _localConfigFileName;
|
||||
struct LocalConfig * _localConfig;
|
||||
int _ownNodeId;
|
||||
|
||||
char * m_connectString;
|
||||
char * m_defaultConnectString;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
79
ndb/include/mgmcommon/IPCConfig.hpp
Normal file
79
ndb/include/mgmcommon/IPCConfig.hpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* 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 IPCConfig_H
|
||||
#define IPCConfig_H
|
||||
|
||||
#include <ndb_types.h>
|
||||
#include <ndb_limits.h>
|
||||
#include <kernel_types.h>
|
||||
#include <Properties.hpp>
|
||||
|
||||
/**
|
||||
* @class IPCConfig
|
||||
* @brief Config transporters in TransporterRegistry using Properties config
|
||||
*/
|
||||
class IPCConfig
|
||||
{
|
||||
public:
|
||||
IPCConfig(Properties * props);
|
||||
~IPCConfig();
|
||||
|
||||
/** @return 0 for OK */
|
||||
int init();
|
||||
|
||||
NodeId ownId() const;
|
||||
|
||||
/** @return No of transporters configured */
|
||||
int configureTransporters(class TransporterRegistry * theTransporterRegistry);
|
||||
|
||||
/**
|
||||
* Supply a nodeId,
|
||||
* and get next higher node id
|
||||
* @return false if none found, true otherwise
|
||||
*
|
||||
* getREPHBFrequency and getNodeType uses the last Id supplied to
|
||||
* getNextRemoteNodeId.
|
||||
*/
|
||||
bool getNextRemoteNodeId(NodeId & nodeId) const;
|
||||
Uint32 getREPHBFrequency(NodeId id) const;
|
||||
const char* getNodeType(NodeId id) const;
|
||||
|
||||
NodeId getNoOfRemoteNodes() const {
|
||||
return theNoOfRemoteNodes;
|
||||
}
|
||||
|
||||
void print() const { props->print(); }
|
||||
|
||||
private:
|
||||
NodeId the_ownId;
|
||||
Properties * props;
|
||||
|
||||
bool addRemoteNodeId(NodeId nodeId);
|
||||
NodeId theNoOfRemoteNodes;
|
||||
NodeId theRemoteNodeIds[MAX_NODES];
|
||||
};
|
||||
|
||||
inline
|
||||
NodeId
|
||||
IPCConfig::ownId() const
|
||||
{
|
||||
return the_ownId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // IPCConfig_H
|
||||
74
ndb/include/mgmcommon/MgmtErrorReporter.hpp
Normal file
74
ndb/include/mgmcommon/MgmtErrorReporter.hpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* 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 */
|
||||
|
||||
//******************************************************************************
|
||||
// Description: This file contains the error reporting macros to be used
|
||||
// within management server.
|
||||
//
|
||||
// Author: Peter Lind
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
#include <NdbOut.hpp>
|
||||
#include <stdlib.h> // exit
|
||||
|
||||
#define REPORT_WARNING(message) \
|
||||
ndbout << "WARNING: " << message << endl
|
||||
|
||||
//****************************************************************************
|
||||
// Description: Report a warning, the message is printed on ndbout.
|
||||
// Parameters:
|
||||
// message: A text describing the warning.
|
||||
// Returns: -
|
||||
//****************************************************************************
|
||||
|
||||
|
||||
#define REPORT_ERROR(message) \
|
||||
ndbout << "ERROR: " << message << endl
|
||||
|
||||
//****************************************************************************
|
||||
// Description: Report an error, the message is printed on ndbout.
|
||||
// Parameters:
|
||||
// message: A text describing the error.
|
||||
// Returns: -
|
||||
//****************************************************************************
|
||||
|
||||
|
||||
#ifdef MGMT_TRACE
|
||||
|
||||
#define TRACE(message) \
|
||||
ndbout << "MGMT_TRACE: " << message << endl
|
||||
#else
|
||||
#define TRACE(message)
|
||||
|
||||
#endif
|
||||
|
||||
//****************************************************************************
|
||||
// Description: Print a message on ndbout.
|
||||
// Parameters:
|
||||
// message: The message
|
||||
// Returns: -
|
||||
//****************************************************************************
|
||||
|
||||
#ifndef NDB_ASSERT
|
||||
#define NDB_ASSERT(trueToContinue, message) \
|
||||
if ( !(trueToContinue) ) { \
|
||||
ndbout << "ASSERT FAILED. FILE: " << __FILE__ << ", LINE: " << __LINE__ << ", MSG: " << message << endl;exit(-1);}
|
||||
#endif
|
||||
|
||||
#define MGM_REQUIRE(x) \
|
||||
if (!(x)) { ndbout << __FILE__ << " " << __LINE__ \
|
||||
<< ": Warning! Requirement failed" << endl; }
|
||||
34
ndb/include/mgmcommon/NdbConfig.h
Normal file
34
ndb/include/mgmcommon/NdbConfig.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* 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 NDB_CONFIG_H
|
||||
#define NDB_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char* NdbConfig_HomePath(char* buf, int buflen);
|
||||
|
||||
const char* NdbConfig_NdbCfgName(char* buf, int buflen, int with_ndb_home);
|
||||
const char* NdbConfig_ErrorFileName(char* buf, int buflen);
|
||||
const char* NdbConfig_ClusterLogFileName(char* buf, int buflen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue