Commit f02ebd6f authored by joreland@mysql.com's avatar joreland@mysql.com

bug#5128 - remove need of unique fs-path

bug#4761 - more validation of hosts
bug#4511 - only non depricated should be saved in config
         - fix ConfigInfo::BOOL w.r.t deprication
parent a3c99571
...@@ -5,6 +5,7 @@ DataMemory: CHOOSE_DataMemory ...@@ -5,6 +5,7 @@ DataMemory: CHOOSE_DataMemory
IndexMemory: CHOOSE_IndexMemory IndexMemory: CHOOSE_IndexMemory
Diskless: CHOOSE_Diskless Diskless: CHOOSE_Diskless
TimeBetweenWatchDogCheck: 30000 TimeBetweenWatchDogCheck: 30000
FileSystemPath: CHOOSE_FILESYSTEM
[COMPUTER] [COMPUTER]
Id: 1 Id: 1
...@@ -16,11 +17,9 @@ HostName: CHOOSE_HOSTNAME_2 ...@@ -16,11 +17,9 @@ HostName: CHOOSE_HOSTNAME_2
[DB] [DB]
ExecuteOnComputer: 1 ExecuteOnComputer: 1
FileSystemPath: CHOOSE_FILESYSTEM_NODE_1
[DB] [DB]
ExecuteOnComputer: 2 ExecuteOnComputer: 2
FileSystemPath: CHOOSE_FILESYSTEM_NODE_2
[MGM] [MGM]
PortNumber: CHOOSE_PORT_MGM PortNumber: CHOOSE_PORT_MGM
......
...@@ -54,7 +54,7 @@ while test $# -gt 0; do ...@@ -54,7 +54,7 @@ while test $# -gt 0; do
stop_ndb=1 stop_ndb=1
;; ;;
--initial) --initial)
flags_ndb=$flags_ndb" -i" flags_ndb="$flags_ndb -i"
initial_ndb=1 initial_ndb=1
;; ;;
--status) --status)
...@@ -81,20 +81,18 @@ while test $# -gt 0; do ...@@ -81,20 +81,18 @@ while test $# -gt 0; do
shift shift
done done
fs_ndb=$fsdir/ndbcluster-$port_base fs_ndb="$fsdir/ndbcluster-$port_base"
fs_name_1=$fs_ndb/node-1-fs
fs_name_2=$fs_ndb/node-2-fs
NDB_HOME= NDB_HOME=
if [ ! -x $fsdir ]; then if [ ! -x "$fsdir" ]; then
echo "$fsdir missing" echo "$fsdir missing"
exit 1 exit 1
fi fi
if [ ! -x $exec_ndb ]; then if [ ! -x "$exec_ndb" ]; then
echo "$exec_ndb missing" echo "$exec_ndb missing"
exit 1 exit 1
fi fi
if [ ! -x $exec_mgmtsrvr ]; then if [ ! -x "$exec_mgmtsrvr" ]; then
echo "$exec_mgmtsrvr missing" echo "$exec_mgmtsrvr missing"
exit 1 exit 1
fi fi
...@@ -108,12 +106,10 @@ start_default_ndbcluster() { ...@@ -108,12 +106,10 @@ start_default_ndbcluster() {
# do some checks # do some checks
if [ $initial_ndb ] ; then if [ "$initial_ndb" ] ; then
[ -d $fs_ndb ] || mkdir $fs_ndb [ -d "$fs_ndb" ] || mkdir "$fs_ndb"
[ -d $fs_name_1 ] || mkdir $fs_name_1
[ -d $fs_name_2 ] || mkdir $fs_name_2
fi fi
if [ -d "$fs_ndb" -a -d "$fs_name_1" -a -d "$fs_name_2" ]; then :; else if [ -d "$fs_ndb" ]; then :; else
echo "$fs_ndb filesystem directory does not exist" echo "$fs_ndb filesystem directory does not exist"
exit 1 exit 1
fi fi
...@@ -128,42 +124,41 @@ port_transporter=`expr $ndb_mgmd_port + 2` ...@@ -128,42 +124,41 @@ port_transporter=`expr $ndb_mgmd_port + 2`
if [ $initial_ndb ] ; then if [ $initial_ndb ] ; then
sed \ sed \
-e s,"CHOOSE_MaxNoOfConcurrentOperations",$ndb_con_op,g \ -e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \
-e s,"CHOOSE_DataMemory",$ndb_dmem,g \ -e s,"CHOOSE_DataMemory","$ndb_dmem",g \
-e s,"CHOOSE_IndexMemory",$ndb_imem,g \ -e s,"CHOOSE_IndexMemory","$ndb_imem",g \
-e s,"CHOOSE_Diskless",$ndb_diskless,g \ -e s,"CHOOSE_Diskless","$ndb_diskless",g \
-e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \ -e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \
-e s,"CHOOSE_FILESYSTEM_NODE_1","$fs_name_1",g \ -e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \
-e s,"CHOOSE_FILESYSTEM_NODE_2","$fs_name_2",g \ -e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \
-e s,"CHOOSE_PORT_MGM",$ndb_mgmd_port,g \ -e s,"CHOOSE_PORT_TRANSPORTER","$port_transporter",g \
-e s,"CHOOSE_PORT_TRANSPORTER",$port_transporter,g \
< ndb/ndb_config_2_node.ini \ < ndb/ndb_config_2_node.ini \
> "$fs_ndb/config.ini" > "$fs_ndb/config.ini"
fi fi
rm -f $cfgfile 2>&1 | cat > /dev/null rm -f "$cfgfile" 2>&1 | cat > /dev/null
rm -f $fs_ndb/$cfgfile 2>&1 | cat > /dev/null rm -f "$fs_ndb/$cfgfile" 2>&1 | cat > /dev/null
if ( cd $fs_ndb ; $exec_mgmtsrvr -d -c config.ini ) ; then :; else if ( cd "$fs_ndb" ; $exec_mgmtsrvr -d -c config.ini ) ; then :; else
echo "Unable to start $exec_mgmtsrvr from `pwd`" echo "Unable to start $exec_mgmtsrvr from `pwd`"
exit 1 exit 1
fi fi
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node # Start database node
echo "Starting ndbd" echo "Starting ndbd"
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & ) ( cd "$fs_ndb" ; $exec_ndb -d $flags_ndb & )
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node # Start database node
echo "Starting ndbd" echo "Starting ndbd"
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & ) ( cd "$fs_ndb" ; $exec_ndb -d $flags_ndb & )
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# test if Ndb Cluster starts properly # test if Ndb Cluster starts properly
...@@ -173,7 +168,7 @@ if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else ...@@ -173,7 +168,7 @@ if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else
exit 1 exit 1
fi fi
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile cat `find "$fs_ndb" -name 'ndb_*.pid'` > $fs_ndb/$pidfile
status_ndbcluster status_ndbcluster
} }
...@@ -200,9 +195,9 @@ exec_mgmtclient="$exec_mgmtclient --try-reconnect=1" ...@@ -200,9 +195,9 @@ exec_mgmtclient="$exec_mgmtclient --try-reconnect=1"
echo "all stop" | $exec_mgmtclient 2>&1 | cat > /dev/null echo "all stop" | $exec_mgmtclient 2>&1 | cat > /dev/null
if [ -f $fs_ndb/$pidfile ] ; then if [ -f "$fs_ndb/$pidfile" ] ; then
kill -9 `cat $fs_ndb/$pidfile` 2> /dev/null kill -9 `cat "$fs_ndb/$pidfile"` 2> /dev/null
rm $fs_ndb/$pidfile rm "$fs_ndb/$pidfile"
fi fi
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <NdbTCP.h>
#include "ConfigInfo.hpp" #include "ConfigInfo.hpp"
#include <mgmapi_config_parameters.h> #include <mgmapi_config_parameters.h>
#include <ndb_limits.h> #include <ndb_limits.h>
...@@ -48,24 +49,25 @@ sizeof(m_sectionNames)/sizeof(char*); ...@@ -48,24 +49,25 @@ sizeof(m_sectionNames)/sizeof(char*);
/**************************************************************************** /****************************************************************************
* Section Rules declarations * Section Rules declarations
****************************************************************************/ ****************************************************************************/
bool transformComputer(InitConfigFileParser::Context & ctx, const char *); static bool transformComputer(InitConfigFileParser::Context & ctx, const char *);
bool transformSystem(InitConfigFileParser::Context & ctx, const char *); static bool transformSystem(InitConfigFileParser::Context & ctx, const char *);
bool transformExternalSystem(InitConfigFileParser::Context & ctx, const char *); static bool transformExternalSystem(InitConfigFileParser::Context & ctx, const char *);
bool transformNode(InitConfigFileParser::Context & ctx, const char *); static bool transformNode(InitConfigFileParser::Context & ctx, const char *);
bool transformExtNode(InitConfigFileParser::Context & ctx, const char *); static bool transformExtNode(InitConfigFileParser::Context & ctx, const char *);
bool transformConnection(InitConfigFileParser::Context & ctx, const char *); static bool transformConnection(InitConfigFileParser::Context & ctx, const char *);
bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *); static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *);
bool checkMandatory(InitConfigFileParser::Context & ctx, const char *); static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *);
bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *); static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *);
bool fixShmkey(InitConfigFileParser::Context & ctx, const char *); static bool fixShmkey(InitConfigFileParser::Context & ctx, const char *);
bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *); static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *);
bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *); static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *);
bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data); static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *);
bool fixHostname(InitConfigFileParser::Context & ctx, const char * data); static bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data);
bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data); static bool fixHostname(InitConfigFileParser::Context & ctx, const char * data);
bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data); static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data);
bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data);
bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *);
static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *);
const ConfigInfo::SectionRule const ConfigInfo::SectionRule
ConfigInfo::m_SectionRules[] = { ConfigInfo::m_SectionRules[] = {
...@@ -130,6 +132,8 @@ ConfigInfo::m_SectionRules[] = { ...@@ -130,6 +132,8 @@ ConfigInfo::m_SectionRules[] = {
{ "SCI", checkConnectionConstraints, 0 }, { "SCI", checkConnectionConstraints, 0 },
{ "OSE", checkConnectionConstraints, 0 }, { "OSE", checkConnectionConstraints, 0 },
{ "TCP", checkTCPConstraints, "HostName1" },
{ "TCP", checkTCPConstraints, "HostName2" },
{ "*", checkMandatory, 0 }, { "*", checkMandatory, 0 },
...@@ -148,13 +152,13 @@ const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule); ...@@ -148,13 +152,13 @@ const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);
/**************************************************************************** /****************************************************************************
* Config Rules declarations * Config Rules declarations
****************************************************************************/ ****************************************************************************/
bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
...@@ -812,7 +816,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -812,7 +816,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
1}, 1},
{ {
CFG_DB_DISCLESS, KEY_INTERNAL,
"Discless", "Discless",
"DB", "DB",
"Diskless", "Diskless",
...@@ -2219,22 +2223,13 @@ fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2219,22 +2223,13 @@ fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){
require(ctx.m_currentSection->put("HostName", "")); require(ctx.m_currentSection->put("HostName", ""));
const char * type; const char * type;
if(ctx.m_currentSection->get("Type", &type) && if(ctx.m_currentSection->get("Type", &type) && strcmp(type,"DB") == 0) {
strcmp(type,"DB") == 0) ctx.reportError("Parameter \"ExecuteOnComputer\" missing from DB section"
{ " [%s] starting at line: %d",
ctx.reportError("Parameter \"ExecuteOnComputer\" missing from DB section "
"[%s] starting at line: %d",
ctx.fname, ctx.m_sectionLineno); ctx.fname, ctx.m_sectionLineno);
return false; return false;
} }
return true; return true;
#if 0
ctx.reportError("Parameter \"ExecuteOnComputer\" missing from section "
"[%s] starting at line: %d",
ctx.fname, ctx.m_sectionLineno);
return false;
#endif
} }
const Properties * computer; const Properties * computer;
...@@ -2362,6 +2357,22 @@ transformComputer(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2362,6 +2357,22 @@ transformComputer(InitConfigFileParser::Context & ctx, const char * data){
ctx.m_userProperties.get("NoOfComputers", &computers); ctx.m_userProperties.get("NoOfComputers", &computers);
ctx.m_userProperties.put("NoOfComputers", ++computers, true); ctx.m_userProperties.put("NoOfComputers", ++computers, true);
const char * hostname = 0;
ctx.m_currentSection->get("HostName", &hostname);
if(!hostname){
return true;
}
if(!strcmp(hostname, "localhost") || !strcmp(hostname, "127.0.0.1")){
if(ctx.m_userProperties.get("$computer-localhost", &hostname)){
ctx.reportError("Mixing of localhost with other hostname(%s) is illegal",
hostname);
return false;
}
} else {
ctx.m_userProperties.put("$computer-localhost", hostname);
}
return true; return true;
} }
...@@ -2449,7 +2460,7 @@ checkMandatory(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2449,7 +2460,7 @@ checkMandatory(InitConfigFileParser::Context & ctx, const char * data){
* Transform a string "NodeidX" (e.g. "uppsala.32") * Transform a string "NodeidX" (e.g. "uppsala.32")
* into a Uint32 "NodeIdX" (e.g. 32) and a string "SystemX" (e.g. "uppsala"). * into a Uint32 "NodeIdX" (e.g. 32) and a string "SystemX" (e.g. "uppsala").
*/ */
bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data) static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
{ {
char buf[] = "NodeIdX"; buf[6] = data[sizeof("NodeI")]; char buf[] = "NodeIdX"; buf[6] = data[sizeof("NodeI")];
char sysbuf[] = "SystemX"; sysbuf[6] = data[sizeof("NodeI")]; char sysbuf[] = "SystemX"; sysbuf[6] = data[sizeof("NodeI")];
...@@ -2485,7 +2496,7 @@ bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data) ...@@ -2485,7 +2496,7 @@ bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
* - name of external system in parameter extSystemName, and * - name of external system in parameter extSystemName, and
* - nodeId of external node in parameter extSystemNodeId. * - nodeId of external node in parameter extSystemNodeId.
*/ */
bool static bool
isExtConnection(InitConfigFileParser::Context & ctx, isExtConnection(InitConfigFileParser::Context & ctx,
const char **extSystemName, Uint32 * extSystemNodeId){ const char **extSystemName, Uint32 * extSystemNodeId){
...@@ -2513,7 +2524,7 @@ isExtConnection(InitConfigFileParser::Context & ctx, ...@@ -2513,7 +2524,7 @@ isExtConnection(InitConfigFileParser::Context & ctx,
* If connection is to an external system, then move connection into * If connection is to an external system, then move connection into
* external system configuration (i.e. a sub-property). * external system configuration (i.e. a sub-property).
*/ */
bool static bool
fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){ fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){
const char * extSystemName; const char * extSystemName;
...@@ -2568,7 +2579,7 @@ fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2568,7 +2579,7 @@ fixExtConnection(InitConfigFileParser::Context & ctx, const char * data){
* -# Via Node's ExecuteOnComputer lookup Hostname * -# Via Node's ExecuteOnComputer lookup Hostname
* -# Add HostName to Connection * -# Add HostName to Connection
*/ */
bool static bool
fixHostname(InitConfigFileParser::Context & ctx, const char * data){ fixHostname(InitConfigFileParser::Context & ctx, const char * data){
char buf[] = "NodeIdX"; buf[6] = data[sizeof("HostNam")]; char buf[] = "NodeIdX"; buf[6] = data[sizeof("HostNam")];
...@@ -2591,7 +2602,7 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2591,7 +2602,7 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){
/** /**
* Connection rule: Fix port number (using a port number adder) * Connection rule: Fix port number (using a port number adder)
*/ */
bool static bool
fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
Uint32 id1= 0, id2= 0; Uint32 id1= 0, id2= 0;
...@@ -2645,7 +2656,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2645,7 +2656,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
/** /**
* DB Node rule: Check various constraints * DB Node rule: Check various constraints
*/ */
bool static bool
checkDbConstraints(InitConfigFileParser::Context & ctx, const char *){ checkDbConstraints(InitConfigFileParser::Context & ctx, const char *){
Uint32 t1 = 0, t2 = 0; Uint32 t1 = 0, t2 = 0;
...@@ -2678,7 +2689,7 @@ checkDbConstraints(InitConfigFileParser::Context & ctx, const char *){ ...@@ -2678,7 +2689,7 @@ checkDbConstraints(InitConfigFileParser::Context & ctx, const char *){
/** /**
* Connection rule: Check varius constraints * Connection rule: Check varius constraints
*/ */
bool static bool
checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){
Uint32 id1 = 0, id2 = 0; Uint32 id1 = 0, id2 = 0;
...@@ -2734,6 +2745,22 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){ ...@@ -2734,6 +2745,22 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){
ctx.fname, ctx.m_sectionLineno); ctx.fname, ctx.m_sectionLineno);
return false; return false;
} }
return true;
}
static bool
checkTCPConstraints(InitConfigFileParser::Context & ctx, const char * data){
const char * host;
struct in_addr addr;
if(ctx.m_currentSection->get(data, &host) && strlen(host) &&
Ndb_getInAddr(&addr, host)){
ctx.reportError("Unable to lookup/illegal hostname %s"
" - [%s] starting at line: %d",
host, ctx.fname, ctx.m_sectionLineno);
return false;
}
return true; return true;
} }
...@@ -2777,15 +2804,15 @@ transform(InitConfigFileParser::Context & ctx, ...@@ -2777,15 +2804,15 @@ transform(InitConfigFileParser::Context & ctx,
return false; return false;
} }
if(newType == ConfigInfo::INT){ if(newType == ConfigInfo::INT || newType == ConfigInfo::BOOL){
require(dst.put(newName, (Uint32)newVal)); require(dst.put(newName, (Uint32)newVal));
} else { } else if(newType == ConfigInfo::INT64) {
require(dst.put64(newName, newVal)); require(dst.put64(newName, newVal));
} }
return true; return true;
} }
bool static bool
fixDepricated(InitConfigFileParser::Context & ctx, const char * data){ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
const char * name; const char * name;
/** /**
...@@ -2845,7 +2872,7 @@ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2845,7 +2872,7 @@ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
return true; return true;
} }
bool static bool
saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
const Properties * sec; const Properties * sec;
if(!ctx.m_currentInfo->get(ctx.fname, &sec)){ if(!ctx.m_currentInfo->get(ctx.fname, &sec)){
...@@ -2893,30 +2920,34 @@ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2893,30 +2920,34 @@ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
Uint32 val; Uint32 val;
require(ctx.m_currentSection->get(n, &val)); require(ctx.m_currentSection->get(n, &val));
ok = ctx.m_configValues.put(id, val); ok = ctx.m_configValues.put(id, val);
ndbout_c("put %s %d %d", n, id, val);
break; break;
} }
case PropertiesType_Uint64:{ case PropertiesType_Uint64:{
Uint64 val; Uint64 val;
require(ctx.m_currentSection->get(n, &val)); require(ctx.m_currentSection->get(n, &val));
ok = ctx.m_configValues.put64(id, val); ok = ctx.m_configValues.put64(id, val);
ndbout_c("put64 %s %d %lld", n, id, val);
break; break;
} }
case PropertiesType_char:{ case PropertiesType_char:{
const char * val; const char * val;
require(ctx.m_currentSection->get(n, &val)); require(ctx.m_currentSection->get(n, &val));
ok = ctx.m_configValues.put(id, val); ok = ctx.m_configValues.put(id, val);
ndbout_c("put %s %d %s", n, id, val);
break; break;
} }
default: default:
abort(); abort();
} }
require(ok);
} }
ctx.m_configValues.closeSection(); ctx.m_configValues.closeSection();
} while(0); } while(0);
return true; return true;
} }
bool static bool
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data) const char * rule_data)
...@@ -3003,7 +3034,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3003,7 +3034,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
} }
bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data) const char * rule_data)
{ {
...@@ -3042,7 +3073,7 @@ bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3042,7 +3073,7 @@ bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
return true; return true;
} }
bool static bool
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data) const char * rule_data)
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <mgmapi.h> #include <mgmapi.h>
#include <mgmapi_config_parameters.h> #include <mgmapi_config_parameters.h>
#include <mgmapi_configuration.hpp>
#include <ConfigValues.hpp> #include <ConfigValues.hpp>
#include <NdbHost.h> #include <NdbHost.h>
...@@ -267,7 +268,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -267,7 +268,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
char localhost[MAXHOSTNAMELEN]; char localhost[MAXHOSTNAMELEN];
if(NdbHost_GetHostName(localhost) != 0){ if(NdbHost_GetHostName(localhost) != 0){
snprintf(buf, 255, "Unable to own hostname"); snprintf(buf, 255, "Unable to get own hostname");
setError(CR_ERROR, buf); setError(CR_ERROR, buf);
return false; return false;
} }
...@@ -317,6 +318,46 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -317,6 +318,46 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
return false; return false;
} }
/**
* Check hostnames
*/
ndb_mgm_configuration_iterator iter(* conf, CFG_SECTION_CONNECTION);
for(iter.first(); iter.valid(); iter.next()){
Uint32 type = CONNECTION_TYPE_TCP + 1;
if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;
if(type != CONNECTION_TYPE_TCP) continue;
Uint32 nodeId1, nodeId2, remoteNodeId;
if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue;
if(nodeId1 != _ownNodeId && nodeId2 != _ownNodeId) continue;
remoteNodeId = (_ownNodeId == nodeId1 ? nodeId2 : nodeId1);
const char * name;
struct in_addr addr;
BaseString tmp;
if(!iter.get(CFG_TCP_HOSTNAME_1, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",
name, _ownNodeId, remoteNodeId);
setError(CR_ERROR, tmp.c_str());
return false;
}
}
if(!iter.get(CFG_TCP_HOSTNAME_2, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d",
name, _ownNodeId, remoteNodeId);
setError(CR_ERROR, tmp.c_str());
return false;
}
}
}
return true; return true;
} }
......
...@@ -108,8 +108,8 @@ AsyncFile::AsyncFile() : ...@@ -108,8 +108,8 @@ AsyncFile::AsyncFile() :
} }
void void
AsyncFile::doStart(const char * filesystemPath) { AsyncFile::doStart(Uint32 nodeId, const char * filesystemPath) {
theFileName.init(filesystemPath); theFileName.init(nodeId, filesystemPath);
// Stacksize for filesystem threads // Stacksize for filesystem threads
// An 8k stack should be enough // An 8k stack should be enough
......
...@@ -181,7 +181,7 @@ public: ...@@ -181,7 +181,7 @@ public:
void execute( Request* request ); void execute( Request* request );
void doStart(const char * fspath); void doStart(Uint32 nodeId, const char * fspath);
// its a thread so its always running // its a thread so its always running
void run(); void run();
......
...@@ -46,7 +46,7 @@ Filename::Filename() : ...@@ -46,7 +46,7 @@ Filename::Filename() :
} }
void void
Filename::init(const char * pFileSystemPath){ Filename::init(Uint32 nodeid, const char * pFileSystemPath){
if (pFileSystemPath == NULL) { if (pFileSystemPath == NULL) {
ERROR_SET(fatal, AFS_ERROR_NOPATH, ""," Filename::init()"); ERROR_SET(fatal, AFS_ERROR_NOPATH, ""," Filename::init()");
return; return;
...@@ -75,8 +75,15 @@ Filename::init(const char * pFileSystemPath){ ...@@ -75,8 +75,15 @@ Filename::init(const char * pFileSystemPath){
DIR_SEPARATOR) != 0) DIR_SEPARATOR) != 0)
strcat(theBaseDirectory, DIR_SEPARATOR); strcat(theBaseDirectory, DIR_SEPARATOR);
} snprintf(buf2, sizeof(buf2), "ndb_%u_fs%s", nodeid, DIR_SEPARATOR);
strcat(theBaseDirectory, buf2);
#ifdef NDB_WIN32
CreateDirectory(theBaseDirectory, 0);
#else
mkdir(theBaseDirectory, S_IRUSR | S_IWUSR | S_IXUSR | S_IXGRP | S_IRGRP);
#endif
}
Filename::~Filename(){ Filename::~Filename(){
} }
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
int levels() const; int levels() const;
const char* c_str() const; const char* c_str() const;
void init(const char * fileSystemPath); void init(Uint32 nodeid, const char * fileSystemPath);
private: private:
int theLevelDepth; int theLevelDepth;
......
...@@ -559,7 +559,7 @@ Ndbfs::createAsyncFile(){ ...@@ -559,7 +559,7 @@ Ndbfs::createAsyncFile(){
} }
AsyncFile* file = new AsyncFile; AsyncFile* file = new AsyncFile;
file->doStart(theFileSystemPath); file->doStart(getOwnNodeId(), theFileSystemPath);
// Put the file in list of all files // Put the file in list of all files
theFiles.push_back(file); theFiles.push_back(file);
......
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