summaryrefslogtreecommitdiff
path: root/ndb/test/tools
diff options
context:
space:
mode:
authorunknown <magnus@neptunus.(none)>2004-04-14 10:53:21 +0200
committerunknown <magnus@neptunus.(none)>2004-04-14 10:53:21 +0200
commit6386c55cee50bad6a9979d1fab28e03bb8612ca7 (patch)
tree3fbbacf704304b69228474b9f03549ccd585a017 /ndb/test/tools
parent0ba6cb48d84f1ff951d09871a96be6cdef3f2c3c (diff)
downloadmariadb-git-6386c55cee50bad6a9979d1fab28e03bb8612ca7.tar.gz
Initial revision of NDB Cluster files
BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'ndb/test/tools')
-rw-r--r--ndb/test/tools/Makefile9
-rw-r--r--ndb/test/tools/hugoCalculator/Makefile11
-rw-r--r--ndb/test/tools/hugoCalculator/hugoCalculator.cpp68
-rw-r--r--ndb/test/tools/hugoFill/Makefile11
-rw-r--r--ndb/test/tools/hugoFill/hugoFill.cpp78
-rw-r--r--ndb/test/tools/hugoLoad/Makefile11
-rw-r--r--ndb/test/tools/hugoLoad/hugoLoad.cpp82
-rw-r--r--ndb/test/tools/hugoLockRecords/Makefile9
-rw-r--r--ndb/test/tools/hugoLockRecords/hugoLockRecords.cpp90
-rw-r--r--ndb/test/tools/hugoPkDelete/Makefile9
-rw-r--r--ndb/test/tools/hugoPkDelete/hugoPkDel.cpp86
-rw-r--r--ndb/test/tools/hugoPkRead/Makefile9
-rw-r--r--ndb/test/tools/hugoPkRead/hugoPkRead.cpp91
-rw-r--r--ndb/test/tools/hugoPkReadRecord/Makefile11
-rw-r--r--ndb/test/tools/hugoPkReadRecord/hugoPkReadRecord.cpp193
-rw-r--r--ndb/test/tools/hugoPkUpdate/Makefile9
-rw-r--r--ndb/test/tools/hugoPkUpdate/hugoPkUpd.cpp88
-rw-r--r--ndb/test/tools/hugoScanRead/Makefile9
-rw-r--r--ndb/test/tools/hugoScanRead/hugoScanRead.cpp90
-rw-r--r--ndb/test/tools/hugoScanUpdate/Makefile9
-rw-r--r--ndb/test/tools/hugoScanUpdate/hugoScanUpd.cpp100
-rw-r--r--ndb/test/tools/restart/Makefile11
-rw-r--r--ndb/test/tools/restart/restart.cpp84
-rw-r--r--ndb/test/tools/waiter/Makefile11
-rw-r--r--ndb/test/tools/waiter/waiter.cpp57
25 files changed, 1236 insertions, 0 deletions
diff --git a/ndb/test/tools/Makefile b/ndb/test/tools/Makefile
new file mode 100644
index 00000000000..b8e90ae207f
--- /dev/null
+++ b/ndb/test/tools/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+DIRS := hugoCalculator hugoFill hugoLoad hugoLockRecords \
+ hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate \
+ hugoScanRead hugoScanUpdate restart waiter
+
+include $(NDB_TOP)/Epilogue.mk
+
+_bins_ndbapi : _libs_src
diff --git a/ndb/test/tools/hugoCalculator/Makefile b/ndb/test/tools/hugoCalculator/Makefile
new file mode 100644
index 00000000000..a29deeaacd3
--- /dev/null
+++ b/ndb/test/tools/hugoCalculator/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoCalculator
+
+# Source files of non-templated classes (.C files)
+SOURCES = hugoCalculator.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/hugoCalculator/hugoCalculator.cpp b/ndb/test/tools/hugoCalculator/hugoCalculator.cpp
new file mode 100644
index 00000000000..4cb801d3d73
--- /dev/null
+++ b/ndb/test/tools/hugoCalculator/hugoCalculator.cpp
@@ -0,0 +1,68 @@
+/* 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 */
+
+#include <NdbOut.hpp>
+#include <stdlib.h>
+#include <NdbSleep.h>
+#include <NDBT_Tables.hpp>
+#include <getarg.h>
+#include <NDBT.hpp>
+#include <HugoCalculator.hpp>
+
+//extern NdbOut g_info;
+
+int main(int argc, const char** argv)
+{
+ int _row = 0;
+ int _column = 0;
+ int _updates = 0;
+ const char* _tableName = NULL;
+
+ struct getargs args[] = {
+ { "row", 'r', arg_integer, &_row, "The row number", "row" },
+ { "column", 'c', arg_integer, &_column, "The column id", "column" },
+ { "updates", 'u', arg_integer, &_updates, "# of updates", "updates" }
+ };
+
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+
+ if(getarg(args, num_args, argc, argv, &optind) || argv[optind] == NULL) {
+ arg_printusage(args, num_args, argv[0], "table name\n");
+ return NDBT_WRONGARGS;
+ }
+ // Check if table name is supplied
+ if (argv[optind] != NULL)
+ _tableName = argv[optind];
+
+
+ const NdbDictionary::Table* table = NDBT_Tables::getTable(_tableName);
+ const NdbDictionary::Column * attribute = table->getColumn(_column);
+
+ g_info << "Table " << _tableName << endl
+ << "Row: " << _row << ", "
+ << "Column(" << attribute->getName() << ")"
+ << "[" << attribute->getType() << "]"
+ << ", Updates: " << _updates
+ << endl;
+
+ HugoCalculator calc(*table);
+ char buf[8000];
+ g_info << "Value: " << calc.calcValue(_row, _column, _updates, buf)
+ << endl;
+
+ return 0;
+}
diff --git a/ndb/test/tools/hugoFill/Makefile b/ndb/test/tools/hugoFill/Makefile
new file mode 100644
index 00000000000..3da745810b6
--- /dev/null
+++ b/ndb/test/tools/hugoFill/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoFill
+
+# Source files of non-templated classes (.C files)
+SOURCES = hugoFill.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/hugoFill/hugoFill.cpp b/ndb/test/tools/hugoFill/hugoFill.cpp
new file mode 100644
index 00000000000..748623cb253
--- /dev/null
+++ b/ndb/test/tools/hugoFill/hugoFill.cpp
@@ -0,0 +1,78 @@
+/* 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 */
+
+#include <stdio.h>
+
+#include <NdbOut.hpp>
+#include <NdbApi.hpp>
+#include <NdbSleep.h>
+#include <NDBT.hpp>
+#include <HugoTransactions.hpp>
+#include <getarg.h>
+
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ const char* _tabname = NULL;
+ int _help = 0;
+ int _batch = 512;
+
+ struct getargs args[] = {
+ { "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will load one table in Ndb with calculated data \n"\
+ "until the database is full. \n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ // Connect to Ndb and wait for it to become ready
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ if (hugoTrans.fillTable(&MyNdb,
+ _batch) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
diff --git a/ndb/test/tools/hugoLoad/Makefile b/ndb/test/tools/hugoLoad/Makefile
new file mode 100644
index 00000000000..7c5756d0d41
--- /dev/null
+++ b/ndb/test/tools/hugoLoad/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoLoad
+
+# Source files of non-templated classes (.C files)
+SOURCES = hugoLoad.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/hugoLoad/hugoLoad.cpp b/ndb/test/tools/hugoLoad/hugoLoad.cpp
new file mode 100644
index 00000000000..be7f878d106
--- /dev/null
+++ b/ndb/test/tools/hugoLoad/hugoLoad.cpp
@@ -0,0 +1,82 @@
+/* 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 */
+
+
+#include <NdbOut.hpp>
+#include <NdbApi.hpp>
+#include <NdbSleep.h>
+#include <NDBT.hpp>
+#include <HugoTransactions.hpp>
+#include <getarg.h>
+
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ const char* _tabname = NULL;
+ int _help = 0;
+ int _batch = 512;
+
+ struct getargs args[] = {
+ { "records", 'r', arg_integer, &_records, "Number of records", "recs" },
+ { "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will load one table in Ndb with calculated data. \n"\
+ "This means that it is possible to check the validity of the data \n"\
+ "at a later time. The last column in each table is used as an update \n"\
+ "counter, it's initialised to zero and should be incremented for each \n"\
+ "update of the record. \n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _records == 0 || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ // Connect to Ndb and wait for it to become ready
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ if (hugoTrans.loadTable(&MyNdb,
+ _records,
+ _batch) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
diff --git a/ndb/test/tools/hugoLockRecords/Makefile b/ndb/test/tools/hugoLockRecords/Makefile
new file mode 100644
index 00000000000..3235750cbf8
--- /dev/null
+++ b/ndb/test/tools/hugoLockRecords/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoLockRecords
+
+SOURCES := hugoLockRecords.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoLockRecords/hugoLockRecords.cpp b/ndb/test/tools/hugoLockRecords/hugoLockRecords.cpp
new file mode 100644
index 00000000000..90c08649ec2
--- /dev/null
+++ b/ndb/test/tools/hugoLockRecords/hugoLockRecords.cpp
@@ -0,0 +1,90 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _percentVal = 1;
+ int _lockTime = 1000;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "recs" },
+ { "locktime", 't', arg_integer, &_lockTime, "Time in ms to hold lock(default=1000)", "ms" },
+ { "percent", 'p', arg_integer, &_percentVal, "Percent of records to lock(default=1%)", "%" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will lock p% of the records in the table for x milliseconds\n"\
+ "then it will lock the next 1% and continue to do so until it has locked \n"\
+ "all records in the table\n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _records == 0 || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ while (i<_loops || _loops==0) {
+ ndbout << i << ": ";
+ if (hugoTrans.lockRecords(&MyNdb, _records, _percentVal, _lockTime) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
+
diff --git a/ndb/test/tools/hugoPkDelete/Makefile b/ndb/test/tools/hugoPkDelete/Makefile
new file mode 100644
index 00000000000..e6d53611c54
--- /dev/null
+++ b/ndb/test/tools/hugoPkDelete/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoPkDelete
+
+SOURCES := hugoPkDel.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoPkDelete/hugoPkDel.cpp b/ndb/test/tools/hugoPkDelete/hugoPkDel.cpp
new file mode 100644
index 00000000000..f77dc21bd0b
--- /dev/null
+++ b/ndb/test/tools/hugoPkDelete/hugoPkDel.cpp
@@ -0,0 +1,86 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _batch = 0;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ // { "batch", 'b', arg_integer, &_batch, "batch value", "batch" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "records" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will delete all records in a table using PK \n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _records == 0 || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ while (i<_loops || _loops==0) {
+ ndbout << i << ": ";
+ if (hugoTrans.pkDelRecords(&MyNdb, _records) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
+
diff --git a/ndb/test/tools/hugoPkRead/Makefile b/ndb/test/tools/hugoPkRead/Makefile
new file mode 100644
index 00000000000..03580dc0d18
--- /dev/null
+++ b/ndb/test/tools/hugoPkRead/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoPkRead
+
+SOURCES := hugoPkRead.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoPkRead/hugoPkRead.cpp b/ndb/test/tools/hugoPkRead/hugoPkRead.cpp
new file mode 100644
index 00000000000..2e9c2c35260
--- /dev/null
+++ b/ndb/test/tools/hugoPkRead/hugoPkRead.cpp
@@ -0,0 +1,91 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _abort = 0;
+ int _batch = 1;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" },
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ { "batch", 'b', arg_integer, &_batch, "batch value(not 0)", "batch" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "records" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will read 'r' records from one table in Ndb. \n"\
+ "It will verify every column read by calculating the expected value.\n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _records == 0 || _batch == 0 || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ while (i<_loops || _loops==0) {
+ ndbout << i << ": ";
+ if (hugoTrans.pkReadRecords(&MyNdb, _records, _batch) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
+
diff --git a/ndb/test/tools/hugoPkReadRecord/Makefile b/ndb/test/tools/hugoPkReadRecord/Makefile
new file mode 100644
index 00000000000..158a79a5666
--- /dev/null
+++ b/ndb/test/tools/hugoPkReadRecord/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoPkReadRecord
+
+# Source files of non-templated classes (.C files)
+SOURCES = hugoPkReadRecord.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/hugoPkReadRecord/hugoPkReadRecord.cpp b/ndb/test/tools/hugoPkReadRecord/hugoPkReadRecord.cpp
new file mode 100644
index 00000000000..6335c391bc3
--- /dev/null
+++ b/ndb/test/tools/hugoPkReadRecord/hugoPkReadRecord.cpp
@@ -0,0 +1,193 @@
+/* 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 */
+
+#include <NdbOut.hpp>
+#include <stdlib.h>
+#include <NdbSleep.h>
+#include <NDBT_Tables.hpp>
+#include <getarg.h>
+#include <NDBT.hpp>
+#include <Ndb.hpp>
+#include <NdbDictionary.hpp>
+
+//extern NdbOut g_info;
+
+int main(int argc, const char** argv)
+{
+ int _row = 0;
+ int _hex = 0;
+ int _primaryKey = 0;
+ const char* _tableName = NULL;
+
+ struct getargs args[] = {
+ { "row", 'r',
+ arg_integer, &_row, "The row number", "row" },
+ { "primarykey", 'p',
+ arg_integer, &_primaryKey, "The primary key", "primarykey" },
+ { "hex", 'h',
+ arg_flag, &_hex, "Print hex", "hex" }
+ };
+
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+
+ if(getarg(args, num_args, argc, argv, &optind) || argv[optind] == NULL) {
+ arg_printusage(args, num_args, argv[0], "table name\n");
+ return NDBT_WRONGARGS;
+ }
+ // Check if table name is supplied
+ if (argv[optind] != NULL)
+ _tableName = argv[optind];
+
+
+ const NdbDictionary::Table* table = NDBT_Tables::getTable(_tableName);
+ // const NDBT_Attribute* attribute = table->getAttribute(_column);
+
+ g_info << "Table " << _tableName << endl
+ << "Row: " << _row << ", PrimaryKey: " << _primaryKey
+ << endl;
+
+ Ndb* ndb = new Ndb("TEST_DB");
+ if (ndb->init() == 0 && ndb->waitUntilReady(30) == 0)
+ {
+ NdbConnection* conn = ndb->startTransaction();
+ if (conn == NULL)
+ {
+ g_info << "ERROR: " << ndb->getNdbError() << endl;
+ delete ndb;
+ return -1;
+ }
+ NdbOperation* op = conn->getNdbOperation(_tableName);
+ if (op == NULL)
+ {
+ g_info << "ERROR: " << conn->getNdbError() << endl;
+ delete ndb;
+ return -1;
+ }
+ op->readTuple();
+ NdbRecAttr** data = new NdbRecAttr*[table->getNoOfColumns()];
+ for (int i = 0; i < table->getNoOfColumns(); i++)
+ {
+ const NdbDictionary::Column* c = table->getColumn(i);
+ if (c->getPrimaryKey())
+ {
+ op->equal(c->getName(), _primaryKey);
+ data[i] = op->getValue(c->getName(), NULL);
+ }
+ else
+ {
+ data[i] = op->getValue(c->getName(), NULL);
+ }
+ }
+
+ if (conn->execute(Commit) == 0)
+ {
+ // Print column names
+ for (int i = 0; i < table->getNoOfColumns(); i++)
+ {
+ const NdbDictionary::Column* c = table->getColumn(i);
+
+ g_info
+ << c->getName()
+ << "[" << c->getType() << "] ";
+ }
+ g_info << endl;
+
+ if (_hex)
+ {
+ g_info << hex;
+ }
+ for (int i = 0; i < table->getNoOfColumns(); i++)
+ {
+ NdbRecAttr* a = data[i];
+ switch(a->getType())
+ {
+ case NdbDictionary::Column::Char:
+ case NdbDictionary::Column::Varchar:
+ case NdbDictionary::Column::Binary:
+ case NdbDictionary::Column::Varbinary:
+ {
+ if (_hex)
+ {
+ char* b = a->aRef();
+ for (int j = 0; j < a->arraySize(); j++)
+ {
+ //ndbout_c("%x", b[j]);
+ g_info << hex << b[j] << "[" << dec << j << "]";
+ }
+ }
+ else
+ {
+ g_info << "\""
+ << a->aRef() << "\"";
+ }
+ g_info << " ";
+ }
+ break;
+
+ case NdbDictionary::Column::Int:
+ case NdbDictionary::Column::Unsigned:
+ {
+ g_info << a->int32_value() << " ";
+ }
+ break;
+
+ case NdbDictionary::Column::Bigint:
+ case NdbDictionary::Column::Bigunsigned:
+ {
+ g_info << a->int64_value() << " ";
+ }
+ break;
+
+ case NdbDictionary::Column::Float:
+ {
+ g_info << a->float_value() << " ";
+ }
+ break;
+
+ case NdbDictionary::Column::Undefined:
+ default:
+ {
+ g_info << "Undefined!!! ";
+ }
+ break;
+
+ } // case
+ g_info << " ";
+ } // for
+ g_info << endl;
+ } // if (conn
+ else
+ {
+ g_info << "Failed to commit read transaction... "
+ << conn->getNdbError()
+ << ", commitStatus = " << conn->commitStatus()
+ << endl;
+ }
+
+ delete[] data;
+
+ ndb->closeTransaction(conn);
+ } // if (ndb.init
+ else
+ {
+ g_info << "ERROR: Unable to connect to NDB, "
+ << ndb->getNdbError() << endl;
+ }
+ delete ndb;
+
+ return 0;
+}
diff --git a/ndb/test/tools/hugoPkUpdate/Makefile b/ndb/test/tools/hugoPkUpdate/Makefile
new file mode 100644
index 00000000000..48795b62206
--- /dev/null
+++ b/ndb/test/tools/hugoPkUpdate/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoPkUpdate
+
+SOURCES := hugoPkUpd.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoPkUpdate/hugoPkUpd.cpp b/ndb/test/tools/hugoPkUpdate/hugoPkUpd.cpp
new file mode 100644
index 00000000000..141d01e3aee
--- /dev/null
+++ b/ndb/test/tools/hugoPkUpdate/hugoPkUpd.cpp
@@ -0,0 +1,88 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _abort = 0;
+ int _batch = 0;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" },
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ // { "batch", 'b', arg_integer, &_batch, "batch value", "batch" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "records" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will update all records in a table using PK\n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _records == 0 || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ while (i<_loops || _loops==0) {
+ ndbout << "loop " << i << ": ";
+ if (hugoTrans.pkUpdateRecords(&MyNdb,
+ _records) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
diff --git a/ndb/test/tools/hugoScanRead/Makefile b/ndb/test/tools/hugoScanRead/Makefile
new file mode 100644
index 00000000000..b88377c299e
--- /dev/null
+++ b/ndb/test/tools/hugoScanRead/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoScanRead
+
+SOURCES := hugoScanRead.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoScanRead/hugoScanRead.cpp b/ndb/test/tools/hugoScanRead/hugoScanRead.cpp
new file mode 100644
index 00000000000..2376280d004
--- /dev/null
+++ b/ndb/test/tools/hugoScanRead/hugoScanRead.cpp
@@ -0,0 +1,90 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _abort = 0;
+ int _parallelism = 1;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" },
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ { "parallelism", 'p', arg_integer, &_parallelism, "parallelism(1-240)", "para" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "recs" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ " tabname\n"\
+ "This program will scan read all records in one table in Ndb.\n"\
+ "It will verify every column read by calculating the expected value.\n";
+
+ if(getarg(args, num_args, argc, argv, &optind) || argv[optind] == NULL || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ while (i<_loops || _loops==0) {
+ ndbout << i << ": ";
+ if(hugoTrans.scanReadRecords(&MyNdb,
+ 0,
+ _abort,
+ _parallelism) != 0){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
diff --git a/ndb/test/tools/hugoScanUpdate/Makefile b/ndb/test/tools/hugoScanUpdate/Makefile
new file mode 100644
index 00000000000..ec0e07bfd84
--- /dev/null
+++ b/ndb/test/tools/hugoScanUpdate/Makefile
@@ -0,0 +1,9 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := hugoScanUpdate
+
+SOURCES := hugoScanUpd.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/tools/hugoScanUpdate/hugoScanUpd.cpp b/ndb/test/tools/hugoScanUpdate/hugoScanUpd.cpp
new file mode 100644
index 00000000000..56cd3b8c969
--- /dev/null
+++ b/ndb/test/tools/hugoScanUpdate/hugoScanUpd.cpp
@@ -0,0 +1,100 @@
+/* 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 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <NdbOut.hpp>
+
+#include <NdbApi.hpp>
+#include <NdbMain.h>
+#include <NDBT.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <HugoTransactions.hpp>
+
+int main(int argc, const char** argv){
+
+ int _records = 0;
+ int _loops = 1;
+ int _parallelism = 1;
+ int _ver2 = 0;
+ const char* _tabname = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
+ { "parallelism", 'p', arg_integer, &_parallelism, "parallelism(1-240)", "para" },
+ { "records", 'r', arg_integer, &_records, "Number of records", "recs" },
+ { "ver2", '2', arg_flag, &_ver2, "Use version 2 of scanUpdateRecords", "" },
+ { "ver2", '1', arg_negative_flag, &_ver2, "Use version 1 of scanUpdateRecords (default)", "" },
+ { "usage", '?', arg_flag, &_help, "Print help", "" }
+ };
+ int num_args = sizeof(args) / sizeof(args[0]);
+ int optind = 0;
+ char desc[] =
+ "tabname\n"\
+ "This program will scan update all records in one table in Ndb\n";
+
+ if(getarg(args, num_args, argc, argv, &optind) ||
+ argv[optind] == NULL || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _tabname = argv[optind];
+
+ // Connect to Ndb
+ Ndb MyNdb( "TEST_DB" );
+
+ if(MyNdb.init() != 0){
+ ERR(MyNdb.getNdbError());
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ while(MyNdb.waitUntilReady() != 0)
+ ndbout << "Waiting for ndb to become ready..." << endl;
+
+ // Check if table exists in db
+ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
+ if(pTab == NULL){
+ ndbout << " Table " << _tabname << " does not exist!" << endl;
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+
+ HugoTransactions hugoTrans(*pTab);
+ int i = 0;
+ int res = NDBT_FAILED;
+ while (i<_loops || _loops==0) {
+ ndbout << i << ": ";
+ if (_ver2 == 0){
+ res = hugoTrans.scanUpdateRecords(&MyNdb,
+ _records,
+ 0,
+ _parallelism);
+ } else{
+ res = hugoTrans.scanUpdateRecords2(&MyNdb,
+ _records,
+ 0,
+ _parallelism);
+ }
+ if (res != NDBT_OK ){
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+ i++;
+ }
+
+ return NDBT_ProgramExit(NDBT_OK);
+}
diff --git a/ndb/test/tools/restart/Makefile b/ndb/test/tools/restart/Makefile
new file mode 100644
index 00000000000..05d9e98c5bc
--- /dev/null
+++ b/ndb/test/tools/restart/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := restart
+
+# Source files of non-templated classes (.C files)
+SOURCES = restart.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/restart/restart.cpp b/ndb/test/tools/restart/restart.cpp
new file mode 100644
index 00000000000..f391aecabe1
--- /dev/null
+++ b/ndb/test/tools/restart/restart.cpp
@@ -0,0 +1,84 @@
+/* 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 */
+
+
+#include <string.h>
+#include <NdbMain.h>
+#include <OutputStream.hpp>
+#include <NdbOut.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+#include <NdbRestarter.hpp>
+#include <NDBT.hpp>
+#include <assert.h>
+#include <NdbStdio.h>
+
+int main(int argc, const char** argv){
+
+ const char* _hostName = NULL;
+ int _initial = 0;
+ int _help = 0;
+ int _wait = 1;
+
+
+ struct getargs args[] = {
+ { "initial", 'i', arg_flag, &_initial, "Do initial restart"},
+ { "wait", '\0', arg_negative_flag, &_wait, "Wait until restarted(default=true)"},
+ { "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"\
+ " and restart the cluster. \n";
+
+ if(getarg(args, num_args, argc, argv, &optind) || _help) {
+ arg_printusage(args, num_args, argv[0], desc);
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ _hostName = argv[optind];
+
+ NdbRestarter restarter(_hostName);
+ setOutputLevel(1); // Show only g_err
+ int result = NDBT_OK;
+ if (_initial){
+ ndbout << "Restarting cluster with initial restart" << endl;
+ if (restarter.restartAll(true, false, false) != 0)
+ result = NDBT_FAILED;
+ } else {
+ ndbout << "Restarting cluster " << endl;
+ if (restarter.restartAll() != 0)
+ result = NDBT_FAILED;
+ }
+ if (result == NDBT_FAILED){
+ g_err << "Failed to restart cluster" << endl;
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
+
+ if (_wait == 1){
+ ndbout << "Waiting for cluster to start" << endl;
+ if ( restarter.waitClusterStarted(120) != 0){
+ ndbout << "Failed waiting for restart of cluster" << endl;
+ result = NDBT_FAILED;
+ }
+ }
+ ndbout << "Cluster restarted" << endl;
+
+ return NDBT_ProgramExit(result);
+}
diff --git a/ndb/test/tools/waiter/Makefile b/ndb/test/tools/waiter/Makefile
new file mode 100644
index 00000000000..da2c9daff00
--- /dev/null
+++ b/ndb/test/tools/waiter/Makefile
@@ -0,0 +1,11 @@
+include .defs.mk
+
+TYPE := ndbapitest
+
+BIN_TARGET := waiter
+
+# Source files of non-templated classes (.C files)
+SOURCES = waiter.cpp
+
+include $(NDB_TOP)/Epilogue.mk
+
diff --git a/ndb/test/tools/waiter/waiter.cpp b/ndb/test/tools/waiter/waiter.cpp
new file mode 100644
index 00000000000..14803fec71d
--- /dev/null
+++ b/ndb/test/tools/waiter/waiter.cpp
@@ -0,0 +1,57 @@
+/* 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 */
+
+
+#include "mgmapi.h"
+#include <string.h>
+#include <NdbMain.h>
+#include <NdbOut.hpp>
+#include <NdbSleep.h>
+#include <getarg.h>
+
+
+#include <NdbRestarter.hpp>
+#include <NDBT.hpp>
+#include <assert.h>
+
+int main(int argc, const char** argv){
+
+ const char* _hostName = NULL;
+ int _help = 0;
+
+ struct getargs args[] = {
+ { "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);
+ }
+ _hostName = argv[optind];
+
+ NdbRestarter restarter(_hostName);
+
+ if (restarter.waitClusterStarted() != 0)
+ return NDBT_ProgramExit(NDBT_FAILED);
+
+ return NDBT_ProgramExit(NDBT_OK);
+}