List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:October 1 2010 11:35am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (jonas:3819)
View as plain text  
#At file:///home/jonas/src/telco-7.0/ based on revid:jonas@stripped

 3819 Jonas Oreland	2010-10-01
      ndb - make ClusterMgr any other TransporterFacade client using fix-blockno (instead of hardcoded into TF

    modified:
      storage/ndb/include/kernel/BlockNumbers.h
      storage/ndb/src/ndbapi/ClusterMgr.cpp
      storage/ndb/src/ndbapi/ClusterMgr.hpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/TransporterFacade.hpp
=== modified file 'storage/ndb/include/kernel/BlockNumbers.h'
--- a/storage/ndb/include/kernel/BlockNumbers.h	2010-08-23 08:42:53 +0000
+++ b/storage/ndb/include/kernel/BlockNumbers.h	2010-10-01 11:35:36 +0000
@@ -28,14 +28,14 @@
 /* 2047 */
 #define API_PACKED     0x07ff
 
+/* Fixed block numbers in API */
+#define NO_API_FIXED_BLOCKS    2
+
 /* 4002 */
 #define API_CLUSTERMGR 0x0FA2
+#define MGM_CONFIG_MAN 0x0FA3
 
-/* Fixed block numbers in API */
-#define NO_API_FIXED_BLOCKS    1
-#define MIN_API_FIXED_BLOCK_NO (API_CLUSTERMGR+1)
-#define MGM_CONFIG_MAN MIN_API_FIXED_BLOCK_NO
-
+#define MIN_API_FIXED_BLOCK_NO (API_CLUSTERMGR)
 #define MAX_API_FIXED_BLOCK_NO (MIN_API_FIXED_BLOCK_NO + NO_API_FIXED_BLOCKS)
 
 

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.cpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-10-01 11:00:38 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-10-01 11:35:36 +0000
@@ -34,6 +34,8 @@
 #include <signaldata/NodeFailRep.hpp>
 #include <signaldata/NFCompleteRep.hpp>
 #include <signaldata/ApiRegSignalData.hpp>
+#include <signaldata/AlterTable.hpp>
+#include <signaldata/SumaImpl.hpp>
 
 #include <mgmapi.h>
 #include <mgmapi_configuration.hpp>
@@ -69,6 +71,13 @@ ClusterMgr::ClusterMgr(TransporterFacade
   clusterMgrThreadMutex = NdbMutex_Create();
   waitForHBCond= NdbCondition_Create();
   m_auto_reconnect = -1;
+
+  int ret = theFacade.open(this, API_CLUSTERMGR);
+  if (unlikely(ret < 0))
+  {
+    ndbout_c("Failed to register ClusterMgr! ret: %d", ret);
+    abort();
+  }
   DBUG_VOID_RETURN;
 }
 
@@ -323,6 +332,111 @@ ClusterMgr::threadMain( ){
   }
 }
 
