summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-06-28 17:29:58 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-06-28 17:29:58 +0000
commitf9bad1aefccbf77d991fe528db0ad560b95f4149 (patch)
treed4d2a87694d5db66d91bb4e549966eb058d5d4d0
parente99fe5978bb4817d309d9d0e20234b8ebe33edb3 (diff)
downloadmariadb-git-f9bad1aefccbf77d991fe528db0ad560b95f4149.tar.gz
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
-rw-r--r--ndb/include/debugger/EventLogger.hpp7
-rw-r--r--ndb/include/mgmcommon/ConfigRetriever.hpp2
-rw-r--r--ndb/include/mgmcommon/NdbConfig.h13
-rw-r--r--ndb/include/ndb_global.h2
-rw-r--r--ndb/src/common/debugger/EventLogger.cpp9
-rw-r--r--ndb/src/common/mgmcommon/ConfigInfo.cpp26
-rw-r--r--ndb/src/common/mgmcommon/ConfigRetriever.cpp51
-rw-r--r--ndb/src/common/mgmcommon/IPCConfig.cpp2
-rw-r--r--ndb/src/common/mgmcommon/LocalConfig.cpp27
-rw-r--r--ndb/src/common/mgmcommon/NdbConfig.c111
-rw-r--r--ndb/src/common/transporter/TransporterRegistry.cpp4
-rw-r--r--ndb/src/kernel/error/ErrorReporter.cpp39
-rw-r--r--ndb/src/kernel/error/ErrorReporter.hpp2
-rw-r--r--ndb/src/kernel/main.cpp24
-rw-r--r--ndb/src/kernel/vm/Configuration.cpp20
-rw-r--r--ndb/src/kernel/vm/Configuration.hpp5
-rw-r--r--ndb/src/mgmclient/main.cpp7
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.cpp11
-rw-r--r--ndb/src/mgmsrv/Services.cpp8
-rw-r--r--ndb/src/mgmsrv/main.cpp10
-rw-r--r--ndb/src/ndbapi/TransporterFacade.cpp19
-rw-r--r--ndb/src/ndbapi/TransporterFacade.hpp3
22 files changed, 266 insertions, 136 deletions
diff --git a/ndb/include/debugger/EventLogger.hpp b/ndb/include/debugger/EventLogger.hpp
index c49bd176ee8..6cd6a83e68d 100644
--- a/ndb/include/debugger/EventLogger.hpp
+++ b/ndb/include/debugger/EventLogger.hpp
@@ -73,13 +73,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.
*
* @param aFileName the eventlog filename.
diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp
index c1de751b797..d884e914f0b 100644
--- a/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -99,6 +99,8 @@ private:
char * m_connectString;
char * m_defaultConnectString;
+ NdbMgmHandle m_handle;
+
/**
* Verify config
*/
diff --git a/ndb/include/mgmcommon/NdbConfig.h b/ndb/include/mgmcommon/NdbConfig.h
index d9b484edcc5..5c83a348df2 100644
--- a/ndb/include/mgmcommon/NdbConfig.h
+++ b/ndb/include/mgmcommon/NdbConfig.h
@@ -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
}
diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h
index f871acbc075..2975d0a5f78 100644
--- a/ndb/include/ndb_global.h
+++ b/ndb/include/ndb_global.h
@@ -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
diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp
index dd957d67383..8f976e7b991 100644
--- a/ndb/src/common/debugger/EventLogger.cpp
+++ b/ndb/src/common/debugger/EventLogger.cpp
@@ -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
diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp
index 9c8f4416d05..60b77a4cd8c 100644
--- a/ndb/src/common/mgmcommon/ConfigInfo.cpp
+++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp
@@ -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);
diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index c34d9bb01f9..2de82d7250e 100644
--- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -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){
-
- NdbMgmHandle h;
- h = ndb_mgm_create_handle();
- if (h == NULL) {
+ if (m_handle) {
+ ndb_mgm_disconnect(m_handle);
+ ndb_mgm_destroy_handle(&m_handle);
+ }
+
+ 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;
diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp
index 6a4e98e9f66..6dd8e7c1589 100644
--- a/ndb/src/common/mgmcommon/IPCConfig.cpp
+++ b/ndb/src/common/mgmcommon/IPCConfig.cpp
@@ -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;
diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/common/mgmcommon/LocalConfig.cpp
index 67e92064e81..57b538de43c 100644
--- a/ndb/src/common/mgmcommon/LocalConfig.cpp
+++ b/ndb/src/common/mgmcommon/LocalConfig.cpp
@@ -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,25 +81,27 @@ 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)){
- return true;
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "host=localhost:%u", NDB_BASE_PORT);
+ if(readConnectString(buf, onlyNodeId))
+ return true;
}
setError(0, "");
@@ -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;
}
diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/mgmcommon/NdbConfig.c
index 827ef34a840..68ddb5fbec2 100644
--- a/ndb/src/common/mgmcommon/NdbConfig.c
+++ b/ndb/src/common/mgmcommon/NdbConfig.c
@@ -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;
}
diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp
index 4b3481aa0a8..c046e4f4236 100644
--- a/ndb/src/common/transporter/TransporterRegistry.cpp
+++ b/ndb/src/common/transporter/TransporterRegistry.cpp
@@ -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);
}
diff --git a/ndb/src/kernel/error/ErrorReporter.cpp b/ndb/src/kernel/error/ErrorReporter.cpp
index 20a9dd8a993..f1320c44e09 100644
--- a/ndb/src/kernel/error/ErrorReporter.cpp
+++ b/ndb/src/kernel/error/ErrorReporter.cpp
@@ -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];
+
+ char *file_name= NdbConfig_NextTraceFileName(globalData.ownId);
+ NdbAutoPtr<char> tmp_aptr(file_name);
- NdbConfig_HomePath(fileNameBuf, 255);
- strncat(fileNameBuf, "NextTraceFileNo.log", 255);
/*
* 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. */
diff --git a/ndb/src/kernel/error/ErrorReporter.hpp b/ndb/src/kernel/error/ErrorReporter.hpp
index b43b30f1873..3e2551d2056 100644
--- a/ndb/src/kernel/error/ErrorReporter.hpp
+++ b/ndb/src/kernel/error/ErrorReporter.hpp
@@ -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();
diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp
index d2137a63c4d..e6c08b1b96f 100644
--- a/ndb/src/kernel/main.cpp
+++ b/ndb/src/kernel/main.cpp
@@ -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);
diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp
index c97ad951cf3..776780dc05d 100644
--- a/ndb/src/kernel/vm/Configuration.cpp
+++ b/ndb/src/kernel/vm/Configuration.cpp
@@ -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);
diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp
index 1706ad05867..ec5e8b371b1 100644
--- a/ndb/src/kernel/vm/Configuration.hpp
+++ b/ndb/src/kernel/vm/Configuration.hpp
@@ -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
*/
diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp
index 2dcadf9369d..5aefd4609b1 100644
--- a/ndb/src/mgmclient/main.cpp
+++ b/ndb/src/mgmclient/main.cpp
@@ -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;
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index fd1c704e707..1a5a4d1a877 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -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,10 +242,9 @@ 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
diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp
index d78ea369823..ed0711f4765 100644
--- a/ndb/src/mgmsrv/Services.cpp
+++ b/ndb/src/mgmsrv/Services.cpp
@@ -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;
}
diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp
index 1f675e63b84..c546d142810 100644
--- a/ndb/src/mgmsrv/main.cpp
+++ b/ndb/src/mgmsrv/main.cpp
@@ -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;
diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp
index dea7b1e4bec..bc15c7ecf85 100644
--- a/ndb/src/ndbapi/TransporterFacade.cpp
+++ b/ndb/src/ndbapi/TransporterFacade.cpp
@@ -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
diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp
index e6720f7de2e..ea17a7e0b8c 100644
--- a/ndb/src/ndbapi/TransporterFacade.hpp
+++ b/ndb/src/ndbapi/TransporterFacade.hpp
@@ -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;