SumaInit.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:6k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #include "Suma.hpp"
  14. #include <Properties.hpp>
  15. #include <Configuration.hpp>
  16. SumaParticipant::SumaParticipant(const Configuration & conf) :
  17.   SimulatedBlock(SUMA, conf),
  18.   c_metaSubscribers(c_subscriberPool),
  19.   c_dataSubscribers(c_subscriberPool),
  20.   c_prepDataSubscribers(c_subscriberPool),
  21.   c_removeDataSubscribers(c_subscriberPool),
  22.   c_tables(c_tablePool_),
  23.   c_subscriptions(c_subscriptionPool)
  24. {
  25.   BLOCK_CONSTRUCTOR(SumaParticipant);
  26.   
  27.   /**
  28.    * SUMA participant if
  29.    */
  30.   addRecSignal(GSN_SUB_CREATE_REQ, &SumaParticipant::execSUB_CREATE_REQ);
  31.   addRecSignal(GSN_SUB_REMOVE_REQ, &SumaParticipant::execSUB_REMOVE_REQ);
  32.   addRecSignal(GSN_SUB_START_REQ, &SumaParticipant::execSUB_START_REQ);
  33.   addRecSignal(GSN_SUB_STOP_REQ, &SumaParticipant::execSUB_STOP_REQ);
  34.   addRecSignal(GSN_SUB_SYNC_REQ, &SumaParticipant::execSUB_SYNC_REQ);
  35.   
  36.   addRecSignal(GSN_SUB_STOP_CONF, &SumaParticipant::execSUB_STOP_CONF);
  37.   addRecSignal(GSN_SUB_STOP_REF, &SumaParticipant::execSUB_STOP_REF);
  38.   /**
  39.    * Dict interface
  40.    */
  41.   //addRecSignal(GSN_LIST_TABLES_REF, &SumaParticipant::execLIST_TABLES_REF);
  42.   addRecSignal(GSN_LIST_TABLES_CONF, &SumaParticipant::execLIST_TABLES_CONF);
  43.   //addRecSignal(GSN_GET_TABINFOREF, &SumaParticipant::execGET_TABINFO_REF);
  44.   addRecSignal(GSN_GET_TABINFO_CONF, &SumaParticipant::execGET_TABINFO_CONF);
  45.   addRecSignal(GSN_GET_TABINFOREF, &SumaParticipant::execGET_TABINFOREF);
  46. #if 0
  47.   addRecSignal(GSN_GET_TABLEID_CONF, &SumaParticipant::execGET_TABLEID_CONF);
  48.   addRecSignal(GSN_GET_TABLEID_REF, &SumaParticipant::execGET_TABLEID_REF);
  49. #endif
  50.   /**
  51.    * Dih interface
  52.    */
  53.   //addRecSignal(GSN_DI_FCOUNTREF, &SumaParticipant::execDI_FCOUNTREF);
  54.   addRecSignal(GSN_DI_FCOUNTCONF, &SumaParticipant::execDI_FCOUNTCONF);
  55.   //addRecSignal(GSN_DIGETPRIMREF, &SumaParticipant::execDIGETPRIMREF);
  56.   addRecSignal(GSN_DIGETPRIMCONF, &SumaParticipant::execDIGETPRIMCONF);
  57.   /**
  58.    * Scan interface
  59.    */
  60.   addRecSignal(GSN_SCAN_HBREP, &SumaParticipant::execSCAN_HBREP);
  61.   addRecSignal(GSN_TRANSID_AI, &SumaParticipant::execTRANSID_AI);
  62.   addRecSignal(GSN_SCAN_FRAGREF, &SumaParticipant::execSCAN_FRAGREF);
  63.   addRecSignal(GSN_SCAN_FRAGCONF, &SumaParticipant::execSCAN_FRAGCONF);
  64. #if 0
  65.   addRecSignal(GSN_SUB_SYNC_CONTINUE_REF, 
  66.        &SumaParticipant::execSUB_SYNC_CONTINUE_REF);
  67. #endif
  68.   addRecSignal(GSN_SUB_SYNC_CONTINUE_CONF, 
  69.        &SumaParticipant::execSUB_SYNC_CONTINUE_CONF);
  70.   
  71.   /**
  72.    * Trigger stuff
  73.    */
  74.   addRecSignal(GSN_TRIG_ATTRINFO, &SumaParticipant::execTRIG_ATTRINFO);
  75.   addRecSignal(GSN_FIRE_TRIG_ORD, &SumaParticipant::execFIRE_TRIG_ORD);
  76.   addRecSignal(GSN_CREATE_TRIG_REF, &Suma::execCREATE_TRIG_REF);
  77.   addRecSignal(GSN_CREATE_TRIG_CONF, &Suma::execCREATE_TRIG_CONF);
  78.   addRecSignal(GSN_DROP_TRIG_REF, &Suma::execDROP_TRIG_REF);
  79.   addRecSignal(GSN_DROP_TRIG_CONF, &Suma::execDROP_TRIG_CONF);
  80.   
  81.   addRecSignal(GSN_SUB_GCP_COMPLETE_REP, 
  82.        &SumaParticipant::execSUB_GCP_COMPLETE_REP);
  83.   
  84.   /**
  85.    * @todo: fix pool sizes
  86.    */
  87.   Uint32 noTables;
  88.   const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator();
  89.   ndbrequire(p != 0);
  90.   ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES,  
  91.     &noTables);
  92.   c_tablePool_.setSize(noTables);
  93.   c_tables.setSize(noTables);
  94.   
  95.   c_subscriptions.setSize(20); //10
  96.   c_subscriberPool.setSize(64);
  97.   
  98.   c_subscriptionPool.setSize(64); //2
  99.   c_syncPool.setSize(20); //2
  100.   c_dataBufferPool.setSize(128);
  101.   
  102.   {
  103.     SLList<SyncRecord> tmp(c_syncPool);
  104.     Ptr<SyncRecord> ptr;
  105.     while(tmp.seize(ptr))
  106.       new (ptr.p) SyncRecord(* this, c_dataBufferPool);
  107.     tmp.release();
  108.   }
  109.   for( int i = 0; i < NO_OF_BUCKETS; i++) {
  110.     c_buckets[i].active = false;
  111.     c_buckets[i].handover = false;
  112.     c_buckets[i].handover_started = false;
  113.     c_buckets[i].handoverGCI = 0;
  114.   }
  115.   c_handoverToDo = false;
  116.   c_lastInconsistentGCI = RNIL;
  117.   c_lastCompleteGCI = RNIL;
  118.   c_nodeFailGCI = 0;
  119.   c_failedApiNodes.clear();
  120. }
  121.   
  122. SumaParticipant::~SumaParticipant()
  123. {
  124. }
  125. Suma::Suma(const Configuration & conf) :
  126.   SumaParticipant(conf),
  127.   Restart(*this),
  128.   c_nodes(c_nodePool),
  129.   c_runningSubscriptions(c_subCoordinatorPool)
  130. {
  131.   
  132.   c_nodePool.setSize(MAX_NDB_NODES);
  133.   c_masterNodeId = getOwnNodeId();
  134.   c_nodeGroup = c_noNodesInGroup = c_idInNodeGroup = 0;
  135.   for (int i = 0; i < MAX_REPLICAS; i++) {
  136.     c_nodesInGroup[i]   = 0;
  137.   }
  138.   c_subCoordinatorPool.setSize(10);
  139.   
  140.   // Add received signals
  141.   addRecSignal(GSN_STTOR, &Suma::execSTTOR);
  142.   addRecSignal(GSN_NDB_STTOR, &Suma::execNDB_STTOR);
  143.   addRecSignal(GSN_DUMP_STATE_ORD, &Suma::execDUMP_STATE_ORD);
  144.   addRecSignal(GSN_READ_NODESCONF, &Suma::execREAD_NODESCONF);
  145.   addRecSignal(GSN_API_FAILREQ,  &Suma::execAPI_FAILREQ);
  146.   addRecSignal(GSN_NODE_FAILREP, &Suma::execNODE_FAILREP);
  147.   addRecSignal(GSN_INCL_NODEREQ, &Suma::execINCL_NODEREQ);
  148.   addRecSignal(GSN_CONTINUEB, &Suma::execCONTINUEB);
  149.   addRecSignal(GSN_SIGNAL_DROPPED_REP, &Suma::execSIGNAL_DROPPED_REP, true);
  150.   addRecSignal(GSN_UTIL_SEQUENCE_CONF, &Suma::execUTIL_SEQUENCE_CONF);
  151.   addRecSignal(GSN_UTIL_SEQUENCE_REF, &Suma::execUTIL_SEQUENCE_REF);
  152.   addRecSignal(GSN_CREATE_SUBID_REQ, 
  153.        &Suma::execCREATE_SUBID_REQ);
  154.   addRecSignal(GSN_SUB_CREATE_CONF, &Suma::execSUB_CREATE_CONF);
  155.   addRecSignal(GSN_SUB_CREATE_REF, &Suma::execSUB_CREATE_REF);
  156.   addRecSignal(GSN_SUB_SYNC_CONF, &Suma::execSUB_SYNC_CONF);
  157.   addRecSignal(GSN_SUB_SYNC_REF, &Suma::execSUB_SYNC_REF);
  158.   addRecSignal(GSN_SUB_START_CONF, &Suma::execSUB_START_CONF);
  159.   addRecSignal(GSN_SUB_START_REF, &Suma::execSUB_START_REF);
  160.   addRecSignal(GSN_SUMA_START_ME, &Suma::execSUMA_START_ME);
  161.   addRecSignal(GSN_SUMA_HANDOVER_REQ, &Suma::execSUMA_HANDOVER_REQ);
  162.   addRecSignal(GSN_SUMA_HANDOVER_CONF, &Suma::execSUMA_HANDOVER_CONF);
  163.   addRecSignal(GSN_SUB_GCP_COMPLETE_ACC, 
  164.        &Suma::execSUB_GCP_COMPLETE_ACC);
  165. }
  166. Suma::~Suma()
  167. {
  168. }
  169. BLOCK_FUNCTIONS(Suma)
  170. BLOCK_FUNCTIONS(SumaParticipant)