diff options
author | unknown <stewart@mysql.com> | 2006-05-23 16:24:26 +1000 |
---|---|---|
committer | unknown <stewart@mysql.com> | 2006-05-23 16:24:26 +1000 |
commit | e1c9dd5f4bf13158cfcdb1db5ce8cef1578096e3 (patch) | |
tree | fb529e6f054c489046e283da45eeb92a8b2344cd /ndb/src/mgmclient | |
parent | 564ba97b6244bd865ae82a4939e5a3badec104eb (diff) | |
download | mariadb-git-e1c9dd5f4bf13158cfcdb1db5ce8cef1578096e3.tar.gz |
BUG#18966 Change in stop/shutdown behaviour
Improvements that were discussed with Tomas.
Maintain protocol backwards/forwards compatibilty for client and server and support
the commands from ndb_mgm 'as expected'
ndb/include/mgmapi/mgmapi.h:
Add ndb_mgm_stop3 mgmapi function.
- This supports stopping all DB nodes, or all DB and MGM nodes.
- It also returns to mgmapi program if it needs to disconnect to apply changes.
Add ndb_mgm_restart3 mgmapi function.
- Tells mgmapi program if it needs to disconnect to apply changes
Add (internal) ndb_mgm_get_version
- designed to be used to find out what protocol version we need to speak to the server.
ndb/src/mgmapi/mgmapi.cpp:
Add cache of mgmd version to ndb_mgm_handle. Only filled out in functions that
need to know the version of the mgmd we're talking to.
Initialize these members in create handle.
added ndb_mgm_get_version which asks the mgm server what version it is. This call
has been supported since the dawn of time, no compatibility issues here.
Add implementation of ndb_mgm_stop3
Check what version of the protocol the server speaks, and speak it.
Add compatibility for ndb_mgm_stop2
Same for ndb_mgm_restart3.
ndb/src/mgmclient/CommandInterpreter.cpp:
Simplify stop and restart code.
Use the new ndb_mgm_(stop|restart)3 calls to find out if we need to disconnect.
ndb/src/mgmsrv/MgmtSrvr.cpp:
Add nice call for shutting down MGM servers (like shutdownDB)
ndb/src/mgmsrv/MgmtSrvr.hpp:
add prototype for shutdownMGM
ndb/src/mgmsrv/Services.cpp:
Add restart node v2, stop v2, stop all v2 while maintaining protocol backwards
compatibility.
Unfortunately we can't add result lines due to protocol errors in clients :(
Neither can we add extra things to the 'result: Ok' line due to the use of
strcmp instead of strncmp.
ndb/src/mgmsrv/Services.hpp:
Add prototypes for restart, stop and stopall v1 and v2
Diffstat (limited to 'ndb/src/mgmclient')
-rw-r--r-- | ndb/src/mgmclient/CommandInterpreter.cpp | 75 |
1 files changed, 19 insertions, 56 deletions
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 9e1224ab3ef..290f57a881a 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -1057,7 +1057,8 @@ CommandInterpreter::executeShutdown(char* parameters) NdbAutoPtr<char> ap1((char*)state); int result = 0; - result = ndb_mgm_stop(m_mgmsrv, 0, 0); + int need_disconnect; + result = ndb_mgm_stop3(m_mgmsrv, -1, 0, 0, &need_disconnect); if (result < 0) { ndbout << "Shutdown of NDB Cluster node(s) failed." << endl; printError(); @@ -1066,39 +1067,11 @@ CommandInterpreter::executeShutdown(char* parameters) ndbout << result << " NDB Cluster node(s) have shutdown." << endl; - int nodeId= 0; - int this_mgmd= 0; - this_mgmd= ndb_mgm_get_mgmd_nodeid(m_mgmsrv); - while(get_next_nodeid(state, &nodeId, NDB_MGM_NODE_TYPE_MGM)) - { - if(nodeId==this_mgmd) - continue; - ndbout << "Shutting down NDB Cluster management server nodeId=" - << nodeId << "..."; - result = ndb_mgm_stop(m_mgmsrv, 1, &nodeId); - if (result <= 0) { - ndbout << " failed." << endl; - printError(); - } - else - ndbout << "Done." << endl; - } - - ndbout << "Shutting down NDB Cluster management server nodeId=" - << this_mgmd << "..."; - result= ndb_mgm_stop(m_mgmsrv, 1, &this_mgmd); - if (result <= 0) { - ndbout << " failed." << endl; - printError(); - } - else - { - ndbout << "Done." << endl; + if(need_disconnect) { ndbout << "Disconnecting to allow management server to shutdown." << endl; disconnect(); } - ndbout << "NDB Cluster management servers shutdown." << endl; return 0; } @@ -1487,6 +1460,7 @@ CommandInterpreter::executeStop(Vector<BaseString> &command_list, unsigned command_pos, int *node_ids, int no_of_nodes) { + int need_disconnect; int abort= 0; for (; command_pos < command_list.size(); command_pos++) { @@ -1501,7 +1475,8 @@ CommandInterpreter::executeStop(Vector<BaseString> &command_list, return; } - int result= ndb_mgm_stop2(m_mgmsrv, no_of_nodes, node_ids, abort); + int result= ndb_mgm_stop3(m_mgmsrv, no_of_nodes, node_ids, abort, + &need_disconnect); if (result < 0) { ndbout_c("Shutdown failed."); @@ -1513,27 +1488,19 @@ CommandInterpreter::executeStop(Vector<BaseString> &command_list, ndbout_c("NDB Cluster has shutdown."); else { - int mgm_id= 0; - int need_reconnect= 0; - mgm_id= ndb_mgm_get_mgmd_nodeid(m_mgmsrv); ndbout << "Node"; for (int i= 0; i < no_of_nodes; i++) - { - if(node_ids[i] == mgm_id) - need_reconnect= 1; - else ndbout << " " << node_ids[i]; - } ndbout_c(" has shutdown."); - if(need_reconnect) - { - ndbout << "You are connected to node " << mgm_id - << ", disconnecting to allow it to shutdown" - << endl; - disconnect(); - } } } + + if(need_disconnect) + { + ndbout << "Disconnecting to allow Management Server to shutdown" << endl; + disconnect(); + } + } void @@ -1624,6 +1591,7 @@ CommandInterpreter::executeRestart(Vector<BaseString> &command_list, int nostart= 0; int initialstart= 0; int abort= 0; + int need_disconnect= 0; for (; command_pos < command_list.size(); command_pos++) { @@ -1648,9 +1616,9 @@ CommandInterpreter::executeRestart(Vector<BaseString> &command_list, return; } - result= ndb_mgm_restart2(m_mgmsrv, no_of_nodes, node_ids, - initialstart, nostart, abort); - + result= ndb_mgm_restart3(m_mgmsrv, no_of_nodes, node_ids, + initialstart, nostart, abort, &need_disconnect); + if (result <= 0) { ndbout_c("Restart failed."); printError(); @@ -1661,18 +1629,13 @@ CommandInterpreter::executeRestart(Vector<BaseString> &command_list, ndbout_c("NDB Cluster is being restarted."); else { - int mgm_id= 0; - mgm_id= ndb_mgm_get_mgmd_nodeid(m_mgmsrv); - ndbout << "Node"; for (int i= 0; i < no_of_nodes; i++) - { - if(node_ids[i] == mgm_id) - disconnect(); ndbout << " " << node_ids[i]; - } ndbout_c(" is being restarted"); } + if(need_disconnect) + disconnect(); } } |