From 987fc113959189c59e8f6e99d8d5364d9d62bc89 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 11:48:27 +0000 Subject: [PATCH] see respective file ndb/src/mgmsrv/InitConfigFileParser.hpp: Rename: ndb/src/common/mgmcommon/InitConfigFileParser.hpp -> ndb/src/mgmsrv/InitConfigFileParser.hpp ndb/src/mgmsrv/InitConfigFileParser.cpp: Rename: ndb/src/common/mgmcommon/InitConfigFileParser.cpp -> ndb/src/mgmsrv/InitConfigFileParser.cpp ndb/src/mgmsrv/ConfigInfo.hpp: Rename: ndb/src/common/mgmcommon/ConfigInfo.hpp -> ndb/src/mgmsrv/ConfigInfo.hpp ndb/src/common/mgmcommon/Makefile.am: moved files to mgmsrv ndb/src/mgmclient/CommandInterpreter.cpp: added shutdown command ndb/src/mgmclient/CommandInterpreter.hpp: added shutdown command ndb/src/mgmsrv/Config.cpp: . ndb/src/mgmsrv/Config.hpp: . ndb/src/mgmsrv/ConfigInfo.cpp: wait with this ndb/src/mgmsrv/Makefile.am: moved files to mgmsrv ndb/test/include/NdbBackup.hpp: backup not necessarily in file system path ndb/test/ndbapi/testDict.cpp: compile error ndb/test/src/NdbBackup.cpp: aligned with new config param --- ndb/src/common/mgmcommon/Makefile.am | 14 +---- ndb/src/mgmclient/CommandInterpreter.cpp | 60 +++++++++++++++++++ ndb/src/mgmclient/CommandInterpreter.hpp | 1 + .../{common/mgmcommon => mgmsrv}/Config.cpp | 1 - .../{common/mgmcommon => mgmsrv}/Config.hpp | 2 +- .../mgmcommon => mgmsrv}/ConfigInfo.cpp | 16 ++--- .../mgmcommon => mgmsrv}/ConfigInfo.hpp | 0 .../InitConfigFileParser.cpp | 0 .../InitConfigFileParser.hpp | 0 ndb/src/mgmsrv/Makefile.am | 13 ++++ ndb/test/include/NdbBackup.hpp | 2 +- ndb/test/ndbapi/testDict.cpp | 2 +- ndb/test/src/NdbBackup.cpp | 10 ++-- 13 files changed, 91 insertions(+), 30 deletions(-) rename ndb/src/{common/mgmcommon => mgmsrv}/Config.cpp (99%) rename ndb/src/{common/mgmcommon => mgmsrv}/Config.hpp (98%) rename ndb/src/{common/mgmcommon => mgmsrv}/ConfigInfo.cpp (99%) rename ndb/src/{common/mgmcommon => mgmsrv}/ConfigInfo.hpp (100%) rename ndb/src/{common/mgmcommon => mgmsrv}/InitConfigFileParser.cpp (100%) rename ndb/src/{common/mgmcommon => mgmsrv}/InitConfigFileParser.hpp (100%) diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am index 174999579d4..29cfa47482a 100644 --- a/ndb/src/common/mgmcommon/Makefile.am +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -1,23 +1,11 @@ -MYSQLDATAdir = $(localstatedir) -MYSQLSHAREdir = $(pkgdatadir) -MYSQLBASEdir= $(prefix) - noinst_LTLIBRARIES = libmgmsrvcommon.la libmgmsrvcommon_la_SOURCES = \ LocalConfig.cpp \ - Config.cpp \ - ConfigInfo.cpp \ ConfigRetriever.cpp \ - InitConfigFileParser.cpp \ IPCConfig.cpp NdbConfig.c -INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi - -DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ - -DDATADIR="\"$(MYSQLDATAdir)\"" \ - -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ - -DNDB_BASE_PORT="\"@ndb_port_base@\"" +INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index c90ed1822f1..631531ca696 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -47,10 +47,13 @@ static const char* helpText = "HELP DEBUG Help for debug compiled version\n" #endif "SHOW Print information about cluster\n" +#if 0 "SHOW CONFIG Print configuration\n" "SHOW PARAMETERS Print configuration parameters\n" +#endif "START BACKUP Start backup\n" "ABORT BACKUP Abort backup\n" +"SHUTDOWN Shutdown all processed in cluster and quit\n" "CLUSTERLOG ON Enable Cluster logging\n" "CLUSTERLOG OFF Disable Cluster logging\n" "CLUSTERLOG FILTER Toggle severity filter on/off\n" @@ -62,7 +65,9 @@ static const char* helpText = "EXIT SINGLE USER MODE Exit single user mode\n" " STATUS Print status\n" " CLUSTERLOG {=}+ Set log level for cluster log\n" +#ifdef HAVE_GLOBAL_REPLICATION "REP CONNECT Connect to REP server on host:port\n" +#endif "QUIT Quit management client\n" ; @@ -299,6 +304,10 @@ CommandInterpreter::readAndExecute(int _try_reconnect) executeShow(allAfterFirstToken); return true; } + else if (strcmp(firstToken, "SHUTDOWN") == 0) { + executeShutdown(allAfterFirstToken); + return true; + } else if (strcmp(firstToken, "CLUSTERLOG") == 0){ executeClusterLog(allAfterFirstToken); return true; @@ -628,6 +637,57 @@ CommandInterpreter::executeHelp(char* parameters) } +/***************************************************************************** + * SHUTDOWN + *****************************************************************************/ + +void +CommandInterpreter::executeShutdown(char* parameters) +{ + connect(); + + ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); + if(state == NULL) { + ndbout_c("Could not get status"); + printError(); + return; + } + + int result = 0; + result = ndb_mgm_stop(m_mgmsrv, 0, 0); + if (result <= 0) { + ndbout << "Shutdown failed." << endl; + printError(); + return; + } + + ndbout << "NDB Cluster storage node(s) have shutdown." << endl; + + int mgm_id= 0; + for(int i=0; i < state->no_of_nodes; i++) { + if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_MGM && + state->node_states[i].version != 0){ + if (mgm_id == 0) + mgm_id= state->node_states[i].node_id; + else { + ndbout << "Unable to locate management server, shutdown manually with #STOP" + << endl; + } + } + } + + result = 0; + result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id); + if (result <= 0) { + ndbout << "Shutdown failed." << endl; + printError(); + return; + } + + ndbout << "NDB Cluster management server shutdown." << endl; + exit(0); +} + /***************************************************************************** * SHOW *****************************************************************************/ diff --git a/ndb/src/mgmclient/CommandInterpreter.hpp b/ndb/src/mgmclient/CommandInterpreter.hpp index 478e03d129a..eecc48a739e 100644 --- a/ndb/src/mgmclient/CommandInterpreter.hpp +++ b/ndb/src/mgmclient/CommandInterpreter.hpp @@ -127,6 +127,7 @@ private: */ void executeHelp(char* parameters); void executeShow(char* parameters); + void executeShutdown(char* parameters); void executeRun(char* parameters); void executeInfo(char* parameters); void executeClusterLog(char* parameters); diff --git a/ndb/src/common/mgmcommon/Config.cpp b/ndb/src/mgmsrv/Config.cpp similarity index 99% rename from ndb/src/common/mgmcommon/Config.cpp rename to ndb/src/mgmsrv/Config.cpp index c0819b9f463..b8a494cb759 100644 --- a/ndb/src/common/mgmcommon/Config.cpp +++ b/ndb/src/mgmsrv/Config.cpp @@ -19,7 +19,6 @@ #include #include "MgmtErrorReporter.hpp" #include -#include "ConfigInfo.hpp" //***************************************************************************** // Ctor / Dtor diff --git a/ndb/src/common/mgmcommon/Config.hpp b/ndb/src/mgmsrv/Config.hpp similarity index 98% rename from ndb/src/common/mgmcommon/Config.hpp rename to ndb/src/mgmsrv/Config.hpp index 26fd53dbed2..b5e1e17b027 100644 --- a/ndb/src/common/mgmcommon/Config.hpp +++ b/ndb/src/mgmsrv/Config.hpp @@ -24,7 +24,7 @@ #include #include #include -#include "ConfigInfo.hpp" +#include class ConfigInfo; diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp similarity index 99% rename from ndb/src/common/mgmcommon/ConfigInfo.cpp rename to ndb/src/mgmsrv/ConfigInfo.cpp index 52023fe4619..7bbd26581e2 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -33,15 +33,15 @@ * Section names ****************************************************************************/ -#define DB_TOKEN "NDBD" -#define MGM_TOKEN "NDB_MGMD" -#define API_TOKEN "MYSQLD" +#define DB_TOKEN "DB" +#define MGM_TOKEN "MGM" +#define API_TOKEN "API" const ConfigInfo::AliasPair ConfigInfo::m_sectionNameAliases[]={ - {API_TOKEN, "API"}, - {DB_TOKEN, "DB"}, - {MGM_TOKEN, "MGM"}, + {API_TOKEN, "MYSQLD"}, + {DB_TOKEN, "NDBD"}, + {MGM_TOKEN, "NDB_MGMD"}, {0, 0} }; @@ -975,7 +975,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::STRING, - DATADIR, + MYSQLCLUSTERDIR, 0, 0 }, { @@ -1349,7 +1349,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::STRING, - DATADIR, + MYSQLCLUSTERDIR, 0, 0 }, { diff --git a/ndb/src/common/mgmcommon/ConfigInfo.hpp b/ndb/src/mgmsrv/ConfigInfo.hpp similarity index 100% rename from ndb/src/common/mgmcommon/ConfigInfo.hpp rename to ndb/src/mgmsrv/ConfigInfo.hpp diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp similarity index 100% rename from ndb/src/common/mgmcommon/InitConfigFileParser.cpp rename to ndb/src/mgmsrv/InitConfigFileParser.cpp diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.hpp b/ndb/src/mgmsrv/InitConfigFileParser.hpp similarity index 100% rename from ndb/src/common/mgmcommon/InitConfigFileParser.hpp rename to ndb/src/mgmsrv/InitConfigFileParser.hpp diff --git a/ndb/src/mgmsrv/Makefile.am b/ndb/src/mgmsrv/Makefile.am index 630a19e0356..60b579d18e1 100644 --- a/ndb/src/mgmsrv/Makefile.am +++ b/ndb/src/mgmsrv/Makefile.am @@ -1,3 +1,7 @@ +MYSQLDATAdir = $(localstatedir) +MYSQLSHAREdir = $(pkgdatadir) +MYSQLBASEdir= $(prefix) +MYSQLCLUSTERdir= $(prefix)/mysql-cluster ndbbin_PROGRAMS = ndb_mgmd @@ -11,6 +15,9 @@ ndb_mgmd_SOURCES = \ NodeLogLevelList.cpp \ SignalQueue.cpp \ MgmtSrvrConfig.cpp \ + ConfigInfo.cpp \ + InitConfigFileParser.cpp \ + Config.cpp \ CommandInterpreter.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/ndbapi \ @@ -24,6 +31,12 @@ LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/strings/libmystrings.a @TERMCAP_LIB@ +DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ + -DDATADIR="\"$(MYSQLDATAdir)\"" \ + -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ + -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" \ + -DNDB_BASE_PORT="\"@ndb_port_base@\"" + include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am diff --git a/ndb/test/include/NdbBackup.hpp b/ndb/test/include/NdbBackup.hpp index 0a372eca7df..e2e672b8a72 100644 --- a/ndb/test/include/NdbBackup.hpp +++ b/ndb/test/include/NdbBackup.hpp @@ -47,7 +47,7 @@ private: int _node_id, unsigned _backup_id); - const char * getFileSystemPathForNode(int _node_id); + const char * getBackupDataDirForNode(int _node_id); }; diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index c527bbd655b..a0c7bb1414b 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1305,7 +1305,7 @@ runTableRenameNF(NDBT_Context* ctx, NDBT_Step* step){ const int numNodes = restarter.getNumDbNodes(); for(int i = 0; i