+void
+ClusterMgr::trp_deliver_signal(const NdbApiSignal* sig,
+                               const LinearSectionPtr ptr[3])
+{
+  const Uint32 gsn = sig->theVerId_signalNumber;
+  const Uint32 * theData = sig->getDataPtr();
+
+  switch (gsn){
+  case GSN_API_REGREQ:
+    execAPI_REGREQ(theData);
+    break;
+
+  case GSN_API_REGCONF:
+  {
+    execAPI_REGCONF(theData);
+
+    // Distribute signal to all threads/blocks
+    theFacade.for_each(this, sig, ptr);
+    break;
+  }
+
+  case GSN_API_REGREF:
+    execAPI_REGREF(theData);
+    break;
+
+  case GSN_NODE_FAILREP:
+    execNODE_FAILREP(theData);
+    break;
+
+  case GSN_NF_COMPLETEREP:
+    execNF_COMPLETEREP(theData);
+    break;
+
+  case GSN_ARBIT_STARTREQ:
+    if (theFacade.theArbitMgr != NULL)
+      theFacade.theArbitMgr->doStart(theData);
+    break;
+
+  case GSN_ARBIT_CHOOSEREQ:
+    if (theFacade.theArbitMgr != NULL)
+      theFacade.theArbitMgr->doChoose(theData);
+    break;
+
+  case GSN_ARBIT_STOPORD:
+    if(theFacade.theArbitMgr != NULL)
+      theFacade.theArbitMgr->doStop(theData);
+    break;
+
+  case GSN_ALTER_TABLE_REP:
+  {
+    if (theFacade.m_globalDictCache == NULL)
+      break;
+    const AlterTableRep* rep = (const AlterTableRep*)theData;
+    theFacade.m_globalDictCache->lock();
+    theFacade.m_globalDictCache->
+      alter_table_rep((const char*)ptr[0].p,
+                      rep->tableId,
+                      rep->tableVersion,
+                      rep->changeType == AlterTableRep::CT_ALTERED);
+    theFacade.m_globalDictCache->unlock();
+    break;
+  }
+  case GSN_SUB_GCP_COMPLETE_REP:
+  {
+    /**
+     * Report
+     */
+    theFacade.for_each(this, sig, ptr);
+
+    /**
+     * Reply
+     */
+    {
+      BlockReference ownRef = numberToRef(API_CLUSTERMGR, theFacade.ownId());
+      NdbApiSignal tSignal(* sig);
+      Uint32* send= tSignal.getDataPtrSend();
+      memcpy(send, theData, tSignal.getLength() << 2);
+      ((SubGcpCompleteAck*)send)->rep.senderRef = ownRef;
+      Uint32 ref= sig->theSendersBlockRef;
+      Uint32 aNodeId= refToNode(ref);
+      tSignal.theReceiversBlockNumber= refToBlock(ref);
+      tSignal.theVerId_signalNumber= GSN_SUB_GCP_COMPLETE_ACK;
+      theFacade.sendSignalUnCond(&tSignal, aNodeId);
+    }
+    break;
+  }
+  case GSN_TAKE_OVERTCCONF:
+  {
+    /**
+     * Report
+     */
+    theFacade.for_each(this, sig, ptr);
+    return;
+  }
+  default:
+    break;
+
+  }
+  return;
+}
+
+void
+ClusterMgr::trp_node_status(Uint32 nodeId, Uint32 event)
+{
+}
 
 ClusterMgr::Node::Node()
   : m_state(NodeState::SL_NOTHING),

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.hpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-09-30 09:32:28 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-10-01 11:35:36 +0000
@@ -27,6 +27,7 @@
 #include <signaldata/NodeStateSignalData.hpp>
 #include <NodeInfo.hpp>
 #include <NodeState.hpp>
+#include "trp_client.hpp"
 
 extern "C" void* runClusterMgr_C(void * me);
 
