diff options
-rw-r--r-- | acinclude.m4 | 7 | ||||
-rw-r--r-- | configure.in | 8 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 11 | ||||
-rw-r--r-- | mysql-test/ndb/Makefile.am | 2 | ||||
-rw-r--r-- | mysql-test/ndb/ndbcluster.sh | 16 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/LocalConfig.cpp | 6 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/Makefile.am | 2 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/NdbConfig.c | 2 | ||||
-rw-r--r-- | ndb/src/mgmclient/CommandInterpreter.cpp | 76 | ||||
-rw-r--r-- | ndb/src/mgmclient/main.cpp | 46 | ||||
-rw-r--r-- | ndb/src/mgmclient/ndb_mgmclient.h | 33 | ||||
-rw-r--r-- | ndb/src/mgmclient/ndb_mgmclient.hpp | 8 | ||||
-rw-r--r-- | ndb/src/mgmsrv/ConfigInfo.cpp | 8 | ||||
-rw-r--r-- | ndb/src/mgmsrv/Makefile.am | 1 |
14 files changed, 148 insertions, 78 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 671e279a9f3..448bf7a2653 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1614,9 +1614,14 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [ --with-ndb-docs Include the NDB Cluster ndbapi and mgmapi documentation], [ndb_docs="$withval"], [ndb_docs=no]) + AC_ARG_WITH([ndb-port], + [ + --with-ndb-port Port for NDB Cluster management server], + [ndb_port="$withval"], + [ndb_port="default"]) AC_ARG_WITH([ndb-port-base], [ - --with-ndb-port-base Base port for NDB Cluster], + --with-ndb-port-base Base port for NDB Cluster transporters], [ndb_port_base="$withval"], [ndb_port_base="default"]) diff --git a/configure.in b/configure.in index cd2daf10690..764261c6933 100644 --- a/configure.in +++ b/configure.in @@ -3052,9 +3052,15 @@ AC_SUBST([NDB_DEFS]) AC_SUBST([ndb_cxxflags_fix]) +if test X"$ndb_port" = Xdefault +then + ndb_port="1186" +fi +AC_SUBST([ndb_port]) + if test X"$ndb_port_base" = Xdefault then - ndb_port_base="2200" + ndb_port_base="2202" fi AC_SUBST([ndb_port_base]) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 65be9bf9c8e..fcb9e5eee2d 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -457,6 +457,9 @@ SMALL_SERVER="--key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M" export MASTER_MYPORT MASTER_MYPORT1 SLAVE_MYPORT MYSQL_TCP_PORT MASTER_MYSOCK MASTER_MYSOCK1 +NDBCLUSTER_BASE_PORT=`expr $NDBCLUSTER_PORT + 2` +NDBCLUSTER_OPTS="--port=$NDBCLUSTER_PORT --port-base=$NDBCLUSTER_BASE_PORT --data-dir=$MYSQL_TEST_DIR/var" + if [ x$SOURCE_DIST = x1 ] ; then MY_BASEDIR=$MYSQL_TEST_DIR else @@ -939,11 +942,11 @@ start_ndbcluster() echo "Starting ndbcluster" if [ "$DO_BENCH" = 1 ] then - NDBCLUSTER_OPTS="" + NDBCLUSTER_EXTRA_OPTS="" else - NDBCLUSTER_OPTS="--small" + NDBCLUSTER_EXTRA_OPTS="--small" fi - ./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT $NDBCLUSTER_OPTS --diskless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1 + ./ndb/ndbcluster $NDBCLUSTER_OPTS $NDBCLUSTER_EXTRA_OPTS --diskless --initial || exit 1 NDB_CONNECTSTRING="host=localhost:$NDBCLUSTER_PORT" else NDB_CONNECTSTRING="$USE_RUNNING_NDBCLUSTER" @@ -961,7 +964,7 @@ stop_ndbcluster() if [ -z "$USE_RUNNING_NDBCLUSTER" ] then # Kill any running ndbcluster stuff - ./ndb/ndbcluster --data-dir=$MYSQL_TEST_DIR/var --port-base=$NDBCLUSTER_PORT --stop + ./ndb/ndbcluster $NDBCLUSTER_OPTS --stop fi fi } diff --git a/mysql-test/ndb/Makefile.am b/mysql-test/ndb/Makefile.am index 3ed222344a6..502ccee099e 100644 --- a/mysql-test/ndb/Makefile.am +++ b/mysql-test/ndb/Makefile.am @@ -13,6 +13,8 @@ SUFFIXES = .sh .sh: @RM@ -f $@ $@-t @SED@ \ + -e 's!@''ndb_port''@!$(ndb_port)!g' \ + -e 's!@''ndb_port_base''@!$(ndb_port_base)!g' \ -e 's!@''ndbbindir''@!$(ndbbindir)!g' \ -e 's!@''ndbtoolsdir''@!$(ndbtoolsdir)!g' \ $< > $@-t diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index f5757a11056..3486a879eec 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -5,7 +5,8 @@ # This scripts starts the table handler ndbcluster # configurable parameters, make sure to change in mysqlcluterd as well -port_base="2200" +port=@ndb_port@ +port_base=@ndb_port_base@ fsdir=`pwd` # end configurable parameters @@ -84,6 +85,9 @@ while test $# -gt 0; do --data-dir=*) fsdir=`echo "$1" | sed -e "s;--data-dir=;;"` ;; + --port=*) + port=`echo "$1" | sed -e "s;--port=;;"` + ;; --port-base=*) port_base=`echo "$1" | sed -e "s;--port-base=;;"` ;; @@ -94,7 +98,7 @@ while test $# -gt 0; do shift done -fs_ndb="$fsdir/ndbcluster-$port_base" +fs_ndb="$fsdir/ndbcluster-$port" NDB_HOME= if [ ! -x "$fsdir" ]; then @@ -120,7 +124,7 @@ exec_ndb="$exec_ndb --no-defaults" exec_waiter="$exec_waiter --no-defaults" ndb_host="localhost" -ndb_mgmd_port=$port_base +ndb_mgmd_port=$port NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port" export NDB_CONNECTSTRING @@ -158,10 +162,6 @@ if [ -d "$fs_ndb" ]; then :; else exit 1 fi -# set som help variables - -port_transporter=`expr $ndb_mgmd_port + 2` - # Start management server as deamon # Edit file system path and ports in config file @@ -176,7 +176,7 @@ sed \ -e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \ -e s,"CHOOSE_FILESYSTEM","$fs_ndb",g \ -e s,"CHOOSE_PORT_MGM","$ndb_mgmd_port",g \ - -e s,"CHOOSE_PORT_TRANSPORTER","$port_transporter",g \ + -e s,"CHOOSE_PORT_TRANSPORTER","$port_base",g \ < ndb/ndb_config_2_node.ini \ > "$fs_ndb/config.ini" fi diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/common/mgmcommon/LocalConfig.cpp index 3cd4341c6b7..679de716be0 100644 --- a/ndb/src/common/mgmcommon/LocalConfig.cpp +++ b/ndb/src/common/mgmcommon/LocalConfig.cpp @@ -90,7 +90,7 @@ LocalConfig::init(const char *connectString, //7. Check { char buf[256]; - BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_BASE_PORT); + BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_PORT); if(readConnectString(buf, "default connect string")) return true; } @@ -124,12 +124,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 - << " | host=localhost:"<<NDB_BASE_PORT<<endl; + << " | host=localhost:"<<NDB_PORT<<endl; ndbout << "2. Use the environment variable NDB_CONNECTSTRING to "<<endl << " provide this information." <<endl << " Ex: " << endl - << " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_BASE_PORT<<"\"" + << " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_PORT<<"\"" <<endl<<endl; } diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am index ed6a526eb47..b787da51ab9 100644 --- a/ndb/src/common/mgmcommon/Makefile.am +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -7,7 +7,7 @@ libmgmsrvcommon_la_SOURCES = \ INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv -DEFS_LOC = -DNDB_BASE_PORT="\"@ndb_port_base@\"" +DEFS_LOC = -DNDB_PORT="\"@ndb_port@\"" include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/mgmcommon/NdbConfig.c index e92f8fa8392..8adc4c20dff 100644 --- a/ndb/src/common/mgmcommon/NdbConfig.c +++ b/ndb/src/common/mgmcommon/NdbConfig.c @@ -74,7 +74,7 @@ NdbConfig_NdbCfgName(int with_ndb_home){ static char *get_prefix_buf(int len, int node_id) { - char tmp_buf[sizeof("ndb_pid#########")+1]; + char tmp_buf[sizeof("ndb_pid#############")+1]; char *buf; if (node_id > 0) snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 523c271ed9e..f1a953769b8 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -17,17 +17,6 @@ #include <ndb_global.h> #include <my_sys.h> -// copied from mysql.cc to get readline -extern "C" { -#if defined( __WIN__) || defined(OS2) -#include <conio.h> -#elif !defined(__NETWARE__) -#include <readline/readline.h> -extern "C" int add_history(const char *command); /* From readline directory */ -#define HAVE_READLINE -#endif -} - //#define HAVE_GLOBAL_REPLICATION #include <Vector.hpp> @@ -65,7 +54,6 @@ public: * * @return true until quit/bye/exit has been typed */ - int readAndExecute(int _try_reconnect=-1); int execute(const char *_line, int _try_reconnect=-1); private: @@ -180,6 +168,7 @@ private: */ #include "ndb_mgmclient.hpp" +#include "ndb_mgmclient.h" Ndb_mgmclient::Ndb_mgmclient(const char *host) { @@ -189,10 +178,6 @@ Ndb_mgmclient::~Ndb_mgmclient() { delete m_cmd; } -int Ndb_mgmclient::read_and_execute(int _try_reconnect) -{ - return m_cmd->readAndExecute(_try_reconnect); -} int Ndb_mgmclient::execute(const char *_line, int _try_reconnect) { return m_cmd->execute(_line,_try_reconnect); @@ -203,7 +188,20 @@ Ndb_mgmclient::disconnect() return m_cmd->disconnect(); } - +extern "C" { + Ndb_mgmclient_handle ndb_mgmclient_handle_create(const char *connect_string) + { + return (Ndb_mgmclient_handle) new Ndb_mgmclient(connect_string); + } + int ndb_mgmclient_execute(Ndb_mgmclient_handle h, int argc, const char** argv) + { + return ((Ndb_mgmclient*)h)->execute(argc, argv, 1); + } + int ndb_mgmclient_handle_destroy(Ndb_mgmclient_handle h) + { + delete (Ndb_mgmclient*)h; + } +} /* * The CommandInterpreter */ @@ -227,6 +225,17 @@ Ndb_mgmclient::disconnect() #include <util/InputStream.hpp> #include <util/OutputStream.hpp> +int Ndb_mgmclient::execute(int argc, const char** argv, int _try_reconnect) +{ + if (argc <= 0) + return 0; + BaseString _line(argv[0]); + for (int i= 1; i < argc; i++) + { + _line.appfmt(" %s", argv[i]); + } + return m_cmd->execute(_line.c_str(),_try_reconnect); +} /***************************************************************************** * HELP @@ -457,39 +466,6 @@ CommandInterpreter::disconnect() //***************************************************************************** int -CommandInterpreter::readAndExecute(int _try_reconnect) -{ - static char *line_read = (char *)NULL; - - /* If the buffer has already been allocated, return the memory - to the free pool. */ - if (line_read) - { - free (line_read); - line_read = (char *)NULL; - } -#ifdef HAVE_READLINE - /* Get a line from the user. */ - line_read = readline ("ndb_mgm> "); - /* If the line has any text in it, save it on the history. */ - if (line_read && *line_read) - add_history (line_read); -#else - static char linebuffer[254]; - fputs("ndb_mgm> ", stdout); - linebuffer[sizeof(linebuffer)-1]=0; - line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); - if (line_read == linebuffer) { - char *q=linebuffer; - while (*q > 31) q++; - *q=0; - line_read= strdup(linebuffer); - } -#endif - return execute(line_read,_try_reconnect); -} - -int CommandInterpreter::execute(const char *_line, int _try_reconnect) { if (_try_reconnect >= 0) diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 3415ede1985..8f5d9e6656c 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -17,6 +17,17 @@ #include <ndb_global.h> #include <ndb_opts.h> +// copied from mysql.cc to get readline +extern "C" { +#if defined( __WIN__) || defined(OS2) +#include <conio.h> +#elif !defined(__NETWARE__) +#include <readline/readline.h> +extern "C" int add_history(const char *command); /* From readline directory */ +#define HAVE_READLINE +#endif +} + #include <NdbMain.h> #include <NdbHost.h> #include <mgmapi.h> @@ -90,6 +101,39 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), return 0; } +static int +read_and_execute(int _try_reconnect) +{ + static char *line_read = (char *)NULL; + + /* If the buffer has already been allocated, return the memory + to the free pool. */ + if (line_read) + { + free (line_read); + line_read = (char *)NULL; + } +#ifdef HAVE_READLINE + /* Get a line from the user. */ + line_read = readline ("ndb_mgm> "); + /* If the line has any text in it, save it on the history. */ + if (line_read && *line_read) + add_history (line_read); +#else + static char linebuffer[254]; + fputs("ndb_mgm> ", stdout); + linebuffer[sizeof(linebuffer)-1]=0; + line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); + if (line_read == linebuffer) { + char *q=linebuffer; + while (*q > 31) q++; + *q=0; + line_read= strdup(linebuffer); + } +#endif + return com->execute(line_read,_try_reconnect); +} + int main(int argc, char** argv){ NDB_INIT(argv[0]); const char *_host = 0; @@ -128,7 +172,7 @@ int main(int argc, char** argv){ signal(SIGPIPE, handler); com = new Ndb_mgmclient(buf); - while(com->read_and_execute(_try_reconnect)); + while(read_and_execute(_try_reconnect)); delete com; return 0; diff --git a/ndb/src/mgmclient/ndb_mgmclient.h b/ndb/src/mgmclient/ndb_mgmclient.h new file mode 100644 index 00000000000..265e6bc67ec --- /dev/null +++ b/ndb/src/mgmclient/ndb_mgmclient.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef Ndb_mgmclient_h +#define Ndb_mgmclient_h + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* Ndb_mgmclient_handle; +Ndb_mgmclient_handle ndb_mgmclient_handle_create(const char *connect_string); +int ndb_mgmclient_execute(Ndb_mgmclient_handle, int argc, const char** argv); +int ndb_mgmclient_handle_destroy(Ndb_mgmclient_handle); + +#ifdef __cplusplus +} +#endif + +#endif /* Ndb_mgmclient_h */ diff --git a/ndb/src/mgmclient/ndb_mgmclient.hpp b/ndb/src/mgmclient/ndb_mgmclient.hpp index 2f021a0f2b6..933d1bab5ce 100644 --- a/ndb/src/mgmclient/ndb_mgmclient.hpp +++ b/ndb/src/mgmclient/ndb_mgmclient.hpp @@ -14,8 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef Ndb_mgmclient_h -#define Ndb_mgmclient_h +#ifndef Ndb_mgmclient_hpp +#define Ndb_mgmclient_hpp class CommandInterpreter; class Ndb_mgmclient @@ -23,11 +23,11 @@ class Ndb_mgmclient public: Ndb_mgmclient(const char*); ~Ndb_mgmclient(); - int read_and_execute(int _try_reconnect=-1); int execute(const char *_line, int _try_reconnect=-1); + int execute(int argc, const char** argv, int _try_reconnect=-1); int disconnect(); private: CommandInterpreter *m_cmd; }; -#endif // Ndb_mgmclient_h +#endif // Ndb_mgmclient_hpp diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index ad346b30ead..4af1556a0c0 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -1478,7 +1478,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - NDB_BASE_PORT, + NDB_PORT, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1490,7 +1490,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::INT, - "2199", + UNDEFINED, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -3010,7 +3010,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ if(!(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base)) && !ctx.m_systemDefaults->get("PortNumber", &base)) { - base= strtoll(NDB_BASE_PORT,0,0)+2; + base= strtoll(NDB_BASE_PORT,0,0); // ctx.reportError("Cannot retrieve base port number"); // return false; } @@ -3442,7 +3442,7 @@ static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>§ions, #if 0 Properties * props= ctx.m_config; Properties computers(true); - Uint32 port_base = NDB_BASE_PORT+2; + Uint32 port_base = NDB_BASE_PORT; Uint32 nNodes; ctx.m_userProperties.get("NoOfNodes", &nNodes); diff --git a/ndb/src/mgmsrv/Makefile.am b/ndb/src/mgmsrv/Makefile.am index 4cb164d48fe..ee5220ef9f8 100644 --- a/ndb/src/mgmsrv/Makefile.am +++ b/ndb/src/mgmsrv/Makefile.am @@ -33,6 +33,7 @@ DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" \ + -DNDB_PORT="\"@ndb_port@\"" \ -DNDB_BASE_PORT="\"@ndb_port_base@\"" include $(top_srcdir)/ndb/config/common.mk.am |