Commit ff93ca1f authored by unknown's avatar unknown

added support for stopping ndb_mgmd from client

parent 385fd57c
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "Services.hpp" #include "Services.hpp"
extern bool g_StopServer;
static const unsigned int MAX_READ_TIMEOUT = 1000 ; static const unsigned int MAX_READ_TIMEOUT = 1000 ;
static const unsigned int MAX_WRITE_TIMEOUT = 100 ; static const unsigned int MAX_WRITE_TIMEOUT = 100 ;
...@@ -1012,11 +1014,28 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &, ...@@ -1012,11 +1014,28 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &,
nodes.push_back(atoi(p)); 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; int stopped = 0, result = 0;
for(size_t i=0; i < nodes.size(); i++) for(size_t i=0; i < nodes.size(); i++)
if (nodes[i] != m_mgmsrv.getOwnNodeId()) {
if((result = m_mgmsrv.stopNode(nodes[i], abort != 0)) == 0) if((result = m_mgmsrv.stopNode(nodes[i], abort != 0)) == 0)
stopped++; stopped++;
} else
stopped++;
m_output->println("stop reply"); m_output->println("stop reply");
if(result != 0) if(result != 0)
...@@ -1025,6 +1044,9 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &, ...@@ -1025,6 +1044,9 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &,
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("stopped: %d", stopped); m_output->println("stopped: %d", stopped);
m_output->println(""); m_output->println("");
if (stop_self)
g_StopServer= true;
} }
......
...@@ -265,9 +265,10 @@ NDB_MAIN(mgmsrv){ ...@@ -265,9 +265,10 @@ NDB_MAIN(mgmsrv){
NdbSleep_MilliSleep(500); NdbSleep_MilliSleep(500);
} }
g_EventLogger.info("Shutting down server...");
glob.socketServer->stopServer(); glob.socketServer->stopServer();
glob.socketServer->stopSessions(); glob.socketServer->stopSessions();
g_EventLogger.info("Shutdown complete");
return 0; return 0;
error_end: error_end:
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment