From 987fc113959189c59e8f6e99d8d5364d9d62bc89 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 11:48:27 +0000 Subject: 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/mgmclient/CommandInterpreter.cpp | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'ndb/src/mgmclient/CommandInterpreter.cpp') 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 *****************************************************************************/ -- cgit v1.2.1