void NDBT_Context::stopTest(){ NdbMutex_Lock(propertyMutexPtr); g_info << "|- stopTest called" << endl; stopped = true; NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); }
void ClusterMgr::startup() { assert(theStop == -1); Uint32 nodeId = getOwnNodeId(); Node & cm_node = theNodes[nodeId]; trp_node & theNode = cm_node; assert(theNode.defined); lock(); theFacade.doConnect(nodeId); flush_send_buffers(); unlock(); for (Uint32 i = 0; i<3000; i++) { lock(); theFacade.theTransporterRegistry->update_connections(); flush_send_buffers(); unlock(); if (theNode.is_connected()) break; NdbSleep_MilliSleep(20); } assert(theNode.is_connected()); Guard g(clusterMgrThreadMutex); theStop = 0; NdbCondition_Broadcast(waitForHBCond); }
void NDBT_Context::setProperty(const char* _name, const char* _val){ NdbMutex_Lock(propertyMutexPtr); const bool b = props.put(_name, _val, true); require(b == true); NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); }
void ClusterMgr::startup() { assert(theStop == -1); Uint32 nodeId = getOwnNodeId(); Node & cm_node = theNodes[nodeId]; trp_node & theNode = cm_node; assert(theNode.defined); lock(); theFacade.doConnect(nodeId); flush_send_buffers(); unlock(); for (Uint32 i = 0; i<3000; i++) { theFacade.request_connection_check(); start_poll(); do_poll(0); complete_poll(); if (theNode.is_connected()) break; NdbSleep_MilliSleep(20); } assert(theNode.is_connected()); Guard g(clusterMgrThreadMutex); /* Signalling to creating thread that we are done with thread startup */ theStop = 0; NdbCondition_Broadcast(waitForHBCond); }
void NDBT_Context::incProperty(const char * name){ NdbMutex_Lock(propertyMutexPtr); Uint32 val = 0; props.get(name, &val); props.put(name, (val + 1), true); NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); }
void NDBT_Context::decProperty(const char * name){ NdbMutex_Lock(propertyMutexPtr); Uint32 val = 0; if(props.get(name, &val)){ require(val > 0); props.put(name, (val - 1), true); } NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); }
Uint32 NDBT_Context::casProperty(const char * name, Uint32 oldValue, Uint32 newValue) { NdbMutex_Lock(propertyMutexPtr); Uint32 val = 0; props.get(name, &val); if (val == oldValue) { props.put(name, newValue, true); NdbCondition_Broadcast(propertyCondPtr); } NdbMutex_Unlock(propertyMutexPtr); return val; }
void SignalQueue::receive(NdbApiSignal *signal) { QueueEntry *n = new QueueEntry(); n->signal = signal; n->next = NULL; Guard guard(m_mutex); if(m_signalQueueHead == NULL) { m_signalQueueHead = n; NdbCondition_Broadcast(m_cond); return; } QueueEntry *cur = m_signalQueueHead; while(cur->next != NULL) cur = cur->next; cur->next = n; NdbCondition_Broadcast(m_cond); }
void ClusterMgr::execAPI_REGCONF(const Uint32 * theData){ const ApiRegConf * const apiRegConf = (ApiRegConf *)&theData[0]; const NodeId nodeId = refToNode(apiRegConf->qmgrRef); #ifdef DEBUG_REG ndbout_c("ClusterMgr: Recd API_REGCONF from node %d", nodeId); #endif assert(nodeId > 0 && nodeId < MAX_NODES); Node & node = theNodes[nodeId]; assert(node.defined == true); assert(node.connected == true); if(node.m_info.m_version != apiRegConf->version){ node.m_info.m_version = apiRegConf->version; if(theNodes[theFacade.ownId()].m_info.m_type == NodeInfo::MGM) node.compatible = ndbCompatible_mgmt_ndb(NDB_VERSION, node.m_info.m_version); else node.compatible = ndbCompatible_api_ndb(NDB_VERSION, node.m_info.m_version); } node.m_api_reg_conf = true; node.m_state = apiRegConf->nodeState; if (node.compatible && (node.m_state.startLevel == NodeState::SL_STARTED || node.m_state.getSingleUserMode())){ set_node_alive(node, true); } else { set_node_alive(node, false); }//if node.m_info.m_heartbeat_cnt = 0; node.hbCounter = 0; if(waitingForHB) { waitForHBFromNodes.clear(nodeId); if(waitForHBFromNodes.isclear()) { waitingForHB= false; NdbCondition_Broadcast(waitForHBCond); } } node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50; }
void ClusterMgr::check_wait_for_hb(NodeId nodeId) { if(waitingForHB) { waitForHBFromNodes.clear(nodeId); if(waitForHBFromNodes.isclear()) { waitingForHB= false; NdbCondition_Broadcast(waitForHBCond); } } return; }
void Test::wait_started() { NdbMutex_Lock(mutex); if (waiting_start + 1 == cnt_threads) { waiting_stop = 0; } waiting_start++; assert(waiting_start <= cnt_threads); while (waiting_start < cnt_threads) NdbCondition_Wait(cond, mutex); NdbCondition_Broadcast(cond); NdbMutex_Unlock(mutex); }
void Test::wait_completed() { NdbMutex_Lock(mutex); if (waiting_stop + 1 == cnt_threads) { rep.validate(); waiting_start = 0; } waiting_stop++; assert(waiting_stop <= cnt_threads); while (waiting_stop < cnt_threads) NdbCondition_Wait(cond, mutex); NdbCondition_Broadcast(cond); NdbMutex_Unlock(mutex); }
NdbTableImpl * GlobalDictCache::put(const char * name, NdbTableImpl * tab) { DBUG_ENTER("GlobalDictCache::put"); DBUG_PRINT("enter", ("name: %s, internal_name: %s", name, tab ? tab->m_internalName.c_str() : "tab NULL")); const Uint32 len = strlen(name); Vector<TableVersion> * vers = m_tableHash.getData(name, len); if(vers == 0){ // Should always tried to retreive it first // and thus there should be a record abort(); } const Uint32 sz = vers->size(); if(sz == 0){ // Should always tried to retreive it first // and thus there should be a record abort(); } TableVersion & ver = vers->back(); if(ver.m_status != RETREIVING || !(ver.m_impl == 0 || ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || ver.m_version != 0 || ver.m_refCount == 0){ abort(); } if(tab == 0) { DBUG_PRINT("info", ("No table found in db")); vers->erase(sz - 1); } else if (ver.m_impl == 0) { ver.m_impl = tab; ver.m_version = tab->m_version; ver.m_status = OK; } else if (ver.m_impl == &f_invalid_table) { ver.m_impl = tab; ver.m_version = tab->m_version; ver.m_status = DROPPED; ver.m_impl->m_status = NdbDictionary::Object::Invalid; } else if(ver.m_impl == &f_altered_table) { ver.m_impl = tab; ver.m_version = tab->m_version; ver.m_status = DROPPED; ver.m_impl->m_status = NdbDictionary::Object::Altered; } else { abort(); } NdbCondition_Broadcast(m_waitForTableCondition); DBUG_RETURN(tab); }
void NDBT_Context::broadcast(){ NdbMutex_Lock(propertyMutexPtr); NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); }