Commit e2d3f7b0 authored by unknown's avatar unknown

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
parent 1addcc2f
......@@ -72,13 +72,6 @@ public:
*/
~EventLogger();
/**
* Open/create the eventlog, the default name is 'cluster.log'.
*
* @return true if successful.
*/
bool open();
/**
* Opens/creates the eventlog with the specified filename.
*
......
......@@ -99,6 +99,8 @@ private:
char * m_connectString;
char * m_defaultConnectString;
NdbMgmHandle m_handle;
/**
* Verify config
*/
......
......@@ -21,11 +21,14 @@
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);
char* NdbConfig_NdbCfgName(int with_ndb_home);
char* NdbConfig_ErrorFileName(int node_id);
char* NdbConfig_ClusterLogFileName(int node_id);
char* NdbConfig_SignalLogFileName(int node_id);
char* NdbConfig_TraceFileName(int node_id, int file_no);
char* NdbConfig_NextTraceFileName(int node_id);
char* NdbConfig_PidFileName(int node_id);
char* NdbConfig_StdoutFileName(int node_id);
#ifdef __cplusplus
}
......
......@@ -4,6 +4,8 @@
#include <my_global.h>
#define NDB_BASE_PORT 2200
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
#define NDB_WIN32
#else
......
......@@ -1350,15 +1350,6 @@ EventLogger::EventLogger() : Logger(), m_logLevel(), m_filterLevel(15)
EventLogger::~EventLogger()
{
}
bool
EventLogger::open()
{
char clusterLog[128];
NdbConfig_ClusterLogFileName(clusterLog, 128);
return open(clusterLog);
}
bool
......
......@@ -103,7 +103,7 @@ ConfigInfo::m_SectionRules[] = {
{ "OSE", fixHostname, "HostName1" },
{ "OSE", fixHostname, "HostName2" },
{ "TCP", fixPortNumber, 0 },
{ "TCP", fixPortNumber, 0 }, // has to come after fixHostName
//{ "SHM", fixShmKey, 0 },
/**
......@@ -337,7 +337,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
ConfigInfo::USED,
false,
ConfigInfo::INT,
2202,
NDB_BASE_PORT+2,
0,
0x7FFFFFFF },
......@@ -1382,7 +1382,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
ConfigInfo::USED,
false,
ConfigInfo::INT,
2200,
NDB_BASE_PORT,
0,
0x7FFFFFFF },
......@@ -1566,7 +1566,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
ConfigInfo::USED,
false,
ConfigInfo::INT,
2202,
NDB_BASE_PORT+2,
0,
0x7FFFFFFF },
......@@ -2517,11 +2517,27 @@ transformNode(InitConfigFileParser::Context & ctx, const char * data){
Uint32 id;
if(!ctx.m_currentSection->get("Id", &id)){
Uint32 nextNodeId= 1;
ctx.m_userProperties.get("NextNodeId", &nextNodeId);
id= nextNodeId;
while (ctx.m_userProperties.get("AllocatedNodeId_", id, &id))
id++;
ctx.m_userProperties.put("NextNodeId", id+1, true);
ctx.m_currentSection->put("Id", id);
#if 0
ctx.reportError("Mandatory parameter Id missing from section "
"[%s] starting at line: %d",
ctx.fname, ctx.m_sectionLineno);
return false;
#endif
} else if(ctx.m_userProperties.get("AllocatedNodeId_", id, &id)) {
ctx.reportError("Duplicate Id in section "
"[%s] starting at line: %d",
ctx.fname, ctx.m_sectionLineno);
return false;
}
ctx.m_userProperties.put("AllocatedNodeId_", id, id);
snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
ctx.m_currentSection->put("Type", ctx.fname);
......@@ -3317,7 +3333,7 @@ bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
#if 0
Properties * props= ctx.m_config;
Properties computers;
Uint32 port_base = 2202;
Uint32 port_base = NDB_BASE_PORT+2;
Uint32 nNodes;
ctx.m_userProperties.get("NoOfNodes", &nNodes);
......
......@@ -45,13 +45,15 @@
ConfigRetriever::ConfigRetriever() {
_localConfigFileName = NULL;
m_defaultConnectString = NULL;
_localConfigFileName = 0;
m_defaultConnectString = 0;
errorString = 0;
_localConfig = new LocalConfig();
m_connectString = NULL;
m_connectString = 0;
m_handle= 0;
}
ConfigRetriever::~ConfigRetriever(){
......@@ -68,6 +70,11 @@ ConfigRetriever::~ConfigRetriever(){
free(errorString);
delete _localConfig;
if (m_handle) {
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
}
......@@ -158,45 +165,51 @@ ConfigRetriever::getConfig(const char * mgmhost,
short port,
int versionId,
int nodetype){
if (m_handle) {
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
NdbMgmHandle h;
h = ndb_mgm_create_handle();
if (h == NULL) {
m_handle = ndb_mgm_create_handle();
if (m_handle == 0) {
setError(CR_ERROR, "Unable to allocate mgm handle");
return 0;
}
BaseString tmp;
tmp.assfmt("%s:%d", mgmhost, port);
if (ndb_mgm_connect(h, tmp.c_str()) != 0) {
setError(CR_RETRY, ndb_mgm_get_latest_error_desc(h));
ndb_mgm_destroy_handle(&h);
if (ndb_mgm_connect(m_handle, tmp.c_str()) != 0) {
setError(CR_RETRY, ndb_mgm_get_latest_error_desc(m_handle));
ndb_mgm_destroy_handle(&m_handle);
m_handle= 0;
return 0;
}
ndb_mgm_configuration * conf = ndb_mgm_get_configuration(h, versionId);
ndb_mgm_configuration * conf = ndb_mgm_get_configuration(m_handle, versionId);
if(conf == 0){
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(h));
ndb_mgm_destroy_handle(&h);
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
m_handle= 0;
return 0;
}
{
unsigned nodeid= getOwnNodeId();
int res= ndb_mgm_alloc_nodeid(h, versionId, &nodeid, nodetype);
int res= ndb_mgm_alloc_nodeid(m_handle, versionId, &nodeid, nodetype);
if(res != 0) {
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(h));
ndb_mgm_destroy_handle(&h);
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
m_handle= 0;
return 0;
}
_ownNodeId= nodeid;
}
ndb_mgm_disconnect(h);
ndb_mgm_destroy_handle(&h);
return conf;
#if 0
bool compatible;
......
......@@ -443,7 +443,7 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if (nodeId <= nodeId1 && nodeId <= nodeId2) {
if (server_port && server_port != conf.port) {
ndbout << "internal error in config setup line=" << __LINE__ << endl;
ndbout << "internal error in config setup of server ports line= " << __LINE__ << endl;
exit(-1);
}
server_port= conf.port;
......
......@@ -17,6 +17,7 @@
#include "LocalConfig.hpp"
#include <NdbEnv.h>
#include <NdbConfig.h>
#include <NdbAutoPtr.hpp>
LocalConfig::LocalConfig(){
ids = 0; size = 0; items = 0;
......@@ -69,10 +70,10 @@ LocalConfig::init(bool onlyNodeId,
//4. Check Ndb.cfg in NDB_HOME
{
bool fopenError;
char buf[256];
if(readFile(NdbConfig_NdbCfgName(buf, sizeof(buf), 1 /*true*/), fopenError, onlyNodeId)){
char *buf= NdbConfig_NdbCfgName(1 /*true*/);
NdbAutoPtr<char> tmp_aptr(buf);
if(readFile(buf, fopenError, onlyNodeId))
return true;
}
if (!fopenError)
return false;
}
......@@ -80,24 +81,26 @@ LocalConfig::init(bool onlyNodeId,
//5. Check Ndb.cfg in cwd
{
bool fopenError;
char buf[256];
if(readFile(NdbConfig_NdbCfgName(buf, sizeof(buf), 0 /*false*/), fopenError, onlyNodeId)){
char *buf= NdbConfig_NdbCfgName(0 /*false*/);
NdbAutoPtr<char> tmp_aptr(buf);
if(readFile(buf, fopenError, onlyNodeId))
return true;
}
if (!fopenError)
return false;
}
//6. Check defaultConnectString
if(defaultConnectString != 0) {
if(readConnectString(defaultConnectString, onlyNodeId)){
if(readConnectString(defaultConnectString, onlyNodeId))
return true;
}
return false;
}
//7. Check
if(readConnectString("host=localhost:2200", onlyNodeId)){
{
char buf[256];
snprintf(buf, sizeof(buf), "host=localhost:%u", NDB_BASE_PORT);
if(readConnectString(buf, onlyNodeId))
return true;
}
......@@ -150,12 +153,12 @@ void LocalConfig::printUsage() const {
ndbout << "1. Put a Ndb.cfg file in the directory where you start"<<endl
<< " the node. "<< endl
<< " Ex: Ndb.cfg" << endl
<< " | nodeid=11;host=localhost:2200"<<endl<<endl;
<< " | host=localhost:"<<NDB_BASE_PORT<<endl;
ndbout << "2. Use the environment variable NDB_CONNECTSTRING to "<<endl
<< " provide this information." <<endl
<< " Ex: " << endl
<< " >export NDB_CONNECTSTRING=\"nodeid=11;host=localhost:2200\""
<< " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_BASE_PORT<<"\""
<<endl<<endl;
}
......
......@@ -18,43 +18,92 @@
#include <NdbConfig.h>
#include <NdbEnv.h>
const char*
NdbConfig_HomePath(char* buf, int buflen){
const char* p;
p = NdbEnv_GetEnv("NDB_HOME", buf, buflen);
if (p == NULL){
strlcpy(buf, "", buflen);
p = buf;
} else {
const int len = strlen(buf);
if(len != 0 && buf[len-1] != '/'){
buf[len] = '/';
buf[len+1] = 0;
}
}
return p;
}
const char*
NdbConfig_NdbCfgName(char* buf, int buflen, int with_ndb_home){
if (with_ndb_home)
NdbConfig_HomePath(buf, buflen);
static char*
NdbConfig_AllocHomePath(int _len)
{
const char *path= NdbEnv_GetEnv("NDB_HOME", 0, 0);
int len= _len;
int path_len= 0;
if (path)
path_len= strlen(path);
len+= path_len;
char *buf= malloc(len);
if (path_len > 0)
snprintf(buf, len, "%s%c", path, DIR_SEPARATOR);
else
buf[0] = 0;
strlcat(buf, "Ndb.cfg", buflen);
buf[0]= 0;
return buf;
}
char*
NdbConfig_NdbCfgName(int with_ndb_home){
char *buf;
int len= 0;
if (with_ndb_home) {
buf= NdbConfig_AllocHomePath(128);
len= strlen(buf);
} else
buf= malloc(128);
snprintf(buf+len, 128, "Ndb.cfg");
return buf;
}
char*
NdbConfig_ErrorFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_error.log", node_id);
return buf;
}
char*
NdbConfig_ClusterLogFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_cluster.log", node_id);
return buf;
}
char*
NdbConfig_SignalLogFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_signal.log", node_id);
return buf;
}
char*
NdbConfig_TraceFileName(int node_id, int file_no){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_trace.log.%u", node_id, file_no);
return buf;
}
char*
NdbConfig_NextTraceFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_trace.log.next", node_id);
return buf;
}
const char*
NdbConfig_ErrorFileName(char* buf, int buflen){
NdbConfig_HomePath(buf, buflen);
strlcat(buf, "error.log", buflen);
char*
NdbConfig_PidFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u.pid", node_id);
return buf;
}
const char*
NdbConfig_ClusterLogFileName(char* buf, int buflen){
NdbConfig_HomePath(buf, buflen);
strlcat(buf, "cluster.log", buflen);
char*
NdbConfig_StdoutFileName(int node_id){
char *buf= NdbConfig_AllocHomePath(128);
int len= strlen(buf);
snprintf(buf+len, 128, "ndb_%u_out.log", node_id);
return buf;
}
......@@ -85,11 +85,11 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
Transporter *t= m_transporter_registry->theTransporters[nodeId];
// send info about own id (just as response to acnowledge connection)
// send info about own id (just as response to acknowledge connection)
SocketOutputStream s_output(sockfd);
s_output.println("%d", t->getLocalNodeId());
// setup transporter (transporter responsable for closing sockfd)
// setup transporter (transporter responsible for closing sockfd)
t->connect_server(sockfd);
}
......
......@@ -27,6 +27,8 @@
#include <NdbConfig.h>
#include <Configuration.hpp>
#include <NdbAutoPtr.hpp>
#define MESSAGE_LENGTH 400
const char* errorType[] = {
......@@ -66,23 +68,23 @@ ErrorReporter::formatTimeStampString(){
return (const char *)&theDateTimeString;
}
void
ErrorReporter::formatTraceFileName(char* theName, int maxLen){
int
ErrorReporter::get_trace_no(){
FILE *stream;
unsigned int traceFileNo;
char fileNameBuf[255];
char buf[255];
NdbConfig_HomePath(fileNameBuf, 255);
strncat(fileNameBuf, "NextTraceFileNo.log", 255);
char *file_name= NdbConfig_NextTraceFileName(globalData.ownId);
NdbAutoPtr<char> tmp_aptr(file_name);
/*
* Read last number from tracefile
*/
stream = fopen(fileNameBuf, "r+");
stream = fopen(file_name, "r+");
if (stream == NULL){
traceFileNo = 1;
} else {
char buf[255];
fgets(buf, 255, stream);
const int scan = sscanf(buf, "%u", &traceFileNo);
if(scan != 1){
......@@ -103,16 +105,13 @@ ErrorReporter::formatTraceFileName(char* theName, int maxLen){
/**
* Save new number to the file
*/
stream = fopen(fileNameBuf, "w");
stream = fopen(file_name, "w");
if(stream != NULL){
fprintf(stream, "%u", traceFileNo);
fclose(stream);
}
/**
* Format trace file name
*/
snprintf(theName, maxLen, "%sNDB_TraceFile_%u.trace",
NdbConfig_HomePath(fileNameBuf, 255), traceFileNo);
return traceFileNo;
}
......@@ -214,16 +213,22 @@ WriteMessage(ErrorCategory thrdType, int thrdMessageID,
unsigned offset;
unsigned long maxOffset; // Maximum size of file.
char theMessage[MESSAGE_LENGTH];
char theTraceFileName[255];
char theErrorFileName[255];
ErrorReporter::formatTraceFileName(theTraceFileName, 255);
/**
* Format trace file name
*/
int file_no= ErrorReporter::get_trace_no();
char *theTraceFileName= NdbConfig_TraceFileName(globalData.ownId, file_no);
NdbAutoPtr<char> tmp_aptr1(theTraceFileName);
// The first 69 bytes is info about the current offset
Uint32 noMsg = globalEmulatorData.theConfiguration->maxNoOfErrorLogs();
maxOffset = (69 + (noMsg * MESSAGE_LENGTH));
NdbConfig_ErrorFileName(theErrorFileName, 255);
char *theErrorFileName= (char *)NdbConfig_ErrorFileName(globalData.ownId);
NdbAutoPtr<char> tmp_aptr2(theErrorFileName);
stream = fopen(theErrorFileName, "r+");
if (stream == NULL) { /* If the file could not be opened. */
......
......@@ -81,7 +81,7 @@ public:
const char* theNameOfTheTraceFile,
char* messptr);
static void formatTraceFileName(char* theName, int maxLen);
static int get_trace_no();
static const char* formatTimeStampString();
......
......@@ -31,7 +31,8 @@
#include <LogLevel.hpp>
#include <EventLogger.hpp>
#include <NodeState.hpp>
#include <NdbAutoPtr.hpp>
#if defined NDB_SOLARIS // ok
#include <sys/processor.h> // For system informatio
......@@ -71,15 +72,12 @@ NDB_MAIN(ndb_kernel){
theConfig->setupConfiguration();
}
// Get NDB_HOME path
char homePath[255];
NdbConfig_HomePath(homePath, 255);
if (theConfig->getDaemonMode()) {
// Become a daemon
char lockfile[255], logfile[255];
snprintf(lockfile, 255, "%snode%d.pid", homePath, globalData.ownId);
snprintf(logfile, 255, "%snode%d.out", homePath, globalData.ownId);
char *lockfile= NdbConfig_PidFileName(globalData.ownId);
char *logfile= NdbConfig_StdoutFileName(globalData.ownId);
NdbAutoPtr<char> tmp_aptr1(lockfile), tmp_aptr2(logfile);
if (NdbDaemon_Make(lockfile, logfile, 0) == -1) {
ndbout << "Cannot become daemon: " << NdbDaemon_ErrorText << endl;
return 1;
......@@ -90,6 +88,8 @@ NDB_MAIN(ndb_kernel){
/**
* Parent
*/
theConfig->closeConfiguration();
catchsigs(true);
int status = 0;
......@@ -147,9 +147,9 @@ NDB_MAIN(ndb_kernel){
#ifdef VM_TRACE
// Create a signal logger
char buf[255];
strcpy(buf, homePath);
FILE * signalLog = fopen(strncat(buf,"Signal.log", 255), "a");
char *buf= NdbConfig_SignalLogFileName(globalData.ownId);
NdbAutoPtr<char> tmp_aptr(buf);
FILE * signalLog = fopen(buf, "a");
globalSignalLoggers.setOwnNodeId(globalData.ownId);
globalSignalLoggers.setOutputStream(signalLog);
#endif
......@@ -185,6 +185,8 @@ NDB_MAIN(ndb_kernel){
socket_server.startServer();
// theConfig->closeConfiguration();
globalEmulatorData.theThreadConfig->ipControlLoop();
NdbShutdown(NST_Normal);
......
......@@ -138,6 +138,7 @@ Configuration::Configuration()
_fsPath = 0;
_initialStart = false;
_daemonMode = false;
m_config_retriever= 0;
}
Configuration::~Configuration(){
......@@ -146,6 +147,18 @@ Configuration::~Configuration(){
if(_fsPath != NULL)
free(_fsPath);
if (m_config_retriever) {
delete m_config_retriever;
}
}
void
Configuration::closeConfiguration(){
if (m_config_retriever) {
delete m_config_retriever;
}
m_config_retriever= 0;
}
void
......@@ -153,7 +166,12 @@ Configuration::setupConfiguration(){
/**
* Fetch configuration from management server
*/
ConfigRetriever cr;
if (m_config_retriever) {
delete m_config_retriever;
}
m_config_retriever= new ConfigRetriever();
ConfigRetriever &cr= *m_config_retriever;
cr.setConnectString(_connectString);
stopOnError(true);
ndb_mgm_configuration * p = cr.getConfig(NDB_VERSION, NODE_TYPE_DB);
......
......@@ -20,6 +20,8 @@
#include <mgmapi.h>
#include <ndb_types.h>
class ConfigRetriever;
class Configuration {
public:
Configuration();
......@@ -31,6 +33,7 @@ public:
bool init(int argc, const char** argv);
void setupConfiguration();
void closeConfiguration();
bool lockPagesInMainMemory() const;
......@@ -78,6 +81,8 @@ private:
ndb_mgm_configuration_iterator * m_clusterConfigIter;
ndb_mgm_configuration_iterator * m_ownConfigIterator;
ConfigRetriever *m_config_retriever;
/**
* arguments to NDB process
*/
......
......@@ -26,7 +26,7 @@
#include <signal.h>
const char *progname = "mgmtclient";
const char *progname = "ndb_mgm";
static CommandInterpreter* com;
......@@ -47,7 +47,10 @@ handler(int sig){
int main(int argc, const char** argv){
int optind = 0;
const char *_default_connectstring = "host=localhost:2200;nodeid=0";
char _default_connectstring_buf[256];
snprintf(_default_connectstring_buf, sizeof(_default_connectstring_buf),
"host=localhost:%u", NDB_BASE_PORT);
const char *_default_connectstring= _default_connectstring_buf;
const char *_host = 0;
int _port = 0;
int _help = 0;
......
......@@ -47,6 +47,8 @@
#include "NodeLogLevel.hpp"
#include <NdbConfig.h>
#include <NdbAutoPtr.hpp>
#include <mgmapi.h>
#include <mgmapi_configuration.hpp>
#include <mgmapi_config_parameters.h>
......@@ -240,9 +242,8 @@ MgmtSrvr::startEventLog()
const char * tmp;
BaseString logdest;
char clusterLog[MAXPATHLEN];
NdbConfig_ClusterLogFileName(clusterLog, sizeof(clusterLog));
char *clusterLog= NdbConfig_ClusterLogFileName(_ownNodeId);
NdbAutoPtr<char> tmp_aptr(clusterLog);
if(ndb_mgm_get_string_parameter(iter, CFG_LOG_DESTINATION, &tmp) == 0){
logdest.assign(tmp);
......@@ -2325,7 +2326,7 @@ MgmtSrvr::getFreeNodeId(NodeId * nodeId, enum ndb_mgm_node_type type,
// getsockname(int s, struct sockaddr *name, socklen_t *namelen);
if (config_hostname && config_hostname[0] != 0) {
if (config_hostname && config_hostname[0] != 0 && client_addr) {
// check hostname compatability
struct in_addr config_addr;
if(Ndb_getInAddr(&config_addr, config_hostname) != 0
......
......@@ -124,6 +124,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("get nodeid", &MgmApiSession::get_nodeid, ""),
MGM_ARG("version", Int, Mandatory, "Configuration version number"),
MGM_ARG("nodetype", Int, Mandatory, "Node type"),
MGM_ARG("transporter", String, Optional, "Transporter type"),
MGM_ARG("nodeid", Int, Optional, "Node ID"),
MGM_ARG("user", String, Mandatory, "Password"),
MGM_ARG("password", String, Mandatory, "Password"),
......@@ -359,12 +360,14 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
{
const char *cmd= "get nodeid reply";
Uint32 version, nodeid= 0, nodetype= 0xff;
const char * transporter;
const char * user;
const char * password;
const char * public_key;
args.get("version", &version);
args.get("nodetype", &nodetype);
args.get("transporter", &transporter);
args.get("nodeid", &nodeid);
args.get("user", &user);
args.get("password", &password);
......@@ -388,9 +391,10 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
struct sockaddr addr;
socklen_t addrlen;
if (getsockname(m_socket, &addr, &addrlen)) {
int r;
if (r= getsockname(m_socket, &addr, &addrlen)) {
m_output->println(cmd);
m_output->println("result: getsockname(%d)", m_socket);
m_output->println("result: getsockname(%d) failed, err= %d", m_socket, r);
m_output->println("");
return;
}
......
......@@ -37,6 +37,8 @@
#include <mgmapi_config_parameters.h>
#include <getarg.h>
#include <NdbAutoPtr.hpp>
#if defined NDB_OSE || defined NDB_SOFTOSE
#include <efs.h>
#else
......@@ -217,10 +219,10 @@ NDB_MAIN(mgmsrv){
if (glob.daemon) {
// Become a daemon
char homePath[255],lockfile[255], logfile[255];
NdbConfig_HomePath(homePath, 255);
snprintf(lockfile, 255, "%snode%d.pid", homePath, glob.localNodeId);
snprintf(logfile, 255, "%snode%d.out", homePath, glob.localNodeId);
char *lockfile= NdbConfig_PidFileName(glob.localNodeId);
char *logfile= NdbConfig_StdoutFileName(glob.localNodeId);
NdbAutoPtr<char> tmp_aptr1(lockfile), tmp_aptr2(logfile);
if (NdbDaemon_Make(lockfile, logfile, 0) == -1) {
ndbout << "Cannot become daemon: " << NdbDaemon_ErrorText << endl;
return 1;
......
......@@ -48,7 +48,7 @@
#endif
TransporterFacade* TransporterFacade::theFacadeInstance = NULL;
ConfigRetriever *TransporterFacade::s_config_retriever= 0;
/*****************************************************************************
......@@ -333,11 +333,15 @@ atexit_stop_instance(){
*
* Which is protected by a mutex
*/
TransporterFacade*
TransporterFacade::start_instance(const char * connectString){
// TransporterFacade used from API get config from mgmt srvr
ConfigRetriever configRetriever;
s_config_retriever= new ConfigRetriever;
ConfigRetriever &configRetriever= *s_config_retriever;
configRetriever.setConnectString(connectString);
ndb_mgm_configuration * props = configRetriever.getConfig(NDB_VERSION,
NODE_TYPE_API);
......@@ -390,6 +394,14 @@ TransporterFacade::start_instance(int nodeId,
return tf;
}
void
TransporterFacade::close_configuration(){
if (s_config_retriever) {
delete s_config_retriever;
s_config_retriever= 0;
}
}
/**
* Note that this function need no locking since its
* only called from the destructor of Ndb (the NdbObject)
......@@ -398,6 +410,9 @@ TransporterFacade::start_instance(int nodeId,
*/
void
TransporterFacade::stop_instance(){
close_configuration();
if(theFacadeInstance == NULL){
/**
* We are called from atexit function
......
......@@ -29,6 +29,7 @@ class ClusterMgr;
class ArbitMgr;
class IPCConfig;
struct ndb_mgm_configuration;
class ConfigRetriever;
class Ndb;
class NdbApiSignal;
......@@ -56,6 +57,7 @@ public:
static TransporterFacade* instance();
static TransporterFacade* start_instance(int, const ndb_mgm_configuration*);
static TransporterFacade* start_instance(const char *connectString);
static void close_configuration();
static void stop_instance();
/**
......@@ -218,6 +220,7 @@ public:
NdbMutex* theMutexPtr;
private:
static TransporterFacade* theFacadeInstance;
static ConfigRetriever *s_config_retriever;
public:
GlobalDictCache m_globalDictCache;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment