21 #include <ndb_limits.h>
22 #include <NdbThread.h>
24 #include <NdbCondition.h>
25 #include <signaldata/ArbitSignalData.hpp>
26 #include <signaldata/NodeStateSignalData.hpp>
27 #include "trp_client.hpp"
28 #include "trp_node.hpp"
29 #include <signaldata/DisconnectRep.hpp>
31 extern "C" void* runClusterMgr_C(
void * me);
41 friend void* runClusterMgr_C(
void * me);
50 bool checkUpgradeCompatability(Uint32 nodeVersion);
56 void set_max_api_reg_req_interval(
unsigned int millisec) {
57 m_max_api_reg_req_interval = millisec;
60 void lock() { NdbMutex_Lock(clusterMgrThreadMutex); trp_client::lock(); }
61 void unlock() { trp_client::unlock();NdbMutex_Unlock(clusterMgrThreadMutex); }
73 CS_waiting_for_clean_cache = 0,
74 CS_waiting_for_first_connect,
90 const trp_node & getNodeInfo(NodeId)
const;
91 Uint32 getNoOfConnectedNodes()
const;
92 void hb_received(NodeId);
95 Uint32 m_connect_count;
97 Uint32 m_max_api_reg_req_interval;
98 Uint32 noOfAliveNodes;
99 Uint32 noOfConnectedNodes;
101 Node theNodes[MAX_NODES];
108 enum Cluster_state m_cluster_state;
112 NdbMutex* clusterMgrThreadMutex;
117 void execAPI_REGREQ (
const Uint32 * theData);
119 void execAPI_REGREF (
const Uint32 * theData);
125 void check_wait_for_hb(NodeId nodeId);
127 inline void set_node_alive(
trp_node& node,
bool alive){
133 if(node.m_alive && !alive)
135 assert(noOfAliveNodes);
138 else if(!node.m_alive && alive)
142 node.m_alive = alive;
147 void print_nodes(
const char* where, NdbOut& out = ndbout);
148 void recalcMinDbVersion();
160 ClusterMgr::getNodeInfo(NodeId nodeId)
const {
162 assert(nodeId < MAX_NODES);
163 return theNodes[nodeId];
168 ClusterMgr::getNoOfConnectedNodes()
const {
169 return noOfConnectedNodes;
174 ClusterMgr::hb_received(NodeId nodeId) {
176 assert(nodeId > 0 && nodeId < MAX_NODES);
177 theNodes[nodeId].hbMissed = 0;
188 extern "C" void* runArbitMgr_C(
void* me);
196 inline void setRank(
unsigned n) { theRank =
n; }
197 inline void setDelay(
unsigned n) { theDelay =
n; }
199 void doStart(
const Uint32* theData);
200 void doChoose(
const Uint32* theData);
201 void doStop(
const Uint32* theData);
203 friend void* runArbitMgr_C(
void* me);
212 NdbMutex* theThreadMutex;
215 GlobalSignalNumber gsn;
221 inline void init(GlobalSignalNumber aGsn,
const Uint32* aData) {
224 memcpy(&data, aData,
sizeof(data));
226 memset(&data, 0,
sizeof(data));
229 inline void setTimestamp() {
230 timestamp = NdbTick_CurrentMillisecond();
233 inline NDB_TICKS getTimediff() {
234 NDB_TICKS now = NdbTick_CurrentMillisecond();
235 return now < timestamp ? 0 : now - timestamp;
239 NdbMutex* theInputMutex;
243 ArbitSignal theInputBuffer;
245 void sendSignalToThread(ArbitSignal& aSignal);
262 void threadStart(ArbitSignal& aSignal);
263 void threadChoose(ArbitSignal& aSignal);
264 void threadTimeout();
265 void threadStop(ArbitSignal& aSignal);
267 ArbitSignal theStartReq;
268 ArbitSignal theChooseReq1;
269 ArbitSignal theChooseReq2;
270 ArbitSignal theStopOrd;
272 void sendStartConf(ArbitSignal& aSignal, Uint32);
273 void sendChooseRef(ArbitSignal& aSignal, Uint32);
274 void sendChooseConf(ArbitSignal& aSignal, Uint32);
275 void sendStopRep(ArbitSignal& aSignal, Uint32);
277 void sendSignalToQmgr(ArbitSignal& aSignal);