summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-11-14 11:02:06 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-11-14 11:02:06 +0000
commitbbe9e857e6aff7116bd816d2c2e3f39905abee43 (patch)
tree57617e59cb2ee43ba481c87b953a8a7f43ac17d8 /ndb
parentae39bbf7ccf1a4f21911d14996e60a16814d8af8 (diff)
downloadmariadb-git-bbe9e857e6aff7116bd816d2c2e3f39905abee43.tar.gz
moved ndb_restore together with rest of the ndb tools
kernel includes needed by ndb_restore changed link order moved LocalConfig to mgmapi Moved NdbConfig to Portlib mgmapi to use LocalConfig for connectstring parsing instead of it's own enable usage of "NULL" connectstring for default new ndbmgmclient lib that can be used by e.g. mysqladmin later LocalConfig no longer needed here, now in mgmapi Send connectstring to mgmapi instead added valid connectstring to be with only host without port i.e. valid connectstring =host1,host2,host3 default port will be added ndb/src/common/portlib/NdbConfig.c: Rename: ndb/src/common/mgmcommon/NdbConfig.c -> ndb/src/common/portlib/NdbConfig.c ndb/include/portlib/NdbConfig.h: Rename: ndb/include/mgmcommon/NdbConfig.h -> ndb/include/portlib/NdbConfig.h ndb/include/mgmapi/LocalConfig.hpp: Rename: ndb/include/mgmcommon/LocalConfig.hpp -> ndb/include/mgmapi/LocalConfig.hpp ndb/tools/restore/Makefile.am: Rename: ndb/src/kernel/blocks/backup/restore/Makefile.am -> ndb/tools/restore/Makefile.am ndb/tools/restore/consumer.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer.cpp -> ndb/tools/restore/consumer.cpp ndb/tools/restore/consumer.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer.hpp -> ndb/tools/restore/consumer.hpp ndb/tools/restore/consumer_printer.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp -> ndb/tools/restore/consumer_printer.hpp ndb/tools/restore/consumer_printer.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp -> ndb/tools/restore/consumer_printer.cpp ndb/tools/restore/consumer_restore.hpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp -> ndb/tools/restore/consumer_restore.hpp ndb/tools/restore/main.cpp: Rename: ndb/src/kernel/blocks/backup/restore/main.cpp -> ndb/tools/restore/main.cpp ndb/tools/restore/consumer_restorem.cpp: Rename: ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp -> ndb/tools/restore/consumer_restorem.cpp configure.in: moved ndb_restore together with rest of the ndb tools ndb/config/type_ndbapitools.mk.am: kernel includes needed by ndb_restore ndb/src/Makefile.am: changed link order ndb/src/common/mgmcommon/Makefile.am: mived LocalConfig to mgmapi ndb/src/common/portlib/Makefile.am: Moved NdbConfig to Portlib ndb/src/kernel/blocks/backup/Makefile.am: moved restore together with rest of ndb tools ndb/src/mgmapi/LocalConfig.cpp: added valid connectstring to be with only host without port i.e. valid connectstring =host1,host2,host3 default port will be added ndb/src/mgmapi/Makefile.am: LocalConfig part of the libmgmapi ndb/src/mgmapi/mgmapi.cpp: mgmapi to use LocalConfig for connectstring parsing instead of it's own ndb/src/mgmclient/CommandInterpreter.cpp: enable usage of "NULL" connectstring for default ndb/src/mgmclient/Makefile.am: new ndbmgmclient lib that can be used by e.g. mysqladmin later ndb/src/mgmclient/main.cpp: LocalConfig no longer needed here, now in mgmapi Send connectstring to mgmapi instead ndb/tools/Makefile.am: add ndb_restore to make of tools ndb/tools/restore/Restore.cpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/restore/Restore.hpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/restore/consumer_restore.cpp: moved include BackupFormat and NdbDictionaryImpl to Restore.hpp ndb/tools/waiter.cpp: LocalConfig moved
Diffstat (limited to 'ndb')
-rw-r--r--ndb/config/type_ndbapitools.mk.am3
-rw-r--r--ndb/include/mgmapi/LocalConfig.hpp (renamed from ndb/include/mgmcommon/LocalConfig.hpp)0
-rw-r--r--ndb/include/portlib/NdbConfig.h (renamed from ndb/include/mgmcommon/NdbConfig.h)0
-rw-r--r--ndb/src/Makefile.am2
-rw-r--r--ndb/src/common/mgmcommon/Makefile.am5
-rw-r--r--ndb/src/common/portlib/Makefile.am3
-rw-r--r--ndb/src/common/portlib/NdbConfig.c (renamed from ndb/src/common/mgmcommon/NdbConfig.c)0
-rw-r--r--ndb/src/kernel/blocks/backup/Makefile.am2
-rw-r--r--ndb/src/mgmapi/LocalConfig.cpp (renamed from ndb/src/common/mgmcommon/LocalConfig.cpp)28
-rw-r--r--ndb/src/mgmapi/Makefile.am7
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp84
-rw-r--r--ndb/src/mgmclient/CommandInterpreter.cpp8
-rw-r--r--ndb/src/mgmclient/Makefile.am11
-rw-r--r--ndb/src/mgmclient/main.cpp30
-rw-r--r--ndb/tools/Makefile.am17
-rw-r--r--ndb/tools/restore/Makefile.am (renamed from ndb/src/kernel/blocks/backup/restore/Makefile.am)0
-rw-r--r--ndb/tools/restore/Restore.cpp (renamed from ndb/src/kernel/blocks/backup/restore/Restore.cpp)4
-rw-r--r--ndb/tools/restore/Restore.hpp (renamed from ndb/src/kernel/blocks/backup/restore/Restore.hpp)3
-rw-r--r--ndb/tools/restore/consumer.cpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer.cpp)0
-rw-r--r--ndb/tools/restore/consumer.hpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer.hpp)0
-rw-r--r--ndb/tools/restore/consumer_printer.cpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp)0
-rw-r--r--ndb/tools/restore/consumer_printer.hpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp)0
-rw-r--r--ndb/tools/restore/consumer_restore.cpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp)1
-rw-r--r--ndb/tools/restore/consumer_restore.hpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp)0
-rw-r--r--ndb/tools/restore/consumer_restorem.cpp (renamed from ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp)0
-rw-r--r--ndb/tools/restore/main.cpp (renamed from ndb/src/kernel/blocks/backup/restore/main.cpp)0
-rw-r--r--ndb/tools/waiter.cpp5
27 files changed, 106 insertions, 107 deletions
diff --git a/ndb/config/type_ndbapitools.mk.am b/ndb/config/type_ndbapitools.mk.am
index ed6d8699e05..d4eb090112d 100644
--- a/ndb/config/type_ndbapitools.mk.am
+++ b/ndb/config/type_ndbapitools.mk.am
@@ -11,4 +11,5 @@ INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include/util \
-I$(top_srcdir)/ndb/include/portlib \
-I$(top_srcdir)/ndb/test/include \
- -I$(top_srcdir)/ndb/include/mgmapi
+ -I$(top_srcdir)/ndb/include/mgmapi \
+ -I$(top_srcdir)/ndb/include/kernel
diff --git a/ndb/include/mgmcommon/LocalConfig.hpp b/ndb/include/mgmapi/LocalConfig.hpp
index 9ceeffdba36..9ceeffdba36 100644
--- a/ndb/include/mgmcommon/LocalConfig.hpp
+++ b/ndb/include/mgmapi/LocalConfig.hpp
diff --git a/ndb/include/mgmcommon/NdbConfig.h b/ndb/include/portlib/NdbConfig.h
index 1bca825ab8d..1bca825ab8d 100644
--- a/ndb/include/mgmcommon/NdbConfig.h
+++ b/ndb/include/portlib/NdbConfig.h
diff --git a/ndb/src/Makefile.am b/ndb/src/Makefile.am
index bed43438e91..36a4c3f247f 100644
--- a/ndb/src/Makefile.am
+++ b/ndb/src/Makefile.am
@@ -11,8 +11,8 @@ libndbclient_la_LIBADD = \
common/transporter/libtransporter.la \
common/debugger/libtrace.la \
common/debugger/signaldata/libsignaldataprint.la \
- common/mgmcommon/libmgmsrvcommon.la \
mgmapi/libmgmapi.la \
+ common/mgmcommon/libmgmsrvcommon.la \
common/logger/liblogger.la \
common/portlib/libportlib.la \
common/util/libgeneral.la
diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am
index b787da51ab9..a0aca3e68f1 100644
--- a/ndb/src/common/mgmcommon/Makefile.am
+++ b/ndb/src/common/mgmcommon/Makefile.am
@@ -1,14 +1,11 @@
noinst_LTLIBRARIES = libmgmsrvcommon.la
libmgmsrvcommon_la_SOURCES = \
- LocalConfig.cpp \
ConfigRetriever.cpp \
- IPCConfig.cpp NdbConfig.c
+ IPCConfig.cpp
INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv
-DEFS_LOC = -DNDB_PORT="\"@ndb_port@\""
-
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_ndbapi.mk.am
include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am
diff --git a/ndb/src/common/portlib/Makefile.am b/ndb/src/common/portlib/Makefile.am
index 6f3a3fe01a9..73125ad918d 100644
--- a/ndb/src/common/portlib/Makefile.am
+++ b/ndb/src/common/portlib/Makefile.am
@@ -5,7 +5,8 @@ noinst_LTLIBRARIES = libportlib.la
libportlib_la_SOURCES = \
NdbCondition.c NdbMutex.c NdbSleep.c NdbTick.c \
NdbEnv.c NdbThread.c NdbHost.c NdbTCP.cpp \
- NdbDaemon.c NdbMem.c
+ NdbDaemon.c NdbMem.c \
+ NdbConfig.c
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am
diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/portlib/NdbConfig.c
index 8adc4c20dff..8adc4c20dff 100644
--- a/ndb/src/common/mgmcommon/NdbConfig.c
+++ b/ndb/src/common/portlib/NdbConfig.c
diff --git a/ndb/src/kernel/blocks/backup/Makefile.am b/ndb/src/kernel/blocks/backup/Makefile.am
index 85bf5b12415..e669febdc0d 100644
--- a/ndb/src/kernel/blocks/backup/Makefile.am
+++ b/ndb/src/kernel/blocks/backup/Makefile.am
@@ -1,6 +1,4 @@
-SUBDIRS = restore
-
noinst_LIBRARIES = libbackup.a
libbackup_a_SOURCES = Backup.cpp BackupInit.cpp
diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/mgmapi/LocalConfig.cpp
index 679de716be0..d0ff97cdedf 100644
--- a/ndb/src/common/mgmcommon/LocalConfig.cpp
+++ b/ndb/src/mgmapi/LocalConfig.cpp
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "LocalConfig.hpp"
+#include <LocalConfig.hpp>
#include <NdbEnv.h>
#include <NdbConfig.h>
#include <NdbAutoPtr.hpp>
@@ -164,17 +164,25 @@ LocalConfig::parseNodeId(const char * buf){
bool
LocalConfig::parseHostName(const char * buf){
char tempString[1024];
+ char tempString2[1024];
int port;
- for(int i = 0; hostNameTokens[i] != 0; i++) {
- if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) {
- MgmtSrvrId mgmtSrvrId;
- mgmtSrvrId.type = MgmId_TCP;
- mgmtSrvrId.name.assign(tempString);
- mgmtSrvrId.port = port;
- ids.push_back(mgmtSrvrId);
- return true;
+ do {
+ for(int i = 0; hostNameTokens[i] != 0; i++) {
+ if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) {
+ MgmtSrvrId mgmtSrvrId;
+ mgmtSrvrId.type = MgmId_TCP;
+ mgmtSrvrId.name.assign(tempString);
+ mgmtSrvrId.port = port;
+ ids.push_back(mgmtSrvrId);
+ return true;
+ }
}
- }
+ if (buf == tempString2)
+ break;
+ // try to add default port to see if it works
+ snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT);
+ buf= tempString2;
+ } while(1);
return false;
}
diff --git a/ndb/src/mgmapi/Makefile.am b/ndb/src/mgmapi/Makefile.am
index 0f0e1cea5d8..d64216b56c0 100644
--- a/ndb/src/mgmapi/Makefile.am
+++ b/ndb/src/mgmapi/Makefile.am
@@ -1,10 +1,11 @@
noinst_LTLIBRARIES = libmgmapi.la
-libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp
+libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp LocalConfig.cpp
-INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon
-DEFS_LOC = -DNO_DEBUG_MESSAGES
+INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi
+
+DEFS_LOC = -DNO_DEBUG_MESSAGES -DNDB_PORT="\"@ndb_port@\""
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index 66f0dbb1842..51f2d7cee01 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -17,6 +17,7 @@
#include <ndb_global.h>
#include <my_sys.h>
+#include <LocalConfig.hpp>
#include <NdbAutoPtr.hpp>
#include <NdbTCP.h>
@@ -94,6 +95,8 @@ struct ndb_mgm_handle {
NDB_SOCKET_TYPE socket;
+ char cfg_ptr[sizeof(LocalConfig)];
+
#ifdef MGMAPI_LOG
FILE* logfile;
#endif
@@ -146,10 +149,12 @@ ndb_mgm_create_handle()
h->last_error = 0;
h->last_error_line = 0;
h->hostname = 0;
- h->socket = -1;
+ h->socket = NDB_INVALID_SOCKET;
h->read_timeout = 50000;
h->write_timeout = 100;
+ new (h->cfg_ptr) LocalConfig;
+
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
#ifdef MGMAPI_LOG
h->logfile = 0;
@@ -177,6 +182,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
(* handle)->logfile = 0;
}
#endif
+ ((LocalConfig*)((*handle)->cfg_ptr))->~LocalConfig();
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0;
}
@@ -220,42 +226,6 @@ ndb_mgm_get_latest_error_msg(const NdbMgmHandle h)
return "Error"; // Unknown Error message
}
-static
-int
-parse_connect_string(const char * connect_string,
- NdbMgmHandle handle)
-{
- if(connect_string == 0){
- SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
- return -1;
- }
-
- char * line = my_strdup(connect_string,MYF(MY_WME));
- My_auto_ptr<char> ap1(line);
- if(line == 0){
- SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, "");
- return -1;
- }
-
- char * tmp = strchr(line, ':');
- if(tmp == 0){
- SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, "");
- return -1;
- }
- * tmp = 0; tmp++;
-
- int port = 0;
- if(sscanf(tmp, "%d", &port) != 1){
- SET_ERROR(handle, NDB_MGM_ILLEGAL_PORT_NUMBER, "");
- return -1;
- }
-
- my_free(handle->hostname,MYF(MY_ALLOW_ZERO_PTR));
- handle->hostname = my_strdup(line,MYF(MY_WME));
- handle->port = port;
- return 0;
-}
-
/*
* Call an operation, and return the reply
*/
@@ -348,11 +318,6 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv)
{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_connect");
CHECK_HANDLE(handle, -1);
-
- if(parse_connect_string(mgmsrv, handle) != 0) {
- SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
- return -1;
- }
#ifdef MGMAPI_LOG
/**
@@ -366,14 +331,37 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv)
/**
* Do connect
*/
- SocketClient s(handle->hostname, handle->port);
- const NDB_SOCKET_TYPE sockfd = s.connect();
- if (sockfd < 0) {
+ LocalConfig *cfg= (LocalConfig*)(handle->cfg_ptr);
+ new (cfg) LocalConfig;
+ if (!cfg->init(mgmsrv, 0) ||
+ cfg->ids.size() == 0)
+ {
+ SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
+ return -1;
+ }
+
+ NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET;
+ Uint32 i;
+ for (i = 0; i < cfg->ids.size(); i++)
+ {
+ if (cfg->ids[i].type != MgmId_TCP)
+ continue;
+ SocketClient s(cfg->ids[i].name.c_str(), cfg->ids[i].port);
+ sockfd = s.connect();
+ if (sockfd != NDB_INVALID_SOCKET)
+ break;
+ }
+ if (sockfd == NDB_INVALID_SOCKET)
+ {
setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__,
- "Unable to connect to %s", mgmsrv);
+ "Unable to connect using connectstring %s", mgmsrv);
return -1;
}
-
+
+ my_free(handle->hostname,MYF(MY_ALLOW_ZERO_PTR));
+ handle->hostname = my_strdup(cfg->ids[i].name.c_str(),MYF(MY_WME));
+ handle->port = cfg->ids[i].port;
+
handle->socket = sockfd;
handle->connected = 1;
@@ -392,7 +380,7 @@ ndb_mgm_disconnect(NdbMgmHandle handle)
CHECK_CONNECTED(handle, -1);
NDB_CLOSE_SOCKET(handle->socket);
- handle->socket = -1;
+ handle->socket = NDB_INVALID_SOCKET;
handle->connected = 0;
return 0;
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp
index fde4e5a2e91..d940f6e165a 100644
--- a/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -384,8 +384,10 @@ CommandInterpreter::CommandInterpreter(const char *_host)
connected = false;
try_reconnect = 0;
-
- host = my_strdup(_host,MYF(MY_WME));
+ if (_host)
+ host= my_strdup(_host,MYF(MY_WME));
+ else
+ host= 0;
#ifdef HAVE_GLOBAL_REPLICATION
rep_host = NULL;
m_repserver = NULL;
@@ -400,7 +402,7 @@ CommandInterpreter::~CommandInterpreter()
{
connected = false;
ndb_mgm_destroy_handle(&m_mgmsrv);
- my_free((char *)host,MYF(0));
+ my_free((char *)host,MYF(MY_ALLOW_ZERO_PTR));
host = NULL;
}
diff --git a/ndb/src/mgmclient/Makefile.am b/ndb/src/mgmclient/Makefile.am
index cd6ddb0ad57..b8f9f82e501 100644
--- a/ndb/src/mgmclient/Makefile.am
+++ b/ndb/src/mgmclient/Makefile.am
@@ -3,17 +3,24 @@ noinst_LTLIBRARIES = libndbmgmclient.la
ndbtools_PROGRAMS = ndb_mgm
libndbmgmclient_la_SOURCES = CommandInterpreter.cpp
+libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \
+ ../common/logger/liblogger.la \
+ ../common/portlib/libportlib.la \
+ ../common/util/libgeneral.la \
+ ../common/portlib/libportlib.la
+
ndb_mgm_SOURCES = main.cpp
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_ndbapi.mk.am
-INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon
+INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi \
+ -I$(top_srcdir)/ndb/src/common/mgmcommon
LDADD_LOC = $(noinst_LTLIBRARIES) \
+ ../common/portlib/libportlib.la \
@readline_link@ \
- $(top_builddir)/ndb/src/libndbclient.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a \
diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp
index 8f5d9e6656c..401a9198f30 100644
--- a/ndb/src/mgmclient/main.cpp
+++ b/ndb/src/mgmclient/main.cpp
@@ -145,33 +145,21 @@ int main(int argc, char** argv){
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
- LocalConfig cfg;
-
- if(argc >= 1) {
- _host = argv[0];
- if(argc >= 2) {
- _port = atoi(argv[1]);
- }
- } else {
- if(cfg.init(opt_connect_str, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){
- _host = cfg.ids[0].name.c_str();
- _port = cfg.ids[0].port;
- } else {
- cfg.printError();
- cfg.printUsage();
- return 1;
- }
- }
-
char buf[MAXHOSTNAMELEN+10];
- BaseString::snprintf(buf, sizeof(buf), "%s:%d", _host, _port);
+ if(argc == 1) {
+ BaseString::snprintf(buf, sizeof(buf), "%s", argv[0]);
+ opt_connect_str= buf;
+ } else if (argc >= 2) {
+ BaseString::snprintf(buf, sizeof(buf), "%s:%s", argv[0], argv[1]);
+ opt_connect_str= buf;
+ }
ndbout << "-- NDB Cluster -- Management Client --" << endl;
- printf("Connecting to Management Server: %s\n", buf);
+ printf("Connecting to Management Server: %s\n", opt_connect_str ? opt_connect_str : "default");
signal(SIGPIPE, handler);
- com = new Ndb_mgmclient(buf);
+ com = new Ndb_mgmclient(opt_connect_str);
while(read_and_execute(_try_reconnect));
delete com;
diff --git a/ndb/tools/Makefile.am b/ndb/tools/Makefile.am
index fad9bf9ff84..9c086d665c1 100644
--- a/ndb/tools/Makefile.am
+++ b/ndb/tools/Makefile.am
@@ -8,9 +8,12 @@ ndbtools_PROGRAMS = \
ndb_drop_index \
ndb_show_tables \
ndb_select_all \
- ndb_select_count
+ ndb_select_count \
+ ndb_restore
-tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp ../test/src/NDBT_Table.cpp ../test/src/NDBT_Output.cpp
+tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp \
+ ../test/src/NDBT_Table.cpp \
+ ../test/src/NDBT_Output.cpp
ndb_test_platform_SOURCES = ndb_test_platform.cpp
ndb_waiter_SOURCES = waiter.cpp $(tools_common_sources)
@@ -19,8 +22,15 @@ ndb_desc_SOURCES = desc.cpp $(tools_common_sources)
ndb_drop_index_SOURCES = drop_index.cpp $(tools_common_sources)
ndb_drop_table_SOURCES = drop_tab.cpp $(tools_common_sources)
ndb_show_tables_SOURCES = listTables.cpp $(tools_common_sources)
-ndb_select_all_SOURCES = select_all.cpp ../test/src/NDBT_ResultRow.cpp $(tools_common_sources)
+ndb_select_all_SOURCES = select_all.cpp \
+ ../test/src/NDBT_ResultRow.cpp \
+ $(tools_common_sources)
ndb_select_count_SOURCES = select_count.cpp $(tools_common_sources)
+ndb_restore_SOURCES = restore/main.cpp \
+ restore/consumer.cpp \
+ restore/consumer_restore.cpp \
+ restore/consumer_printer.cpp \
+ restore/Restore.cpp
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_ndbapitools.mk.am
@@ -34,6 +44,7 @@ ndb_drop_index_LDFLAGS = @ndb_bin_am_ldflags@
ndb_show_tables_LDFLAGS = @ndb_bin_am_ldflags@
ndb_select_all_LDFLAGS = @ndb_bin_am_ldflags@
ndb_select_count_LDFLAGS = @ndb_bin_am_ldflags@
+ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/ndb/src/kernel/blocks/backup/restore/Makefile.am b/ndb/tools/restore/Makefile.am
index 16550f13546..16550f13546 100644
--- a/ndb/src/kernel/blocks/backup/restore/Makefile.am
+++ b/ndb/tools/restore/Makefile.am
diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.cpp b/ndb/tools/restore/Restore.cpp
index fb3bde6bdef..6e2fcaed3af 100644
--- a/ndb/src/kernel/blocks/backup/restore/Restore.cpp
+++ b/ndb/tools/restore/Restore.cpp
@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "Restore.hpp"
-#include "BackupFormat.hpp"
#include <NdbTCP.h>
#include <OutputStream.hpp>
#include <Bitmask.hpp>
@@ -25,9 +24,6 @@
#include <SimpleProperties.hpp>
#include <signaldata/DictTabInfo.hpp>
-// from src/ndbapi
-#include <NdbDictionaryImpl.hpp>
-
Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data
Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data
Uint64 Twiddle64(Uint64 in); // Byte shift 64-bit data
diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.hpp b/ndb/tools/restore/Restore.hpp
index 0ec1ab852e9..82fcdcdb183 100644
--- a/ndb/src/kernel/blocks/backup/restore/Restore.hpp
+++ b/ndb/tools/restore/Restore.hpp
@@ -19,7 +19,8 @@
#include <ndb_global.h>
#include <NdbOut.hpp>
-#include <BackupFormat.hpp>
+#include "../src/kernel/blocks/backup/BackupFormat.hpp"
+#include "../src/ndbapi/NdbDictionaryImpl.hpp"
#include <NdbApi.hpp>
#include <ndb_version.h>
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp
index e94c31b2666..e94c31b2666 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer.cpp
+++ b/ndb/tools/restore/consumer.cpp
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.hpp b/ndb/tools/restore/consumer.hpp
index 692c814159f..692c814159f 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer.hpp
+++ b/ndb/tools/restore/consumer.hpp
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp b/ndb/tools/restore/consumer_printer.cpp
index 0aa5b521d29..0aa5b521d29 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp
+++ b/ndb/tools/restore/consumer_printer.cpp
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp b/ndb/tools/restore/consumer_printer.hpp
index 7cbc924e364..7cbc924e364 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp
+++ b/ndb/tools/restore/consumer_printer.hpp
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp
index a35d9d22c65..e2c55e5a0b1 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp
+++ b/ndb/tools/restore/consumer_restore.cpp
@@ -16,7 +16,6 @@
#include "consumer_restore.hpp"
#include <NdbSleep.h>
-#include <NdbDictionaryImpl.hpp>
extern FilteredNdbOut err;
extern FilteredNdbOut info;
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp b/ndb/tools/restore/consumer_restore.hpp
index 59e2734ea1f..59e2734ea1f 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp
+++ b/ndb/tools/restore/consumer_restore.hpp
diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp b/ndb/tools/restore/consumer_restorem.cpp
index 6a9ec07148a..6a9ec07148a 100644
--- a/ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp
+++ b/ndb/tools/restore/consumer_restorem.cpp
diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/tools/restore/main.cpp
index 482212911cb..482212911cb 100644
--- a/ndb/src/kernel/blocks/backup/restore/main.cpp
+++ b/ndb/tools/restore/main.cpp
diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp
index be572d7c275..e24164ea807 100644
--- a/ndb/tools/waiter.cpp
+++ b/ndb/tools/waiter.cpp
@@ -23,12 +23,13 @@
#include <NdbOut.hpp>
#include <NdbSleep.h>
#include <kernel/ndb_limits.h>
-#include "../include/mgmcommon/LocalConfig.hpp"
+#include <LocalConfig.hpp>
#include <NDBT.hpp>
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);
static const char* opt_connect_str= 0;
static int _no_contact = 0;