summaryrefslogtreecommitdiff
path: root/storage/ndb/include/kernel/signaldata/StopReq.hpp
blob: 88d235804659ca8d15b3603a022b295f32a0aca9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/* Copyright (c) 2003, 2005, 2006 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */

#ifndef STOP_REQ_HPP
#define STOP_REQ_HPP

#include "SignalData.hpp"

class StopReq 
{
  /**
   * Reciver(s)
   */
  friend class Ndbcntr;

  /**
   * Sender
   */
  friend class MgmtSrvr;

public:
  STATIC_CONST( SignalLength = 9 + NdbNodeBitmask::Size);
  
public:
  Uint32 senderRef;
  Uint32 senderData;
  
  Uint32 requestInfo;
  Uint32 singleuser;          // Indicates whether or not to enter 
                              // single user mode.
                              // Only in conjunction with system stop
  Uint32 singleUserApi;       // allowed api in singleuser

  Int32 apiTimeout;           // Timeout before api transactions are refused
  Int32 transactionTimeout;   // Timeout before transactions are aborted
  Int32 readOperationTimeout; // Timeout before read operations are aborted
  Int32 operationTimeout;     // Timeout before all operations are aborted

  Uint32 nodes[NdbNodeBitmask::Size];

  static void setSystemStop(Uint32 & requestInfo, bool value);
  static void setPerformRestart(Uint32 & requestInfo, bool value);
  static void setNoStart(Uint32 & requestInfo, bool value);
  static void setInitialStart(Uint32 & requestInfo, bool value);
  /**
   * Don't perform "graceful" shutdown/restart...
   */
  static void setStopAbort(Uint32 & requestInfo, bool value);
  static void setStopNodes(Uint32 & requestInfo, bool value);

  static bool getSystemStop(const Uint32 & requestInfo);
  static bool getPerformRestart(const Uint32 & requestInfo);
  static bool getNoStart(const Uint32 & requestInfo);
  static bool getInitialStart(const Uint32 & requestInfo);
  static bool getStopAbort(const Uint32 & requestInfo);
  static bool getStopNodes(const Uint32 & requestInfo);
};

struct StopConf
{
  STATIC_CONST( SignalLength = 2 );
  Uint32 senderData;
  union {
    Uint32 nodeState;
    Uint32 nodeId;
  };
};

class StopRef 
{
  /**
   * Reciver(s)
   */
  friend class MgmtSrvr;
  
  /**
   * Sender
   */
  friend class Ndbcntr;

public:
  STATIC_CONST( SignalLength = 3 );
  
  enum ErrorCode {
    OK = 0,
    NodeShutdownInProgress = 1,
    SystemShutdownInProgress = 2,
    NodeShutdownWouldCauseSystemCrash = 3,
    TransactionAbortFailed = 4,
    UnsupportedNodeShutdown = 5,
    MultiNodeShutdownNotMaster = 6
  };
  
public:
  Uint32 senderData;
  Uint32 errorCode;
  Uint32 masterNodeId;
};

inline
bool
StopReq::getSystemStop(const Uint32 & requestInfo)
{
  return requestInfo & 1;
}

inline
bool
StopReq::getPerformRestart(const Uint32 & requestInfo)
{
  return requestInfo & 2;
}

inline
bool
StopReq::getNoStart(const Uint32 & requestInfo)
{
  return requestInfo & 4;
}

inline
bool
StopReq::getInitialStart(const Uint32 & requestInfo)
{
  return requestInfo & 8;
}

inline
bool
StopReq::getStopAbort(const Uint32 & requestInfo)
{
  return requestInfo & 32;
}

inline
bool
StopReq::getStopNodes(const Uint32 & requestInfo)
{
  return requestInfo & 64;
}


inline
void
StopReq::setSystemStop(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 1;
  else
    requestInfo &= ~1;
}

inline
void 
StopReq::setPerformRestart(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 2;
  else
    requestInfo &= ~2;
}

inline
void 
StopReq::setNoStart(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 4;
  else
    requestInfo &= ~4;
}

inline
void
StopReq::setInitialStart(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 8;
  else
    requestInfo &= ~8;
}

inline
void
StopReq::setStopAbort(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 32;
  else
    requestInfo &= ~32;
}

inline
void
StopReq::setStopNodes(Uint32 & requestInfo, bool value)
{
  if(value)
    requestInfo |= 64;
  else
    requestInfo &= ~64;
}

#endif