Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-03-13 14:39:16+01:00, jonas@stripped +4 -0
ndb - add new mgmapi call ndb_mgm_get_status2
storage/ndb/include/mgmapi/mgmapi.h@stripped, 2008-03-13 14:39:14+01:00, jonas@stripped +19 -0
new function call
storage/ndb/src/mgmapi/mgmapi.cpp@stripped, 2008-03-13 14:39:14+01:00, jonas@stripped +52 -0
new function call
storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2008-03-13 14:39:14+01:00, jonas@stripped +99 -68
change ndb_mgm to use new interface
storage/ndb/src/mgmsrv/Services.cpp@stripped, 2008-03-13 14:39:14+01:00, jonas@stripped +35 -24
new function call
diff -Nrup a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h
--- a/storage/ndb/include/mgmapi/mgmapi.h 2007-06-14 12:35:33 +02:00
+++ b/storage/ndb/include/mgmapi/mgmapi.h 2008-03-13 14:39:14 +01:00
@@ -614,6 +614,25 @@ extern "C" {
*/
struct ndb_mgm_cluster_state * ndb_mgm_get_status(NdbMgmHandle handle);
+
+ /**
+ * Gets status of the nodes *of specified types* in an NDB Cluster
+ *
+ * @note The caller must free the pointer returned by this function.
+ * @note Passing a NULL pointer into types make this equivalent to
+ * ndb_mgm_get_status
+ *
+ * @param handle Management handle.
+ * @param types Pointer to array of interesting node types.
+ * Array should be terminated
+ * by *NDB_MGM_NODE_TYPE_UNKNOWN*.
+ *
+ * @return Cluster state (or <var>NULL</var> on error).
+ */
+ struct ndb_mgm_cluster_state *
+ ndb_mgm_get_status2(NdbMgmHandle handle,
+ const enum ndb_mgm_node_type types[]);
+
/** @} *********************************************************************/
/**
* @name Functions: Start/stop nodes
diff -Nrup a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp
--- a/storage/ndb/src/mgmapi/mgmapi.cpp 2007-08-29 02:51:05 +02:00
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp 2008-03-13 14:39:14 +01:00
@@ -830,14 +830,66 @@ extern "C"
struct ndb_mgm_cluster_state *
ndb_mgm_get_status(NdbMgmHandle handle)
{
+ return ndb_mgm_get_status2(handle, 0);
+}
+
+extern "C"
+struct ndb_mgm_cluster_state *
+ndb_mgm_get_status2(NdbMgmHandle handle, const enum ndb_mgm_node_type types[])
+{
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_status");
CHECK_HANDLE(handle, NULL);
CHECK_CONNECTED(handle, NULL);
+ char typestring[1024];
+ typestring[0] = 0;
+ if (types != 0)
+ {
+ int pos = 0;
+ for (Uint32 i = 0; types[i] != NDB_MGM_NODE_TYPE_UNKNOWN; i++)
+ {
+ if (int(types[i]) < NDB_MGM_NODE_TYPE_MIN ||
+ int(types[i]) > NDB_MGM_NODE_TYPE_MAX)
+ {
+ SET_ERROR(handle, EINVAL,
+ "Incorrect node type for ndb_mgm_get_status2");
+ return 0;
+ }
+ /**
+ * Check for duplicates
+ */
+ for (Int32 j = i - 1; j >= 0; j--)
+ {
+ if (types[i] == types[j])
+ {
+ SET_ERROR(handle, EINVAL,
+ "Duplicate types for ndb_mgm_get_status2");
+ return 0;
+ }
+ }
+
+ int left = sizeof(typestring) - pos;
+ int len = BaseString::snprintf(typestring+pos, left, "%s ",
+ ndb_mgm_get_node_type_string(types[i]));
+
+ if (len >= left)
+ {
+ SET_ERROR(handle, EINVAL,
+ "Out of memory for type-string for ndb_mgm_get_status2");
+ return 0;
+ }
+ pos += len;
+ }
+ }
+
SocketOutputStream out(handle->socket, handle->timeout);
SocketInputStream in(handle->socket, handle->timeout);
out.println("get status");
+ if (types)
+ {
+ out.println("types: %s", typestring);
+ }
out.println("");
CHECK_TIMEDOUT_RET(handle, in, out, NULL);
diff -Nrup a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-12-15 09:23:44 +01:00
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2008-03-13 14:39:14 +01:00
@@ -1339,6 +1339,8 @@ CommandInterpreter::executeForAll(const
retval = (this->*fun)(nodeId, allAfterSecondToken, true);
ndbout_c("Trying to start all nodes of system.");
ndbout_c("Use ALL STATUS to see the system start-up phases.");
+ } else if (strcasecmp(cmd, "STATUS") == 0) {
+ (this->*fun)(nodeId, allAfterSecondToken, true);
} else {
Guard g(m_print_mutex);
struct ndb_mgm_cluster_state *cl= ndb_mgm_get_status(m_mgmsrv);
@@ -2120,6 +2122,103 @@ CommandInterpreter::executeRestart(Vecto
return retval;
}
+/**
+ * print status of one node
+ */
+static
+void
+print_status(const ndb_mgm_node_state * state)
+{
+ Uint32 version = state->version;
+ if (state->node_type != NDB_MGM_NODE_TYPE_NDB)
+ {
+ if (version != 0)
+ {
+ ndbout << "Node " << state->node_id <<": connected" ;
+ ndbout_c(" (Version %d.%d.%d)",
+ getMajor(version) ,
+ getMinor(version),
+ getBuild(version));
+
+ }
+ else
+ {
+ ndbout << "Node " << state->node_id << ": not connected" << endl;
+ }
+ return;
+ }
+
+ ndbout << "Node " << state->node_id
+ << ": " << status_string(state->node_status);
+ switch(state->node_status){
+ case NDB_MGM_NODE_STATUS_STARTING:
+ ndbout << " (Phase " << state->start_phase << ")";
+ break;
+ case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
+ ndbout << " (Phase " << state->start_phase << ")";
+ break;
+ default:
+ break;
+ }
+
+ if(state->node_status != NDB_MGM_NODE_STATUS_NO_CONTACT)
+ {
+ ndbout_c(" (Version %d.%d.%d)",
+ getMajor(version),
+ getMinor(version),
+ getBuild(version));
+ }
+ else
+ {
+ ndbout << endl;
+ }
+}
+
+int
+CommandInterpreter::executeStatus(int processId,
+ const char* parameters, bool all)
+{
+ if (! emptyString(parameters)) {
+ ndbout_c("No parameters expected to this command.");
+ return -1;
+ }
+
+ ndb_mgm_node_type types[2] = {
+ NDB_MGM_NODE_TYPE_NDB,
+ NDB_MGM_NODE_TYPE_UNKNOWN
+ };
+ struct ndb_mgm_cluster_state *cl;
+ cl = ndb_mgm_get_status2(m_mgmsrv, all ? types : 0);
+ if(cl == NULL)
+ {
+ ndbout_c("Cannot get status of node %d.", processId);
+ printError();
+ return -1;
+ }
+ NdbAutoPtr<char> ap1((char*)cl);
+
+ if (all)
+ {
+ for (int i = 0; i<cl->no_of_nodes; i++)
+ print_status(cl->node_states+i);
+ return 0;
+ }
+ else
+ {
+ for (int i = 0; i<cl->no_of_nodes; i++)
+ {
+ if (cl->node_states[i].node_id == processId)
+ {
+ print_status(cl->node_states + i);
+ return 0;
+ }
+ }
+ ndbout << processId << ": Node not found" << endl;
+ return -1;
+ }
+ return 0;
+} //
+
int
CommandInterpreter::executeDumpState(int processId, const char* parameters,
bool all)
@@ -2157,74 +2256,6 @@ CommandInterpreter::executeDumpState(int
struct ndb_mgm_reply reply;
return ndb_mgm_dump_state(m_mgmsrv, processId, pars, no, &reply);
}
-
-int
-CommandInterpreter::executeStatus(int processId,
- const char* parameters, bool all)
-{
- if (! emptyString(parameters)) {
- ndbout_c("No parameters expected to this command.");
- return -1;
- }
-
- ndb_mgm_node_status status;
- Uint32 startPhase, version;
-
- struct ndb_mgm_cluster_state *cl;
- cl = ndb_mgm_get_status(m_mgmsrv);
- if(cl == NULL) {
- ndbout_c("Cannot get status of node %d.", processId);
- printError();
- return -1;
- }
- NdbAutoPtr<char> ap1((char*)cl);
-
- int i = 0;
- while((i < cl->no_of_nodes) && cl->node_states[i].node_id != processId)
- i++;
- if(cl->node_states[i].node_id != processId) {
- ndbout << processId << ": Node not found" << endl;
- return -1;
- }
- if (cl->node_states[i].node_type != NDB_MGM_NODE_TYPE_NDB){
- if (cl->node_states[i].version != 0){
- version = cl->node_states[i].version;
- ndbout << "Node "<< cl->node_states[i].node_id <<": connected" ;
- ndbout_c(" (Version %d.%d.%d)",
- getMajor(version) ,
- getMinor(version),
- getBuild(version));
-
- }else
- ndbout << "Node "<< cl->node_states[i].node_id <<": not connected" << endl;
- return 0;
- }
- status = cl->node_states[i].node_status;
- startPhase = cl->node_states[i].start_phase;
- version = cl->node_states[i].version;
-
- ndbout << "Node " << processId << ": " << status_string(status);
- switch(status){
- case NDB_MGM_NODE_STATUS_STARTING:
- ndbout << " (Phase " << startPhase << ")";
- break;
- case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
- ndbout << " (Phase " << startPhase << ")";
- break;
- default:
- break;
- }
- if(status != NDB_MGM_NODE_STATUS_NO_CONTACT)
- ndbout_c(" (Version %d.%d.%d)",
- getMajor(version) ,
- getMinor(version),
- getBuild(version));
- else
- ndbout << endl;
-
- return 0;
-}
-
//*****************************************************************************
//*****************************************************************************
diff -Nrup a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp
--- a/storage/ndb/src/mgmsrv/Services.cpp 2007-11-06 14:55:08 +01:00
+++ b/storage/ndb/src/mgmsrv/Services.cpp 2008-03-13 14:39:14 +01:00
@@ -140,9 +140,10 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("log_event", Int, Optional, "Log failure in cluster log"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""),
-
- MGM_CMD("get status", &MgmApiSession::getStatus, ""),
+ MGM_CMD("get status", &MgmApiSession::getStatus, ""),
+ MGM_ARG("types", String, Optional, "Types"),
+
MGM_CMD("get info clusterlog", &MgmApiSession::getInfoClusterLog, ""),
MGM_CMD("get cluster loglevel", &MgmApiSession::getClusterLogLevel, ""),
@@ -993,40 +994,50 @@ printNodeStatus(OutputStream *output,
output->println("node.%d.connect_count: %d", nodeId, connectCount);
output->println("node.%d.address: %s", nodeId, address ? address : "");
}
-
}
void
MgmApiSession::getStatus(Parser<MgmApiSession>::Context &,
- Properties const &) {
+ Properties const & args) {
+ Uint32 i;
int noOfNodes = 0;
+ BaseString typestring;
- NodeId nodeId = 0;
- while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)){
- noOfNodes++;
+ enum ndb_mgm_node_type types[10];
+ if (args.get("types", typestring))
+ {
+ Vector<BaseString> tmp;
+ typestring.split(tmp, " ");
+ for (i = 0; i < tmp.size(); i++)
+ {
+ types[i] = ndb_mgm_match_node_type(tmp[i].c_str());
+ }
+ types[i] = NDB_MGM_NODE_TYPE_UNKNOWN;
+ }
+ else
+ {
+ types[0] = NDB_MGM_NODE_TYPE_NDB;
+ types[1] = NDB_MGM_NODE_TYPE_MGM;
+ types[2] = NDB_MGM_NODE_TYPE_API;
+ types[3] = NDB_MGM_NODE_TYPE_UNKNOWN;
}
- nodeId = 0;
- while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_API)){
- noOfNodes++;
- }
- nodeId = 0;
- while(m_mgmsrv.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_MGM)){
- noOfNodes++;
+
+ for (i = 0; types[i] != NDB_MGM_NODE_TYPE_UNKNOWN; i++)
+ {
+ NodeId nodeId = 0;
+ while(m_mgmsrv.getNextNodeId(&nodeId, types[i]))
+ noOfNodes++;
}
+
SLEEP_ERROR_INSERTED(5);
m_output->println("node status");
SLEEP_ERROR_INSERTED(6);
m_output->println("nodes: %d", noOfNodes);
- m_mgmsrv.updateStatus();
- SLEEP_ERROR_INSERTED(7);
- printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_NDB);
- printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_MGM);
- SLEEP_ERROR_INSERTED(8);
- printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_API);
- SLEEP_ERROR_INSERTED(9);
-
- nodeId = 0;
-
+ for (i = 0; types[i] != NDB_MGM_NODE_TYPE_UNKNOWN; i++)
+ {
+ SLEEP_ERROR_INSERTED(7+i);
+ printNodeStatus(m_output, m_mgmsrv, types[i]);
+ }
m_output->println("");
}
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2535) | jonas | 13 Mar |