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 LQH_TRANS_CONF_H
26 #define LQH_TRANS_CONF_H
27
28 #include "SignalData.hpp"
29
30 #define JAM_FILE_ID 21
31
32
33 /**
34 * This signal is sent as response to a LQH_TRANSREQ
35 * which is sent as by a take-over TC
36 */
37 class LqhTransConf {
38 /**
39 * Reciver(s)
40 */
41 friend class Dbtc;
42
43 /**
44 * Sender(s)
45 */
46 friend class Dblqh;
47 friend class DblqhProxy;
48
49 friend bool printLQH_TRANSCONF(FILE *, const Uint32 *, Uint32, Uint16);
50 public:
51 STATIC_CONST( SignalLength = 18 );
52
53 /**
54 * Upgrade
55 */
56 STATIC_CONST( SignalLength_GCI_LO = 16 );
57 STATIC_CONST( SignalLength_FRAG_ID = 17 );
58 STATIC_CONST( SignalLength_INST_ID = 18 );
59 private:
60
61 /**
62 * This type describes the state of the operation returned in this signal
63 */
64 enum OperationStatus {
65 InvalidStatus = 0, /**< This status should never be sent in a signal
66 it is only used for initializing variables so that
67 you can easily later check if they have changed */
68 LastTransConf = 4, /**< This status indicates that LQH has finished the scan
69 of operations belonging to the died TC.
70 Data 0 - 2 is valid */
71
72 Prepared = 2,
73 Committed = 3,
74 Aborted = 1,
75 Marker = 5 /**< This means that the only thing left is a marker,
76 Data 0 - 6 is valid */
77 };
78
79 /**
80 * DATA VARIABLES
81 */
82 Uint32 tcRef; // 0
83 Uint32 lqhNodeId; // 1
84 Uint32 operationStatus; // 2 See enum OperationStatus
85 Uint32 transId1; // 3
86 Uint32 transId2; // 4
87 Uint32 apiRef; // 5
88 Uint32 apiOpRec; // 6
89 Uint32 lqhConnectPtr;
90 Uint32 oldTcOpRec;
91 Uint32 requestInfo;
92 Uint32 gci_hi;
93 Uint32 nextNodeId1;
94 Uint32 nextNodeId2;
95 Uint32 nextNodeId3;
96 Uint32 tableId;
97 Uint32 gci_lo;
98 Uint32 fragId;
99 Uint32 maxInstanceId;
100
101 /**
102 * Getters
103 */
104 static Uint32 getReplicaNo(Uint32 & requestInfo);
105 static Uint32 getReplicaType(Uint32 & requestInfo);
106 static Uint32 getLastReplicaNo(Uint32 & requestInfo);
107 static Uint32 getSimpleFlag(Uint32 & requestInfo);
108 static Uint32 getDirtyFlag(Uint32 & requestInfo);
109 static Uint32 getOperation(Uint32 & requestInfo);
110 static Uint32 getMarkerFlag(Uint32 & requestInfo);
111
112 static void setReplicaNo(UintR & requestInfo, UintR val);
113 static void setReplicaType(UintR & requestInfo, UintR val);
114 static void setLastReplicaNo(UintR & requestInfo, UintR val);
115 static void setSimpleFlag(UintR & requestInfo, UintR val);
116 static void setDirtyFlag(UintR & requestInfo, UintR val);
117 static void setOperation(UintR & requestInfo, UintR val);
118 static void setMarkerFlag(Uint32 & requestInfo, Uint32 val);
119 };
120
121 /**
122 * Request Info
123 *
124 * t = replica type - 2 Bits (0-1)
125 * r = Replica No - 2 Bits (2-3)
126 * l = Last Replica No - 2 Bits (4-5)
127 * s = Simple - 1 Bits (6)
128 * d = Dirty - 1 Bit (7)
129 * o = Operation - 3 Bit (8-9)
130 * m = Marker present - 1 Bit (10)
131 *
132 * 1111111111222222222233
133 * 01234567890123456789012345678901
134 * ttrrllsdooom
135 */
136 #define LTC_REPLICA_TYPE_SHIFT (0)
137 #define LTC_REPLICA_TYPE_MASK (3)
138 #define LTC_REPLICA_NO_SHIFT (2)
139 #define LTC_REPLICA_NO_MASK (3)
140 #define LTC_LAST_REPLICA_SHIFT (4)
141 #define LTC_LAST_REPLICA_MASK (3)
142 #define LTC_SIMPLE_SHIFT (6)
143 #define LTC_DIRTY_SHIFT (7)
144 #define LTC_OPERATION_SHIFT (8)
145 #define LTC_OPERATION_MASK (7)
146 #define LTC_MARKER_SHIFT (10)
147
148 inline
149 Uint32
getReplicaType(Uint32 & requestInfo)150 LqhTransConf::getReplicaType(Uint32 & requestInfo){
151 return (requestInfo >> LTC_REPLICA_TYPE_SHIFT) & LTC_REPLICA_TYPE_MASK;
152 }
153
154 inline
155 Uint32
getReplicaNo(Uint32 & requestInfo)156 LqhTransConf::getReplicaNo(Uint32 & requestInfo){
157 return (requestInfo >> LTC_REPLICA_NO_SHIFT) & LTC_REPLICA_NO_MASK;
158 }
159
160 inline
161 Uint32
getLastReplicaNo(Uint32 & requestInfo)162 LqhTransConf::getLastReplicaNo(Uint32 & requestInfo){
163 return (requestInfo >> LTC_LAST_REPLICA_SHIFT) & LTC_LAST_REPLICA_MASK;
164 }
165
166 inline
167 Uint32
getSimpleFlag(Uint32 & requestInfo)168 LqhTransConf::getSimpleFlag(Uint32 & requestInfo){
169 return (requestInfo >> LTC_SIMPLE_SHIFT) & 1;
170 }
171
172 inline
173 Uint32
getDirtyFlag(Uint32 & requestInfo)174 LqhTransConf::getDirtyFlag(Uint32 & requestInfo){
175 return (requestInfo >> LTC_DIRTY_SHIFT) & 1;
176 }
177
178 inline
179 Uint32
getOperation(Uint32 & requestInfo)180 LqhTransConf::getOperation(Uint32 & requestInfo){
181 return (requestInfo >> LTC_OPERATION_SHIFT) & LTC_OPERATION_MASK;
182 }
183
184 inline
185 Uint32
getMarkerFlag(Uint32 & requestInfo)186 LqhTransConf::getMarkerFlag(Uint32 & requestInfo){
187 return (requestInfo >> LTC_MARKER_SHIFT) & 1;
188 }
189
190
191 inline
192 void
setReplicaNo(UintR & requestInfo,UintR val)193 LqhTransConf::setReplicaNo(UintR & requestInfo, UintR val){
194 ASSERT_MAX(val, LTC_REPLICA_NO_MASK, "LqhTransConf::setReplicaNo");
195 requestInfo |= (val << LTC_REPLICA_NO_SHIFT);
196 }
197
198 inline
199 void
setReplicaType(UintR & requestInfo,UintR val)200 LqhTransConf::setReplicaType(UintR & requestInfo, UintR val){
201 ASSERT_MAX(val, LTC_REPLICA_TYPE_MASK, "LqhTransConf::setReplicaType");
202 requestInfo |= (val << LTC_REPLICA_TYPE_SHIFT);
203 }
204
205 inline
206 void
setLastReplicaNo(UintR & requestInfo,UintR val)207 LqhTransConf::setLastReplicaNo(UintR & requestInfo, UintR val){
208 ASSERT_MAX(val, LTC_LAST_REPLICA_MASK, "LqhTransConf::setLastReplicaNo");
209 requestInfo |= (val << LTC_LAST_REPLICA_SHIFT);
210 }
211
212 inline
213 void
setSimpleFlag(UintR & requestInfo,UintR val)214 LqhTransConf::setSimpleFlag(UintR & requestInfo, UintR val){
215 ASSERT_BOOL(val, "LqhTransConf::setSimpleFlag");
216 requestInfo |= (val << LTC_SIMPLE_SHIFT);
217 }
218
219 inline
220 void
setDirtyFlag(UintR & requestInfo,UintR val)221 LqhTransConf::setDirtyFlag(UintR & requestInfo, UintR val){
222 ASSERT_BOOL(val, "LqhTransConf::setDirtyFlag");
223 requestInfo |= (val << LTC_DIRTY_SHIFT);
224 }
225
226 inline
227 void
setOperation(UintR & requestInfo,UintR val)228 LqhTransConf::setOperation(UintR & requestInfo, UintR val){
229 ASSERT_MAX(val, LTC_OPERATION_MASK, "LqhTransConf::setOperation");
230 requestInfo |= (val << LTC_OPERATION_SHIFT);
231 }
232
233 inline
234 void
setMarkerFlag(UintR & requestInfo,UintR val)235 LqhTransConf::setMarkerFlag(UintR & requestInfo, UintR val){
236 ASSERT_BOOL(val, "LqhTransConf::setMarkerFlag");
237 requestInfo |= (val << LTC_MARKER_SHIFT);
238 }
239
240
241 #undef JAM_FILE_ID
242
243 #endif
244