summaryrefslogtreecommitdiff
path: root/storage/ndb/include/kernel/signaldata/LqhTransConf.hpp
blob: 4a72d344ad6d9c99a633970f62e59da7705ed155 (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
217
/* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef LQH_TRANS_CONF_H
#define LQH_TRANS_CONF_H

#include "SignalData.hpp"

/**
 * This signal is sent as response to a LQH_TRANSREQ
 * which is sent as by a take-over TC
 */
class LqhTransConf {
  /**
   * Reciver(s)
   */
  friend class Dbtc;

  /**
   * Sender(s)
   */
  friend class Dblqh;      

  friend bool printLQH_TRANSCONF(FILE *, const Uint32 *, Uint32, Uint16);  
public:
  STATIC_CONST( SignalLength = 15 );
private:

  /**
   * This type describes the state of the operation returned in this signal
   */
  enum OperationStatus {
    InvalidStatus = 0, /**< This status should never be sent in a signal
			  it is only used for initializing variables so that
			  you can easily later check if they have changed */
    LastTransConf = 4, /**< This status indicates that LQH has finished the scan
			  of operations belonging to the died TC.
			  Data 0 - 2 is valid */
    
    Prepared  = 2,
    Committed = 3,
    Aborted   = 1,
    Marker    = 5 /**< This means that the only thing left is a marker,
		     Data 0 - 6 is valid */
  };
  
  /**
   * DATA VARIABLES
   */
  Uint32 tcRef;           // 0
  Uint32 lqhNodeId;       // 1   
  Uint32 operationStatus; // 2 See enum OperationStatus
  Uint32 transId1;        // 3
  Uint32 transId2;        // 4
  Uint32 apiRef;          // 5
  Uint32 apiOpRec;        // 6
  Uint32 lqhConnectPtr;
  Uint32 oldTcOpRec;
  Uint32 requestInfo;
  Uint32 gci;
  Uint32 nextNodeId1;
  Uint32 nextNodeId2;
  Uint32 nextNodeId3;
  Uint32 tableId;

  /**
   * Getters
   */
  static Uint32 getReplicaNo(Uint32 & requestInfo);
  static Uint32 getReplicaType(Uint32 & requestInfo);
  static Uint32 getLastReplicaNo(Uint32 & requestInfo);
  static Uint32 getSimpleFlag(Uint32 & requestInfo);
  static Uint32 getDirtyFlag(Uint32 & requestInfo);
  static Uint32 getOperation(Uint32 & requestInfo);
  static Uint32 getMarkerFlag(Uint32 & requestInfo);

  static void setReplicaNo(UintR & requestInfo, UintR val);
  static void setReplicaType(UintR & requestInfo, UintR val);
  static void setLastReplicaNo(UintR & requestInfo, UintR val);
  static void setSimpleFlag(UintR & requestInfo, UintR val);
  static void setDirtyFlag(UintR & requestInfo, UintR val);
  static void setOperation(UintR & requestInfo, UintR val);
  static void setMarkerFlag(Uint32 & requestInfo, Uint32 val);
};

/**
 * Request Info
 *
 * t = replica type           - 2  Bits (0-1)
 * r = Replica No             - 2  Bits (2-3)
 * l = Last Replica No        - 2  Bits (4-5)
 * s = Simple                 - 1  Bits (6)
 * d = Dirty                  - 1  Bit  (7)
 * o = Operation              - 3  Bit  (8-9)
 * m = Marker present         - 1  Bit  (10)
 *
 *           1111111111222222222233
 * 01234567890123456789012345678901
 * ttrrllsdooom
 */
#define LTC_REPLICA_TYPE_SHIFT    (0)
#define LTC_REPLICA_TYPE_MASK     (3)
#define LTC_REPLICA_NO_SHIFT      (2)
#define LTC_REPLICA_NO_MASK       (3)
#define LTC_LAST_REPLICA_SHIFT    (4)
#define LTC_LAST_REPLICA_MASK     (3)
#define LTC_SIMPLE_SHIFT          (6)
#define LTC_DIRTY_SHIFT           (7)
#define LTC_OPERATION_SHIFT       (8)
#define LTC_OPERATION_MASK        (7)
#define LTC_MARKER_SHIFT          (10)

inline
Uint32
LqhTransConf::getReplicaType(Uint32 & requestInfo){
  return (requestInfo >> LTC_REPLICA_TYPE_SHIFT) & LTC_REPLICA_TYPE_MASK;
}

inline
Uint32
LqhTransConf::getReplicaNo(Uint32 & requestInfo){
  return (requestInfo >> LTC_REPLICA_NO_SHIFT) & LTC_REPLICA_NO_MASK;
}

inline
Uint32
LqhTransConf::getLastReplicaNo(Uint32 & requestInfo){
  return (requestInfo >> LTC_LAST_REPLICA_SHIFT) & LTC_LAST_REPLICA_MASK;
}

inline
Uint32
LqhTransConf::getSimpleFlag(Uint32 & requestInfo){
  return (requestInfo >> LTC_SIMPLE_SHIFT) & 1;
}

inline
Uint32
LqhTransConf::getDirtyFlag(Uint32 & requestInfo){
  return (requestInfo >> LTC_DIRTY_SHIFT) & 1;
}

inline
Uint32
LqhTransConf::getOperation(Uint32 & requestInfo){
  return (requestInfo >> LTC_OPERATION_SHIFT) & LTC_OPERATION_MASK;
}

inline
Uint32
LqhTransConf::getMarkerFlag(Uint32 & requestInfo){
  return (requestInfo >> LTC_MARKER_SHIFT) & 1;
}


inline
void
LqhTransConf::setReplicaNo(UintR & requestInfo, UintR val){
  ASSERT_MAX(val, LTC_REPLICA_NO_MASK, "LqhTransConf::setReplicaNo");
  requestInfo |= (val << LTC_REPLICA_NO_SHIFT);
}

inline
void
LqhTransConf::setReplicaType(UintR & requestInfo, UintR val){
  ASSERT_MAX(val, LTC_REPLICA_TYPE_MASK, "LqhTransConf::setReplicaType");
  requestInfo |= (val << LTC_REPLICA_TYPE_SHIFT);
}

inline
void
LqhTransConf::setLastReplicaNo(UintR & requestInfo, UintR val){
  ASSERT_MAX(val, LTC_LAST_REPLICA_MASK, "LqhTransConf::setLastReplicaNo");
  requestInfo |= (val << LTC_LAST_REPLICA_SHIFT);
}

inline
void
LqhTransConf::setSimpleFlag(UintR & requestInfo, UintR val){
  ASSERT_BOOL(val, "LqhTransConf::setSimpleFlag");
  requestInfo |= (val << LTC_SIMPLE_SHIFT);
}

inline
void
LqhTransConf::setDirtyFlag(UintR & requestInfo, UintR val){
  ASSERT_BOOL(val, "LqhTransConf::setDirtyFlag");
  requestInfo |= (val << LTC_DIRTY_SHIFT);
}

inline
void
LqhTransConf::setOperation(UintR & requestInfo, UintR val){
  ASSERT_MAX(val, LTC_OPERATION_MASK, "LqhTransConf::setOperation");
  requestInfo |= (val << LTC_OPERATION_SHIFT);
}

inline
void
LqhTransConf::setMarkerFlag(UintR & requestInfo, UintR val){
  ASSERT_BOOL(val, "LqhTransConf::setMarkerFlag");
  requestInfo |= (val << LTC_MARKER_SHIFT);
}

#endif