List:Commits« Previous MessageNext Message »
From:John David Duncan Date:June 22 2011 3:45pm
Subject:bzr commit into mysql-5.1-telco-7.2 branch (john.duncan:4186)
View as plain text  
#At file:///Users/jdd/bzr-repo/working/cluster-7.2-build/ based on revid:john.duncan@stripped

 4186 John David Duncan	2011-06-22
      Access to NDB API client-side statistics from memcached "STATS NDB" command.

    modified:
      storage/ndb/memcache/include/ClusterConnectionPool.h
      storage/ndb/memcache/include/Scheduler.h
      storage/ndb/memcache/include/ndb_pipeline.h
      storage/ndb/memcache/src/ClusterConnectionPool.cc
      storage/ndb/memcache/src/ndb_engine.c
      storage/ndb/memcache/src/ndb_pipeline.cc
      storage/ndb/memcache/src/schedulers/Bulk.cc
      storage/ndb/memcache/src/schedulers/Bulk.h
      storage/ndb/memcache/src/schedulers/Flex.cc
      storage/ndb/memcache/src/schedulers/Flex.h
      storage/ndb/memcache/src/schedulers/Stockholm.cc
      storage/ndb/memcache/src/schedulers/Stockholm.h
=== modified file 'storage/ndb/memcache/include/ClusterConnectionPool.h'
--- a/storage/ndb/memcache/include/ClusterConnectionPool.h	2011-04-06 04:31:28 +0000
+++ b/storage/ndb/memcache/include/ClusterConnectionPool.h	2011-06-22 15:44:47 +0000
@@ -22,6 +22,8 @@
 
 #define MAX_CONNECT_POOL 4
 
+#include <memcached/engine.h>
+
 #include <NdbApi.hpp>
 
 #include "NdbInstance.h"
@@ -68,6 +70,9 @@ public:
    
   /** Get the master NdbInstance for this connection */ 
   NdbInstance * getNdbInstance(int my_id) const;                    // inlined
+  
+  /** Get aggregated NDB API client statistics */
+  void add_stats(const char *, ADD_STAT, const void *);
 };
 
 /* Inline functions */

=== modified file 'storage/ndb/memcache/include/Scheduler.h'
--- a/storage/ndb/memcache/include/Scheduler.h	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/include/Scheduler.h	2011-06-22 15:44:47 +0000
@@ -70,7 +70,7 @@ public:
   
   /** add_stats() allows the engine to delegate certain statistics
      to the scheduler. */
-  virtual void add_stats(ADD_STAT, const void *) = 0;
+  virtual void add_stats(const char *key, ADD_STAT, const void *) = 0;
 
   /* each scheduler instance serves a single NDB pipeline */
   ndb_pipeline *pipeline;

=== modified file 'storage/ndb/memcache/include/ndb_pipeline.h'
--- a/storage/ndb/memcache/include/ndb_pipeline.h	2011-04-06 04:31:28 +0000
+++ b/storage/ndb/memcache/include/ndb_pipeline.h	2011-06-22 15:44:47 +0000
@@ -110,7 +110,7 @@ ndb_pipeline * get_request_pipeline();
 void ndb_pipeline_shutdown(void *);
 
 /** call into a pipeline for its own statistics */
-void pipeline_add_stats(ndb_pipeline *, ADD_STAT, const void *);
+void pipeline_add_stats(ndb_pipeline *, const char *key, ADD_STAT, const void *);
 
 /** Global initialization of scheduler, at startup time */
 void * initialize_scheduler(const char *name, int nthreads, int threadnum);

=== modified file 'storage/ndb/memcache/src/ClusterConnectionPool.cc'
--- a/storage/ndb/memcache/src/ClusterConnectionPool.cc	2011-05-17 04:55:39 +0000
+++ b/storage/ndb/memcache/src/ClusterConnectionPool.cc	2011-06-22 15:44:47 +0000
@@ -19,6 +19,10 @@
  */
 #include <stdio.h>
 
+/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
+#define __STDC_FORMAT_MACROS 
+#include <inttypes.h>
+
 #include <memcached/extension_loggers.h>
 
 #include "debug.h"
@@ -105,3 +109,23 @@ Ndb_cluster_connection * ClusterConnecti
   return conn;
 }
 
