summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/ndb_config.result5
-rw-r--r--mysql-test/std_data/ndb_config_mycnf2.cnf31
-rw-r--r--mysql-test/t/ndb_config.test5
-rw-r--r--ndb/include/mgmapi/mgmapi_config_parameters.h1
-rw-r--r--ndb/src/common/mgmcommon/IPCConfig.cpp24
-rw-r--r--ndb/src/mgmsrv/ConfigInfo.cpp345
-rw-r--r--ndb/src/mgmsrv/InitConfigFileParser.cpp11
-rw-r--r--ndb/tools/ndb_config.cpp103
8 files changed, 246 insertions, 279 deletions
diff --git a/mysql-test/r/ndb_config.result b/mysql-test/r/ndb_config.result
index 629d37f1e5e..9ca7ab5bf3a 100644
--- a/mysql-test/r/ndb_config.result
+++ b/mysql-test/r/ndb_config.result
@@ -5,3 +5,8 @@ ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysql
1 2
ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysqld,6, mysqld,7,
ndbd,1,localhost,52428800,26214400 ndbd,2,localhost,52428800,36700160 ndbd,3,localhost,52428800,52428800 ndbd,4,localhost,52428800,52428800 ndb_mgmd,5,localhost,, mysqld,6,localhost,,
+ndbd,1,localhost ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndb_mgmd,5,localhost mysqld,6, mysqld,7, mysqld,8, mysqld,9, mysqld,10,
+Cluster configuration warning line 0: Could not use next node id 2 for section [API], using next unused node id 7.
+ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndb_mgmd,6,localhost mysqld,1, mysqld,7, mysqld,8, mysqld,9, mysqld,10,
+ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndbd,6,localhost ndb_mgmd,1,localhost ndb_mgmd,2,localhost mysqld,11, mysqld,12, mysqld,13, mysqld,14, mysqld,15,
+shm,3,4,35,3 shm,3,5,35,3 shm,3,6,35,3 shm,4,5,35,4 shm,4,6,35,4 shm,5,6,35,5 tcp,11,3,55,3 tcp,11,4,55,4 tcp,11,5,55,5 tcp,11,6,55,6 tcp,12,3,55,3 tcp,12,4,55,4 tcp,12,5,55,5 tcp,12,6,55,6 tcp,13,3,55,3 tcp,13,4,55,4 tcp,13,5,55,5 tcp,13,6,55,6 tcp,14,3,55,3 tcp,14,4,55,4 tcp,14,5,55,5 tcp,14,6,55,6 tcp,15,3,55,3 tcp,15,4,55,4 tcp,15,5,55,5 tcp,15,6,55,6 tcp,1,3,55,1 tcp,1,4,55,1 tcp,1,5,55,1 tcp,1,6,55,1 tcp,2,3,55,2 tcp,2,4,55,2 tcp,2,5,55,2 tcp,2,6,55,2
diff --git a/mysql-test/std_data/ndb_config_mycnf2.cnf b/mysql-test/std_data/ndb_config_mycnf2.cnf
new file mode 100644
index 00000000000..3bf6b9a1194
--- /dev/null
+++ b/mysql-test/std_data/ndb_config_mycnf2.cnf
@@ -0,0 +1,31 @@
+#
+# Testing automatic node id generation
+#
+[cluster_config]
+NoOfReplicas=2
+Signum=39
+
+[cluster_config.cluster0]
+ndbd = localhost,localhost,localhost,localhost
+ndb_mgmd = localhost
+mysqld = ,,,,
+
+[cluster_config.cluster1]
+ndbd = localhost,localhost,localhost,localhost
+ndb_mgmd = localhost
+mysqld = ,,,,
+[cluster_config.ndbd.1.cluster1]
+NodeId=2
+[cluster_config.mysqld.1.cluster1]
+NodeId=1
+
+[cluster_config.cluster2]
+ndbd = localhost,localhost,localhost,localhost
+ndb_mgmd = localhost,localhost
+mysqld = ,,,,
+[cluster_config.mysqld.1.cluster2]
+NodeId=11
+[cluster_config.ndb_mgmd.1.cluster2]
+NodeId=1
+[cluster_config.ndbd.1.cluster2]
+NodeId=3
diff --git a/mysql-test/t/ndb_config.test b/mysql-test/t/ndb_config.test
index 9d1c107472f..e40e89d76bd 100644
--- a/mysql-test/t/ndb_config.test
+++ b/mysql-test/t/ndb_config.test
@@ -11,3 +11,8 @@
# End of 4.1 tests
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.jonas --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf1.cnf --query=type,nodeid,host,IndexMemory,DataMemory --mycnf 2> /dev/null
+
+--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster0 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
+--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster1 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
+--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
+--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null
diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h
index 8f95e159b38..41516b1c3e4 100644
--- a/ndb/include/mgmapi/mgmapi_config_parameters.h
+++ b/ndb/include/mgmapi/mgmapi_config_parameters.h
@@ -116,6 +116,7 @@
#define CFG_CONNECTION_HOSTNAME_1 407
#define CFG_CONNECTION_HOSTNAME_2 408
#define CFG_CONNECTION_GROUP 409
+#define CFG_CONNECTION_NODE_ID_SERVER 410
#define CFG_TCP_SERVER 452
#define CFG_TCP_SEND_BUFFER_SIZE 454
diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp
index f935f8ffab4..bc442ffc3ef 100644
--- a/ndb/src/common/mgmcommon/IPCConfig.cpp
+++ b/ndb/src/common/mgmcommon/IPCConfig.cpp
@@ -231,8 +231,11 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32 server_port= 0;
if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port)) break;
+ Uint32 nodeIdServer= 0;
+ if(iter.get(CFG_CONNECTION_NODE_ID_SERVER, &nodeIdServer)) break;
+
/*
- We check the node type. MGM node becomes server.
+ We check the node type.
*/
Uint32 node1type, node2type;
ndb_mgm_configuration_iterator node1iter(config, CFG_SECTION_NODE);
@@ -242,20 +245,12 @@ IPCConfig::configureTransporters(Uint32 nodeId,
node1iter.get(CFG_TYPE_OF_SECTION,&node1type);
node2iter.get(CFG_TYPE_OF_SECTION,&node2type);
- conf.serverNodeId= (nodeId1 < nodeId2)? nodeId1:nodeId2;
-
- conf.isMgmConnection= false;
- if(node2type==NODE_TYPE_MGM)
- {
- conf.isMgmConnection= true;
- conf.serverNodeId= nodeId2;
- }
- else if(node1type==NODE_TYPE_MGM)
- {
+ if(node1type==NODE_TYPE_MGM || node2type==NODE_TYPE_MGM)
conf.isMgmConnection= true;
- conf.serverNodeId= nodeId1;
- }
- else if (nodeId == conf.serverNodeId) {
+ else
+ conf.isMgmConnection= false;
+
+ if (nodeId == nodeIdServer && !conf.isMgmConnection) {
tr.add_transporter_interface(remoteNodeId, localHostName, server_port);
}
@@ -279,6 +274,7 @@ IPCConfig::configureTransporters(Uint32 nodeId,
conf.s_port = server_port;
conf.localHostName = localHostName;
conf.remoteHostName = remoteHostName;
+ conf.serverNodeId = nodeIdServer;
switch(type){
case CONNECTION_TYPE_SHM:
diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp
index 98e5744fe32..47f513e2d1d 100644
--- a/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -57,7 +57,6 @@ ConfigInfo::m_sectionNameAliases[]={
const char*
ConfigInfo::m_sectionNames[]={
"SYSTEM",
- "EXTERNAL SYSTEM",
"COMPUTER",
DB_TOKEN,
@@ -78,9 +77,7 @@ sizeof(m_sectionNames)/sizeof(char*);
****************************************************************************/
static bool transformComputer(InitConfigFileParser::Context & ctx, const char *);
static bool transformSystem(InitConfigFileParser::Context & ctx, const char *);
-static bool transformExternalSystem(InitConfigFileParser::Context & ctx, const char *);
static bool transformNode(InitConfigFileParser::Context & ctx, const char *);
-static bool transformExtNode(InitConfigFileParser::Context & ctx, const char *);
static bool checkConnectionSupport(InitConfigFileParser::Context & ctx, const char *);
static bool transformConnection(InitConfigFileParser::Context & ctx, const char *);
static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *);
@@ -93,7 +90,6 @@ static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *);
static bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data);
static bool fixHostname(InitConfigFileParser::Context & ctx, const char * data);
static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data);
-static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data);
static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *);
static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *);
static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data);
@@ -104,7 +100,6 @@ static bool checkLocalhostHostnameMix(InitConfigFileParser::Context & ctx, const
const ConfigInfo::SectionRule
ConfigInfo::m_SectionRules[] = {
{ "SYSTEM", transformSystem, 0 },
- { "EXTERNAL SYSTEM", transformExternalSystem, 0 },
{ "COMPUTER", transformComputer, 0 },
{ DB_TOKEN, transformNode, 0 },
@@ -151,14 +146,6 @@ ConfigInfo::m_SectionRules[] = {
{ "SHM", fixPortNumber, 0 }, // has to come after fixHostName
{ "SCI", fixPortNumber, 0 }, // has to come after fixHostName
- /**
- * fixExtConnection must be after fixNodeId
- */
- { "TCP", fixExtConnection, 0 },
- { "SHM", fixExtConnection, 0 },
- { "SCI", fixExtConnection, 0 },
- { "OSE", fixExtConnection, 0 },
-
{ "*", applyDefaultValues, "user" },
{ "*", fixDepricated, 0 },
{ "*", applyDefaultValues, "system" },
@@ -174,9 +161,6 @@ ConfigInfo::m_SectionRules[] = {
{ DB_TOKEN, checkDbConstraints, 0 },
- /**
- * checkConnectionConstraints must be after fixExtConnection
- */
{ "TCP", checkConnectionConstraints, 0 },
{ "SHM", checkConnectionConstraints, 0 },
{ "SCI", checkConnectionConstraints, 0 },
@@ -214,9 +198,6 @@ static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx,
const char * rule_data);
-static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
- struct InitConfigFileParser::Context &ctx,
- const char * rule_data);
static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx,
const char * rule_data);
@@ -226,7 +207,6 @@ ConfigInfo::m_ConfigRules[] = {
{ sanity_checks, 0 },
{ add_node_connections, 0 },
{ set_connection_priorities, 0 },
- { add_server_ports, 0 },
{ check_node_vs_replicas, 0 },
{ 0, 0 }
};
@@ -242,9 +222,9 @@ struct DepricationTransform {
static
const DepricationTransform f_deprication[] = {
{ DB_TOKEN, "Discless", "Diskless", 0, 1 },
- { DB_TOKEN, "Id", "nodeid", 0, 1 },
- { API_TOKEN, "Id", "nodeid", 0, 1 },
- { MGM_TOKEN, "Id", "nodeid", 0, 1 },
+ { DB_TOKEN, "Id", "NodeId", 0, 1 },
+ { API_TOKEN, "Id", "NodeId", 0, 1 },
+ { MGM_TOKEN, "Id", "NodeId", 0, 1 },
{ 0, 0, 0, 0, 0}
};
@@ -422,7 +402,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
{
CFG_NODE_ID,
- "nodeid",
+ "NodeId",
DB_TOKEN,
"Number identifying the database node ("DB_TOKEN_PRINT")",
ConfigInfo::CI_USED,
@@ -1273,7 +1253,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
{
CFG_NODE_ID,
- "nodeid",
+ "NodeId",
API_TOKEN,
"Number identifying application node ("API_TOKEN_PRINT")",
ConfigInfo::CI_USED,
@@ -1416,7 +1396,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
{
CFG_NODE_ID,
- "nodeid",
+ "NodeId",
MGM_TOKEN,
"Number identifying the management server node ("MGM_TOKEN_PRINT")",
ConfigInfo::CI_USED,
@@ -1579,6 +1559,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0", "200" },
{
+ CFG_CONNECTION_NODE_ID_SERVER,
+ "NodeIdServer",
+ "TCP",
+ "",
+ ConfigInfo::CI_USED,
+ false,
+ ConfigInfo::CI_INT,
+ MANDATORY,
+ "1", "63" },
+
+ {
CFG_CONNECTION_SEND_SIGNAL_ID,
"SendSignalId",
"TCP",
@@ -1767,6 +1758,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0", "200" },
{
+ CFG_CONNECTION_NODE_ID_SERVER,
+ "NodeIdServer",
+ "SHM",
+ "",
+ ConfigInfo::CI_USED,
+ false,
+ ConfigInfo::CI_INT,
+ MANDATORY,
+ "1", "63" },
+
+ {
CFG_CONNECTION_SEND_SIGNAL_ID,
"SendSignalId",
"SHM",
@@ -1888,6 +1890,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0", "200" },
{
+ CFG_CONNECTION_NODE_ID_SERVER,
+ "NodeIdServer",
+ "SCI",
+ "",
+ ConfigInfo::CI_USED,
+ false,
+ ConfigInfo::CI_INT,
+ MANDATORY,
+ "1", "63" },
+
+ {
CFG_CONNECTION_HOSTNAME_1,
"HostName1",
"SCI",
@@ -2555,29 +2568,32 @@ void ConfigInfo::print(const Properties * section,
bool
transformNode(InitConfigFileParser::Context & ctx, const char * data){
- Uint32 id;
- if(!ctx.m_currentSection->get("nodeid", &id) && !ctx.m_currentSection->get("Id", &id)){
+ Uint32 id, line;
+ if(!ctx.m_currentSection->get("NodeId", &id) && !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))
+ while (ctx.m_userProperties.get("AllocatedNodeId_", id, &line))
id++;
- ctx.m_userProperties.put("NextNodeId", id+1, true);
- ctx.m_currentSection->put("nodeid", 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)) {
+ if (id != nextNodeId)
+ {
+ ndbout_c("Cluster configuration warning line %d: "
+ "Could not use next node id %d for section [%s], "
+ "using next unused node id %d.",
+ ctx.m_sectionLineno, nextNodeId, ctx.fname, id);
+ }
+ ctx.m_currentSection->put("NodeId", id);
+ } else if(ctx.m_userProperties.get("AllocatedNodeId_", id, &line)) {
ctx.reportError("Duplicate nodeid in section "
- "[%s] starting at line: %d",
- ctx.fname, ctx.m_sectionLineno);
+ "[%s] starting at line: %d. Previously used on line %d.",
+ ctx.fname, ctx.m_sectionLineno, line);
return false;
}
- ctx.m_userProperties.put("AllocatedNodeId_", id, id);
+ // next node id _always_ next numbers after last used id
+ ctx.m_userProperties.put("NextNodeId", id+1, true);
+
+ ctx.m_userProperties.put("AllocatedNodeId_", id, ctx.m_sectionLineno);
BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Node_%d", id);
ctx.m_currentSection->put("Type", ctx.fname);
@@ -2691,38 +2707,6 @@ fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){
return false;
}
-bool
-transformExtNode(InitConfigFileParser::Context & ctx, const char * data){
-
- Uint32 id;
- const char * systemName;
-
- if(!ctx.m_currentSection->get("Id", &id)){
- ctx.reportError("Mandatory parameter 'Id' missing from section "
- "[%s] starting at line: %d",
- ctx.fname, ctx.m_sectionLineno);
- return false;
- }
-
- if(!ctx.m_currentSection->get("System", &systemName)){
- ctx.reportError("Mandatory parameter 'System' missing from section "
- "[%s] starting at line: %d",
- ctx.fname, ctx.m_sectionLineno);
- return false;
- }
-
- ctx.m_currentSection->put("Type", ctx.fname);
-
- Uint32 nodes = 0;
- ctx.m_userProperties.get("ExtNoOfNodes", &nodes);
- require(ctx.m_userProperties.put("ExtNoOfNodes",++nodes, true));
-
- BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s:Node_%d",
- systemName, id);
-
- return true;
-}
-
/**
* Connection rule: Check support of connection
*/
@@ -2799,23 +2783,6 @@ transformSystem(InitConfigFileParser::Context & ctx, const char * data){
}
/**
- * External system rule: Just add it
- */
-bool
-transformExternalSystem(InitConfigFileParser::Context & ctx, const char * data){
- const char * name;
- if(!ctx.m_currentSection->get("Name", &name)){
- ctx.reportError("Mandatory parameter Name missing from section "
- "[%s] starting at line: %d",
- ctx.fname, ctx.m_sectionLineno);
- return false;
- }
- BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "EXTERNAL SYSTEM_%s", name);
-
- return true;
-}
-
-/**
* Computer rule: Update "NoOfComputers", add "Type"
*/
bool
@@ -2991,87 +2958,6 @@ static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
}
/**
- * @returns true if connection is external (one node is external)
- * Also returns:
- * - name of external system in parameter extSystemName, and
- * - nodeId of external node in parameter extSystemNodeId.
- */
-static bool
-isExtConnection(InitConfigFileParser::Context & ctx,
- const char **extSystemName, Uint32 * extSystemNodeId){
-
- Uint32 nodeId1, nodeId2;
-
- if (ctx.m_currentSection->contains("System1") &&
- ctx.m_currentSection->get("System1", extSystemName) &&
- ctx.m_currentSection->get("NodeId1", &nodeId1)) {
- *extSystemNodeId = nodeId1;
- return true;
- }
-
- if (ctx.m_currentSection->contains("System2") &&
- ctx.m_currentSection->get("System2", extSystemName) &&
- ctx.m_currentSection->get("NodeId2", &nodeId2)) {
- *extSystemNodeId = nodeId2;
- return true;
- }
-
- return false;
-}
-
-/**
- * External Connection Rule:
- * If connection is to an external system, then move connection into
- * external system configuration (i.e. a sub-property).
- */
-static bool
-fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){
-
- const char * extSystemName;
- Uint32 extSystemNodeId;
-
- if (isExtConnection(ctx, &extSystemName, &extSystemNodeId)) {
-
- Uint32 connections = 0;
- ctx.m_userProperties.get("ExtNoOfConnections", &connections);
- require(ctx.m_userProperties.put("ExtNoOfConnections",++connections, true));
-
- char tmpLine1[MAX_LINE_LENGTH];
- BaseString::snprintf(tmpLine1, MAX_LINE_LENGTH, "Connection_%d", connections-1);
-
- /**
- * Section: EXTERNAL SYSTEM_<Ext System Name>
- */
- char extSystemPropName[MAX_LINE_LENGTH];
- strncpy(extSystemPropName, "EXTERNAL SYSTEM_", MAX_LINE_LENGTH);
- strncat(extSystemPropName, extSystemName, MAX_LINE_LENGTH);
- strncat(extSystemPropName, ":", MAX_LINE_LENGTH);
- strncat(extSystemPropName, tmpLine1, MAX_LINE_LENGTH);
-
- /**
- * Increase number of external connections for the system
- *
- * @todo Limitation: Only one external system is allowed
- */
- require(ctx.m_userProperties.put("ExtSystem", extSystemName, true));
-
- /**
- * Make sure section is stored in right place
- */
- strncpy(ctx.pname, extSystemPropName, MAX_LINE_LENGTH);
-
- /**
- * Since this is an external connection,
- * decrease number of internal connections
- */
- require(ctx.m_userProperties.get("NoOfConnections", &connections));
- require(ctx.m_userProperties.put("NoOfConnections", --connections, true));
- }
-
- return true;
-}
-
-/**
* Connection rule: Fix hostname
*
* Unless Hostname is not already specified, do steps:
@@ -3113,7 +2999,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
DBUG_ENTER("fixPortNumber");
- Uint32 id1= 0, id2= 0;
+ Uint32 id1, id2;
const char *hostName1;
const char *hostName2;
require(ctx.m_currentSection->get("NodeId1", &id1));
@@ -3123,17 +3009,46 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
DBUG_PRINT("info",("NodeId1=%d HostName1=\"%s\"",id1,hostName1));
DBUG_PRINT("info",("NodeId2=%d HostName2=\"%s\"",id2,hostName2));
- if (id1 > id2) {
- Uint32 tmp= id1;
- const char *tmp_name= hostName1;
- hostName1= hostName2;
- id1= id2;
- hostName2= tmp_name;
- id2= tmp;
- }
+ const Properties *node1, *node2;
+ require(ctx.m_config->get("Node", id1, &node1));
+ require(ctx.m_config->get("Node", id2, &node2));
- const Properties * node;
- require(ctx.m_config->get("Node", id1, &node));
+ const char *type1, *type2;
+ require(node1->get("Type", &type1));
+ require(node2->get("Type", &type2));
+
+ /* add NodeIdServer info */
+ {
+ Uint32 nodeIdServer = id1 < id2 ? id1 : id2;
+ if(strcmp(type1, API_TOKEN) == 0 || strcmp(type2, MGM_TOKEN) == 0)
+ nodeIdServer = id2;
+ else if(strcmp(type2, API_TOKEN) == 0 || strcmp(type1, MGM_TOKEN) == 0)
+ nodeIdServer = id1;
+ ctx.m_currentSection->put("NodeIdServer", nodeIdServer);
+
+ if (id2 == nodeIdServer) {
+ {
+ const char *tmp= hostName1;
+ hostName1= hostName2;
+ hostName2= tmp;
+ }
+ {
+ Uint32 tmp= id1;
+ id1= id2;
+ id2= tmp;
+ }
+ {
+ const Properties *tmp= node1;
+ node1= node2;
+ node2= tmp;
+ }
+ {
+ const char *tmp= type1;
+ type1= type2;
+ type2= tmp;
+ }
+ }
+ }
BaseString hostname(hostName1);
@@ -3144,21 +3059,13 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
}
Uint32 port= 0;
- const char * type1;
- const char * type2;
- const Properties * node2;
-
- node->get("Type", &type1);
- ctx.m_config->get("Node", id2, &node2);
- node2->get("Type", &type2);
-
if(strcmp(type1, MGM_TOKEN)==0)
- node->get("PortNumber",&port);
+ node1->get("PortNumber",&port);
else if(strcmp(type2, MGM_TOKEN)==0)
node2->get("PortNumber",&port);
if (!port &&
- !node->get("ServerPort", &port) &&
+ !node1->get("ServerPort", &port) &&
!ctx.m_userProperties.get("ServerPort_", id1, &port))
{
Uint32 base= 0;
@@ -3309,11 +3216,6 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){
ctx.m_currentSection->get("NodeId1", &id1);
ctx.m_currentSection->get("NodeId2", &id2);
- // If external connection, just accept it
- if (ctx.m_currentSection->contains("System1") ||
- ctx.m_currentSection->contains("System2"))
- return true;
-
if(id1 == id2){
ctx.reportError("Illegal connection from node to itself"
" - [%s] starting at line: %d",
@@ -3346,12 +3248,10 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){
* Report error if the following are true
* -# None of the nodes is of type DB
* -# Not both of them are MGMs
- * -# None of them contain a "SystemX" name
*/
if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) &&
- !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0) &&
- !ctx.m_currentSection->contains("System1") &&
- !ctx.m_currentSection->contains("System2")){
+ !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0))
+ {
ctx.reportError("Invalid connection between node %d (%s) and node %d (%s)"
" - [%s] starting at line: %d",
id1, type1, id2, type2,
@@ -3441,11 +3341,11 @@ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
if(strcmp(p->m_section, ctx.fname) == 0){
double mul = p->m_mul;
double add = p->m_add;
- if(strcmp(name, p->m_oldName) == 0){
+ if(strcasecmp(name, p->m_oldName) == 0){
if(!transform(ctx, tmp, name, p->m_newName, add, mul)){
return false;
}
- } else if(strcmp(name, p->m_newName) == 0) {
+ } else if(strcasecmp(name, p->m_newName) == 0) {
if(!transform(ctx, tmp, name, p->m_oldName, -add/mul,1.0/mul)){
return false;
}
@@ -3724,45 +3624,6 @@ static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sect
DBUG_RETURN(true);
}
-static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
- struct InitConfigFileParser::Context &ctx,
- const char * rule_data)
-{
-#if 0
- Properties * props= ctx.m_config;
- Properties computers(true);
- Uint32 port_base = NDB_TCP_BASE_PORT;
-
- Uint32 nNodes;
- ctx.m_userProperties.get("NoOfNodes", &nNodes);
-
- for (Uint32 i= 0, n= 0; n < nNodes; i++){
- Properties * tmp;
- if(!props->get("Node", i, &tmp)) continue;
- n++;
-
- const char * type;
- if(!tmp->get("Type", &type)) continue;
-
- Uint32 port;
- if (tmp->get("ServerPort", &port)) continue;
-
- Uint32 computer;
- if (!tmp->get("ExecuteOnComputer", &computer)) continue;
-
- Uint32 adder= 0;
- computers.get("",computer, &adder);
-
- if (strcmp(type,DB_TOKEN) == 0) {
- adder++;
- tmp->put("ServerPort", port_base+adder);
- computers.put("",computer, adder);
- }
- }
-#endif
- return true;
-}
-
static bool
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx,
diff --git a/ndb/src/mgmsrv/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp
index f643349a493..f937daf8620 100644
--- a/ndb/src/mgmsrv/InitConfigFileParser.cpp
+++ b/ndb/src/mgmsrv/InitConfigFileParser.cpp
@@ -640,7 +640,7 @@ InitConfigFileParser::store_in_properties(Vector<struct my_option>& options,
value_int = *(Uint64*)options[i].value;
break;
case GET_STR:
- ctx.m_currentSection->put(options[i].name, (char*)options[i].value);
+ ctx.m_currentSection->put(options[i].name, *(char**)options[i].value);
continue;
default:
abort();
@@ -762,9 +762,6 @@ InitConfigFileParser::parse_mycnf()
Vector<struct my_option> options;
for(i = 0; i<ConfigInfo::m_NoOfParams; i++)
{
- if (strcmp(ConfigInfo::m_ParamInfo[i]._section, "DB") == 0 ||
- strcmp(ConfigInfo::m_ParamInfo[i]._section, "API") == 0 ||
- strcmp(ConfigInfo::m_ParamInfo[i]._section, "MGM") == 0)
{
struct my_option opt;
bzero(&opt, sizeof(opt));
@@ -855,6 +852,12 @@ InitConfigFileParser::parse_mycnf()
goto end;
if(!handle_mycnf_defaults(options, ctx, "MGM"))
goto end;
+ if(!handle_mycnf_defaults(options, ctx, "TCP"))
+ goto end;
+ if(!handle_mycnf_defaults(options, ctx, "SHM"))
+ goto end;
+ if(!handle_mycnf_defaults(options, ctx, "SCI"))
+ goto end;
{
struct sect { struct my_option* src; const char * name; } sections[] =
diff --git a/ndb/tools/ndb_config.cpp b/ndb/tools/ndb_config.cpp
index 1b9a771f243..b4eacd34f8e 100644
--- a/ndb/tools/ndb_config.cpp
+++ b/ndb/tools/ndb_config.cpp
@@ -33,7 +33,7 @@
static int g_verbose = 0;
static int try_reconnect = 3;
-static int g_nodes = 1;
+static int g_nodes, g_connections, g_section;
static const char * g_connectstring = 0;
static const char * g_query = 0;
@@ -70,13 +70,19 @@ static struct my_option my_long_options[] =
"Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg",
(gptr*) &g_connectstring, (gptr*) &g_connectstring,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "ndb-shm", 256, "Print nodes",
+ (gptr*) &opt_ndb_shm, (gptr*) &opt_ndb_shm,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "nodes", 256, "Print nodes",
(gptr*) &g_nodes, (gptr*) &g_nodes,
- 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { "connections", 256, "Print connections",
+ (gptr*) &g_connections, (gptr*) &g_connections,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "query", 'q', "Query option(s)",
(gptr*) &g_query, (gptr*) &g_query,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- { "host", 257, "Host",
+ { "host", 256, "Host",
(gptr*) &g_host, (gptr*) &g_host,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "type", 258, "Type of node/connection",
@@ -155,6 +161,11 @@ struct NodeTypeApply : public Apply
virtual int apply(const Iter&);
};
+struct ConnectionTypeApply : public Apply
+{
+ virtual int apply(const Iter&);
+};
+
static int parse_query(Vector<Apply*>&, int &argc, char**& argv);
static int parse_where(Vector<Match*>&, int &argc, char**& argv);
static int eval(const Iter&, const Vector<Match*>&);
@@ -172,6 +183,15 @@ main(int argc, char** argv){
ndb_std_get_one_option)))
return -1;
+ if (g_nodes && g_connections)
+ {
+ ndbout_c("Only one option of --nodes and --connections allowed");
+ }
+
+ g_section = CFG_SECTION_NODE; //default
+ if (g_connections)
+ g_section = CFG_SECTION_CONNECTION;
+
ndb_mgm_configuration * conf = 0;
if (g_config_file || g_mycnf)
@@ -202,7 +222,7 @@ main(int argc, char** argv){
exit(0);
}
- Iter iter(* conf, CFG_SECTION_NODE);
+ Iter iter(* conf, g_section);
bool prev= false;
iter.first();
for(iter.first(); iter.valid(); iter.next())
@@ -231,13 +251,32 @@ parse_query(Vector<Apply*>& select, int &argc, char**& argv)
for(unsigned i = 0; i<list.size(); i++)
{
const char * str= list[i].c_str();
- if(strcasecmp(str, "id") == 0 || strcasecmp(str, "nodeid") == 0)
- select.push_back(new Apply(CFG_NODE_ID));
- else if(strncasecmp(str, "host", 4) == 0)
- select.push_back(new Apply(CFG_NODE_HOST));
- else if(strcasecmp(str, "type") == 0)
- select.push_back(new NodeTypeApply());
- else if(g_nodes)
+ if(g_section == CFG_SECTION_NODE)
+ {
+ if(strcasecmp(str, "id") == 0 || strcasecmp(str, "nodeid") == 0)
+ {
+ select.push_back(new Apply(CFG_NODE_ID));
+ continue;
+ }
+ else if(strncasecmp(str, "host", 4) == 0)
+ {
+ select.push_back(new Apply(CFG_NODE_HOST));
+ continue;
+ }
+ else if(strcasecmp(str, "type") == 0)
+ {
+ select.push_back(new NodeTypeApply());
+ continue;
+ }
+ }
+ else if (g_section == CFG_SECTION_CONNECTION)
+ {
+ if(strcasecmp(str, "type") == 0)
+ {
+ select.push_back(new ConnectionTypeApply());
+ continue;
+ }
+ }
{
bool found = false;
for(int p = 0; p<ConfigInfo::m_NoOfParams; p++)
@@ -245,9 +284,15 @@ parse_query(Vector<Apply*>& select, int &argc, char**& argv)
if(0)ndbout_c("%s %s",
ConfigInfo::m_ParamInfo[p]._section,
ConfigInfo::m_ParamInfo[p]._fname);
- if(strcmp(ConfigInfo::m_ParamInfo[p]._section, "DB") == 0 ||
- strcmp(ConfigInfo::m_ParamInfo[p]._section, "API") == 0 ||
- strcmp(ConfigInfo::m_ParamInfo[p]._section, "MGM") == 0)
+ if(g_section == CFG_SECTION_CONNECTION &&
+ (strcmp(ConfigInfo::m_ParamInfo[p]._section, "TCP") == 0 ||
+ strcmp(ConfigInfo::m_ParamInfo[p]._section, "SCI") == 0 ||
+ strcmp(ConfigInfo::m_ParamInfo[p]._section, "SHM") == 0)
+ ||
+ g_section == CFG_SECTION_NODE &&
+ (strcmp(ConfigInfo::m_ParamInfo[p]._section, "DB") == 0 ||
+ strcmp(ConfigInfo::m_ParamInfo[p]._section, "API") == 0 ||
+ strcmp(ConfigInfo::m_ParamInfo[p]._section, "MGM") == 0))
{
if(strcasecmp(ConfigInfo::m_ParamInfo[p]._fname, str) == 0)
{
@@ -263,11 +308,6 @@ parse_query(Vector<Apply*>& select, int &argc, char**& argv)
return 1;
}
}
- else
- {
- fprintf(stderr, "Unknown query option: %s\n", str);
- return 1;
- }
}
}
return 0;
@@ -425,6 +465,31 @@ NodeTypeApply::apply(const Iter& iter)
return 0;
}
+int
+ConnectionTypeApply::apply(const Iter& iter)
+{
+ Uint32 val32;
+ if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
+ {
+ switch (val32)
+ {
+ case CONNECTION_TYPE_TCP:
+ printf("tcp");
+ break;
+ case CONNECTION_TYPE_SCI:
+ printf("sci");
+ break;
+ case CONNECTION_TYPE_SHM:
+ printf("shm");
+ break;
+ default:
+ printf("<unknown>");
+ break;
+ }
+ }
+ return 0;
+}
+
ndb_mgm_configuration*
fetch_configuration()
{