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