+
+void ClusterConnectionPool::add_stats(const char *prefix,
+                                      ADD_STAT add_stat, 
+                                      const void *cookie) {
+  char key[128];
+  char val[128];
+  int klen, vlen;
+  Ndb *ndb = master_instances[0]->db;
+  Uint64 ndb_stats[Ndb::NumClientStatistics];
+  
+  for(int i = 0 ; i < pool_size ; i++) {
+    pool_connections[i]->collect_client_stats(ndb_stats, Ndb::NumClientStatistics);
+  
+    for(int s = 0 ; s < Ndb::NumClientStatistics ; s++) {
+      klen = sprintf(key, "%s_conn%d_%s", prefix, i, ndb->getClientStatName(s));
+      vlen = sprintf(val, "%"PRIu64, ndb_stats[s]);
+      add_stat(key, klen, val, vlen, cookie);
+    }
+  }
+}

=== modified file 'storage/ndb/memcache/src/ndb_engine.c'
--- a/storage/ndb/memcache/src/ndb_engine.c	2011-04-09 07:36:24 +0000
+++ b/storage/ndb/memcache/src/ndb_engine.c	2011-06-22 15:44:47 +0000
@@ -433,9 +433,14 @@ static ENGINE_ERROR_CODE ndb_get_stats(E
     
   DEBUG_ENTER(); 
     
-  pipeline_add_stats(pipeline, add_stat, cookie);
-  return def_eng->engine.get_stats(ndb_eng->m_default_engine, cookie,
-                                   stat_key, nkey, add_stat);
+  if(stat_key == NULL) {
+    return def_eng->engine.get_stats(ndb_eng->m_default_engine, cookie,
+                                     stat_key, nkey, add_stat);
+  }
+  else {
+    pipeline_add_stats(pipeline, stat_key, add_stat, cookie);
+    return ENGINE_SUCCESS;
+  }
 }
 
 

=== modified file 'storage/ndb/memcache/src/ndb_pipeline.cc'
--- a/storage/ndb/memcache/src/ndb_pipeline.cc	2011-04-19 01:16:36 +0000
+++ b/storage/ndb/memcache/src/ndb_pipeline.cc	2011-06-22 15:44:47 +0000
@@ -144,30 +144,39 @@ void ndb_pipeline_shutdown(void *arg) {
   return;
 }
 
