MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GlobalData.hpp
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 #ifndef GLOBAL_DATA_H
19 #define GLOBAL_DATA_H
20 
21 #include <ndb_global.h>
22 #include <kernel_types.h>
23 #include "Prio.hpp"
24 #include "VMSignal.hpp"
25 
26 #include <BlockNumbers.h>
27 #include <NodeState.hpp>
28 #include <NodeInfo.hpp>
29 #include "ArrayPool.hpp"
30 
31 // #define GCP_TIMER_HACK
32 #ifdef GCP_TIMER_HACK
33 #include <NdbTick.h>
34 #endif
35 
36 class SimulatedBlock;
37 
38 enum restartStates {initial_state,
39  perform_start,
40  system_started,
41  perform_stop};
42 
43 struct GlobalData {
44  Uint32 m_restart_seq; //
45  NodeVersionInfo m_versionInfo;
46  NodeInfo m_nodeInfo[MAX_NODES];
47  Signal VMSignals[1]; // Owned by FastScheduler::
48 
49  Uint64 internalMillisecCounter; // Owned by ThreadConfig::
50  Uint32 highestAvailablePrio; // Owned by FastScheduler::
51  Uint32 JobCounter; // Owned by FastScheduler
52  Uint64 JobLap; // Owned by FastScheduler
53  Uint32 loopMax; // Owned by FastScheduler
54 
55  Uint32 theNextTimerJob; // Owned by TimeQueue::
56  Uint32 theCurrentTimer; // Owned by TimeQueue::
57  Uint32 theShortTQIndex; // Owned by TimeQueue::
58 
59  Uint32 theLongTQIndex; // Owned by TimeQueue::
60  Uint32 theCountTimer; // Owned by TimeQueue::
61  Uint32 theFirstFreeTQIndex; // Owned by TimeQueue::
62  Uint32 testOn; // Owned by the Signal Loggers
63 
64  NodeId ownId; // Own processor id
65 
66  Uint32 theStartLevel;
67  restartStates theRestartFlag;
68  Uint32 theSignalId;
69 
70  Uint32 sendPackedActivated;
71  Uint32 activateSendPacked;
72 
73  bool isNdbMt; // ndbd multithreaded, no workers
74  bool isNdbMtLqh; // ndbd multithreaded, LQH workers
75  Uint32 ndbMtLqhWorkers;
76  Uint32 ndbMtLqhThreads;
77 
78  GlobalData(){
79  theSignalId = 0;
80  theStartLevel = NodeState::SL_NOTHING;
81  theRestartFlag = perform_start;
82  isNdbMt = false;
83  isNdbMtLqh = false;
84  ndbMtLqhWorkers = 0;
85  ndbMtLqhThreads = 0;
86 #ifdef GCP_TIMER_HACK
87  gcp_timer_limit = 0;
88 #endif
89  }
90  ~GlobalData() { m_global_page_pool.clear(); m_shared_page_pool.clear();}
91 
92  void setBlock(BlockNumber blockNo, SimulatedBlock * block);
93  SimulatedBlock * getBlock(BlockNumber blockNo);
94  SimulatedBlock * getBlock(BlockNumber blockNo, Uint32 instanceNo);
95  SimulatedBlock * getBlockInstance(BlockNumber fullBlockNo) {
96  return getBlock(blockToMain(fullBlockNo), blockToInstance(fullBlockNo));
97  }
98  SimulatedBlock * mt_getBlock(BlockNumber blockNo, Uint32 instanceNo);
99 
100  void incrementWatchDogCounter(Uint32 place);
101  Uint32 * getWatchDogPtr();
102 
103 private:
104  Uint32 watchDog;
105  SimulatedBlock* blockTable[NO_OF_BLOCKS]; // Owned by Dispatcher::
106 public:
107  SafeArrayPool<GlobalPage> m_global_page_pool;
108  ArrayPool<GlobalPage> m_shared_page_pool;
109 
110 #ifdef GCP_TIMER_HACK
111  // timings are local to the node
112 
113  // from prepare to commit (DIH, TC)
114  MicroSecondTimer gcp_timer_commit[2];
115  // from GCP_SAVEREQ to GCP_SAVECONF (LQH)
116  MicroSecondTimer gcp_timer_save[2];
117  // sysfile update (DIH)
118  MicroSecondTimer gcp_timer_copygci[2];
119 
120  // report threshold in ms, if 0 guessed, set with dump 7901 <limit>
121  Uint32 gcp_timer_limit;
122 #endif
123 };
124 
125 extern GlobalData globalData;
126 
127 #define GLOBAL_TEST_ON (localTestOn)
128 #define GET_GLOBAL_TEST_FLAG bool localTestOn = globalData.testOn
129 #define SET_GLOBAL_TEST_ON (globalData.testOn = true)
130 #define SET_GLOBAL_TEST_OFF (globalData.testOn = false)
131 #define TOGGLE_GLOBAL_TEST_FLAG (globalData.testOn = (globalData.testOn == true ? false : true))
132 
133 inline
134 void
135 GlobalData::setBlock(BlockNumber blockNo, SimulatedBlock * block){
136  blockNo -= MIN_BLOCK_NO;
137  assert((blockTable[blockNo] == 0) || (blockTable[blockNo] == block));
138  blockTable[blockNo] = block;
139 }
140 
141 inline
143 GlobalData::getBlock(BlockNumber blockNo){
144  blockNo -= MIN_BLOCK_NO;
145  return blockTable[blockNo];
146 }
147 
148 inline
149 void
150 GlobalData::incrementWatchDogCounter(Uint32 place){
151  watchDog = place;
152 }
153 
154 inline
155 Uint32 *
156 GlobalData::getWatchDogPtr(){
157  return &watchDog;
158 }
159 
160 #endif