Commit 983cad51 authored by unknown's avatar unknown

Bug #13009 No gaps allowed in node id number sequence

+ some small bugfixes in ndb_config
+ extending ndb_config to print connections and take shm option

parent e0fd72c9
......@@ -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
#
# 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
......@@ -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
......@@ -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
......
......@@ -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:
......
This diff is collapsed.
......@@ -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[] =
......
......@@ -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()
{
......
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