1 /*
2 Copyright (c) 2003, 2021, Oracle and/or its affiliates.
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, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #ifndef STOP_REQ_HPP
26 #define STOP_REQ_HPP
27
28 #include "SignalData.hpp"
29
30 #define JAM_FILE_ID 188
31
32
33 class StopReq
34 {
35 /**
36 * Reciver(s)
37 */
38 friend class Ndbcntr;
39
40 /**
41 * Sender
42 */
43 friend class MgmtSrvr;
44
45 public:
46 STATIC_CONST( SignalLength = 9 + NdbNodeBitmask::Size);
47
48 public:
49 Uint32 senderRef;
50 Uint32 senderData;
51
52 Uint32 requestInfo;
53 Uint32 singleuser; // Indicates whether or not to enter
54 // single user mode.
55 // Only in conjunction with system stop
56 Uint32 singleUserApi; // allowed api in singleuser
57
58 Int32 apiTimeout; // Timeout before api transactions are refused
59 Int32 transactionTimeout; // Timeout before transactions are aborted
60 Int32 readOperationTimeout; // Timeout before read operations are aborted
61 Int32 operationTimeout; // Timeout before all operations are aborted
62
63 Uint32 nodes[NdbNodeBitmask::Size];
64
65 static void setSystemStop(Uint32 & requestInfo, bool value);
66 static void setPerformRestart(Uint32 & requestInfo, bool value);
67 static void setNoStart(Uint32 & requestInfo, bool value);
68 static void setInitialStart(Uint32 & requestInfo, bool value);
69 /**
70 * Don't perform "graceful" shutdown/restart...
71 */
72 static void setStopAbort(Uint32 & requestInfo, bool value);
73 static void setStopNodes(Uint32 & requestInfo, bool value);
74
75 static bool getSystemStop(const Uint32 & requestInfo);
76 static bool getPerformRestart(const Uint32 & requestInfo);
77 static bool getNoStart(const Uint32 & requestInfo);
78 static bool getInitialStart(const Uint32 & requestInfo);
79 static bool getStopAbort(const Uint32 & requestInfo);
80 static bool getStopNodes(const Uint32 & requestInfo);
81 };
82
83 struct StopConf
84 {
85 STATIC_CONST( SignalLength = 2 );
86 Uint32 senderData;
87 union {
88 Uint32 nodeState;
89 Uint32 nodeId;
90 };
91 };
92
93 class StopRef
94 {
95 /**
96 * Reciver(s)
97 */
98 friend class MgmtSrvr;
99
100 /**
101 * Sender
102 */
103 friend class Ndbcntr;
104
105 public:
106 STATIC_CONST( SignalLength = 3 );
107
108 enum ErrorCode {
109 OK = 0,
110 NodeShutdownInProgress = 1,
111 SystemShutdownInProgress = 2,
112 NodeShutdownWouldCauseSystemCrash = 3,
113 TransactionAbortFailed = 4,
114 UnsupportedNodeShutdown = 5,
115 MultiNodeShutdownNotMaster = 6
116 };
117
118 public:
119 Uint32 senderData;
120 Uint32 errorCode;
121 Uint32 masterNodeId;
122 };
123
124 inline
125 bool
getSystemStop(const Uint32 & requestInfo)126 StopReq::getSystemStop(const Uint32 & requestInfo)
127 {
128 return requestInfo & 1;
129 }
130
131 inline
132 bool
getPerformRestart(const Uint32 & requestInfo)133 StopReq::getPerformRestart(const Uint32 & requestInfo)
134 {
135 return requestInfo & 2;
136 }
137
138 inline
139 bool
getNoStart(const Uint32 & requestInfo)140 StopReq::getNoStart(const Uint32 & requestInfo)
141 {
142 return requestInfo & 4;
143 }
144
145 inline
146 bool
getInitialStart(const Uint32 & requestInfo)147 StopReq::getInitialStart(const Uint32 & requestInfo)
148 {
149 return requestInfo & 8;
150 }
151
152 inline
153 bool
getStopAbort(const Uint32 & requestInfo)154 StopReq::getStopAbort(const Uint32 & requestInfo)
155 {
156 return requestInfo & 32;
157 }
158
159 inline
160 bool
getStopNodes(const Uint32 & requestInfo)161 StopReq::getStopNodes(const Uint32 & requestInfo)
162 {
163 return requestInfo & 64;
164 }
165
166
167 inline
168 void
setSystemStop(Uint32 & requestInfo,bool value)169 StopReq::setSystemStop(Uint32 & requestInfo, bool value)
170 {
171 if(value)
172 requestInfo |= 1;
173 else
174 requestInfo &= ~1;
175 }
176
177 inline
178 void
setPerformRestart(Uint32 & requestInfo,bool value)179 StopReq::setPerformRestart(Uint32 & requestInfo, bool value)
180 {
181 if(value)
182 requestInfo |= 2;
183 else
184 requestInfo &= ~2;
185 }
186
187 inline
188 void
setNoStart(Uint32 & requestInfo,bool value)189 StopReq::setNoStart(Uint32 & requestInfo, bool value)
190 {
191 if(value)
192 requestInfo |= 4;
193 else
194 requestInfo &= ~4;
195 }
196
197 inline
198 void
setInitialStart(Uint32 & requestInfo,bool value)199 StopReq::setInitialStart(Uint32 & requestInfo, bool value)
200 {
201 if(value)
202 requestInfo |= 8;
203 else
204 requestInfo &= ~8;
205 }
206
207 inline
208 void
setStopAbort(Uint32 & requestInfo,bool value)209 StopReq::setStopAbort(Uint32 & requestInfo, bool value)
210 {
211 if(value)
212 requestInfo |= 32;
213 else
214 requestInfo &= ~32;
215 }
216
217 inline
218 void
setStopNodes(Uint32 & requestInfo,bool value)219 StopReq::setStopNodes(Uint32 & requestInfo, bool value)
220 {
221 if(value)
222 requestInfo |= 64;
223 else
224 requestInfo &= ~64;
225 }
226
227
228 #undef JAM_FILE_ID
229
230 #endif
231
232