1 /*
2    Copyright (c) 2003, 2013, 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, 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 CM_REG_HPP
26 #define CM_REG_HPP
27 
28 #include <NodeBitmask.hpp>
29 
30 #define JAM_FILE_ID 65
31 
32 
33 /**
34  * This is the first distributed signal
35  *   (the node tries to register in the cluster)
36  */
37 class CmRegReq {
38   /**
39    * Sender(s) & Reciver(s)
40    */
41   friend class Qmgr;
42 
43 public:
44   STATIC_CONST( SignalLength = 6 + NdbNodeBitmask::Size );
45 private:
46 
47   Uint32 blockRef;
48   Uint32 nodeId;
49   Uint32 version;    // See ndb_version.h
50   Uint32 mysql_version;
51 
52   Uint32 start_type; // As specified by cmd-line or mgm, NodeState::StartType
53   Uint32 latest_gci; // 0 means no fs
54   Uint32 skip_nodes[NdbNodeBitmask::Size]; // Nodes that does not _need_
55                                            // to be part of restart
56 };
57 
58 /**
59  * The node receving this signal has been accepted into the cluster
60  */
61 class CmRegConf {
62   /**
63    * Sender(s) & Reciver(s)
64    */
65   friend class Qmgr;
66 
67 public:
68   STATIC_CONST( SignalLength = 5 + NdbNodeBitmask::Size );
69 private:
70 
71   Uint32 presidentBlockRef;
72   Uint32 presidentNodeId;
73   Uint32 presidentVersion;
74   Uint32 presidentMysqlVersion;
75 
76   /**
77    * The dynamic id that the node reciving this signal has
78    */
79   Uint32 dynamicId;
80   Uint32 allNdbNodes[NdbNodeBitmask::Size];
81 };
82 
83 /**
84  *
85  */
86 class CmRegRef {
87   /**
88    * Sender(s) & Reciver(s)
89    */
90   friend class Qmgr;
91 
92 public:
93   STATIC_CONST( SignalLength = 7 + NdbNodeBitmask::Size );
94 
95   enum ErrorCode {
96     ZBUSY = 0,          /* Only the president can send this */
97     ZBUSY_PRESIDENT = 1,/* Only the president can send this */
98     ZBUSY_TO_PRES = 2,  /* Only the president can send this */
99     ZNOT_IN_CFG = 3,    /* Only the president can send this */
100     ZELECTION = 4,      /* Receiver is definitely not president,
101                          * but we are not sure if sender ends up
102                          * as president. */
103     ZNOT_PRESIDENT = 5, /* We are not president */
104     ZNOT_DEAD = 6,       /* We are not dead when we are starting  */
105     ZINCOMPATIBLE_VERSION = 7,
106     ZINCOMPATIBLE_START_TYPE = 8,
107     ZSINGLE_USER_MODE = 9, /* The cluster is in single user mode,
108 			    * data node is not allowed to get added
109 			    * in the cluster while in single user mode */
110     ZGENERIC = 100 /* The generic error code */
111   };
112 private:
113 
114   Uint32 blockRef;
115   Uint32 nodeId;
116   Uint32 errorCode;
117   /**
118    * Applicable if ZELECTION
119    */
120   Uint32 presidentCandidate;
121   Uint32 candidate_latest_gci; // 0 means non
122 
123   /**
124    * Data for sending node sending node
125    */
126   Uint32 latest_gci;
127   Uint32 start_type;
128   Uint32 skip_nodes[NdbNodeBitmask::Size]; // Nodes that does not _need_
129                                            // to be part of restart
130 };
131 
132 class CmAdd {
133   /**
134    * Sender(s) & Reciver(s)
135    */
136   friend class Qmgr;
137 
138 public:
139   STATIC_CONST( SignalLength = 4 );
140 
141 private:
142   enum RequestType {
143     Prepare   = 0,
144     AddCommit = 1,
145     CommitNew = 2
146   };
147 
148   Uint32 requestType;
149   Uint32 startingNodeId;
150   Uint32 startingVersion;
151   Uint32 startingMysqlVersion;
152 };
153 
154 class CmAckAdd {
155   /**
156    * Sender(s) & Reciver(s)
157    */
158   friend class Qmgr;
159 
160 public:
161   STATIC_CONST( SignalLength = 3 );
162 
163 private:
164   Uint32 senderNodeId;
165   Uint32 requestType; // see CmAdd::RequestType
166   Uint32 startingNodeId;
167 };
168 
169 class CmNodeInfoReq {
170   /**
171    * Sender(s) & Reciver(s)
172    */
173   friend class Qmgr;
174 
175 public:
176   STATIC_CONST( SignalLength = 5 );
177 
178 private:
179   /**
180    * This is information for sending node (starting node)
181    */
182   Uint32 nodeId;
183   Uint32 dynamicId;
184   Uint32 version;
185   Uint32 mysql_version;
186   Uint32 lqh_workers;   // added in telco-6.4
187 };
188 
189 class CmNodeInfoRef {
190   /**
191    * Sender(s) & Reciver(s)
192    */
193   friend class Qmgr;
194 
195 public:
196   STATIC_CONST( SignalLength = 3 );
197 
198   enum ErrorCode {
199     NotRunning = 1
200   };
201 
202 private:
203   Uint32 nodeId;
204   Uint32 errorCode;
205 };
206 
207 class CmNodeInfoConf {
208   /**
209    * Sender(s) & Reciver(s)
210    */
211   friend class Qmgr;
212 
213 public:
214   STATIC_CONST( SignalLength = 5 );
215 
216 private:
217   Uint32 nodeId;
218   Uint32 dynamicId;
219   Uint32 version;
220   Uint32 mysql_version;
221   Uint32 lqh_workers;   // added in telco-6.4
222 };
223 
224 
225 #undef JAM_FILE_ID
226 
227 #endif
228