22 #include <ndb_types.h>
23 #include <ndb_limits.h>
24 #include <NodeBitmask.hpp>
35 #define NO_NODE_GROUP_ID ((1 << NODEID_BITS) - 1)
47 #define _SYSFILE_SIZE32 (6 + \
49 NODE_ARRAY_SIZE(MAX_NDB_NODES, 4) + \
50 NODE_ARRAY_SIZE(MAX_NDB_NODES, NODEID_BITS) + \
51 NODE_ARRAY_SIZE(MAX_NDB_NODES, NODEID_BITS) + \
52 _NDB_NODE_BITMASK_SIZE)
65 Uint32 systemRestartBits;
73 static void setInitialStartOngoing(Uint32 & systemRestartBits);
74 static void clearInitialStartOngoing(Uint32 & systemRestartBits);
76 static bool getRestartOngoing(
const Uint32 & systemRestartBits);
77 static void setRestartOngoing(Uint32 & systemRestartBits);
78 static void clearRestartOngoing(Uint32 & systemRestartBits);
80 static bool getLCPOngoing(
const Uint32 & systemRestartBits);
81 static void setLCPOngoing(Uint32 & systemRestartBits);
82 static void clearLCPOngoing(Uint32 & systemRestartBits);
85 Uint32 oldestRestorableGCI;
86 Uint32 newestRestorableGCI;
101 ,NS_ActiveMissed_1 = 1
102 ,NS_ActiveMissed_2 = 2
103 ,NS_ActiveMissed_3 = 3
104 ,NS_NotActive_NotTakenOver = 5
106 ,NS_NotActive_TakenOver = 7
110 STATIC_CONST( NODE_STATUS_SIZE = NODE_ARRAY_SIZE(MAX_NDB_NODES, 4) );
111 Uint32 nodeStatus[NODE_STATUS_SIZE];
113 static Uint32 getNodeStatus(NodeId,
const Uint32 nodeStatus[]);
114 static void setNodeStatus(NodeId, Uint32 nodeStatus[], Uint32 status);
120 STATIC_CONST( NODE_GROUPS_SIZE = NODE_ARRAY_SIZE(MAX_NDB_NODES,
122 Uint32 nodeGroups[NODE_GROUPS_SIZE];
124 static Uint16 getNodeGroup(NodeId,
const Uint32 nodeGroups[]);
125 static void setNodeGroup(NodeId, Uint32 nodeGroups[], Uint16
group);
130 STATIC_CONST( TAKE_OVER_SIZE = NODE_ARRAY_SIZE(MAX_NDB_NODES,
132 Uint32 takeOver[TAKE_OVER_SIZE];
134 static NodeId getTakeOverNode(NodeId,
const Uint32 takeOver[]);
135 static void setTakeOverNode(NodeId, Uint32 takeOver[], NodeId toNode);
143 #if (MAX_NDB_NODES > (1<<NODEID_BITS))
144 #error "Sysfile node id is too small"
161 return systemRestartBits & 1;
166 Sysfile::setInitialStartOngoing(Uint32 & systemRestartBits){
167 systemRestartBits |= 1;
172 Sysfile::clearInitialStartOngoing(Uint32 & systemRestartBits){
173 systemRestartBits &= ~1;
178 Sysfile::getRestartOngoing(
const Uint32 & systemRestartBits){
179 return (systemRestartBits & 2) != 0;
184 Sysfile::setRestartOngoing(Uint32 & systemRestartBits){
185 systemRestartBits |= 2;
190 Sysfile::clearRestartOngoing(Uint32 & systemRestartBits){
191 systemRestartBits &= ~2;
196 Sysfile::getLCPOngoing(
const Uint32 & systemRestartBits){
197 return systemRestartBits & 4;
202 Sysfile::setLCPOngoing(Uint32 & systemRestartBits){
203 systemRestartBits |= 4;
208 Sysfile::clearLCPOngoing(Uint32 & systemRestartBits){
209 systemRestartBits &= ~4;
214 Sysfile::getNodeStatus(NodeId nodeId,
const Uint32 nodeStatus[]){
215 const int word = nodeId >> 3;
216 const int shift = (nodeId & 7) << 2;
218 return (nodeStatus[word] >> shift) & 15;
223 Sysfile::setNodeStatus(NodeId nodeId, Uint32 nodeStatus[], Uint32 status){
224 const int word = nodeId >> 3;
225 const int shift = (nodeId & 7) << 2;
227 const Uint32 mask = ~(((Uint32)15) << shift);
228 const Uint32 tmp = nodeStatus[
word];
230 nodeStatus[
word] = (tmp & mask) | ((status & 15) << shift);
235 Sysfile::getNodeGroup(NodeId nodeId,
const Uint32 nodeGroups[]){
236 const int word = nodeId >> 2;
237 const int shift = (nodeId & 3) << 3;
239 return (nodeGroups[word] >> shift) & 255;
244 Sysfile::setNodeGroup(NodeId nodeId, Uint32 nodeGroups[], Uint16
group){
245 const int word = nodeId >> 2;
246 const int shift = (nodeId & 3) << 3;
248 const Uint32 mask = ~(((Uint32)255) << shift);
249 const Uint32 tmp = nodeGroups[
word];
251 nodeGroups[
word] = (tmp & mask) | ((group & 255) << shift);
256 Sysfile::getTakeOverNode(NodeId nodeId,
const Uint32 takeOver[]){
257 const int word = nodeId >> 2;
258 const int shift = (nodeId & 3) << 3;
260 return (takeOver[word] >> shift) & 255;
265 Sysfile::setTakeOverNode(NodeId nodeId, Uint32 takeOver[], NodeId toNode){
266 const int word = nodeId >> 2;
267 const int shift = (nodeId & 3) << 3;
269 const Uint32 mask = ~(((Uint32)255) << shift);
270 const Uint32 tmp = takeOver[
word];
272 takeOver[
word] = (tmp & mask) | ((toNode & 255) << shift);