~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/include/kernel/signaldata/LqhTransConf.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef LQH_TRANS_CONF_H
 
17
#define LQH_TRANS_CONF_H
 
18
 
 
19
#include "SignalData.hpp"
 
20
 
 
21
/**
 
22
 * This signal is sent as response to a LQH_TRANSREQ
 
23
 * which is sent as by a take-over TC
 
24
 */
 
25
class LqhTransConf {
 
26
  /**
 
27
   * Reciver(s)
 
28
   */
 
29
  friend class Dbtc;
 
30
 
 
31
  /**
 
32
   * Sender(s)
 
33
   */
 
34
  friend class Dblqh;      
 
35
 
 
36
  friend bool printLQH_TRANSCONF(FILE *, const Uint32 *, Uint32, Uint16);  
 
37
public:
 
38
  STATIC_CONST( SignalLength = 15 );
 
39
private:
 
40
 
 
41
  /**
 
42
   * This type describes the state of the operation returned in this signal
 
43
   */
 
44
  enum OperationStatus {
 
45
    InvalidStatus = 0, /**< This status should never be sent in a signal
 
46
                          it is only used for initializing variables so that
 
47
                          you can easily later check if they have changed */
 
48
    LastTransConf = 4, /**< This status indicates that LQH has finished the scan
 
49
                          of operations belonging to the died TC.
 
50
                          Data 0 - 2 is valid */
 
51
    
 
52
    Prepared  = 2,
 
53
    Committed = 3,
 
54
    Aborted   = 1,
 
55
    Marker    = 5 /**< This means that the only thing left is a marker,
 
56
                     Data 0 - 6 is valid */
 
57
  };
 
58
  
 
59
  /**
 
60
   * DATA VARIABLES
 
61
   */
 
62
  Uint32 tcRef;           // 0
 
63
  Uint32 lqhNodeId;       // 1   
 
64
  Uint32 operationStatus; // 2 See enum OperationStatus
 
65
  Uint32 transId1;        // 3
 
66
  Uint32 transId2;        // 4
 
67
  Uint32 apiRef;          // 5
 
68
  Uint32 apiOpRec;        // 6
 
69
  Uint32 lqhConnectPtr;
 
70
  Uint32 oldTcOpRec;
 
71
  Uint32 requestInfo;
 
72
  Uint32 gci;
 
73
  Uint32 nextNodeId1;
 
74
  Uint32 nextNodeId2;
 
75
  Uint32 nextNodeId3;
 
76
  Uint32 tableId;
 
77
 
 
78
  /**
 
79
   * Getters
 
80
   */
 
81
  static Uint32 getReplicaNo(Uint32 & requestInfo);
 
82
  static Uint32 getReplicaType(Uint32 & requestInfo);
 
83
  static Uint32 getLastReplicaNo(Uint32 & requestInfo);
 
84
  static Uint32 getSimpleFlag(Uint32 & requestInfo);
 
85
  static Uint32 getDirtyFlag(Uint32 & requestInfo);
 
86
  static Uint32 getOperation(Uint32 & requestInfo);
 
87
  static Uint32 getMarkerFlag(Uint32 & requestInfo);
 
88
 
 
89
  static void setReplicaNo(UintR & requestInfo, UintR val);
 
90
  static void setReplicaType(UintR & requestInfo, UintR val);
 
91
  static void setLastReplicaNo(UintR & requestInfo, UintR val);
 
92
  static void setSimpleFlag(UintR & requestInfo, UintR val);
 
93
  static void setDirtyFlag(UintR & requestInfo, UintR val);
 
94
  static void setOperation(UintR & requestInfo, UintR val);
 
95
  static void setMarkerFlag(Uint32 & requestInfo, Uint32 val);
 
96
};
 
97
 
 
98
/**
 
99
 * Request Info
 
100
 *
 
101
 * t = replica type           - 2  Bits (0-1)
 
102
 * r = Replica No             - 2  Bits (2-3)
 
103
 * l = Last Replica No        - 2  Bits (4-5)
 
104
 * s = Simple                 - 1  Bits (6)
 
105
 * d = Dirty                  - 1  Bit  (7)
 
106
 * o = Operation              - 3  Bit  (8-9)
 
107
 * m = Marker present         - 1  Bit  (10)
 
108
 *
 
109
 *           1111111111222222222233
 
110
 * 01234567890123456789012345678901
 
111
 * ttrrllsdooom
 
112
 */
 
113
#define LTC_REPLICA_TYPE_SHIFT    (0)
 
114
#define LTC_REPLICA_TYPE_MASK     (3)
 
115
#define LTC_REPLICA_NO_SHIFT      (2)
 
116
#define LTC_REPLICA_NO_MASK       (3)
 
117
#define LTC_LAST_REPLICA_SHIFT    (4)
 
