1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef NODE_STATE_HPP
17
#define NODE_STATE_HPP
20
#include <NodeBitmask.hpp>
34
* Listening to management server
35
* Qmgr knows nothing...
41
* All blocks are starting
43
* During this phase is <b>startPhase</b> valid
48
* The database is started open for connections
55
* SL_STOPPING_1 - Inform API
56
* API is informed not to start transactions on node
57
* The database is about to close
59
* New TcSeize(s) are refused (TcSeizeRef)
64
* SL_STOPPING_2 - Close TC
65
* New transactions(TC) are refused
73
* SL_STOPPING_3 - Wait for reads in LQH
74
* No transactions are running in TC
75
* New scans(s) and read(s) are refused in LQH
76
* NS: The node is not Primary for any fragment
77
* NS: No node is allow to start
82
* SL_STOPPING_4 - Close LQH
83
* Node is out of DIGETNODES
84
* Insert/Update/Delete can still be running in LQH
86
* Node is not startable w.o Node Recovery
93
ST_SYSTEM_RESTART = 1,
95
ST_INITIAL_NODE_RESTART = 3,
100
* Length in 32-bit words
102
STATIC_CONST( DataLength = 8 + NdbNodeBitmask::Size );
108
NodeState(StartLevel);
109
NodeState(StartLevel, bool systemShutdown);
110
NodeState(StartLevel, Uint32 startPhase, StartType);
114
* Current start level
121
Uint32 nodeGroup; // valid when startLevel == SL_STARTING
127
Uint32 dynamicId; // valid when startLevel == SL_STARTING to API
128
Uint32 masterNodeId; // When from cntr
136
Uint32 startPhase; // valid when startLevel == SL_STARTING
137
Uint32 restartType; // valid when startLevel == SL_STARTING
140
Uint32 systemShutdown; // valid when startLevel == SL_STOPPING_{X}
147
Uint32 singleUserMode;
148
Uint32 singleUserApi; //the single user node
150
BitmaskPOD<NdbNodeBitmask::Size> m_connected_nodes;
152
void setDynamicId(Uint32 dynamic);
153
void setNodeGroup(Uint32 group);
154
void setSingleUser(Uint32 s);
155
void setSingleUserApi(Uint32 n);
159
* Is a node restart in progress (ordinary or initial)
161
bool getNodeRestartInProgress() const;
164
* Is a system restart ongoing
166
bool getSystemRestartInProgress() const;
169
* Is in single user mode?
171
bool getSingleUserMode() const;
174
* Is in single user mode
176
Uint32 getSingleUserApi() const;
178
friend NdbOut & operator<<(NdbOut&, const NodeState&);
182
NodeState::NodeState(){
189
startLevel = SL_CMVMI;
190
nodeGroup = 0xFFFFFFFF;
191
dynamicId = 0xFFFFFFFF;
193
singleUserApi = 0xFFFFFFFF;
194
m_connected_nodes.clear();
198
NodeState::NodeState(StartLevel sl){
202
singleUserApi = 0xFFFFFFFF;
206
NodeState::NodeState(StartLevel sl, Uint32 sp, StartType typeOfStart){
209
starting.startPhase = sp;
210
starting.restartType = typeOfStart;
212
singleUserApi = 0xFFFFFFFF;
216
NodeState::NodeState(StartLevel sl, bool sys){
219
stopping.systemShutdown = sys;
221
singleUserApi = 0xFFFFFFFF;
225
void NodeState::setDynamicId(Uint32 dynamic){
230
void NodeState::setNodeGroup(Uint32 group){
235
void NodeState::setSingleUser(Uint32 s) {
240
void NodeState::setSingleUserApi(Uint32 n) {
244
bool NodeState::getNodeRestartInProgress() const {
245
return startLevel == SL_STARTING &&
246
(starting.restartType == ST_NODE_RESTART ||
247
starting.restartType == ST_INITIAL_NODE_RESTART);
251
bool NodeState::getSingleUserMode() const {
252
return singleUserMode;
256
Uint32 NodeState::getSingleUserApi() const {
257
return singleUserApi;
261
bool NodeState::getSystemRestartInProgress() const {
262
return startLevel == SL_STARTING && starting.restartType == ST_SYSTEM_RESTART;
267
operator<<(NdbOut& ndbout, const NodeState & state){
268
ndbout << "[NodeState: startLevel: ";
269
switch(state.startLevel){
270
case NodeState::SL_NOTHING:
271
ndbout << "<NOTHING> ]";
273
case NodeState::SL_CMVMI:
274
ndbout << "<CMVMI> ]";
276
case NodeState::SL_STARTING:
277
ndbout << "<STARTING type: ";
278
switch(state.starting.restartType){
279
case NodeState::ST_INITIAL_START:
280
ndbout << " INITIAL START";
282
case NodeState::ST_SYSTEM_RESTART:
283
ndbout << " SYSTEM RESTART ";
285
case NodeState::ST_NODE_RESTART:
286
ndbout << " NODE RESTART ";
288
case NodeState::ST_INITIAL_NODE_RESTART:
289
ndbout << " INITIAL NODE RESTART ";
291
case NodeState::ST_ILLEGAL_TYPE:
293
ndbout << " UNKNOWN " << state.starting.restartType;
295
ndbout << " phase: " << state.starting.startPhase << "> ]";
297
case NodeState::SL_STARTED:
298
ndbout << "<STARTED> ]";
300
case NodeState::SL_STOPPING_1:
301
ndbout << "<STOPPING 1 sys: " << state.stopping.systemShutdown << "> ]";
303
case NodeState::SL_STOPPING_2:
304
ndbout << "<STOPPING 2 sys: " << state.stopping.systemShutdown << "> ]";
306
case NodeState::SL_STOPPING_3:
307
ndbout << "<STOPPING 3 sys: " << state.stopping.systemShutdown << "> ]";
309
case NodeState::SL_STOPPING_4:
310
ndbout << "<STOPPING 4 sys: " << state.stopping.systemShutdown << "> ]";
313
ndbout << "<UNKNOWN " << state.startLevel << "> ]";