diff options
Diffstat (limited to 'ndb/src/kernel')
-rw-r--r-- | ndb/src/kernel/blocks/backup/restore/main.cpp | 178 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 5 | ||||
-rw-r--r-- | ndb/src/kernel/error/ErrorReporter.cpp | 2 | ||||
-rw-r--r-- | ndb/src/kernel/main.cpp | 8 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Configuration.cpp | 136 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Configuration.hpp | 2 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Emulator.hpp | 1 | ||||
-rw-r--r-- | ndb/src/kernel/vm/LongSignal.hpp | 2 |
8 files changed, 178 insertions, 156 deletions
diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/src/kernel/blocks/backup/restore/main.cpp index f7b1479cc93..482212911cb 100644 --- a/ndb/src/kernel/blocks/backup/restore/main.cpp +++ b/ndb/src/kernel/blocks/backup/restore/main.cpp @@ -14,7 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <getarg.h> +#include <ndb_global.h> +#include <ndb_opts.h> #include <Vector.hpp> #include <ndb_limits.h> #include <NdbTCP.h> @@ -35,80 +36,107 @@ static Vector<class BackupConsumer *> g_consumers; 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 */ static bool ga_restore = 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 -readArguments(const int argc, const char** argv) +readArguments(int *pargc, char*** pargv) { - - int _print = 0; - int _print_meta = 0; - 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) || + const char *load_default_groups[]= { "ndb_tools","ndb_restore",0 }; + load_defaults("my",load_default_groups,pargc,pargv); + if (handle_options(pargc, pargv, my_long_options, get_one_option) || ga_nodeId == 0 || ga_backupId == 0 || ga_nParallelism < 1 || - ga_nParallelism >1024) - { - arg_printusage(args, num_args, argv[0], "<path to backup files>\n"); - return false; + ga_nParallelism >1024) { + exit(1); } BackupPrinter* printer = new BackupPrinter(); @@ -122,10 +150,6 @@ readArguments(const int argc, const char** argv) 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) { ga_print = true; @@ -169,15 +193,14 @@ readArguments(const int argc, const char** argv) g_consumers.push_back(c); } // Set backup file path - if (argv[optind] != NULL) + if (*pargv[0] != NULL) { - ga_backupPath = argv[optind]; + ga_backupPath = *pargv[0]; } return true; } - void clearConsumers() { @@ -204,19 +227,16 @@ free_data_callback() } int -main(int argc, const char** argv) +main(int argc, char** argv) { - ndb_init(); - if (!readArguments(argc, argv)) + NDB_INIT(argv[0]); + + if (!readArguments(&argc, &argv)) { return -1; } - if (ga_connect_NDB != NULL) - { - // Use connection string - Ndb::setConnectString(ga_connect_NDB); - } + Ndb::setConnectString(opt_connect_str); /** * we must always load meta data, even if we will only print it to stdout diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index d1a8128ea7f..882557daae1 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -3661,9 +3661,8 @@ Dbdict::execCREATE_FRAGMENTATION_CONF(Signal* signal){ req->tableId = tabPtr.i; req->tableVersion = tabEntry->m_tableVersion + 1; - sendSignal(rg, GSN_CREATE_TAB_REQ, signal, - CreateTabReq::SignalLength, JBB); - + sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal, + CreateTabReq::SignalLength, JBB); return; } diff --git a/ndb/src/kernel/error/ErrorReporter.cpp b/ndb/src/kernel/error/ErrorReporter.cpp index 35c99b30994..35cd3f099d9 100644 --- a/ndb/src/kernel/error/ErrorReporter.cpp +++ b/ndb/src/kernel/error/ErrorReporter.cpp @@ -137,7 +137,7 @@ ErrorReporter::formatMessage(ErrorCategory type, faultID, (problemData == NULL) ? "" : problemData, objRef, - programName, + my_progname, processId, theNameOfTheTraceFile ? theNameOfTheTraceFile : "<no tracefile>"); diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index fa44704807d..926647838c9 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -53,11 +53,9 @@ extern "C" void handler_error(int signum); // for process signal handling void systemInfo(const Configuration & conf, const LogLevel & ll); -const char programName[] = "NDB Kernel"; - -NDB_MAIN(ndb_kernel){ - - ndb_init(); +int main(int argc, char** argv) +{ + NDB_INIT(argv[0]); // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 706f60fd9cf..b3a436275f7 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> #include <LocalConfig.hpp> #include "Configuration.hpp" @@ -28,8 +29,6 @@ #include <NdbOut.hpp> #include <WatchDog.hpp> -#include <getarg.h> - #include <mgmapi_configuration.hpp> #include <mgmapi_config_parameters_debug.h> #include <kernel_config_parameters.h> @@ -47,81 +46,86 @@ extern "C" { #include <EventLogger.hpp> 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 -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); - /** - * Default values for arguments - */ - 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", "" }, + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); - { "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) { _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", ("initial=%d", _initial)); DBUG_PRINT("info", ("daemon=%d", _daemon)); - DBUG_PRINT("info", ("connect_str=%s", _connect_str)); + DBUG_PRINT("info", ("connect_str=%s", opt_connect_str)); ndbSetOwnVersion(); - if (_print_version) { - ndbPrintVersion(); - return false; - } - // Check the start flag if (_no_start) globalData.theRestartFlag = initial_state; @@ -133,8 +137,8 @@ Configuration::init(int argc, const char** argv){ _initialStart = true; // Check connectstring - if (_connect_str) - _connectString = strdup(_connect_str); + if (opt_connect_str) + _connectString = strdup(opt_connect_str); // Check daemon flag if (_daemon) diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp index 2ea32ffea37..e4cd64f5ca8 100644 --- a/ndb/src/kernel/vm/Configuration.hpp +++ b/ndb/src/kernel/vm/Configuration.hpp @@ -31,7 +31,7 @@ public: /** * 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 setupConfiguration(); diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index bd240f8679b..b3c64830802 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -25,6 +25,7 @@ // //=========================================================================== #include <kernel_types.h> +#include <TransporterRegistry.hpp> extern class JobTable globalJobTable; extern class TimeQueue globalTimeQueue; diff --git a/ndb/src/kernel/vm/LongSignal.hpp b/ndb/src/kernel/vm/LongSignal.hpp index f9ed443d995..9818358011f 100644 --- a/ndb/src/kernel/vm/LongSignal.hpp +++ b/ndb/src/kernel/vm/LongSignal.hpp @@ -25,7 +25,7 @@ */ struct SectionSegment { - STATIC_CONST( DataLength = 60 ); + STATIC_CONST( DataLength = NDB_SECTION_SEGMENT_SZ ); Uint32 m_ownerRef; Uint32 m_sz; |