[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql-internals
Subject: Insanley small I_S table (NDB_NODE_STATUS)
From: Stewart Smith <stewart () mysql ! com>
Date: 2007-04-25 18:32:21
Message-ID: 1177525941.6255.12.camel () localhost ! localdomain
[Download RAW message or body]
So, this is patch that i wrote while listening to sessions yesterday to
add a INFORMATION_SCHEMA.NDB_NODE_STATUS table that's a bit like the
output from "ndb_mgm -e show".
Doesn't work perfectly for functionality, but is a pretty good "howto"
of adding a pluggable INFORMATION_SCHEMA table to your pluggable engine.
Falcon does some of this and I looked there for the ideas. Their
abstractions are a bit cooler... mine is "bare bones" :)
INFORMATION_SCHEMA.NDB_NODE_STATUS
Use pluggable information schema to add a casually crappy table
that will show you the current status of the cluster (similar
to ndb_mgm -e show)
Thoughts welcome.
Index: ndb-work/sql/ha_ndbcluster.cc
===================================================================
--- ndb-work.orig/sql/ha_ndbcluster.cc 2007-04-24 11:59:45.365147500 -0700
+++ ndb-work/sql/ha_ndbcluster.cc 2007-04-24 14:16:07.916314000 -0700
@@ -11327,6 +11327,88 @@ static int ndbcluster_fill_files_table(h
DBUG_RETURN(0);
}
+ST_FIELD_INFO nodeStatusFieldInfo[]=
+{
+ {"NODE_ID", 4, MYSQL_TYPE_LONG, 0, 0, "Node ID"},
+ {"NODE_TYPE",4, MYSQL_TYPE_LONG, 0, 0, "Node Type"},
+ {"NODE_STATUS",4, MYSQL_TYPE_LONG, 0, 0, "Node Type"},
+ {"NODE_GROUP",4, MYSQL_TYPE_LONG, 0, 0, "Node Group"},
+ {"START_PHASE",4, MYSQL_TYPE_LONG, 0, 0, "Start Phase"},
+ {0, 0, MYSQL_TYPE_STRING,0, 0, 0}
+};
+
+
+class NdbInfoSchema
+{
+public:
+ static int initNdbNodeStatus(void*p);
+ static int deinitNdbNodeStatus(void*p);
+ static int fillNdbNodeStatus(THD *thd, TABLE_LIST *tables, COND *cond);
+};
+
+int NdbInfoSchema::initNdbNodeStatus(void *p)
+{
+ DBUG_ENTER("initNdbNodeStatus");
+ ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
+ schema->fields_info = nodeStatusFieldInfo;
+ schema->fill_table = NdbInfoSchema::fillNdbNodeStatus;
+ DBUG_RETURN(0);
+}
+
+int NdbInfoSchema::deinitNdbNodeStatus(void *p)
+{
+ DBUG_ENTER("deinitNdbNodeStatus");
+ DBUG_RETURN(0);
+}
+
+#include <mgmapi.h>
+
+int NdbInfoSchema::fillNdbNodeStatus(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ char cstr[256];
+ NdbMgmHandle h;
+ int err= 0;
+
+ TABLE* table= tables->table;
+
+ g_ndb_cluster_connection->get_connectstring(cstr, sizeof(cstr));
+
+ if((h= ndb_mgm_create_handle())==NULL)
+ {
+ return 1;
+ err= 1;
+// goto done;
+ }
+
+ ndb_mgm_set_connectstring(h, cstr);
+ ndb_mgm_set_timeout(h, 4000);
+ ndb_mgm_connect(h, 0, 0, 0);
+
+ struct ndb_mgm_cluster_state *cl= ndb_mgm_get_status(h);
+ if(cl == 0){
+// ndbout_c("Unable get status from management server");
+// printError();
+ return -1;
+ }
+ int nodeId;
+ int i= 0;
+ for(int i=0; i< cl->no_of_nodes; i++)
+ {
+ int c=0;
+ table->field[c++]->store(cl->node_states[i].node_id);
+ table->field[c++]->store(cl->node_states[i].node_type);
+ table->field[c++]->store(cl->node_states[i].node_status);
+ table->field[c++]->store(cl->node_states[i].node_group);
+ table->field[c++]->store(cl->node_states[i].start_phase);
+ int error= schema_table_store_record(thd, table);
+ }
+
+cleanup:
+// ndb_mgm_destroy_handle(h);
+done:
+ return err;
+}
+
SHOW_VAR ndb_status_variables_export[]= {
{"Ndb", (char*) &ndb_status_variables, SHOW_ARRAY},
{NullS, NullS, SHOW_LONG}
@@ -11335,6 +11417,9 @@ SHOW_VAR ndb_status_variables_export[]=
struct st_mysql_storage_engine ndbcluster_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
+static st_mysql_information_schema ndb_node_status=
+{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
+
mysql_declare_plugin(ndbcluster)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -11350,6 +11435,21 @@ mysql_declare_plugin(ndbcluster)
NULL, /* system variables */
NULL /* config options */
}
+ ,
+{
+ MYSQL_INFORMATION_SCHEMA_PLUGIN,
+ &ndb_node_status,
+ "NDB_NODE_STATUS",
+ "MySQL AB",
+ "NDB Node Status",
+ PLUGIN_LICENSE_GPL,
+ NdbInfoSchema::initNdbNodeStatus, /* plugin init */
+ NdbInfoSchema::deinitNdbNodeStatus, /* plugin deinit */
+ 0x0001,
+ NULL, /* status variables */
+ NULL, /* system variables */
+ NULL /* config options */
+ }
mysql_declare_plugin_end;
#endif
--
Stewart Smith, Software Engineer
MySQL AB, www.mysql.com
Office: +14082136540 Ext: 6616
VoIP: 6616@sip.us.mysql.com
Mobile: +61 4 3 8844 332
Jumpstart your cluster:
http://www.mysql.com/consulting/packaged/cluster.html
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic