MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QmgrInit.cpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 
19 
20 #define QMGR_C
21 #include "Qmgr.hpp"
22 
23 #define DEBUG(x) { ndbout << "Qmgr::" << x << endl; }
24 
25 
26 void Qmgr::initData()
27 {
28  creadyDistCom = ZFALSE;
29 
30  // Records with constant sizes
31  nodeRec = new NodeRec[MAX_NODES];
32  for (Uint32 i = 0; i<MAX_NODES; i++)
33  {
34  nodeRec[i].m_secret = 0;
35  }
36 
37  cnoCommitFailedNodes = 0;
38  c_maxDynamicId = 0;
39  c_clusterNodes.clear();
40  c_stopReq.senderRef = 0;
41 
45  ndbrequire((Uint32)NodeInfo::DB == 0);
46  ndbrequire((Uint32)NodeInfo::API == 1);
47  ndbrequire((Uint32)NodeInfo::MGM == 2);
48 
49  m_micro_gcp_enabled = false;
50  m_hb_order_config_used = false;
51 
52  NodeRecPtr nodePtr;
53  nodePtr.i = getOwnNodeId();
54  ptrAss(nodePtr, nodeRec);
55  nodePtr.p->blockRef = reference();
56 
57  c_connectedNodes.set(getOwnNodeId());
58  setNodeInfo(getOwnNodeId()).m_version = NDB_VERSION;
59 
60 
65  m_ctx.m_config.getOwnConfigIterator();
66  ndbrequire(p != 0);
67 
68  Uint32 hbDBAPI = 1500;
69  ndb_mgm_get_int_parameter(p, CFG_DB_API_HEARTBEAT_INTERVAL, &hbDBAPI);
70 
71  setHbApiDelay(hbDBAPI);
72 
73 #ifdef ERROR_INSERT
74  nodeFailCount = 0;
75 #endif
76 
77  cfailureNr = 1;
78  ccommitFailureNr = 1;
79  cprepareFailureNr = 1;
80  cnoFailedNodes = 0;
81  cnoPrepFailedNodes = 0;
82  creadyDistCom = ZFALSE;
83  cpresident = ZNIL;
84  c_start.m_president_candidate = ZNIL;
85  c_start.m_president_candidate_gci = 0;
86  cpdistref = 0;
87  cneighbourh = ZNIL;
88  cneighbourl = ZNIL;
89  cdelayRegreq = ZDELAY_REGREQ;
90  cactivateApiCheck = 0;
91  c_allow_api_connect = 0;
92  ctoStatus = Q_NOT_ACTIVE;
93  clatestTransactionCheck = 0;
94 }//Qmgr::initData()
95 
96 void Qmgr::initRecords()
97 {
98  // Records with dynamic sizes
99 }//Qmgr::initRecords()
100 
101 Qmgr::Qmgr(Block_context& ctx)
102  : SimulatedBlock(QMGR, ctx)
103 {
104  BLOCK_CONSTRUCTOR(Qmgr);
105 
106  // Transit signals
107  addRecSignal(GSN_DUMP_STATE_ORD, &Qmgr::execDUMP_STATE_ORD);
108  addRecSignal(GSN_STOP_REQ, &Qmgr::execSTOP_REQ);
109  addRecSignal(GSN_DEBUG_SIG, &Qmgr::execDEBUG_SIG);
110  addRecSignal(GSN_CONTINUEB, &Qmgr::execCONTINUEB);
111  addRecSignal(GSN_CM_HEARTBEAT, &Qmgr::execCM_HEARTBEAT);
112  addRecSignal(GSN_CM_ADD, &Qmgr::execCM_ADD);
113  addRecSignal(GSN_CM_ACKADD, &Qmgr::execCM_ACKADD);
114  addRecSignal(GSN_CM_REGREQ, &Qmgr::execCM_REGREQ);
115  addRecSignal(GSN_CM_REGCONF, &Qmgr::execCM_REGCONF);
116  addRecSignal(GSN_CM_REGREF, &Qmgr::execCM_REGREF);
117  addRecSignal(GSN_CM_NODEINFOREQ, &Qmgr::execCM_NODEINFOREQ);
118  addRecSignal(GSN_CM_NODEINFOCONF, &Qmgr::execCM_NODEINFOCONF);
119  addRecSignal(GSN_CM_NODEINFOREF, &Qmgr::execCM_NODEINFOREF);
120  addRecSignal(GSN_PREP_FAILREQ, &Qmgr::execPREP_FAILREQ);
121  addRecSignal(GSN_PREP_FAILCONF, &Qmgr::execPREP_FAILCONF);
122  addRecSignal(GSN_PREP_FAILREF, &Qmgr::execPREP_FAILREF);
123  addRecSignal(GSN_COMMIT_FAILREQ, &Qmgr::execCOMMIT_FAILREQ);
124  addRecSignal(GSN_COMMIT_FAILCONF, &Qmgr::execCOMMIT_FAILCONF);
125  addRecSignal(GSN_FAIL_REP, &Qmgr::execFAIL_REP);
126  addRecSignal(GSN_PRES_TOREQ, &Qmgr::execPRES_TOREQ);
127  addRecSignal(GSN_PRES_TOCONF, &Qmgr::execPRES_TOCONF);
128 
129  // Received signals
130  addRecSignal(GSN_CONNECT_REP, &Qmgr::execCONNECT_REP);
131  addRecSignal(GSN_NDB_FAILCONF, &Qmgr::execNDB_FAILCONF);
132  addRecSignal(GSN_NF_COMPLETEREP, &Qmgr::execNF_COMPLETEREP);
133  addRecSignal(GSN_READ_CONFIG_REQ, &Qmgr::execREAD_CONFIG_REQ);
134  addRecSignal(GSN_STTOR, &Qmgr::execSTTOR);
135  addRecSignal(GSN_CLOSE_COMCONF, &Qmgr::execCLOSE_COMCONF);
136  addRecSignal(GSN_API_REGREQ, &Qmgr::execAPI_REGREQ);
137  addRecSignal(GSN_API_VERSION_REQ, &Qmgr::execAPI_VERSION_REQ);
138  addRecSignal(GSN_DISCONNECT_REP, &Qmgr::execDISCONNECT_REP);
139  addRecSignal(GSN_API_FAILREQ, &Qmgr::execAPI_FAILREQ);
140  addRecSignal(GSN_API_FAILCONF, &Qmgr::execAPI_FAILCONF);
141  addRecSignal(GSN_READ_NODESREQ, &Qmgr::execREAD_NODESREQ);
142  addRecSignal(GSN_API_BROADCAST_REP, &Qmgr::execAPI_BROADCAST_REP);
143 
144  addRecSignal(GSN_NODE_FAILREP, &Qmgr::execNODE_FAILREP);
145  addRecSignal(GSN_ALLOC_NODEID_REQ, &Qmgr::execALLOC_NODEID_REQ);
146  addRecSignal(GSN_ALLOC_NODEID_CONF, &Qmgr::execALLOC_NODEID_CONF);
147  addRecSignal(GSN_ALLOC_NODEID_REF, &Qmgr::execALLOC_NODEID_REF);
148  addRecSignal(GSN_ENABLE_COMCONF, &Qmgr::execENABLE_COMCONF);
149 
150  // Arbitration signals
151  addRecSignal(GSN_ARBIT_PREPREQ, &Qmgr::execARBIT_PREPREQ);
152  addRecSignal(GSN_ARBIT_PREPCONF, &Qmgr::execARBIT_PREPCONF);
153  addRecSignal(GSN_ARBIT_PREPREF, &Qmgr::execARBIT_PREPREF);
154  addRecSignal(GSN_ARBIT_STARTCONF, &Qmgr::execARBIT_STARTCONF);
155  addRecSignal(GSN_ARBIT_STARTREF, &Qmgr::execARBIT_STARTREF);
156  addRecSignal(GSN_ARBIT_CHOOSECONF, &Qmgr::execARBIT_CHOOSECONF);
157  addRecSignal(GSN_ARBIT_CHOOSEREF, &Qmgr::execARBIT_CHOOSEREF);
158  addRecSignal(GSN_ARBIT_STOPREP, &Qmgr::execARBIT_STOPREP);
159 
160  addRecSignal(GSN_READ_NODESREF, &Qmgr::execREAD_NODESREF);
161  addRecSignal(GSN_READ_NODESCONF, &Qmgr::execREAD_NODESCONF);
162 
163  addRecSignal(GSN_DIH_RESTARTREF, &Qmgr::execDIH_RESTARTREF);
164  addRecSignal(GSN_DIH_RESTARTCONF, &Qmgr::execDIH_RESTARTCONF);
165  addRecSignal(GSN_NODE_VERSION_REP, &Qmgr::execNODE_VERSION_REP);
166  addRecSignal(GSN_START_ORD, &Qmgr::execSTART_ORD);
167 
168  addRecSignal(GSN_UPGRADE_PROTOCOL_ORD, &Qmgr::execUPGRADE_PROTOCOL_ORD);
169 
170  // Connectivity check signals
171  addRecSignal(GSN_NODE_PING_REQ, &Qmgr::execNODE_PINGREQ);
172  addRecSignal(GSN_NODE_PING_CONF, &Qmgr::execNODE_PINGCONF);
173 
174  initData();
175 }//Qmgr::Qmgr()
176 
177 Qmgr::~Qmgr()
178 {
179  delete []nodeRec;
180 }//Qmgr::~Qmgr()
181 
182 
183 BLOCK_FUNCTIONS(Qmgr)