Commit 29ab7097 authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1
parents aababf28 41e39c7b
...@@ -4,6 +4,7 @@ dnl Process this file with autoconf to produce a configure script. ...@@ -4,6 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc) AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line! # The Docs Makefile.am parses this line!
# remember to also change ndb version below and update version.c in ndb
AM_INIT_AUTOMAKE(mysql, 4.1.8) AM_INIT_AUTOMAKE(mysql, 4.1.8)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
...@@ -13,9 +14,9 @@ DOT_FRM_VERSION=6 ...@@ -13,9 +14,9 @@ DOT_FRM_VERSION=6
SHARED_LIB_VERSION=14:0:0 SHARED_LIB_VERSION=14:0:0
# ndb version # ndb version
NDB_VERSION_MAJOR=3 NDB_VERSION_MAJOR=4
NDB_VERSION_MINOR=5 NDB_VERSION_MINOR=1
NDB_VERSION_BUILD=4 NDB_VERSION_BUILD=8
NDB_VERSION_STATUS="" NDB_VERSION_STATUS=""
# Set all version vars based on $VERSION. How do we do this more elegant ? # Set all version vars based on $VERSION. How do we do this more elegant ?
...@@ -1142,8 +1143,8 @@ dnl Is this the right match for DEC OSF on alpha? ...@@ -1142,8 +1143,8 @@ dnl Is this the right match for DEC OSF on alpha?
fi fi
echo "Adding defines for OSF1" echo "Adding defines for OSF1"
# gethostbyname_r is deprecated and doesn't work ok on OSF1 # gethostbyname_r is deprecated and doesn't work ok on OSF1
CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC"
CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_ZERO" CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R -DSNPRINTF_RETURN_TRUNC"
# fix to handle include of <stdint.h> correctly on OSF1 with cxx compiler # fix to handle include of <stdint.h> correctly on OSF1 with cxx compiler
CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk" CXXFLAGS="$CXXFLAGS -I/usr/include/cxx -I/usr/include/cxx_cname -I/usr/include -I/usr/include.dtk"
;; ;;
......
...@@ -82,19 +82,12 @@ extern "C" { ...@@ -82,19 +82,12 @@ extern "C" {
/* call in main() - does not return on error */ /* call in main() - does not return on error */
extern int ndb_init(void); extern int ndb_init(void);
extern void ndb_end(int); extern void ndb_end(int);
#define NDB_INIT(prog_name) {my_progname=(prog_name); ndb_init();}
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
extern char * strdup(const char *s); extern char * strdup(const char *s);
#endif #endif
#ifndef HAVE_STRLCPY
extern size_t strlcpy (char *dst, const char *src, size_t dst_sz);
#endif
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *dst, const char *src, size_t dst_sz);
#endif
#ifndef HAVE_STRCASECMP #ifndef HAVE_STRCASECMP
extern int strcasecmp(const char *s1, const char *s2); extern int strcasecmp(const char *s1, const char *s2);
extern int strncasecmp(const char *s1, const char *s2, size_t n); extern int strncasecmp(const char *s1, const char *s2, size_t n);
......
/* 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_OPTS_H
#define _NDB_OPTS_H
#include <my_sys.h>
#include <my_getopt.h>
#include <mysql_version.h>
#include <ndb_version.h>
#ifndef DBUG_OFF
#define NDB_STD_OPTS(prog_name) \
{ "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "usage", '?', "Display this help and exit.", \
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "help", '?', "Display this help and exit.", \
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "version", 'V', "Output version information and exit.", 0, 0, 0, \
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "connect-string", 'c', \
"Set connect string for connecting to ndb_mgmd. " \
"<constr>=\"host=<hostname:port>[;nodeid=<id>]\". " \
"Overides specifying entries in NDB_CONNECTSTRING and config file", \
(gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }
#else
#define NDB_STD_OPTS(prog_name) \
{ "usage", '?', "Display this help and exit.", \
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "help", '?', "Display this help and exit.", \
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "version", 'V', "Output version information and exit.", 0, 0, 0, \
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
{ "connect-string", 'c', \
"Set connect string for connecting to ndb_mgmd. " \
"<constr>=\"host=<hostname:port>[;nodeid=<id>]\". " \
"Overides specifying entries in NDB_CONNECTSTRING and config file", \
(gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }
#endif
#endif /*_NDB_OPTS_H */
...@@ -138,6 +138,11 @@ rl_add_slash(char *path, char *p, size_t p_len) ...@@ -138,6 +138,11 @@ rl_add_slash(char *path, char *p, size_t p_len)
{ {
struct stat Sb; struct stat Sb;
if (stat(path, &Sb) >= 0) if (stat(path, &Sb) >= 0) {
(void)strlcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ", p_len); int len= strlen(p);
if (len+1 < p_len) {
p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' ';
p[len+1]= 0;
}
}
} }
...@@ -7,8 +7,8 @@ libgeneral_la_SOURCES = \ ...@@ -7,8 +7,8 @@ libgeneral_la_SOURCES = \
SocketServer.cpp SocketClient.cpp SocketAuthenticator.cpp\ SocketServer.cpp SocketClient.cpp SocketAuthenticator.cpp\
OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \
NdbSqlUtil.cpp new.cpp \ NdbSqlUtil.cpp new.cpp \
uucode.c random.c getarg.c version.c \ uucode.c random.c version.c \
strdup.c strlcat.c strlcpy.c \ strdup.c \
ConfigValues.cpp ndb_init.c basestring_vsnprintf.c ConfigValues.cpp ndb_init.c basestring_vsnprintf.c
include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/common.mk.am
......
...@@ -34,20 +34,19 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) ...@@ -34,20 +34,19 @@ basestring_snprintf(char *str, size_t size, const char *format, ...)
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
#define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d)
#else #else
#define SNPRINTF_RETURN_ZERO #define SNPRINTF_RETURN_TRUNC
#define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d)
extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap); extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif #endif
#ifdef SNPRINTF_RETURN_TRUNC
#ifdef SNPRINTF_RETURN_ZERO
static char basestring_vsnprintf_buf[16*1024]; static char basestring_vsnprintf_buf[16*1024];
#endif #endif
int int
basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap)
{ {
int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap);
#ifdef SNPRINTF_RETURN_ZERO #ifdef SNPRINTF_RETURN_TRUNC
if (ret == 0 && format != 0 && format[0] != '\0') { if (ret == size-1) {
ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf,
sizeof(basestring_vsnprintf_buf), sizeof(basestring_vsnprintf_buf),
format, ap); format, ap);
......
...@@ -172,22 +172,21 @@ vprint_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -172,22 +172,21 @@ vprint_socket(NDB_SOCKET_TYPE socket, int timeout_millis,
const char * fmt, va_list ap){ const char * fmt, va_list ap){
char buf[1000]; char buf[1000];
char *buf2 = buf; char *buf2 = buf;
size_t size = sizeof(buf); size_t size;
if (fmt != 0) { if (fmt != 0 && fmt[0] != 0) {
size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap);
/* Check if the output was truncated */ /* Check if the output was truncated */
if(size >= sizeof(buf)) { if(size > sizeof(buf)) {
buf2 = (char *)malloc(size+1); buf2 = (char *)malloc(size);
if(buf2 == NULL) if(buf2 == NULL)
return -1; return -1;
BaseString::vsnprintf(buf2, size, fmt, ap); BaseString::vsnprintf(buf2, size, fmt, ap);
} else }
size = sizeof(buf);
} else } else
buf[0] = 0; return 0;
int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); int ret = write_socket(socket, timeout_millis, buf2, size);
if(buf2 != buf) if(buf2 != buf)
free(buf2); free(buf2);
return ret; return ret;
...@@ -199,23 +198,23 @@ vprintln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -199,23 +198,23 @@ vprintln_socket(NDB_SOCKET_TYPE socket, int timeout_millis,
const char * fmt, va_list ap){ const char * fmt, va_list ap){
char buf[1000]; char buf[1000];
char *buf2 = buf; char *buf2 = buf;
size_t size = sizeof(buf); size_t size;
if (fmt != 0) { if (fmt != 0 && fmt[0] != 0) {
size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap)+1;// extra byte for '/n'
/* Check if the output was truncated */ /* Check if the output was truncated */
if(size >= sizeof(buf)-1) { if(size > sizeof(buf)) {
buf2 = (char *)malloc(size+2); buf2 = (char *)malloc(size);
if(buf2 == NULL) if(buf2 == NULL)
return -1; return -1;
BaseString::vsnprintf(buf2, size+1, fmt, ap); BaseString::vsnprintf(buf2, size, fmt, ap);
} else }
size = sizeof(buf); } else {
} else size = 1;
buf[0] = 0; }
strlcat(buf2, "\n", size+2); buf2[size-1]='\n';
int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); int ret = write_socket(socket, timeout_millis, buf2, size);
if(buf2 != buf) if(buf2 != buf)
free(buf2); free(buf2);
return ret; return ret;
......
/*
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <ndb_global.h>
/* RCSID("$KTH: strlcat.c,v 1.1 2000/08/16 01:23:47 lha Exp $"); */
#ifndef HAVE_STRLCAT
size_t
strlcat (char *dst, const char *src, size_t dst_sz)
{
size_t len = strlen(dst);
return len + strlcpy (dst + len, src, dst_sz - len);
}
#endif
/*
* Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <ndb_global.h>
/* RCSID("$KTH: strlcpy.c,v 1.1 2000/08/16 01:23:48 lha Exp $"); */
#ifndef HAVE_STRLCPY
size_t
strlcpy (char *dst, const char *src, size_t dst_sz)
{
size_t n;
char *p;
for (p = dst, n = 0;
n + 1 < dst_sz && *src != '\0';
++p, ++src, ++n)
*p = *src;
*p = '\0';
if (*src == '\0')
return n;
else
return n + strlen (src);
}
#endif
...@@ -70,6 +70,7 @@ struct NdbUpGradeCompatible { ...@@ -70,6 +70,7 @@ struct NdbUpGradeCompatible {
#ifndef TEST_VERSION #ifndef TEST_VERSION
struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { struct NdbUpGradeCompatible ndbCompatibleTable_full[] = {
{ MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact }, { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact },
{ MAKE_VERSION(4,1,8), MAKE_VERSION(3,5,4), UG_Exact }, /* Aligned version with MySQL */
{ 0, 0, UG_Null } { 0, 0, UG_Null }
}; };
......
...@@ -96,66 +96,3 @@ insert_file(const char * filename, class Properties& p){ ...@@ -96,66 +96,3 @@ insert_file(const char * filename, class Properties& p){
if(f) fclose(f); if(f) fclose(f);
return res; return res;
} }
int
parse_config_file(struct getargs args[], int num_arg, const Properties& p){
Properties::Iterator it(&p);
for(const char * name = it.first(); name != 0; name = it.next()){
bool found = false;
for(int i = 0; i<num_arg; i++){
if(strcmp(name, args[i].long_name) != 0)
continue;
found = true;
const char * tmp;
p.get(name, &tmp);
int t = 1;
switch(args[i].type){
case arg_integer:{
int val = atoi(tmp);
if(args[i].value){
*((int*)args[i].value) = val;
}
}
break;
case arg_string:
if(args[i].value){
*((const char**)args[i].value) = tmp;
}
break;
case arg_negative_flag:
t = 0;
case arg_flag:
if(args[i].value){
if(!strcasecmp(tmp, "y") ||
!strcasecmp(tmp, "on") ||
!strcasecmp(tmp, "true") ||
!strcasecmp(tmp, "1")){
*((int*)args[i].value) = t;
}
if(!strcasecmp(tmp, "n") ||
!strcasecmp(tmp, "off") ||
!strcasecmp(tmp, "false") ||
!strcasecmp(tmp, "0")){
*((int*)args[i].value) = t;
}
}
t = 1;
break;
case arg_strings:
case arg_double:
case arg_collect:
case arg_counter:
break;
}
}
if(!found) {
printf("Unknown parameter: %s\n", name);
return 1;
}
}
return 0;
}
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <logger/Logger.hpp> #include <logger/Logger.hpp>
#if 0
#include <getarg.h> #include <getarg.h>
#endif
extern int debug; extern int debug;
...@@ -30,6 +32,5 @@ int insert(const char * pair, class Properties & p); ...@@ -30,6 +32,5 @@ int insert(const char * pair, class Properties & p);
int insert_file(const char * filename, class Properties&); int insert_file(const char * filename, class Properties&);
int insert_file(FILE *, class Properties&, bool break_on_empty = false); int insert_file(FILE *, class Properties&, bool break_on_empty = false);
int parse_config_file(struct getargs args[], int num_arg, const Properties& p);
#endif /* ! __CPCD_COMMON_HPP_INCLUDED__ */ #endif /* ! __CPCD_COMMON_HPP_INCLUDED__ */
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
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 <ndb_global.h> /* Needed for mkdir(2) */ #include <ndb_global.h> /* Needed for mkdir(2) */
#include <ndb_opts.h>
#include "CPCD.hpp" #include "CPCD.hpp"
#include "APIService.hpp" #include "APIService.hpp"
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <BaseString.hpp> #include <BaseString.hpp>
#include <getarg.h>
#include <logger/Logger.hpp> #include <logger/Logger.hpp>
#include <logger/FileLogHandler.hpp> #include <logger/FileLogHandler.hpp>
#include <logger/SysLogHandler.hpp> #include <logger/SysLogHandler.hpp>
...@@ -29,28 +29,44 @@ ...@@ -29,28 +29,44 @@
#include "common.hpp" #include "common.hpp"
static const char *work_dir = CPCD_DEFAULT_WORK_DIR; static const char *work_dir = CPCD_DEFAULT_WORK_DIR;
static int port = CPCD_DEFAULT_TCP_PORT; static int port;
static int use_syslog = 0; static int use_syslog;
static const char *logfile = NULL; static const char *logfile = NULL;
static const char *config_file = CPCD_DEFAULT_CONFIG_FILE; static const char *config_file = CPCD_DEFAULT_CONFIG_FILE;
static const char *user = 0; static const char *user = 0;
static struct getargs args[] = { static struct my_option my_long_options[] =
{ "work-dir", 'w', arg_string, &work_dir, {
"Work directory", "directory" }, { "work-dir", 'w', "Work directory",
{ "port", 'p', arg_integer, &port, (gptr*) &work_dir, (gptr*) &work_dir, 0,
"TCP port to listen on", "port" }, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "syslog", 'S', arg_flag, &use_syslog, { "port", 'p', "TCP port to listen on",
"Log events to syslog", NULL}, (gptr*) &port, (gptr*) &port, 0,
{ "logfile", 'L', arg_string, &logfile, GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 },
"File to log events to", "file"}, { "syslog", 'S', "Log events to syslog",
{ "debug", 'D', arg_flag, &debug, (gptr*) &use_syslog, (gptr*) &use_syslog, 0,
"Enable debug mode", NULL}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "config", 'c', arg_string, &config_file, "Config file", NULL }, { "logfile", 'L', "File to log events to",
{ "user", 'u', arg_string, &user, "Run as user", NULL } (gptr*) &logfile, (gptr*) &logfile, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "debug", 'D', "Enable debug mode",
(gptr*) &debug, (gptr*) &debug, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "config", 'c', "Config file",
(gptr*) &config_file, (gptr*) &config_file, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "user", 'u', "Run as user",
(gptr*) &user, (gptr*) &user, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static const int num_args = sizeof(args) / sizeof(args[0]); static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
return 0;
}
static CPCD * g_cpcd = 0; static CPCD * g_cpcd = 0;
#if 0 #if 0
...@@ -59,23 +75,16 @@ extern "C" static void sig_child(int signo, siginfo_t*, void*); ...@@ -59,23 +75,16 @@ extern "C" static void sig_child(int signo, siginfo_t*, void*);
const char *progname = "ndb_cpcd"; const char *progname = "ndb_cpcd";
NDB_MAIN(ndb_cpcd){ int main(int argc, char** argv){
int optind = 0; int save_argc= argc;
char** save_argv= argv;
if(getarg(args, num_args, argc, argv, &optind)) { const char *load_default_groups[]= { "ndb_cpcd",0 };
arg_printusage(args, num_args, progname, ""); MY_INIT(argv[0]);
exit(1);
}
Properties p;
insert_file(config_file, p);
if(parse_config_file(args, num_args, p)){
ndbout_c("Invalid config file: %s", config_file);
exit(1);
}
if(getarg(args, num_args, argc, argv, &optind)) { load_defaults("ndb_cpcd",load_default_groups,&argc,&argv);
arg_printusage(args, num_args, progname, ""); if (handle_options(&argc, &argv, my_long_options, get_one_option)) {
my_print_help(my_long_options);
my_print_variables(my_long_options);
exit(1); exit(1);
} }
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
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 <getarg.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <Vector.hpp> #include <Vector.hpp>
#include <ndb_limits.h> #include <ndb_limits.h>
#include <NdbTCP.h> #include <NdbTCP.h>
...@@ -35,80 +36,107 @@ static Vector<class BackupConsumer *> g_consumers; ...@@ -35,80 +36,107 @@ static Vector<class BackupConsumer *> g_consumers;
static const char* ga_backupPath = "." DIR_SEPARATOR; static const char* ga_backupPath = "." DIR_SEPARATOR;
static const char* ga_connect_NDB = NULL; static const char* opt_connect_str= NULL;
/** /**
* print and restore flags * print and restore flags
*/ */
static bool ga_restore = false; static bool ga_restore = false;
static bool ga_print = false; static bool ga_print = false;
static int _print = 0;
static int _print_meta = 0;
static int _print_data = 0;
static int _print_log = 0;
static int _restore_data = 0;
static int _restore_meta = 0;
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_restore"),
{ "connect", 'c', "same as --connect-string",
(gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "nodeid", 'n', "Backup files from node with id",
(gptr*) &ga_nodeId, (gptr*) &ga_nodeId, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "backupid", 'b', "Backup id",
(gptr*) &ga_backupId, (gptr*) &ga_backupId, 0,
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "restore_data", 'r',
"Restore table data/logs into NDB Cluster using NDBAPI",
(gptr*) &_restore_data, (gptr*) &_restore_data, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "restore_meta", 'm',
"Restore meta data into NDB Cluster using NDBAPI",
(gptr*) &_restore_meta, (gptr*) &_restore_meta, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 'p',
"No of parallel transactions during restore of data."
"(parallelism can be 1 to 1024)",
(gptr*) &ga_nParallelism, (gptr*) &ga_nParallelism, 0,
GET_INT, REQUIRED_ARG, 128, 0, 0, 0, 0, 0 },
{ "print", 256, "Print data and log to stdout",
(gptr*) &_print, (gptr*) &_print, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_data", 257, "Print data to stdout",
(gptr*) &_print_data, (gptr*) &_print_data, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_meta", 258, "Print meta data to stdout",
(gptr*) &_print_meta, (gptr*) &_print_meta, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "print_log", 259, "Print log to stdout",
(gptr*) &_print_log, (gptr*) &_print_log, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "dont_ignore_systab_0", 'f',
"Experimental. Do not ignore system table during restore.",
(gptr*) &ga_dont_ignore_systab_0, (gptr*) &ga_dont_ignore_systab_0, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void short_usage_sub(void)
{
printf("Usage: %s [OPTIONS] [<path to backup files>]\n", my_progname);
}
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
short_usage_sub();
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_restore.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
bool bool
readArguments(const int argc, const char** argv) readArguments(int *pargc, char*** pargv)
{ {
const char *load_default_groups[]= { "ndb_tools","ndb_restore",0 };
int _print = 0; load_defaults("my",load_default_groups,pargc,pargv);
int _print_meta = 0; if (handle_options(pargc, pargv, my_long_options, get_one_option) ||
int _print_data = 0;
int _print_log = 0;
int _restore_data = 0;
int _restore_meta = 0;
struct getargs args[] =
{
{ "connect", 'c', arg_string, &ga_connect_NDB,
"NDB Cluster connection", "\"nodeid=<api id>;host=<hostname:port>\""},
{ "nodeid", 'n', arg_integer, &ga_nodeId,
"Backup files from node", "db node id"},
{ "backupid", 'b',arg_integer, &ga_backupId, "Backup id", "backup id"},
{ "print", '\0', arg_flag, &_print,
"Print data and log to stdout", "print data and log"},
{ "print_data", '\0', arg_flag, &_print_data,
"Print data to stdout", "print data"},
{ "print_meta", '\0', arg_flag, &_print_meta,
"Print meta data to stdout", "print meta data"},
{ "print_log", '\0', arg_flag, &_print_log,
"Print log to stdout", "print log"},
{ "restore_data", 'r', arg_flag, &_restore_data,
"Restore table data/logs into NDB Cluster using NDBAPI",
"Restore table data/log"},
{ "restore_meta", 'm', arg_flag, &_restore_meta,
"Restore meta data into NDB Cluster using NDBAPI", "Restore meta data"},
{ "parallelism", 'p', arg_integer, &ga_nParallelism,
"No of parallel transactions during restore of data."
"(parallelism can be 1 to 1024)",
"Parallelism"},
#ifdef USE_MYSQL
{ "use_mysql", '\0', arg_flag, &use_mysql,
"Restore meta data via mysql. Systab will be ignored. Data is restored "
"using NDBAPI.", "use mysql"},
{ "user", '\0', arg_string, &ga_user, "MySQL user", "Default: root"},
{ "password", '\0', arg_string, &ga_password, "MySQL user's password",
"Default: \"\" "},
{ "host", '\0', arg_string, &ga_host, "Hostname of MySQL server",
"Default: localhost"},
{ "socket", '\0', arg_string, &ga_socket, "Path to MySQL server socket file",
"Default: /tmp/mysql.sock"},
{ "port", '\0', arg_integer, &ga_port, "Port number of MySQL server",
"Default: 3306"},
#endif
{ "dont_ignore_systab_0", 'f', arg_flag, &ga_dont_ignore_systab_0,
"Experimental. Do not ignore system table during restore.",
"dont_ignore_systab_0"}
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
if (getarg(args, num_args, argc, argv, &optind) ||
ga_nodeId == 0 || ga_nodeId == 0 ||
ga_backupId == 0 || ga_backupId == 0 ||
ga_nParallelism < 1 || ga_nParallelism < 1 ||
ga_nParallelism >1024) ga_nParallelism >1024) {
{ exit(1);
arg_printusage(args, num_args, argv[0], "<path to backup files>\n");
return false;
} }
BackupPrinter* printer = new BackupPrinter(); BackupPrinter* printer = new BackupPrinter();
...@@ -122,10 +150,6 @@ readArguments(const int argc, const char** argv) ...@@ -122,10 +150,6 @@ readArguments(const int argc, const char** argv)
return false; return false;
} }
/**
* Got segmentation fault when using the printer's attributes directly
* in getargs... Do not have the time to found out why... this is faster...
*/
if (_print) if (_print)
{ {
ga_print = true; ga_print = true;
...@@ -169,15 +193,14 @@ readArguments(const int argc, const char** argv) ...@@ -169,15 +193,14 @@ readArguments(const int argc, const char** argv)
g_consumers.push_back(c); g_consumers.push_back(c);
} }
// Set backup file path // Set backup file path
if (argv[optind] != NULL) if (*pargv[0] != NULL)
{ {
ga_backupPath = argv[optind]; ga_backupPath = *pargv[0];
} }
return true; return true;
} }
void void
clearConsumers() clearConsumers()
{ {
...@@ -204,19 +227,16 @@ free_data_callback() ...@@ -204,19 +227,16 @@ free_data_callback()
} }
int int
main(int argc, const char** argv) main(int argc, char** argv)
{ {
ndb_init(); NDB_INIT(argv[0]);
if (!readArguments(argc, argv))
if (!readArguments(&argc, &argv))
{ {
return -1; return -1;
} }
if (ga_connect_NDB != NULL) Ndb::setConnectString(opt_connect_str);
{
// Use connection string
Ndb::setConnectString(ga_connect_NDB);
}
/** /**
* we must always load meta data, even if we will only print it to stdout * we must always load meta data, even if we will only print it to stdout
......
...@@ -137,7 +137,7 @@ ErrorReporter::formatMessage(ErrorCategory type, ...@@ -137,7 +137,7 @@ ErrorReporter::formatMessage(ErrorCategory type,
faultID, faultID,
(problemData == NULL) ? "" : problemData, (problemData == NULL) ? "" : problemData,
objRef, objRef,
programName, my_progname,
processId, processId,
theNameOfTheTraceFile ? theNameOfTheTraceFile : "<no tracefile>"); theNameOfTheTraceFile ? theNameOfTheTraceFile : "<no tracefile>");
......
...@@ -53,11 +53,9 @@ extern "C" void handler_error(int signum); // for process signal handling ...@@ -53,11 +53,9 @@ extern "C" void handler_error(int signum); // for process signal handling
void systemInfo(const Configuration & conf, void systemInfo(const Configuration & conf,
const LogLevel & ll); const LogLevel & ll);
const char programName[] = "NDB Kernel"; int main(int argc, char** argv)
{
NDB_MAIN(ndb_kernel){ NDB_INIT(argv[0]);
ndb_init();
// Print to stdout/console // Print to stdout/console
g_eventLogger.createConsoleHandler(); g_eventLogger.createConsoleHandler();
g_eventLogger.setCategory("NDB"); g_eventLogger.setCategory("NDB");
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <LocalConfig.hpp> #include <LocalConfig.hpp>
#include "Configuration.hpp" #include "Configuration.hpp"
...@@ -28,8 +29,6 @@ ...@@ -28,8 +29,6 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <WatchDog.hpp> #include <WatchDog.hpp>
#include <getarg.h>
#include <mgmapi_configuration.hpp> #include <mgmapi_configuration.hpp>
#include <mgmapi_config_parameters_debug.h> #include <mgmapi_config_parameters_debug.h>
#include <kernel_config_parameters.h> #include <kernel_config_parameters.h>
...@@ -47,81 +46,86 @@ extern "C" { ...@@ -47,81 +46,86 @@ extern "C" {
#include <EventLogger.hpp> #include <EventLogger.hpp>
extern EventLogger g_eventLogger; extern EventLogger g_eventLogger;
static const char* opt_connect_str= 0;
static int _daemon, _no_daemon, _initial, _no_start;
/**
* Arguments to NDB process
*/
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndbd"),
{ "initial", 256,
"Perform initial start of ndbd, including cleaning the file system. "
"Consult documentation before using this",
(gptr*) &_initial, (gptr*) &_initial, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nostart", 'n',
"Don't start ndbd immediately. Ndbd will await command from ndb_mgmd",
(gptr*) &_no_start, (gptr*) &_no_start, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "daemon", 'd', "Start ndbd as daemon (default)",
(gptr*) &_daemon, (gptr*) &_daemon, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
{ "nodaemon", 257,
"Do not start ndbd as daemon, provided for testing purposes",
(gptr*) &_no_daemon, (gptr*) &_no_daemon, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void short_usage_sub(void)
{
printf("Usage: %s [OPTIONS]\n", my_progname);
}
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
short_usage_sub();
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndbd.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
bool bool
Configuration::init(int argc, const char** argv){ Configuration::init(int argc, char** argv)
{
const char *load_default_groups[]= { "ndbd",0 };
load_defaults("my",load_default_groups,&argc,&argv);
/** int ho_error;
* Default values for arguments if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
*/ exit(ho_error);
int _no_start = 0;
int _initial = 0;
const char* _connect_str = NULL;
int _daemon = 1;
int _no_daemon = 0;
int _help = 0;
int _print_version = 0;
#ifndef DBUG_OFF
const char *debug_option= 0;
#endif
/**
* Arguments to NDB process
*/
struct getargs args[] = {
{ "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" },
{ "nostart", 'n', arg_flag, &_no_start,
"Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" },
{ "daemon", 'd', arg_flag, &_daemon, "Start ndbd as daemon (default)", "" },
{ "nodaemon", 0, arg_flag, &_no_daemon, "Do not start ndbd as daemon, provided for testing purposes", "" },
#ifndef DBUG_OFF
{ "debug", 0, arg_string, &debug_option,
"Specify debug options e.g. d:t:i:o,out.trace", "options" },
#endif
{ "initial", 0, arg_flag, &_initial,
"Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" },
{ "connect-string", 'c', arg_string, &_connect_str,
"Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file",
"<constr>" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"The MySQL Cluster kernel";
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc);
for (int i = 0; i < argc; i++) {
if (strcmp("-i",argv[i]) == 0) {
printf("flag depricated %s, use %s\n", "-i", "--initial");
}
}
return false;
}
if (_no_daemon) { if (_no_daemon) {
_daemon= 0; _daemon= 0;
} }
// check for depricated flag '-i'
#ifndef DBUG_OFF
if (debug_option)
DBUG_PUSH(debug_option);
#endif
DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("no_start=%d", _no_start));
DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("initial=%d", _initial));
DBUG_PRINT("info", ("daemon=%d", _daemon)); DBUG_PRINT("info", ("daemon=%d", _daemon));
DBUG_PRINT("info", ("connect_str=%s", _connect_str)); DBUG_PRINT("info", ("connect_str=%s", opt_connect_str));
ndbSetOwnVersion(); ndbSetOwnVersion();
if (_print_version) {
ndbPrintVersion();
return false;
}
// Check the start flag // Check the start flag
if (_no_start) if (_no_start)
globalData.theRestartFlag = initial_state; globalData.theRestartFlag = initial_state;
...@@ -133,8 +137,8 @@ Configuration::init(int argc, const char** argv){ ...@@ -133,8 +137,8 @@ Configuration::init(int argc, const char** argv){
_initialStart = true; _initialStart = true;
// Check connectstring // Check connectstring
if (_connect_str) if (opt_connect_str)
_connectString = strdup(_connect_str); _connectString = strdup(opt_connect_str);
// Check daemon flag // Check daemon flag
if (_daemon) if (_daemon)
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
/** /**
* Returns false if arguments are invalid * Returns false if arguments are invalid
*/ */
bool init(int argc, const char** argv); bool init(int argc, char** argv);
void fetch_configuration(LocalConfig &local_config); void fetch_configuration(LocalConfig &local_config);
void setupConfiguration(); void setupConfiguration();
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbHost.h> #include <NdbHost.h>
#include <util/getarg.h>
#include <mgmapi.h> #include <mgmapi.h>
#include <ndb_version.h>
#include <LocalConfig.hpp> #include <LocalConfig.hpp>
#include "CommandInterpreter.hpp" #include "CommandInterpreter.hpp"
...@@ -43,28 +44,62 @@ handler(int sig){ ...@@ -43,28 +44,62 @@ handler(int sig){
} }
} }
int main(int argc, const char** argv){
ndb_init(); static unsigned _try_reconnect;
int optind = 0; static char *opt_connect_str= 0;
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_mgm"),
{ "try-reconnect", 't',
"Specify number of retries for connecting to ndb_mgmd, default infinite",
(gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void short_usage_sub(void)
{
printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname);
}
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
short_usage_sub();
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgm.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *_host = 0; const char *_host = 0;
int _port = 0; int _port = 0;
int _help = 0; const char *load_default_groups[]= { "ndb_mgm",0 };
int _try_reconnect = 0;
struct getargs args[] = {
{ "try-reconnect", 't', arg_integer, &_try_reconnect, "Specify number of retries for connecting to ndb_mgmd, default infinite", "#" },
{ "usage", '?', arg_flag, &_help, "Print help", "" },
};
int num_args = sizeof(args) / sizeof(args[0]); /* Number of arguments */
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, progname, "[host [port]]");
exit(1);
}
argv += optind; load_defaults("my",load_default_groups,&argc,&argv);
argc -= optind; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
LocalConfig cfg; LocalConfig cfg;
...@@ -74,7 +109,7 @@ int main(int argc, const char** argv){ ...@@ -74,7 +109,7 @@ int main(int argc, const char** argv){
_port = atoi(argv[1]); _port = atoi(argv[1]);
} }
} else { } else {
if(cfg.init(0, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){ if(cfg.init(opt_connect_str, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){
_host = cfg.ids[0].name.c_str(); _host = cfg.ids[0].name.c_str();
_port = cfg.ids[0].port; _port = cfg.ids[0].port;
} else { } else {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include "MgmtSrvr.hpp" #include "MgmtSrvr.hpp"
#include "EventLogger.hpp" #include "EventLogger.hpp"
...@@ -33,7 +34,6 @@ ...@@ -33,7 +34,6 @@
#include <ndb_version.h> #include <ndb_version.h>
#include <ConfigRetriever.hpp> #include <ConfigRetriever.hpp>
#include <mgmapi_config_parameters.h> #include <mgmapi_config_parameters.h>
#include <getarg.h>
#include <NdbAutoPtr.hpp> #include <NdbAutoPtr.hpp>
...@@ -97,41 +97,70 @@ bool g_StopServer; ...@@ -97,41 +97,70 @@ bool g_StopServer;
extern EventLogger g_EventLogger; extern EventLogger g_EventLogger;
extern int global_mgmt_server_check; extern int global_mgmt_server_check;
int _print_version = 0; static char *opt_connect_str= 0;
#ifndef DBUG_OFF
const char *debug_option= 0; static struct my_option my_long_options[] =
#endif {
NDB_STD_OPTS("ndb_mgmd"),
struct getargs args[] = { { "config-file", 'c', "Specify cluster configuration file",
{ "version", 'v', arg_flag, &_print_version, (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0,
"Print ndb_mgmd version",""}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "config-file", 'c', arg_string, &glob.config_filename, { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)",
"Specify cluster configuration file (default config.ini if available)", (gptr*) &glob.daemon, (gptr*) &glob.daemon, 0,
"filename"}, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
#ifndef DBUG_OFF { "l", 'l', "Specify configuration file connect string (default Ndb.cfg if available)",
{ "debug", 0, arg_string, &debug_option, (gptr*) &glob.local_config_filename, (gptr*) &glob.local_config_filename, 0,
"Specify debug options e.g. d:t:i:o,out.trace", "options"}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif { "interactive", 256, "Run interactive. Not supported but provided for testing purposes",
{ "daemon", 'd', arg_flag, &glob.daemon, (gptr*) &glob.interactive, (gptr*) &glob.interactive, 0,
"Run ndb_mgmd in daemon mode (default)",""}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ NULL, 'l', arg_string, &glob.local_config_filename, { "no-nodeid-checks", 257, "Do not provide any node id checks",
"Specify configuration file connect string (default Ndb.cfg if available)", (gptr*) &g_no_nodeid_checks, (gptr*) &g_no_nodeid_checks, 0,
"filename"}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "interactive", 0, arg_flag, &glob.interactive, { "nodaemon", 258, "Don't run as daemon, but don't read from stdin",
"Run interactive. Not supported but provided for testing purposes", ""}, (gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0,
{ "no-nodeid-checks", 0, arg_flag, &g_no_nodeid_checks, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
"Do not provide any node id checks", ""}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
{ "nodaemon", 0, arg_flag, &glob.non_interactive,
"Don't run as daemon, but don't read from stdin", "non-interactive"}
}; };
static void short_usage_sub(void)
int num_args = sizeof(args) / sizeof(args[0]); {
printf("Usage: %s [OPTIONS]\n", my_progname);
}
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
short_usage_sub();
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgmd.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
/* /*
* MAIN * MAIN
*/ */
NDB_MAIN(mgmsrv){ int main(int argc, char** argv)
ndb_init(); {
NDB_INIT(argv[0]);
/** /**
* OSE specific. Enable shared ownership of file system resources. * OSE specific. Enable shared ownership of file system resources.
...@@ -143,31 +172,20 @@ NDB_MAIN(mgmsrv){ ...@@ -143,31 +172,20 @@ NDB_MAIN(mgmsrv){
#endif #endif
global_mgmt_server_check = 1; global_mgmt_server_check = 1;
glob.config_filename= "config.ini";
int optind = 0; const char *load_default_groups[]= { "ndb_mgmd",0 };
if(getarg(args, num_args, argc, argv, &optind)) { load_defaults("my",load_default_groups,&argc,&argv);
arg_printusage(args, num_args, progname, "");
exit(1); int ho_error;
} if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
if (glob.interactive || if (glob.interactive ||
glob.non_interactive) { glob.non_interactive) {
glob.daemon= 0; glob.daemon= 0;
} }
#ifndef DBUG_OFF
if (debug_option)
DBUG_PUSH(debug_option);
#endif
if (_print_version) {
ndbPrintVersion();
exit(0);
}
if(glob.config_filename == NULL) {
glob.config_filename= "config.ini";
}
glob.socketServer = new SocketServer(); glob.socketServer = new SocketServer();
MgmApiService * mapi = new MgmApiService(); MgmApiService * mapi = new MgmApiService();
......
...@@ -1386,6 +1386,7 @@ Ndb::printState(const char* fmt, ...) ...@@ -1386,6 +1386,7 @@ Ndb::printState(const char* fmt, ...)
va_end(ap); va_end(ap);
NdbMutex_Lock(ndb_print_state_mutex); NdbMutex_Lock(ndb_print_state_mutex);
bool dups = false; bool dups = false;
unsigned i;
ndbout << buf << " ndb=" << hex << this << dec; ndbout << buf << " ndb=" << hex << this << dec;
#ifndef NDB_WIN32 #ifndef NDB_WIN32
ndbout << " thread=" << (int)pthread_self(); ndbout << " thread=" << (int)pthread_self();
...@@ -1406,21 +1407,21 @@ Ndb::printState(const char* fmt, ...) ...@@ -1406,21 +1407,21 @@ Ndb::printState(const char* fmt, ...)
ndbout << "!! DUPS !!" << endl; ndbout << "!! DUPS !!" << endl;
dups = true; dups = true;
} }
for (unsigned i = 0; i < theNoOfPreparedTransactions; i++) for (i = 0; i < theNoOfPreparedTransactions; i++)
thePreparedTransactionsArray[i]->printState(); thePreparedTransactionsArray[i]->printState();
ndbout << "sent: " << theNoOfSentTransactions<< endl; ndbout << "sent: " << theNoOfSentTransactions<< endl;
if (checkdups(theSentTransactionsArray, theNoOfSentTransactions)) { if (checkdups(theSentTransactionsArray, theNoOfSentTransactions)) {
ndbout << "!! DUPS !!" << endl; ndbout << "!! DUPS !!" << endl;
dups = true; dups = true;
} }
for (unsigned i = 0; i < theNoOfSentTransactions; i++) for (i = 0; i < theNoOfSentTransactions; i++)
theSentTransactionsArray[i]->printState(); theSentTransactionsArray[i]->printState();
ndbout << "completed: " << theNoOfCompletedTransactions<< endl; ndbout << "completed: " << theNoOfCompletedTransactions<< endl;
if (checkdups(theCompletedTransactionsArray, theNoOfCompletedTransactions)) { if (checkdups(theCompletedTransactionsArray, theNoOfCompletedTransactions)) {
ndbout << "!! DUPS !!" << endl; ndbout << "!! DUPS !!" << endl;
dups = true; dups = true;
} }
for (unsigned i = 0; i < theNoOfCompletedTransactions; i++) for (i = 0; i < theNoOfCompletedTransactions; i++)
theCompletedTransactionsArray[i]->printState(); theCompletedTransactionsArray[i]->printState();
NdbMutex_Unlock(ndb_print_state_mutex); NdbMutex_Unlock(ndb_print_state_mutex);
} }
......
...@@ -11,7 +11,7 @@ test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ ...@@ -11,7 +11,7 @@ test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \
atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh
atrt_SOURCES = main.cpp atrt_SOURCES = main.cpp
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmclient INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/ndb/src/mgmclient
LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \ LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \
$(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \ $(top_builddir)/dbug/libdbug.a \
......
...@@ -9,7 +9,7 @@ libNDBT_a_SOURCES = \ ...@@ -9,7 +9,7 @@ libNDBT_a_SOURCES = \
HugoAsynchTransactions.cpp UtilTransactions.cpp \ HugoAsynchTransactions.cpp UtilTransactions.cpp \
NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \
NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \ NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \
NdbSchemaCon.cpp NdbSchemaOp.cpp NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/common/mgmcommon -I$(top_srcdir)/ndb/include/mgmcommon -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/src/mgmapi INCLUDES_LOC = -I$(top_srcdir)/ndb/src/common/mgmcommon -I$(top_srcdir)/ndb/include/mgmcommon -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/src/mgmapi
......
...@@ -36,15 +36,33 @@ ...@@ -36,15 +36,33 @@
#include "getarg.h" #include "getarg.h"
#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
extern size_t strlcpy (char *dst, const char *src, size_t dst_sz); static size_t
#endif /* !HAVE_STRLCPY */ strlcpy (char *dst, const char *src, size_t dst_sz)
{
size_t n;
char *p;
for (p = dst, n = 0;
n + 1 < dst_sz && *src != '\0';
++p, ++src, ++n)
*p = *src;
*p = '\0';
if (*src == '\0')
return n;
else
return n + strlen (src);
}
#endif
#ifndef HAVE_STRLCAT #ifndef HAVE_STRLCAT
extern size_t strlcat (char *dst, const char *src, size_t dst_sz); static size_t
#endif /* !HAVE_STRLCAT */ strlcat (char *dst, const char *src, size_t dst_sz)
{
size_t len = strlen(dst);
return len + strlcpy (dst + len, src, dst_sz - len);
}
#endif
#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
#ifndef max #ifndef max
#define max(a, b) (a) > (b) ? (a) : (b) #define max(a, b) (a) > (b) ? (a) : (b)
......
...@@ -15,41 +15,65 @@ ...@@ -15,41 +15,65 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <getarg.h>
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240);
int main(int argc, const char** argv){ static const char* opt_connect_str= 0;
ndb_init(); static const char* _dbname = "TEST_DB";
static struct my_option my_long_options[] =
const char* _tabname = NULL; {
const char* _dbname = "TEST_DB"; NDB_STD_OPTS("ndb_desc"),
int _help = 0; { "database", 'd', "Name of database table is in",
(gptr*) &_dbname, (gptr*) &_dbname, 0,
struct getargs args[] = { GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "usage", '?', arg_flag, &_help, "Print help", "" }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
{ "database", 'd', arg_string, &_dbname, "dbname", };
"Name of database table is in"} static void print_version()
}; {
int num_args = sizeof(args) / sizeof(args[0]); printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
int optind = 0; }
static void usage()
{
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program will delete all records in the specified table using scan delete.\n"; "This program will delete all records in the specified table using scan delete.\n";
print_version();
if(getarg(args, num_args, argc, argv, &optind) || my_print_help(my_long_options);
argv[optind] == NULL || _help) { my_print_variables(my_long_options);
arg_printusage(args, num_args, argv[0], desc); }
return NDBT_ProgramExit(NDBT_WRONGARGS); static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_delete_all.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
} }
_tabname = argv[optind]; return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb::setConnectString(opt_connect_str);
// Connect to Ndb // Connect to Ndb
Ndb MyNdb(_dbname); Ndb MyNdb(_dbname);
...@@ -64,13 +88,12 @@ int main(int argc, const char** argv){ ...@@ -64,13 +88,12 @@ int main(int argc, const char** argv){
// Check if table exists in db // Check if table exists in db
int res = NDBT_OK; int res = NDBT_OK;
for(int i = optind; i<argc; i++){ for(int i = 0; i<argc; i++){
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]);
if(pTab == NULL){ if(pTab == NULL){
ndbout << " Table " << _tabname << " does not exist!" << endl; ndbout << " Table " << argv[i] << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
ndbout << "Deleting all from " << argv[i] << "..."; ndbout << "Deleting all from " << argv[i] << "...";
if(clear_table(&MyNdb, pTab) == NDBT_FAILED){ if(clear_table(&MyNdb, pTab) == NDBT_FAILED){
res = NDBT_FAILED; res = NDBT_FAILED;
......
...@@ -14,40 +14,66 @@ ...@@ -14,40 +14,66 @@
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 <getarg.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
static const char* opt_connect_str= 0;
static const char* _dbname = "TEST_DB";
static int _unqualified = 0;
int main(int argc, const char** argv){ static struct my_option my_long_options[] =
ndb_init(); {
const char* _tabname = NULL; NDB_STD_OPTS("ndb_desc"),
const char* _dbname = "TEST_DB"; { "database", 'd', "Name of database table is in",
int _unqualified = 0; (gptr*) &_dbname, (gptr*) &_dbname, 0,
int _help = 0; GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "unqualified", 'u', "Use unqualified table names",
struct getargs args[] = { (gptr*) &_unqualified, (gptr*) &_unqualified, 0,
{ "unqualified", 'u', arg_flag, &_unqualified, "unqualified", GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
"Use unqualified table names"}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
{ "database", 'd', arg_string, &_dbname, "dbname", };
"Name of database table is in"}, static void print_version()
{ "usage", '?', arg_flag, &_help, "Print help", "" } {
}; printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
int num_args = sizeof(args) / sizeof(args[0]); }
int optind = 0; static void usage()
{
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program list all properties of table(s) in NDB Cluster.\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\
" ex: desc T1 T2 T4\n"; " ex: desc T1 T2 T4\n";
print_version();
if(getarg(args, num_args, argc, argv, &optind) || my_print_help(my_long_options);
argv[optind] == NULL ||_help) { my_print_variables(my_long_options);
arg_printusage(args, num_args, argv[0], desc); }
return NDBT_ProgramExit(NDBT_WRONGARGS); static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_desc.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
} }
_tabname = argv[optind]; return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb::setConnectString(opt_connect_str);
Ndb* pMyNdb; Ndb* pMyNdb;
pMyNdb = new Ndb(_dbname); pMyNdb = new Ndb(_dbname);
...@@ -60,7 +86,7 @@ int main(int argc, const char** argv){ ...@@ -60,7 +86,7 @@ int main(int argc, const char** argv){
ndbout << endl; ndbout << endl;
NdbDictionary::Dictionary * dict = pMyNdb->getDictionary(); NdbDictionary::Dictionary * dict = pMyNdb->getDictionary();
for (int i = optind; i < argc; i++) { for (int i = 0; i < argc; i++) {
NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]); NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]);
if (pTab != 0){ if (pTab != 0){
ndbout << (* pTab) << endl; ndbout << (* pTab) << endl;
......
...@@ -15,38 +15,66 @@ ...@@ -15,38 +15,66 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <getarg.h> static const char* opt_connect_str= 0;
static const char* _dbname = "TEST_DB";
int main(int argc, const char** argv){ static struct my_option my_long_options[] =
ndb_init(); {
NDB_STD_OPTS("ndb_desc"),
const char* _tabname = NULL; { "database", 'd', "Name of database table is in",
const char* _dbname = "TEST_DB"; (gptr*) &_dbname, (gptr*) &_dbname, 0,
int _help = 0; GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
struct getargs args[] = { };
{ "database", 'd', arg_string, &_dbname, "dbname", static void print_version()
"Name of database table is in"}, {
{ "usage", '?', arg_flag, &_help, "Print help", "" } printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}; }
int num_args = sizeof(args) / sizeof(args[0]); static void usage()
int optind = 0; {
char desc[] = char desc[] =
"<indexname>+\n"\ "<indexname>+\n"\
"This program will drop index(es) in Ndb\n"; "This program will drop index(es) in Ndb\n";
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_index.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
if(getarg(args, num_args, argc, argv, &optind) || int main(int argc, char** argv){
argv[optind] == NULL || _help){ NDB_INIT(argv[0]);
arg_printusage(args, num_args, argv[0], desc); const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
if (argc < 1) {
usage();
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
_tabname = argv[optind];
Ndb::setConnectString(opt_connect_str);
// Connect to Ndb // Connect to Ndb
Ndb MyNdb(_dbname); Ndb MyNdb(_dbname);
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
...@@ -58,7 +86,7 @@ int main(int argc, const char** argv){ ...@@ -58,7 +86,7 @@ int main(int argc, const char** argv){
ndbout << "Waiting for ndb to become ready..." << endl; ndbout << "Waiting for ndb to become ready..." << endl;
int res = 0; int res = 0;
for(int i = optind; i<argc; i++){ for(int i = 0; i<argc; i++){
ndbout << "Dropping index " << argv[i] << "..."; ndbout << "Dropping index " << argv[i] << "...";
int tmp; int tmp;
if((tmp = MyNdb.getDictionary()->dropIndex(argv[i], 0)) != 0){ if((tmp = MyNdb.getDictionary()->dropIndex(argv[i], 0)) != 0){
......
...@@ -15,43 +15,67 @@ ...@@ -15,43 +15,67 @@
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 <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <getarg.h> static const char* opt_connect_str= 0;
static const char* _dbname = "TEST_DB";
int main(int argc, const char** argv){ static struct my_option my_long_options[] =
ndb_init(); {
NDB_STD_OPTS("ndb_desc"),
const char* _tabname = NULL; { "database", 'd', "Name of database table is in",
const char* _dbname = "TEST_DB"; (gptr*) &_dbname, (gptr*) &_dbname, 0,
const char* _connectstr = NULL; GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
int _help = 0; { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
struct getargs args[] = { static void print_version()
{ "database", 'd', arg_string, &_dbname, "dbname", {
"Name of database table is in"}, printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
{ "connstr", 'c', arg_string, &_connectstr, "connect string", ndbPrintVersion();
"How to connect to NDB"}, }
{ "usage", '?', arg_flag, &_help, "Print help", "" } static void usage()
}; {
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program will drop one table in Ndb\n"; "This program will drop one table in Ndb\n";
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
if(getarg(args, num_args, argc, argv, &optind) || int main(int argc, char** argv){
argv[optind] == NULL || _help){ NDB_INIT(argv[0]);
arg_printusage(args, num_args, argv[0], desc); const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
if (argc < 1) {
usage();
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
_tabname = argv[optind];
Ndb::setConnectString(opt_connect_str);
if (_connectstr)
Ndb::setConnectString(_connectstr);
Ndb MyNdb(_dbname); Ndb MyNdb(_dbname);
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
...@@ -62,7 +86,7 @@ int main(int argc, const char** argv){ ...@@ -62,7 +86,7 @@ int main(int argc, const char** argv){
ndbout << "Waiting for ndb to become ready..." << endl; ndbout << "Waiting for ndb to become ready..." << endl;
int res = 0; int res = 0;
for(int i = optind; i<argc; i++){ for(int i = 0; i<argc; i++){
ndbout << "Dropping table " << argv[i] << "..."; ndbout << "Dropping table " << argv[i] << "...";
int tmp; int tmp;
if((tmp = MyNdb.getDictionary()->dropTable(argv[i])) != 0){ if((tmp = MyNdb.getDictionary()->dropTable(argv[i])) != 0){
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
#include <ndb_global.h> #include <ndb_global.h>
#include <getarg.h> #include <ndb_opts.h>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
...@@ -161,39 +161,34 @@ list(const char * tabname, ...@@ -161,39 +161,34 @@ list(const char * tabname,
} }
} }
#ifndef DBUG_OFF static const char* opt_connect_str= 0;
const char *debug_option= 0; static const char* _dbname = "TEST_DB";
#endif static int _loops;
static int _type;
int main(int argc, const char** argv){ static struct my_option my_long_options[] =
ndb_init(); {
int _loops = 1; NDB_STD_OPTS("ndb_desc"),
const char* _tabname = NULL; { "database", 'd', "Name of database table is in",
const char* _dbname = "TEST_DB"; (gptr*) &_dbname, (gptr*) &_dbname, 0,
int _type = 0; GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
int _help = 0; { "loops", 'l', "loops",
const char* _connect_str = NULL; (gptr*) &_loops, (gptr*) &_loops, 0,
GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 },
struct getargs args[] = { { "type", 't', "type",
{ "loops", 'l', arg_integer, &_loops, "loops", (gptr*) &_type, (gptr*) &_type, 0,
"Number of times to run(default = 1)" }, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "unqualified", 'u', arg_flag, &_unqualified, "unqualified", { "unqualified", 'u', "Use unqualified table names",
"Use unqualified table names"}, (gptr*) &_unqualified, (gptr*) &_unqualified, 0,
{ "database", 'd', arg_string, &_dbname, "dbname", GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
"Name of database table is in"}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
{ "type", 't', arg_integer, &_type, "type", };
"Type of objects to show, see NdbDictionary.hpp for numbers(default = 0)" }, static void print_version()
{ "connect-string", 'c', arg_string, &_connect_str, {
"Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file", printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
"<constr>" }, ndbPrintVersion();
#ifndef DBUG_OFF }
{ "debug", 0, arg_string, &debug_option, static void usage()
"Specify debug options e.g. d:t:i:o,out.trace", "options" }, {
#endif
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program list all system objects in NDB Cluster.\n"\ "This program list all system objects in NDB Cluster.\n"\
...@@ -201,19 +196,42 @@ int main(int argc, const char** argv){ ...@@ -201,19 +196,42 @@ int main(int argc, const char** argv){
" ex: list_tables -t 2 would show all UserTables\n"\ " ex: list_tables -t 2 would show all UserTables\n"\
"To show all indexes for a table write table name as final argument\n"\ "To show all indexes for a table write table name as final argument\n"\
" ex: list_tables T1\n"; " ex: list_tables T1\n";
print_version();
if(getarg(args, num_args, argc, argv, &optind) || _help) { my_print_help(my_long_options);
arg_printusage(args, num_args, argv[0], desc); my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_show_tables.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char* _tabname;
const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
if ((_tabname = argv[0]) == 0) {
usage();
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
_tabname = argv[optind];
#ifndef DBUG_OFF
if (debug_option)
DBUG_PUSH(debug_option);
#endif
ndb_cluster_connection = new Ndb_cluster_connection(_connect_str); ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str);
ndb = new Ndb(ndb_cluster_connection, _dbname); ndb = new Ndb(ndb_cluster_connection, _dbname);
if (ndb->init() != 0) if (ndb->init() != 0)
fatal("init"); fatal("init");
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
...@@ -23,13 +24,8 @@ ...@@ -23,13 +24,8 @@
#include <NdbMain.h> #include <NdbMain.h>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <getarg.h>
#include <NdbScanFilter.hpp> #include <NdbScanFilter.hpp>
#ifndef DBUG_OFF
const char *debug_option= 0;
#endif
int scanReadRecords(Ndb*, int scanReadRecords(Ndb*,
const NdbDictionary::Table*, const NdbDictionary::Table*,
const NdbDictionary::Index*, const NdbDictionary::Index*,
...@@ -40,39 +36,44 @@ int scanReadRecords(Ndb*, ...@@ -40,39 +36,44 @@ int scanReadRecords(Ndb*,
char delim, char delim,
bool orderby); bool orderby);
int main(int argc, const char** argv){ static const char* opt_connect_str= 0;
ndb_init(); static const char* _dbname = "TEST_DB";
int _parallelism = 240; static const char* _delimiter = "\t";
const char* _delimiter = "\t"; static int _unqualified, _header, _parallelism, _useHexFormat, _lock,
int _header = true; _order;
int _useHexFormat = false;
const char* _tabname = NULL; static struct my_option my_long_options[] =
const char* _dbname = "TEST_DB"; {
int _help = 0; NDB_STD_OPTS("ndb_desc"),
int _lock = 0; { "database", 'd', "Name of database table is in",
int _order = 0; (gptr*) &_dbname, (gptr*) &_dbname, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
struct getargs args[] = { { "parallelism", 'p', "parallelism",
{ "database", 'd', arg_string, &_dbname, "dbname", (gptr*) &_parallelism, (gptr*) &_parallelism, 0,
"Name of database table is in"}, GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 },
{ "parallelism", 'p', arg_integer, &_parallelism, "parallelism", { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)",
"parallelism" }, (gptr*) &_lock, (gptr*) &_lock, 0,
{ "header", 'h', arg_flag, &_header, "Print header", "header" }, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "useHexFormat", 'x', arg_flag, &_useHexFormat, { "order", 'o', "Sort resultset according to index",
"Output numbers in hexadecimal format", "useHexFormat" }, (gptr*) &_order, (gptr*) &_order, 0,
{ "delimiter", 'd', arg_string, &_delimiter, "Column delimiter", GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
"delimiter" }, { "header", 'h', "Print header",
#ifndef DBUG_OFF (gptr*) &_header, (gptr*) &_header, 0,
{ "debug", 0, arg_string, &debug_option, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
"Specify debug options e.g. d:t:i:o,out.trace", "options" }, { "useHexFormat", 'x', "Output numbers in hexadecimal format",
#endif (gptr*) &_useHexFormat, (gptr*) &_useHexFormat, 0,
{ "usage", '?', arg_flag, &_help, "Print help", "" }, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "lock", 'l', arg_integer, &_lock, { "delimiter", 'D', "Column delimiter",
"Read(0), Read-hold(1), Exclusive(2)", "lock"}, (gptr*) &_delimiter, (gptr*) &_delimiter, 0,
{ "order", 'o', arg_flag, &_order, "Sort resultset according to index", ""} GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
}; { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
int num_args = sizeof(args) / sizeof(args[0]); };
int optind = 0; static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program reads all records from one table in NDB Cluster\n"\ "This program reads all records from one table in NDB Cluster\n"\
...@@ -80,19 +81,42 @@ int main(int argc, const char** argv){ ...@@ -80,19 +81,42 @@ int main(int argc, const char** argv){
"(It only print error messages if it encounters a permanent error.)\n"\ "(It only print error messages if it encounters a permanent error.)\n"\
"It can also be used to dump the content of a table to file \n"\ "It can also be used to dump the content of a table to file \n"\
" ex: select_all --no-header --delimiter=';' T4 > T4.data\n"; " ex: select_all --no-header --delimiter=';' T4 > T4.data\n";
print_version();
if(getarg(args, num_args, argc, argv, &optind) || my_print_help(my_long_options);
argv[optind] == NULL || _help) { my_print_variables(my_long_options);
arg_printusage(args, num_args, argv[0], desc); }
return NDBT_ProgramExit(NDBT_WRONGARGS); static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_all.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
} }
_tabname = argv[optind]; return 0;
}
#ifndef DBUG_OFF int main(int argc, char** argv){
if (debug_option) NDB_INIT(argv[0]);
DBUG_PUSH(debug_option); const char *load_default_groups[]= { "ndb_tools",0 };
#endif load_defaults("my",load_default_groups,&argc,&argv);
const char* _tabname;
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
if ((_tabname = argv[0]) == 0) {
usage();
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
Ndb::setConnectString(opt_connect_str);
// Connect to Ndb // Connect to Ndb
Ndb MyNdb(_dbname); Ndb MyNdb(_dbname);
...@@ -108,8 +132,8 @@ int main(int argc, const char** argv){ ...@@ -108,8 +132,8 @@ int main(int argc, const char** argv){
// Check if table exists in db // Check if table exists in db
const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname); const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
const NdbDictionary::Index * pIdx = 0; const NdbDictionary::Index * pIdx = 0;
if(optind+1 < argc){ if(argc > 1){
pIdx = MyNdb.getDictionary()->getIndex(argv[optind+1], _tabname); pIdx = MyNdb.getDictionary()->getIndex(argv[0], _tabname);
} }
if(pTab == NULL){ if(pTab == NULL){
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
...@@ -23,7 +24,6 @@ ...@@ -23,7 +24,6 @@
#include <NdbMain.h> #include <NdbMain.h>
#include <NDBT.hpp> #include <NDBT.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <getarg.h>
#include <UtilTransactions.hpp> #include <UtilTransactions.hpp>
static int static int
...@@ -32,34 +32,68 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, ...@@ -32,34 +32,68 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
int* count_rows, int* count_rows,
UtilTransactions::ScanLock lock); UtilTransactions::ScanLock lock);
int main(int argc, const char** argv){ static const char* opt_connect_str= 0;
ndb_init(); static const char* _dbname = "TEST_DB";
const char* _dbname = "TEST_DB"; static int _parallelism = 240;
int _parallelism = 240; static int _lock = 0;
int _help = 0; static struct my_option my_long_options[] =
int _lock = 0; {
NDB_STD_OPTS("ndb_desc"),
struct getargs args[] = { { "database", 'd', "Name of database table is in",
{ "database", 'd', arg_string, &_dbname, "dbname", (gptr*) &_dbname, (gptr*) &_dbname, 0,
"Name of database table is in"}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 's', arg_integer, &_parallelism, "parallelism", "parallelism" }, { "parallelism", 'p', "parallelism",
{ "usage", '?', arg_flag, &_help, "Print help", "" }, (gptr*) &_parallelism, (gptr*) &_parallelism, 0,
{ "lock", 'l', arg_integer, &_lock, GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 },
"Read(0), Read-hold(1), Exclusive(2)", "lock"} { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)",
(gptr*) &_lock, (gptr*) &_lock, 0,
}; GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
int num_args = sizeof(args) / sizeof(args[0]); { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
int optind = 0; };
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
char desc[] = char desc[] =
"tabname1 ... tabnameN\n"\ "tabname1 ... tabnameN\n"\
"This program will count the number of records in tables\n"; "This program will count the number of records in tables\n";
print_version();
if(getarg(args, num_args, argc, argv, &optind) || my_print_help(my_long_options);
argv[optind] == NULL || _help) { my_print_variables(my_long_options);
arg_printusage(args, num_args, argv[0], desc); }
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_count.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
if (argc < 1) {
usage();
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb::setConnectString(opt_connect_str);
// Connect to Ndb // Connect to Ndb
Ndb MyNdb(_dbname); Ndb MyNdb(_dbname);
...@@ -72,7 +106,7 @@ int main(int argc, const char** argv){ ...@@ -72,7 +106,7 @@ int main(int argc, const char** argv){
while(MyNdb.waitUntilReady() != 0) while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl; ndbout << "Waiting for ndb to become ready..." << endl;
for(int i = optind; i<argc; i++){ for(int i = 0; i<argc; i++){
// Check if table exists in db // Check if table exists in db
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]);
if(pTab == NULL){ if(pTab == NULL){
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_opts.h>
#include <mgmapi.h> #include <mgmapi.h>
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <getarg.h>
#include <kernel/ndb_limits.h> #include <kernel/ndb_limits.h>
#include "../include/mgmcommon/LocalConfig.hpp" #include "../include/mgmcommon/LocalConfig.hpp"
...@@ -29,34 +30,60 @@ ...@@ -29,34 +30,60 @@
int int
waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout);
int main(int argc, const char** argv){ static const char* opt_connect_str= 0;
ndb_init(); static int _no_contact = 0;
static int _timeout = 120;
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
{ "no-contact", 'n', "Wait for cluster no contact",
(gptr*) &_no_contact, (gptr*) &_no_contact, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "timeout", 't', "Timeout to wait",
(gptr*) &_timeout, (gptr*) &_timeout, 0,
GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void print_version()
{
printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
ndbPrintVersion();
}
static void usage()
{
print_version();
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "ndb_tools",0 };
load_defaults("my",load_default_groups,&argc,&argv);
const char* _hostName = NULL; const char* _hostName = NULL;
int _no_contact = 0; int ho_error;
int _help = 0; if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
int _timeout = 120;
struct getargs args[] = {
{ "timeout", 0, arg_integer, &_timeout, "Timeout to wait", "#" },
{ "no-contact", 0, arg_flag, &_no_contact, "Wait for cluster no contact", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"hostname:port\n"\
"This program will connect to the mgmsrv of a NDB cluster.\n"\
"It will then wait for all nodes to be started\n";
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
}
char buf[255]; char buf[255];
_hostName = argv[optind]; _hostName = argv[0];
if (_hostName == NULL){ if (_hostName == NULL){
LocalConfig lcfg; LocalConfig lcfg;
......
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