@@ -34,12 +35,13 @@ extern "C" void* runClusterMgr_C(void * 
 /**
  * @class ClusterMgr
  */
-class ClusterMgr {
+class ClusterMgr : public trp_client
+{
   friend class TransporterFacade;
   friend void* runClusterMgr_C(void * me);
 public:
   ClusterMgr(class TransporterFacade &);
-  ~ClusterMgr();
+  virtual ~ClusterMgr();
   void configure(const ndb_mgm_configuration* config);
   
   void reportConnected(NodeId nodeId);
@@ -172,6 +174,14 @@ private:
 
   void print_nodes(const char* where, NdbOut& out = ndbout);
   void recalcMinDbVersion();
+
+public:
+  /**
+   * trp_client interface
+   */
+  virtual void trp_deliver_signal(const NdbApiSignal*,
+                                  const LinearSectionPtr p[3]);
+  virtual void trp_node_status(Uint32, Uint32);
 };
 
 inline

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-01 11:00:38 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-01 11:35:36 +0000
@@ -293,113 +293,6 @@ TransporterFacade::deliver_signal(Signal
     }
     return;
   }
-  else if (tRecBlockNo == API_CLUSTERMGR)
-  {
-    /**
-     * The signal was aimed for the Cluster Manager. 
-     * We handle it immediately here.
-     */     
-    ClusterMgr * clusterMgr = theClusterMgr;
-    const Uint32 gsn = header->theVerId_signalNumber;
-    
-    switch (gsn){
-    case GSN_API_REGREQ:
-      clusterMgr->execAPI_REGREQ(theData);
-      break;
-      
-    case GSN_API_REGCONF:
-    {
-      clusterMgr->execAPI_REGCONF(theData);
-      
-      // Distribute signal to all threads/blocks
-      NdbApiSignal tSignal(* header);
-      tSignal.setDataPtr(theData);
-      for_each(&tSignal, ptr);
-      break;
-    }
-    
-    case GSN_API_REGREF:
-      clusterMgr->execAPI_REGREF(theData);
-      break;
-      
-    case GSN_NODE_FAILREP:
-      clusterMgr->execNODE_FAILREP(theData);
-      break;
-      
-    case GSN_NF_COMPLETEREP:
-      clusterMgr->execNF_COMPLETEREP(theData);
-      break;
-      
-    case GSN_ARBIT_STARTREQ:
-      if (theArbitMgr != NULL)
-        theArbitMgr->doStart(theData);
-      break;
-      
-    case GSN_ARBIT_CHOOSEREQ:
-      if (theArbitMgr != NULL)
-        theArbitMgr->doChoose(theData);
-      break;
-      
-    case GSN_ARBIT_STOPORD:
-      if(theArbitMgr != NULL)
-        theArbitMgr->doStop(theData);
-      break;
-      
-    case GSN_ALTER_TABLE_REP:
-    {
-      if (m_globalDictCache == NULL)
-        break;
-      const AlterTableRep* rep = (const AlterTableRep*)theData;
-      m_globalDictCache->lock();
-      m_globalDictCache->
-        alter_table_rep((const char*)ptr[0].p, 
-                        rep->tableId,
-                        rep->tableVersion,
-                        rep->changeType == AlterTableRep::CT_ALTERED);
-      m_globalDictCache->unlock();
-      break;
-    }
-    case GSN_SUB_GCP_COMPLETE_REP:
-    {
-      /**
-       * Report
-       */
-      NdbApiSignal tSignal(* header);
-      tSignal.setDataPtr(theData);
-      for_each(&tSignal, ptr);
-      
-      /**
-       * Reply
-       */
-      {
-        Uint32* send= tSignal.getDataPtrSend();
-        memcpy(send, theData, tSignal.getLength() << 2);
-        CAST_PTR(SubGcpCompleteAck, send)->rep.senderRef = 
-          numberToRef(API_CLUSTERMGR, theOwnId);
-        Uint32 ref= header->theSendersBlockRef;
-        Uint32 aNodeId= refToNode(ref);
-        tSignal.theReceiversBlockNumber= refToBlock(ref);
-        tSignal.theVerId_signalNumber= GSN_SUB_GCP_COMPLETE_ACK;
-        sendSignalUnCond(&tSignal, aNodeId);
-      }
-      break;
-    }
-    case GSN_TAKE_OVERTCCONF:
-    {
-      /**
-       * Report
-       */
-      NdbApiSignal tSignal(* header);
-      tSignal.setDataPtr(theData);
-      for_each(&tSignal, ptr);
-      return;
-    }
-    default:
-      break;
-      
-    }
-    return;
-  }
   else if (tRecBlockNo >= MIN_API_FIXED_BLOCK_NO &&
            tRecBlockNo <= MAX_API_FIXED_BLOCK_NO) 
   {
@@ -888,13 +781,15 @@ TransporterFacade::configure(NodeId node
 }
 
 void
-TransporterFacade::for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
+TransporterFacade::for_each(trp_client* sender,
+                            const NdbApiSignal* aSignal, 
+                            const LinearSectionPtr ptr[3])
 {
   Uint32 sz = m_threads.m_statusNext.size();
   for (Uint32 i = 0; i < sz ; i ++) 
   {
     trp_client * clnt = m_threads.m_objectExecute[i];
-    if (clnt != 0)
+    if (clnt != 0 && clnt != sender)
     {
       clnt->trp_deliver_signal(aSignal, ptr);
     }

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-01 11:00:38 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-01 11:35:36 +0000
@@ -121,7 +121,8 @@ public:
   /**
    * Send signal to each registered object
    */
-  void for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]);
+  void for_each(trp_client* clnt,
+                const NdbApiSignal* aSignal, const LinearSectionPtr ptr[3]);
   
   void lock_mutex();
   void unlock_mutex();


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20101001113536-2i973b2zkkcw5sce.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jonas:3819) Jonas Oreland1 Oct