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

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. #define DBDIH_C
  14. #include "Dbdih.hpp"
  15. #include <ndb_limits.h>
  16. #define DEBUG(x) { ndbout << "DIH::" << x << endl; }
  17. void Dbdih::initData() 
  18. {
  19.   cpageFileSize = ZPAGEREC;
  20.   apiConnectRecord = 0;
  21.   connectRecord = 0;
  22.   fileRecord = 0;
  23.   fragmentstore = 0;
  24.   pageRecord = 0;
  25.   replicaRecord = 0;
  26.   tabRecord = 0;
  27.   takeOverRecord = 0;
  28.   createReplicaRecord = 0;
  29.   nodeGroupRecord = 0;
  30.   nodeRecord = 0;
  31.   c_nextNodeGroup = 0;
  32.   // Records with constant sizes
  33.   createReplicaRecord = (CreateReplicaRecord*)
  34.     allocRecord("CreateReplicaRecord", sizeof(CreateReplicaRecord),
  35.                  ZCREATE_REPLICA_FILE_SIZE);
  36.   nodeGroupRecord = (NodeGroupRecord*)
  37.     allocRecord("NodeGroupRecord", sizeof(NodeGroupRecord), MAX_NDB_NODES);
  38.   nodeRecord = (NodeRecord*)
  39.     allocRecord("NodeRecord", sizeof(NodeRecord), MAX_NDB_NODES);
  40.   Uint32 i;
  41.   for(i = 0; i<MAX_NDB_NODES; i++){
  42.     new (&nodeRecord[i]) NodeRecord();
  43.   }
  44.   
  45.   takeOverRecord = (TakeOverRecord*)allocRecord("TakeOverRecord",
  46.                                                 sizeof(TakeOverRecord), 
  47.                                                 MAX_NDB_NODES);
  48.   for(i = 0; i<MAX_NDB_NODES; i++)
  49.     new (&takeOverRecord[i]) TakeOverRecord();
  50.   for(i = 0; i<MAX_NDB_NODES; i++)
  51.     new (&takeOverRecord[i]) TakeOverRecord();
  52.   
  53.   waitGCPProxyPool.setSize(ZPROXY_FILE_SIZE);
  54.   waitGCPMasterPool.setSize(ZPROXY_MASTER_FILE_SIZE);
  55.   cgcpOrderBlocked = 0;
  56.   c_lcpState.ctcCounter = 0;
  57.   cwaitLcpSr       = false;
  58.   c_blockCommit    = false;
  59.   c_blockCommitNo  = 1;
  60. }//Dbdih::initData()
  61. void Dbdih::initRecords() 
  62. {
  63.   // Records with dynamic sizes
  64.   apiConnectRecord = (ApiConnectRecord*)
  65.     allocRecord("ApiConnectRecord", 
  66.                 sizeof(ApiConnectRecord),
  67.                 capiConnectFileSize);
  68.   connectRecord = (ConnectRecord*)allocRecord("ConnectRecord",
  69.                                               sizeof(ConnectRecord), 
  70.                                               cconnectFileSize);
  71.   fileRecord = (FileRecord*)allocRecord("FileRecord",
  72.                                         sizeof(FileRecord),
  73.                                         cfileFileSize);
  74.   fragmentstore = (Fragmentstore*)allocRecord("Fragmentstore",
  75.                                               sizeof(Fragmentstore),
  76.                                               cfragstoreFileSize);
  77.   pageRecord = (PageRecord*)allocRecord("PageRecord",
  78.                                   sizeof(PageRecord), 
  79.                                   cpageFileSize);
  80.   replicaRecord = (ReplicaRecord*)allocRecord("ReplicaRecord",
  81.                                               sizeof(ReplicaRecord), 
  82.                                               creplicaFileSize);
  83.   tabRecord = (TabRecord*)allocRecord("TabRecord",
  84.                                               sizeof(TabRecord), 
  85.                                               ctabFileSize);
  86.   // Initialize BAT for interface to file system
  87.   NewVARIABLE* bat = allocateBat(22);
  88.   bat[1].WA = &pageRecord->word[0];
  89.   bat[1].nrr = cpageFileSize;
  90.   bat[1].ClusterSize = sizeof(PageRecord);
  91.   bat[1].bits.q = 11;
  92.   bat[1].bits.v = 5;
  93.   bat[20].WA = &sysfileData[0];
  94.   bat[20].nrr = 1;
  95.   bat[20].ClusterSize = sizeof(sysfileData);
  96.   bat[20].bits.q = 7;
  97.   bat[20].bits.v = 5;
  98.   bat[21].WA = &sysfileDataToFile[0];
  99.   bat[21].nrr = 1;
  100.   bat[21].ClusterSize = sizeof(sysfileDataToFile);
  101.   bat[21].bits.q = 7;
  102.   bat[21].bits.v = 5;
  103. }//Dbdih::initRecords()
  104. Dbdih::Dbdih(const class Configuration & config):
  105.   SimulatedBlock(DBDIH, config),
  106.   c_waitGCPProxyList(waitGCPProxyPool),
  107.   c_waitGCPMasterList(waitGCPMasterPool)
  108. {
  109.   BLOCK_CONSTRUCTOR(Dbdih);
  110.   addRecSignal(GSN_DUMP_STATE_ORD, &Dbdih::execDUMP_STATE_ORD);
  111.   addRecSignal(GSN_NDB_TAMPER, &Dbdih::execNDB_TAMPER, true);
  112.   addRecSignal(GSN_DEBUG_SIG, &Dbdih::execDEBUG_SIG);
  113.   addRecSignal(GSN_MASTER_GCPREQ, &Dbdih::execMASTER_GCPREQ);
  114.   addRecSignal(GSN_MASTER_GCPREF, &Dbdih::execMASTER_GCPREF);
  115.   addRecSignal(GSN_MASTER_GCPCONF, &Dbdih::execMASTER_GCPCONF);
  116.   addRecSignal(GSN_EMPTY_LCP_CONF, &Dbdih::execEMPTY_LCP_CONF);
  117.   addRecSignal(GSN_MASTER_LCPREQ, &Dbdih::execMASTER_LCPREQ);
  118.   addRecSignal(GSN_MASTER_LCPREF, &Dbdih::execMASTER_LCPREF);
  119.   addRecSignal(GSN_MASTER_LCPCONF, &Dbdih::execMASTER_LCPCONF);
  120.   addRecSignal(GSN_NF_COMPLETEREP, &Dbdih::execNF_COMPLETEREP);
  121.   addRecSignal(GSN_START_PERMREQ, &Dbdih::execSTART_PERMREQ);
  122.   addRecSignal(GSN_START_PERMCONF, &Dbdih::execSTART_PERMCONF);
  123.   addRecSignal(GSN_START_PERMREF, &Dbdih::execSTART_PERMREF);
  124.   addRecSignal(GSN_INCL_NODEREQ, &Dbdih::execINCL_NODEREQ);
  125.   addRecSignal(GSN_INCL_NODECONF, &Dbdih::execINCL_NODECONF);
  126.   addRecSignal(GSN_END_TOREQ, &Dbdih::execEND_TOREQ);
  127.   addRecSignal(GSN_END_TOCONF, &Dbdih::execEND_TOCONF);
  128.   addRecSignal(GSN_START_TOREQ, &Dbdih::execSTART_TOREQ);
  129.   addRecSignal(GSN_START_TOCONF, &Dbdih::execSTART_TOCONF);
  130.   addRecSignal(GSN_START_MEREQ, &Dbdih::execSTART_MEREQ);
  131.   addRecSignal(GSN_START_MECONF, &Dbdih::execSTART_MECONF);
  132.   addRecSignal(GSN_START_MEREF, &Dbdih::execSTART_MEREF);
  133.   addRecSignal(GSN_START_COPYREQ, &Dbdih::execSTART_COPYREQ);
  134.   addRecSignal(GSN_START_COPYCONF, &Dbdih::execSTART_COPYCONF);
  135.   addRecSignal(GSN_START_COPYREF, &Dbdih::execSTART_COPYREF);
  136.   addRecSignal(GSN_CREATE_FRAGREQ, &Dbdih::execCREATE_FRAGREQ);
  137.   addRecSignal(GSN_CREATE_FRAGCONF, &Dbdih::execCREATE_FRAGCONF);
  138.   addRecSignal(GSN_DIVERIFYREQ, &Dbdih::execDIVERIFYREQ);
  139.   addRecSignal(GSN_GCP_SAVECONF, &Dbdih::execGCP_SAVECONF);
  140.   addRecSignal(GSN_GCP_PREPARECONF, &Dbdih::execGCP_PREPARECONF);
  141.   addRecSignal(GSN_GCP_PREPARE, &Dbdih::execGCP_PREPARE);
  142.   addRecSignal(GSN_GCP_NODEFINISH, &Dbdih::execGCP_NODEFINISH);
  143.   addRecSignal(GSN_GCP_COMMIT, &Dbdih::execGCP_COMMIT);
  144.   addRecSignal(GSN_DIHNDBTAMPER, &Dbdih::execDIHNDBTAMPER);
  145.   addRecSignal(GSN_CONTINUEB, &Dbdih::execCONTINUEB);
  146.   addRecSignal(GSN_COPY_GCIREQ, &Dbdih::execCOPY_GCIREQ);
  147.   addRecSignal(GSN_COPY_GCICONF, &Dbdih::execCOPY_GCICONF);
  148.   addRecSignal(GSN_COPY_TABREQ, &Dbdih::execCOPY_TABREQ);
  149.   addRecSignal(GSN_COPY_TABCONF, &Dbdih::execCOPY_TABCONF);
  150.   addRecSignal(GSN_TCGETOPSIZECONF, &Dbdih::execTCGETOPSIZECONF);
  151.   addRecSignal(GSN_TC_CLOPSIZECONF, &Dbdih::execTC_CLOPSIZECONF);
  152.   addRecSignal(GSN_LCP_COMPLETE_REP, &Dbdih::execLCP_COMPLETE_REP);
  153.   addRecSignal(GSN_LCP_FRAG_REP, &Dbdih::execLCP_FRAG_REP);
  154.   addRecSignal(GSN_START_LCP_REQ, &Dbdih::execSTART_LCP_REQ);
  155.   addRecSignal(GSN_START_LCP_CONF, &Dbdih::execSTART_LCP_CONF);
  156.   
  157.   addRecSignal(GSN_READ_CONFIG_REQ, &Dbdih::execREAD_CONFIG_REQ, true);
  158.   addRecSignal(GSN_UNBLO_DICTCONF, &Dbdih::execUNBLO_DICTCONF);
  159.   addRecSignal(GSN_COPY_ACTIVECONF, &Dbdih::execCOPY_ACTIVECONF);
  160.   addRecSignal(GSN_TAB_COMMITREQ, &Dbdih::execTAB_COMMITREQ);
  161.   addRecSignal(GSN_NODE_FAILREP, &Dbdih::execNODE_FAILREP);
  162.   addRecSignal(GSN_COPY_FRAGCONF, &Dbdih::execCOPY_FRAGCONF);
  163.   addRecSignal(GSN_COPY_FRAGREF, &Dbdih::execCOPY_FRAGREF);
  164.   addRecSignal(GSN_DIADDTABREQ, &Dbdih::execDIADDTABREQ);
  165.   addRecSignal(GSN_DIGETNODESREQ, &Dbdih::execDIGETNODESREQ);
  166.   addRecSignal(GSN_DIRELEASEREQ, &Dbdih::execDIRELEASEREQ);
  167.   addRecSignal(GSN_DISEIZEREQ, &Dbdih::execDISEIZEREQ);
  168.   addRecSignal(GSN_STTOR, &Dbdih::execSTTOR);
  169.   addRecSignal(GSN_DI_FCOUNTREQ, &Dbdih::execDI_FCOUNTREQ);
  170.   addRecSignal(GSN_DIGETPRIMREQ, &Dbdih::execDIGETPRIMREQ);
  171.   addRecSignal(GSN_GCP_SAVEREF, &Dbdih::execGCP_SAVEREF);
  172.   addRecSignal(GSN_GCP_TCFINISHED, &Dbdih::execGCP_TCFINISHED);
  173.   addRecSignal(GSN_READ_NODESCONF, &Dbdih::execREAD_NODESCONF);
  174.   addRecSignal(GSN_NDB_STTOR, &Dbdih::execNDB_STTOR);
  175.   addRecSignal(GSN_DICTSTARTCONF, &Dbdih::execDICTSTARTCONF);
  176.   addRecSignal(GSN_NDB_STARTREQ, &Dbdih::execNDB_STARTREQ);
  177.   addRecSignal(GSN_GETGCIREQ, &Dbdih::execGETGCIREQ);
  178.   addRecSignal(GSN_DIH_RESTARTREQ, &Dbdih::execDIH_RESTARTREQ);
  179.   addRecSignal(GSN_START_RECCONF, &Dbdih::execSTART_RECCONF);
  180.   addRecSignal(GSN_START_FRAGCONF, &Dbdih::execSTART_FRAGCONF);
  181.   addRecSignal(GSN_ADD_FRAGCONF, &Dbdih::execADD_FRAGCONF);
  182.   addRecSignal(GSN_ADD_FRAGREF, &Dbdih::execADD_FRAGREF);
  183.   addRecSignal(GSN_FSOPENCONF, &Dbdih::execFSOPENCONF);
  184.   addRecSignal(GSN_FSOPENREF, &Dbdih::execFSOPENREF, true);
  185.   addRecSignal(GSN_FSCLOSECONF, &Dbdih::execFSCLOSECONF);
  186.   addRecSignal(GSN_FSCLOSEREF, &Dbdih::execFSCLOSEREF, true);
  187.   addRecSignal(GSN_FSREADCONF, &Dbdih::execFSREADCONF);
  188.   addRecSignal(GSN_FSREADREF, &Dbdih::execFSREADREF, true);
  189.   addRecSignal(GSN_FSWRITECONF, &Dbdih::execFSWRITECONF);
  190.   addRecSignal(GSN_FSWRITEREF, &Dbdih::execFSWRITEREF, true);
  191.   addRecSignal(GSN_SET_VAR_REQ, &Dbdih::execSET_VAR_REQ);
  192.   addRecSignal(GSN_START_INFOREQ, 
  193.                &Dbdih::execSTART_INFOREQ);
  194.   addRecSignal(GSN_START_INFOREF, 
  195.                &Dbdih::execSTART_INFOREF);
  196.   addRecSignal(GSN_START_INFOCONF, 
  197.                &Dbdih::execSTART_INFOCONF);
  198.   addRecSignal(GSN_CHECKNODEGROUPSREQ, &Dbdih::execCHECKNODEGROUPSREQ);
  199.   addRecSignal(GSN_BLOCK_COMMIT_ORD,
  200.        &Dbdih::execBLOCK_COMMIT_ORD);
  201.   addRecSignal(GSN_UNBLOCK_COMMIT_ORD,
  202.        &Dbdih::execUNBLOCK_COMMIT_ORD);
  203.   
  204.   addRecSignal(GSN_DIH_SWITCH_REPLICA_REQ,
  205.        &Dbdih::execDIH_SWITCH_REPLICA_REQ);
  206.   
  207.   addRecSignal(GSN_DIH_SWITCH_REPLICA_REF,
  208.        &Dbdih::execDIH_SWITCH_REPLICA_REF);
  209.   
  210.   addRecSignal(GSN_DIH_SWITCH_REPLICA_CONF,
  211.        &Dbdih::execDIH_SWITCH_REPLICA_CONF);
  212.   addRecSignal(GSN_STOP_PERM_REQ, &Dbdih::execSTOP_PERM_REQ);
  213.   addRecSignal(GSN_STOP_PERM_REF, &Dbdih::execSTOP_PERM_REF);
  214.   addRecSignal(GSN_STOP_PERM_CONF, &Dbdih::execSTOP_PERM_CONF);
  215.   addRecSignal(GSN_STOP_ME_REQ, &Dbdih::execSTOP_ME_REQ);
  216.   addRecSignal(GSN_STOP_ME_REF, &Dbdih::execSTOP_ME_REF);
  217.   addRecSignal(GSN_STOP_ME_CONF, &Dbdih::execSTOP_ME_CONF);
  218.   addRecSignal(GSN_WAIT_GCP_REQ, &Dbdih::execWAIT_GCP_REQ);
  219.   addRecSignal(GSN_WAIT_GCP_REF, &Dbdih::execWAIT_GCP_REF);
  220.   addRecSignal(GSN_WAIT_GCP_CONF, &Dbdih::execWAIT_GCP_CONF);
  221.   addRecSignal(GSN_UPDATE_TOREQ, &Dbdih::execUPDATE_TOREQ);
  222.   addRecSignal(GSN_UPDATE_TOCONF, &Dbdih::execUPDATE_TOCONF);
  223.   addRecSignal(GSN_PREP_DROP_TAB_REQ, &Dbdih::execPREP_DROP_TAB_REQ);
  224.   addRecSignal(GSN_WAIT_DROP_TAB_REF, &Dbdih::execWAIT_DROP_TAB_REF);
  225.   addRecSignal(GSN_WAIT_DROP_TAB_CONF, &Dbdih::execWAIT_DROP_TAB_CONF);
  226.   addRecSignal(GSN_DROP_TAB_REQ, &Dbdih::execDROP_TAB_REQ);
  227.   addRecSignal(GSN_ALTER_TAB_REQ, &Dbdih::execALTER_TAB_REQ);
  228.   addRecSignal(GSN_CREATE_FRAGMENTATION_REQ, 
  229.        &Dbdih::execCREATE_FRAGMENTATION_REQ);
  230.   
  231.   initData();
  232. }//Dbdih::Dbdih()
  233. Dbdih::~Dbdih() 
  234. {
  235.   deallocRecord((void **)&apiConnectRecord, "ApiConnectRecord", 
  236.                 sizeof(ApiConnectRecord),
  237.                 capiConnectFileSize);
  238.   
  239.   deallocRecord((void **)&connectRecord, "ConnectRecord",
  240.                 sizeof(ConnectRecord), 
  241.                 cconnectFileSize);
  242.   
  243.   deallocRecord((void **)&fileRecord, "FileRecord",
  244.                 sizeof(FileRecord),
  245.                 cfileFileSize);
  246.   
  247.   deallocRecord((void **)&fragmentstore, "Fragmentstore",
  248.                 sizeof(Fragmentstore),
  249.                 cfragstoreFileSize);
  250.   deallocRecord((void **)&pageRecord, "PageRecord",
  251.                 sizeof(PageRecord), 
  252.                 cpageFileSize);
  253.   
  254.   deallocRecord((void **)&replicaRecord, "ReplicaRecord",
  255.                 sizeof(ReplicaRecord), 
  256.                 creplicaFileSize);
  257.   
  258.   deallocRecord((void **)&tabRecord, "TabRecord",
  259.                 sizeof(TabRecord), 
  260.                 ctabFileSize);
  261.   // Records with constant sizes
  262.   deallocRecord((void **)&createReplicaRecord, 
  263.                 "CreateReplicaRecord", sizeof(CreateReplicaRecord),
  264.                 ZCREATE_REPLICA_FILE_SIZE);
  265.   
  266.   deallocRecord((void **)&nodeGroupRecord, "NodeGroupRecord", 
  267.                 sizeof(NodeGroupRecord), MAX_NDB_NODES);
  268.   
  269.   deallocRecord((void **)&nodeRecord, "NodeRecord", 
  270.                 sizeof(NodeRecord), MAX_NDB_NODES);
  271.   deallocRecord((void **)&takeOverRecord, "TakeOverRecord",
  272.                 sizeof(TakeOverRecord), 
  273.                 MAX_NDB_NODES);
  274. }//Dbdih::~Dbdih()
  275. BLOCK_FUNCTIONS(Dbdih)