Commit b6ed85ba authored by unknown's avatar unknown

added configure switch for ndb port number

    added new variable for ndb port 1186
    changed meaning of ndb_port_base to be default tcp port setting
    changed to use split between port and port_base for ndbcluster
    so that ndb_port and ndb_port_base are propagated to startscript for ndbcluster
    added larger space to pid print
    moved readAndExecute out of CommandInterpreter to avoid linking lib with readline
    added c-api to Ndb_mgmclient
    pass also ndb_port to make


acinclude.m4:
  added configure switch for ndb port number
configure.in:
  added new variable for ndb port 1186
  changed meaning of ndb_port_base to be default tcp port setting
mysql-test/mysql-test-run.sh:
  changed to use split between port and port_base for ndbcluster
mysql-test/ndb/Makefile.am:
  so that ndb_port and ndb_port_base are propagated to startscript for ndbcluster
mysql-test/ndb/ndbcluster.sh:
  so that ndb_port and ndb_port_base are propagated to startscript for ndbcluster
ndb/src/common/mgmcommon/LocalConfig.cpp:
  so that ndb_port and ndb_port_base are propagated to startscript for ndbcluster
ndb/src/common/mgmcommon/Makefile.am:
  so that ndb_port and ndb_port_base are propagated to startscript for ndbcluster
ndb/src/common/mgmcommon/NdbConfig.c:
  added larger space to pid print
ndb/src/mgmclient/CommandInterpreter.cpp:
  moved readAndExecute out of CommandInterpreter to avoid linking lib with readline
  added c-api to Ndb_mgmclient
ndb/src/mgmclient/main.cpp:
  moved readAndExecute out of CommandInterpreter to avoid linking lib with readline
ndb/src/mgmclient/ndb_mgmclient.hpp:
  moved readAndExecute out of CommandInterpreter to avoid linking lib with readline
ndb/src/mgmsrv/ConfigInfo.cpp:
  moved readAndExecute out of CommandInterpreter to avoid linking lib with readline
ndb/src/mgmsrv/Makefile.am:
  pass also ndb_port to make
parent a12d6fd6
......@@ -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"])
......
......@@ -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])
......
......@@ -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
}
......
......@@ -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
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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 @@ class CommandInterpreter {
*
* @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 @@ class CommandInterpreter {
*/
#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
......@@ -456,39 +465,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)
{
......
......@@ -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;
......
/* 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 */
......@@ -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
......@@ -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>&sections,
#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);
......
......@@ -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
......
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