-
 void pipeline_add_stats(ndb_pipeline *self, 
+                        const char *stat_key,
                         ADD_STAT add_stat, 
                         const void *cookie) {
   char key[128];
   char val[128];
-  const char *units[4] = { "ns", "us", "ms", "s" };
-  int klen, vlen, p;
+  int klen, vlen;
   char id;
 
-  klen = sprintf(key, "t%d_workitems", self->id);
-  vlen = sprintf(val, "%d", self->nworkitems);
-  add_stat(key, klen, val, vlen, cookie);
-  
-  self->stats.engine_thread_vtime = get_thread_vtime();
-  if(self->stats.engine_thread_vtime != 0) {
-    klen = sprintf(key, "t%d_engine_thread_time", self->id);
-    vlen = sprintf(val, "%"PRIu64, self->stats.engine_thread_vtime);
+  DEBUG_ENTER();
+  const Configuration & conf = get_Configuration();
+
+  if(stat_key == NULL) {
+    klen = sprintf(key, "t%d_workitems", self->id);
+    vlen = sprintf(val, "%d", self->nworkitems);
     add_stat(key, klen, val, vlen, cookie);
+    
+    self->stats.engine_thread_vtime = get_thread_vtime();
+    if(self->stats.engine_thread_vtime != 0) {
+      klen = sprintf(key, "t%d_engine_thread_time", self->id);
+      vlen = sprintf(val, "%"PRIu64, self->stats.engine_thread_vtime);
+      add_stat(key, klen, val, vlen, cookie);
+    }
+    self->scheduler->add_stats(stat_key, add_stat, cookie);
   }
-  
-  self->scheduler->add_stats(add_stat, cookie);
+  else if(strncasecmp(stat_key,"ndb",3) == 0) {
+    for(int i = 0 ; i < conf.nclusters ; i ++) {
+      sprintf(key, "cl%d", i);
+      conf.getConnectionById(i)->add_stats(key, add_stat, cookie);
+    }
+  }  
 }
-
+  
 
 void * initialize_scheduler(const char *cf, int nthreads, int athread) {
   Scheduler *s = 0;

=== modified file 'storage/ndb/memcache/src/schedulers/Bulk.cc'
--- a/storage/ndb/memcache/src/schedulers/Bulk.cc	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/schedulers/Bulk.cc	2011-06-22 15:44:47 +0000
@@ -191,8 +191,9 @@ void Scheduler_bulk::io_completed(workit
 }
 
 
-void Scheduler_bulk::add_stats(ADD_STAT add_stat, 
-                                  const void * cookie) {  
+void Scheduler_bulk::add_stats(const char *,
+                               ADD_STAT add_stat, 
+                               const void * cookie) {  
   char key[128];
   char val[128];
   const char *units[4] = { "ns", "us", "ms", "s" };

=== modified file 'storage/ndb/memcache/src/schedulers/Bulk.h'
--- a/storage/ndb/memcache/src/schedulers/Bulk.h	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/schedulers/Bulk.h	2011-06-22 15:44:47 +0000
@@ -46,7 +46,7 @@ public:
   void yield(workitem *) const;
   void reschedule(workitem *) const;
   void io_completed(workitem *);
-  void add_stats(ADD_STAT, const void *);
+  void add_stats(const char *, ADD_STAT, const void *);
   void * run_ndb_commit_thread(int thread_id);
 
 private:  

=== modified file 'storage/ndb/memcache/src/schedulers/Flex.cc'
--- a/storage/ndb/memcache/src/schedulers/Flex.cc	2011-04-09 07:36:24 +0000
+++ b/storage/ndb/memcache/src/schedulers/Flex.cc	2011-06-22 15:44:47 +0000
@@ -163,7 +163,9 @@ ENGINE_ERROR_CODE Scheduler_flex::schedu
 }
 
 
-void Scheduler_flex::add_stats(ADD_STAT add_stat, const void * cookie) {
+void Scheduler_flex::add_stats(const char *, 
+                               ADD_STAT add_stat, 
+                               const void * cookie) {
   char key[128];
   char val[128];
   int klen, vlen, p;

=== modified file 'storage/ndb/memcache/src/schedulers/Flex.h'
--- a/storage/ndb/memcache/src/schedulers/Flex.h	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/schedulers/Flex.h	2011-06-22 15:44:47 +0000
@@ -59,7 +59,7 @@ public:
   void yield(workitem *) const;                                       // inlined
   void reschedule(workitem *) const;                                  // inlined
   void io_completed(workitem *);
-  void add_stats(ADD_STAT, const void *);  
+  void add_stats(const char *, ADD_STAT, const void *);
 
 protected:
   int thread_id;

=== modified file 'storage/ndb/memcache/src/schedulers/Stockholm.cc'
--- a/storage/ndb/memcache/src/schedulers/Stockholm.cc	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/schedulers/Stockholm.cc	2011-06-22 15:44:47 +0000
@@ -219,7 +219,8 @@ void Scheduler_stockholm::io_completed(w
 }
 
 
-void Scheduler_stockholm::add_stats(ADD_STAT add_stat, 
+void Scheduler_stockholm::add_stats(const char *, 
+                                    ADD_STAT add_stat, 
                                     const void * cookie) {
   char key[128];
   char val[128];

=== modified file 'storage/ndb/memcache/src/schedulers/Stockholm.h'
--- a/storage/ndb/memcache/src/schedulers/Stockholm.h	2011-05-17 05:22:56 +0000
+++ b/storage/ndb/memcache/src/schedulers/Stockholm.h	2011-06-22 15:44:47 +0000
@@ -49,7 +49,7 @@ public:
   void yield(workitem *) const;                                       // inlined
   void reschedule(workitem *) const;                                  // inlined
   void io_completed(workitem *);
-  void add_stats(ADD_STAT, const void *);
+  void add_stats(const char *, ADD_STAT, const void *);
   void * run_ndb_commit_thread(int cluster_id);
   
 private:  


Attachment: [text/bzr-bundle] bzr/john.duncan@oracle.com-20110622154447-hz9w1umd32irk0db.bundle
Thread
bzr commit into mysql-5.1-telco-7.2 branch (john.duncan:4186) John David Duncan23 Jun