📄 simulatedblock.hpp
字号:
* @return length */ Uint32 xfrm_key(Uint32 tab, const Uint32* src, Uint32 *dst, Uint32 dstSize, Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX]) const; Uint32 xfrm_attr(Uint32 attrDesc, CHARSET_INFO* cs, const Uint32* src, Uint32 & srcPos, Uint32* dst, Uint32 & dstPos, Uint32 dstSize) const; /** * */ Uint32 create_distr_key(Uint32 tableId, Uint32 *data, const Uint32 keyPaLen[MAX_ATTRIBUTES_IN_INDEX])const; private: NewVARIABLE* NewVarRef; /* New Base Address Table for block */ Uint16 theBATSize; /* # entries in BAT */ /** * Node state */ NodeState theNodeState; void execNDB_TAMPER(Signal * signal); void execNODE_STATE_REP(Signal* signal); void execCHANGE_NODE_STATE_REQ(Signal* signal); void execSIGNAL_DROPPED_REP(Signal* signal); void execCONTINUE_FRAGMENTED(Signal* signal); Uint32 c_fragmentIdCounter; ArrayPool<FragmentInfo> c_fragmentInfoPool; DLHashTable<FragmentInfo> c_fragmentInfoHash; bool c_fragSenderRunning; ArrayPool<FragmentSendInfo> c_fragmentSendPool; DLList<FragmentSendInfo> c_linearFragmentSendList; DLList<FragmentSendInfo> c_segmentedFragmentSendList; public: class MutexManager { friend class Mutex; friend class SimulatedBlock; friend class DbUtil; public: MutexManager(class SimulatedBlock &); bool setSize(Uint32 maxNoOfActiveMutexes); Uint32 getSize() const ; // Get maxNoOfActiveMutexes private: /** * core interface */ struct ActiveMutex { Uint32 m_gsn; // state Uint32 m_mutexId; Uint32 m_mutexKey; Callback m_callback; union { Uint32 nextPool; Uint32 nextList; }; Uint32 prevList; }; typedef Ptr<ActiveMutex> ActiveMutexPtr; bool seize(ActiveMutexPtr& ptr); void release(Uint32 activeMutexPtrI); void getPtr(ActiveMutexPtr& ptr); void create(Signal*, ActiveMutexPtr&); void destroy(Signal*, ActiveMutexPtr&); void lock(Signal*, ActiveMutexPtr&); void trylock(Signal*, ActiveMutexPtr&); void unlock(Signal*, ActiveMutexPtr&); private: void execUTIL_CREATE_LOCK_REF(Signal* signal); void execUTIL_CREATE_LOCK_CONF(Signal* signal); void execUTIL_DESTORY_LOCK_REF(Signal* signal); void execUTIL_DESTORY_LOCK_CONF(Signal* signal); void execUTIL_LOCK_REF(Signal* signal); void execUTIL_LOCK_CONF(Signal* signal); void execUTIL_UNLOCK_REF(Signal* signal); void execUTIL_UNLOCK_CONF(Signal* signal); SimulatedBlock & m_block; ArrayPool<ActiveMutex> m_mutexPool; DLList<ActiveMutex> m_activeMutexes; BlockReference reference() const; void progError(int line, int err_code, const char* extra = 0); }; friend class MutexManager; MutexManager c_mutexMgr; void ignoreMutexUnlockCallback(Signal* signal, Uint32 ptrI, Uint32 retVal); SafeCounterManager c_counterMgr;private: void execUTIL_CREATE_LOCK_REF(Signal* signal); void execUTIL_CREATE_LOCK_CONF(Signal* signal); void execUTIL_DESTORY_LOCK_REF(Signal* signal); void execUTIL_DESTORY_LOCK_CONF(Signal* signal); void execUTIL_LOCK_REF(Signal* signal); void execUTIL_LOCK_CONF(Signal* signal); void execUTIL_UNLOCK_REF(Signal* signal); void execUTIL_UNLOCK_CONF(Signal* signal);protected: void execUPGRADE(Signal* signal); void fsRefError(Signal* signal, Uint32 line, const char *msg); void execFSWRITEREF(Signal* signal); void execFSREADREF(Signal* signal); void execFSOPENREF(Signal* signal); void execFSCLOSEREF(Signal* signal); void execFSREMOVEREF(Signal* signal); void execFSSYNCREF(Signal* signal); void execFSAPPENDREF(Signal* signal); // Variable for storing inserted errors, see pc.H ERROR_INSERT_VARIABLE;private: // Metadata common part shared by block instances MetaData::Common* c_ptrMetaDataCommon;public: void setMetaDataCommon(MetaData::Common* ptr) { c_ptrMetaDataCommon = ptr; } MetaData::Common* getMetaDataCommon() { return c_ptrMetaDataCommon; }#ifdef VM_TRACE_TIMEpublic: void clearTimes(); void printTimes(FILE * output); void addTime(Uint32 gsn, Uint64 time); void subTime(Uint32 gsn, Uint64 time); struct TimeTrace { Uint32 cnt; Uint64 sum, sub; } m_timeTrace[MAX_GSN+1]; Uint32 m_currentGsn;#endif#ifdef VM_TRACE Ptr<void> **m_global_variables; void clear_global_variables(); void init_globals_list(void ** tmp, size_t cnt);#endif};inline void SimulatedBlock::executeFunction(GlobalSignalNumber gsn, Signal* signal){ ExecFunction f = theExecArray[gsn]; if(gsn <= MAX_GSN && f != 0){#ifdef VM_TRACE clear_global_variables();#endif (this->*f)(signal); return; } /** * This point only passed if an error has occurred */ char errorMsg[255]; if (!(gsn <= MAX_GSN)) { BaseString::snprintf(errorMsg, 255, "Illegal signal received (GSN %d too high)", gsn); ERROR_SET(fatal, NDBD_EXIT_PRGERR, errorMsg, errorMsg); } if (!(theExecArray[gsn] != 0)) { BaseString::snprintf(errorMsg, 255, "Illegal signal received (GSN %d not added)", gsn); ERROR_SET(fatal, NDBD_EXIT_PRGERR, errorMsg, errorMsg); } ndbrequire(false);}inlinevoidSimulatedBlock::execute(Signal* signal, Callback & c, Uint32 returnCode){ CallbackFunction fun = c.m_callbackFunction; ndbrequire(fun != 0); c.m_callbackFunction = NULL; (this->*fun)(signal, c.m_callbackData, returnCode);}inline BlockNumberSimulatedBlock::number() const { return theNumber;}inlineBlockReferenceSimulatedBlock::reference() const { return theReference;}inlineNodeIdSimulatedBlock::getOwnNodeId() const { return theNodeId;}inlineBlockReferenceSimulatedBlock::calcTcBlockRef (NodeId aNodeId){ return numberToRef(DBTC, aNodeId);}inlineBlockReferenceSimulatedBlock::calcLqhBlockRef (NodeId aNodeId){return numberToRef(DBLQH, aNodeId);}inlineBlockReferenceSimulatedBlock::calcAccBlockRef (NodeId aNodeId){ return numberToRef(DBACC, aNodeId);}inlineBlockReferenceSimulatedBlock::calcTupBlockRef (NodeId aNodeId){ return numberToRef(DBTUP, aNodeId);}inlineBlockReferenceSimulatedBlock::calcTuxBlockRef (NodeId aNodeId){ return numberToRef(DBTUX, aNodeId);}inlineBlockReferenceSimulatedBlock::calcDihBlockRef (NodeId aNodeId){ return numberToRef(DBDIH, aNodeId);}inlineBlockReferenceSimulatedBlock::calcDictBlockRef (NodeId aNodeId){ return numberToRef(DBDICT, aNodeId);}inlineBlockReferenceSimulatedBlock::calcQmgrBlockRef (NodeId aNodeId){ return numberToRef(QMGR, aNodeId);}inlineBlockReferenceSimulatedBlock::calcNdbCntrBlockRef (NodeId aNodeId){ return numberToRef(NDBCNTR, aNodeId);}inlineBlockReferenceSimulatedBlock::calcTrixBlockRef (NodeId aNodeId){ return numberToRef(TRIX, aNodeId);}inlineBlockReferenceSimulatedBlock::calcBackupBlockRef (NodeId aNodeId){ return numberToRef(BACKUP, aNodeId);}inlineBlockReferenceSimulatedBlock::calcSumaBlockRef (NodeId aNodeId){ return numberToRef(SUMA, aNodeId);}inlineBlockReferenceSimulatedBlock::calcApiClusterMgrBlockRef (NodeId aNodeId){ return numberToRef(API_CLUSTERMGR, aNodeId);}inlineconst NodeState &SimulatedBlock::getNodeState() const { return theNodeState;}inlineconst NodeInfo &SimulatedBlock::getNodeInfo(NodeId nodeId) const { ndbrequire(nodeId > 0 && nodeId < MAX_NODES); return globalData.m_nodeInfo[nodeId];}inlinevoidSimulatedBlock::EXECUTE_DIRECT(Uint32 block, Uint32 gsn, Signal* signal, Uint32 len){ signal->setLength(len);#ifdef VM_TRACE if(globalData.testOn){ signal->header.theVerId_signalNumber = gsn; signal->header.theReceiversBlockNumber = block; signal->header.theSendersBlockRef = reference(); globalSignalLoggers.executeDirect(signal->header, 0, // in &signal->theData[0], globalData.ownId); }#endif SimulatedBlock* b = globalData.getBlock(block);#ifdef VM_TRACE_TIME Uint32 us1, us2; Uint64 ms1, ms2; NdbTick_CurrentMicrosecond(&ms1, &us1); Uint32 tGsn = m_currentGsn; b->m_currentGsn = gsn;#endif b->executeFunction(gsn, signal);#ifdef VM_TRACE_TIME NdbTick_CurrentMicrosecond(&ms2, &us2); Uint64 diff = ms2; diff -= ms1; diff *= 1000000; diff += us2; diff -= us1; b->addTime(gsn, diff); m_currentGsn = tGsn; subTime(tGsn, diff);#endif#ifdef VM_TRACE if(globalData.testOn){ signal->header.theVerId_signalNumber = gsn; signal->header.theReceiversBlockNumber = block; signal->header.theSendersBlockRef = reference(); globalSignalLoggers.executeDirect(signal->header, 1, // out &signal->theData[0], globalData.ownId); }#endif}#ifdef VM_TRACE_TIMEinlinevoidSimulatedBlock::addTime(Uint32 gsn, Uint64 time){ m_timeTrace[gsn].cnt ++; m_timeTrace[gsn].sum += time;}inlinevoidSimulatedBlock::subTime(Uint32 gsn, Uint64 time){ m_timeTrace[gsn].sub += time;}#endif/** * Defines for backward compatiblility */#define BLOCK_DEFINES(BLOCK) \ typedef void (BLOCK::* ExecSignalLocal) (Signal* signal); \ typedef void (BLOCK::* BlockCallback)(Signal*, Uint32 callb, Uint32 retCode); \ inline CallbackFunction safe_cast(BlockCallback f){ \ return static_cast<CallbackFunction>(f); \ } \public:\private: \ void addRecSignal(GlobalSignalNumber gsn, ExecSignalLocal f, bool force = false)#define BLOCK_CONSTRUCTOR(BLOCK)#define BLOCK_FUNCTIONS(BLOCK) \void \BLOCK::addRecSignal(GlobalSignalNumber gsn, ExecSignalLocal f, bool force){ \ addRecSignalImpl(gsn, (ExecFunction)f, force);\}#include "Mutex.hpp"#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -