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

 3820 Jonas Oreland	2010-10-01
      ndb - move ArbitMgr-object from TransporterFacade to ClusterMgr

    modified:
      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/src/ndbapi/ClusterMgr.cpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-10-01 11:35:36 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-10-01 11:43:32 +0000
@@ -58,6 +58,7 @@ runClusterMgr_C(void * me)
 ClusterMgr::ClusterMgr(TransporterFacade & _facade):
   theStop(0),
   theFacade(_facade),
+  theArbitMgr(NULL),
   m_connect_count(0),
   m_max_api_reg_req_interval(~0),
   noOfAliveNodes(0),
@@ -85,13 +86,20 @@ ClusterMgr::~ClusterMgr()
 {
   DBUG_ENTER("ClusterMgr::~ClusterMgr");
   doStop();
+  if (theArbitMgr != 0)
+  {
+    delete theArbitMgr;
+    theArbitMgr = 0;
+  }
   NdbCondition_Destroy(waitForHBCond);
   NdbMutex_Destroy(clusterMgrThreadMutex);
   DBUG_VOID_RETURN;
 }
 
 void
-ClusterMgr::configure(const ndb_mgm_configuration* config){
+ClusterMgr::configure(Uint32 nodeId,
+                      const ndb_mgm_configuration* config)
+{
   ndb_mgm_configuration_iterator iter(* config, CFG_SECTION_NODE);
   for(iter.first(); iter.valid(); iter.next()){
     Uint32 nodeId = 0;
@@ -141,6 +149,30 @@ ClusterMgr::configure(const ndb_mgm_conf
   print_nodes("init");
 #endif
 
+  // Configure arbitrator
+  Uint32 rank = 0;
+  iter.first();
+  iter.find(CFG_NODE_ID, nodeId); // let not found in config mean rank=0
+  iter.get(CFG_NODE_ARBIT_RANK, &rank);
+
+  if (rank > 0)
+  {
+    // The arbitrator should be active
+    if (!theArbitMgr)
+      theArbitMgr = new ArbitMgr(theFacade);
+    theArbitMgr->setRank(rank);
+
+    Uint32 delay = 0;
+    iter.get(CFG_NODE_ARBIT_DELAY, &delay);
+    theArbitMgr->setDelay(delay);
+  }
+  else if (theArbitMgr)
+  {
+    // No arbitrator should be started
+    theArbitMgr->doStop(NULL);
+    delete theArbitMgr;
+    theArbitMgr= NULL;
+  }
 }
 
 void
@@ -170,6 +202,11 @@ ClusterMgr::doStop( ){
     NdbThread_Destroy(&theClusterMgrThread);
   }
 
+  if (theArbitMgr != NULL)
+  {
+    theArbitMgr->doStop(NULL);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -366,18 +403,18 @@ ClusterMgr::trp_deliver_signal(const Ndb
     break;
 
   case GSN_ARBIT_STARTREQ:
-    if (theFacade.theArbitMgr != NULL)
-      theFacade.theArbitMgr->doStart(theData);
+    if (theArbitMgr != NULL)
+      theArbitMgr->doStart(theData);
     break;
 
   case GSN_ARBIT_CHOOSEREQ:
-    if (theFacade.theArbitMgr != NULL)
-      theFacade.theArbitMgr->doChoose(theData);
+    if (theArbitMgr != NULL)
+      theArbitMgr->doChoose(theData);
     break;
 
   case GSN_ARBIT_STOPORD:
-    if(theFacade.theArbitMgr != NULL)
-      theFacade.theArbitMgr->doStop(theData);
+    if(theArbitMgr != NULL)
+      theArbitMgr->doStop(theData);
     break;
 
   case GSN_ALTER_TABLE_REP:

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.hpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-10-01 11:35:36 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-10-01 11:43:32 +0000
@@ -42,7 +42,7 @@ class ClusterMgr : public trp_client
 public:
   ClusterMgr(class TransporterFacade &);
   virtual ~ClusterMgr();
-  void configure(const ndb_mgm_configuration* config);
+  void configure(Uint32 nodeId, const ndb_mgm_configuration* config);
   
   void reportConnected(NodeId nodeId);
   void reportDisconnected(NodeId nodeId);
@@ -62,7 +62,8 @@ private:
   
   int  theStop;
   class TransporterFacade & theFacade;
-  
+  class ArbitMgr * theArbitMgr;
+
 public:
   enum Cluster_state {
     CS_waiting_for_clean_cache = 0,

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-01 11:35:36 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-01 11:43:32 +0000
@@ -408,7 +408,6 @@ TransporterFacade::doStop(){
    * and also uses theFacadeInstance to lock/unlock theMutexPtr
    */
   if (theClusterMgr != NULL) theClusterMgr->doStop();
-  if (theArbitMgr != NULL) theArbitMgr->doStop(NULL);
   
   /**
    * Now stop the send and receive threads
@@ -629,7 +628,6 @@ TransporterFacade::TransporterFacade(Glo
   theOwnId(0),
   theStartNodeId(1),
   theClusterMgr(NULL),
-  theArbitMgr(NULL),
   checkCounter(4),
   currentSendLimit(1),
   theStopReceive(0),
@@ -719,7 +717,7 @@ TransporterFacade::configure(NodeId node
     DBUG_RETURN(false);
 
   // Configure cluster manager
-  theClusterMgr->configure(conf);
+  theClusterMgr->configure(nodeId, conf);
 
   ndb_mgm_configuration_iterator iter(* conf, CFG_SECTION_NODE);
   if(iter.find(CFG_NODE_ID, nodeId))
@@ -730,28 +728,6 @@ TransporterFacade::configure(NodeId node
   iter.get(CFG_TOTAL_SEND_BUFFER_MEMORY, &total_send_buffer);
   theTransporterRegistry->allocate_send_buffers(total_send_buffer);
 
-  // Configure arbitrator
-  Uint32 rank = 0;
-  iter.get(CFG_NODE_ARBIT_RANK, &rank);
-  if (rank > 0)
-  {
-    // The arbitrator should be active
-    if (!theArbitMgr)
-      theArbitMgr = new ArbitMgr(* this);
-    theArbitMgr->setRank(rank);
-
-    Uint32 delay = 0;
-    iter.get(CFG_NODE_ARBIT_DELAY, &delay);
-    theArbitMgr->setDelay(delay);
-  }
-  else if (theArbitMgr)
-  {
-    // No arbitrator should be started
-    theArbitMgr->doStop(NULL);
-    delete theArbitMgr;
-    theArbitMgr= NULL;
-  }
-
   Uint32 auto_reconnect=1;
   iter.get(CFG_AUTO_RECONNECT, &auto_reconnect);
 
@@ -888,7 +864,6 @@ TransporterFacade::~TransporterFacade()
 
   NdbMutex_Lock(theMutexPtr);
   delete theClusterMgr;  
-  delete theArbitMgr;
   delete theTransporterRegistry;
   NdbMutex_Unlock(theMutexPtr);
   NdbMutex_Destroy(theMutexPtr);

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-01 11:35:36 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-01 11:43:32 +0000
@@ -233,7 +233,6 @@ private:
   NodeId theStartNodeId;
 
   ClusterMgr* theClusterMgr;
-  ArbitMgr* theArbitMgr;
   
   // Improving the API response time
   int checkCounter;


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20101001114332-3j843dytf5rjzu64.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jonas:3820) Jonas Oreland1 Oct