From b5304c816f6eedac68f3c56fc4841832c7a1dbf3 Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.(none)" <> Date: Tue, 24 Aug 2004 10:44:42 +0000 Subject: [PATCH 1/2] enabling stopping of ndb_mgmd --- ndb/src/mgmsrv/Services.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 121176f5a19..2874fd9691a 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -31,6 +31,8 @@ #include "Services.hpp" +extern bool g_StopServer; + static const unsigned int MAX_READ_TIMEOUT = 1000 ; static const unsigned int MAX_WRITE_TIMEOUT = 100 ; @@ -1012,10 +1014,27 @@ MgmApiSession::stop(Parser::Context &, nodes.push_back(atoi(p)); } + int stop_self= 0; + + for(size_t i=0; i < nodes.size(); i++) { + if (nodes[i] == m_mgmsrv.getOwnNodeId()) { + stop_self= 1; + if (i != nodes.size()-1) { + m_output->println("stop reply"); + m_output->println("result: server must be stopped last"); + m_output->println(""); + return; + } + } + } + int stopped = 0, result = 0; for(size_t i=0; i < nodes.size(); i++) - if((result = m_mgmsrv.stopNode(nodes[i], abort != 0)) == 0) + if (nodes[i] != m_mgmsrv.getOwnNodeId()) { + if((result = m_mgmsrv.stopNode(nodes[i], abort != 0)) == 0) + stopped++; + } else stopped++; m_output->println("stop reply"); @@ -1025,6 +1044,9 @@ MgmApiSession::stop(Parser::Context &, m_output->println("result: Ok"); m_output->println("stopped: %d", stopped); m_output->println(""); + + if (stop_self) + g_StopServer= true; } From 5a24844551fa080ae54af6b95970af4a5bc7b00d Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.(none)" <> Date: Tue, 24 Aug 2004 11:28:19 +0000 Subject: [PATCH 2/2] some more printouts to SHOW command --- mysql-test/ndb/ndbcluster.sh | 1 + ndb/src/mgmclient/CommandInterpreter.cpp | 59 +++++++++++++----------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index a3972ad8f26..bbd3fa3257a 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -194,6 +194,7 @@ stop_default_ndbcluster() { exec_mgmtclient="$exec_mgmtclient --try-reconnect=1" echo "all stop" | $exec_mgmtclient 2>&1 | cat > /dev/null +echo "3 stop" | $exec_mgmtclient 2>&1 | cat > /dev/null if [ -f "$fs_ndb/$pidfile" ] ; then kill -9 `cat "$fs_ndb/$pidfile"` 2> /dev/null diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 8b9568fd12d..7175952aed0 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -649,9 +649,10 @@ CommandInterpreter::executeShow(char* parameters) } int - ndb_nodes = 0, - api_nodes = 0, - mgm_nodes = 0; + master_id= 0, + ndb_nodes= 0, + api_nodes= 0, + mgm_nodes= 0; for(i=0; i < state->no_of_nodes; i++) { switch(state->node_states[i].node_type) { @@ -659,6 +660,8 @@ CommandInterpreter::executeShow(char* parameters) api_nodes++; break; case NDB_MGM_NODE_TYPE_NDB: + if (state->node_states[i].dynamic_id > master_id) + master_id= state->node_states[i].dynamic_id; ndb_nodes++; break; case NDB_MGM_NODE_TYPE_MGM: @@ -681,8 +684,11 @@ CommandInterpreter::executeShow(char* parameters) ndbout << " (Version: " << getMajor(state->node_states[i].version) << "." << getMinor(state->node_states[i].version) << "." - << getBuild(state->node_states[i].version) << ")" << endl; - + << getBuild(state->node_states[i].version) << "," + << " Nodegroup: " << state->node_states[i].node_group; + if (state->node_states[i].dynamic_id == master_id) + ndbout << ", Master"; + ndbout << ")" << endl; } else { ndbout << " (not connected) " << endl; @@ -692,27 +698,6 @@ CommandInterpreter::executeShow(char* parameters) } ndbout << endl; - ndbout << api_nodes - << " API Node(s)" - << endl; - - for(i=0; i < state->no_of_nodes; i++) { - if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_API) { - ndbout << "API node:\t" << state->node_states[i].node_id; - if(state->node_states[i].version != 0) { - ndbout << " (Version: " - << getMajor(state->node_states[i].version) << "." - << getMinor(state->node_states[i].version) << "." - << getBuild(state->node_states[i].version) << ")" << endl; - - } else - { - ndbout << " (not connected) " << endl; - } - } - } - ndbout << endl; - ndbout << mgm_nodes << " MGM Node(s)" << endl; @@ -733,6 +718,28 @@ CommandInterpreter::executeShow(char* parameters) } } ndbout << endl; + + ndbout << api_nodes + << " API Node(s)" + << endl; + + for(i=0; i < state->no_of_nodes; i++) { + if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_API) { + ndbout << "API node:\t" << state->node_states[i].node_id; + if(state->node_states[i].version != 0) { + ndbout << " (Version: " + << getMajor(state->node_states[i].version) << "." + << getMinor(state->node_states[i].version) << "." + << getBuild(state->node_states[i].version) << ")" << endl; + + } else + { + ndbout << " (not connected) " << endl; + } + } + } + ndbout << endl; + // ndbout << helpTextShow; return; } else if (strcmp(parameters, "PROPERTIES") == 0 ||