118
#define LTC_LAST_REPLICA_MASK     (3)
 
119
#define LTC_SIMPLE_SHIFT          (6)
 
120
#define LTC_DIRTY_SHIFT           (7)
 
121
#define LTC_OPERATION_SHIFT       (8)
 
122
#define LTC_OPERATION_MASK        (7)
 
123
#define LTC_MARKER_SHIFT          (10)
 
124
 
 
125
inline
 
126
Uint32
 
127
LqhTransConf::getReplicaType(Uint32 & requestInfo){
 
128
  return (requestInfo >> LTC_REPLICA_TYPE_SHIFT) & LTC_REPLICA_TYPE_MASK;
 
129
}
 
130
 
 
131
inline
 
132
Uint32
 
133
LqhTransConf::getReplicaNo(Uint32 & requestInfo){
 
134
  return (requestInfo >> LTC_REPLICA_NO_SHIFT) & LTC_REPLICA_NO_MASK;
 
135
}
 
136
 
 
137
inline
 
138
Uint32
 
139
LqhTransConf::getLastReplicaNo(Uint32 & requestInfo){
 
140
  return (requestInfo >> LTC_LAST_REPLICA_SHIFT) & LTC_LAST_REPLICA_MASK;
 
141
}
 
142
 
 
143
inline
 
144
Uint32
 
145
LqhTransConf::getSimpleFlag(Uint32 & requestInfo){
 
146
  return (requestInfo >> LTC_SIMPLE_SHIFT) & 1;
 
147
}
 
148
 
 
149
inline
 
150
Uint32
 
151
LqhTransConf::getDirtyFlag(Uint32 & requestInfo){
 
152
  return (requestInfo >> LTC_DIRTY_SHIFT) & 1;
 
153
}
 
154
 
 
155
inline
 
156
Uint32
 
157
LqhTransConf::getOperation(Uint32 & requestInfo){
 
158
  return (requestInfo >> LTC_OPERATION_SHIFT) & LTC_OPERATION_MASK;
 
159
}
 
160
 
 
161
inline
 
162
Uint32
 
163
LqhTransConf::getMarkerFlag(Uint32 & requestInfo){
 
164
  return (requestInfo >> LTC_MARKER_SHIFT) & 1;
 
165
}
 
166
 
 
167
 
 
168
inline
 
169
void
 
170
LqhTransConf::setReplicaNo(UintR & requestInfo, UintR val){
 
171
  ASSERT_MAX(val, LTC_REPLICA_NO_MASK, "LqhTransConf::setReplicaNo");
 
172
  requestInfo |= (val << LTC_REPLICA_NO_SHIFT);
 
173
}
 
174
 
 
175
inline
 
176
void
 
177
LqhTransConf::setReplicaType(UintR & requestInfo, UintR val){
 
178
  ASSERT_MAX(val, LTC_REPLICA_TYPE_MASK, "LqhTransConf::setReplicaType");
 
179
  requestInfo |= (val << LTC_REPLICA_TYPE_SHIFT);
 
180
}
 
181
 
 
182
inline
 
183
void
 
184
LqhTransConf::setLastReplicaNo(UintR & requestInfo, UintR val){
 
185
  ASSERT_MAX(val, LTC_LAST_REPLICA_MASK, "LqhTransConf::setLastReplicaNo");
 
186
  requestInfo |= (val << LTC_LAST_REPLICA_SHIFT);
 
187
}
 
188
 
 
189
inline
 
190
void
 
191
LqhTransConf::setSimpleFlag(UintR & requestInfo, UintR val){
 
192
  ASSERT_BOOL(val, "LqhTransConf::setSimpleFlag");
 
193
  requestInfo |= (val << LTC_SIMPLE_SHIFT);
 
194
}
 
195
 
 
196
inline
 
197
void
 
198
LqhTransConf::setDirtyFlag(UintR & requestInfo, UintR val){
 
199
  ASSERT_BOOL(val, "LqhTransConf::setDirtyFlag");
 
200
  requestInfo |= (val << LTC_DIRTY_SHIFT);
 
201
}
 
202
 
 
203
inline
 
204
void
 
205
LqhTransConf::setOperation(UintR & requestInfo, UintR val){
 
206
  ASSERT_MAX(val, LTC_OPERATION_MASK, "LqhTransConf::setOperation");
 
207
  requestInfo |= (val << LTC_OPERATION_SHIFT);
 
208
}
 
209
 
 
210
inline
 
211
void
 
212
LqhTransConf::setMarkerFlag(UintR & requestInfo, UintR val){
 
213
  ASSERT_BOOL(val, "LqhTransConf::setMarkerFlag");
 
214
  requestInfo |= (val << LTC_MARKER_SHIFT);
 
215
}
 
216
 
 
217
#endif