📄 backup.hpp
字号:
DEFINED, // DEFINE_BACKUP_CONF sent in slave, received all in master STARTED, // Creating triggers SCANNING, // Scanning fragments STOPPING, // Closing files CLEANING, // Cleaning resources ABORTING // Aborting backup }; static const Uint32 validSlaveTransitionsCount; static const Uint32 validMasterTransitionsCount; static const State validSlaveTransitions[]; static const State validMasterTransitions[]; class CompoundState { public: CompoundState(Backup & b, const State valid[], Uint32 count, Uint32 _id) : backup(b) , validTransitions(valid), noOfValidTransitions(count), id(_id) { state = INITIAL; abortState = state; } void setState(State s); State getState() const { return state;} State getAbortState() const { return abortState;} void forceState(State s); BlockNumber number() const { return backup.number(); } void progError(int line, int cause, const char * extra) { backup.progError(line, cause, extra); } private: Backup & backup; State state; State abortState; /** When state == ABORTING, this contains the state when the abort started */ const State * validTransitions; const Uint32 noOfValidTransitions; const Uint32 id; }; friend class CompoundState; /** * Backup record * * One record per backup */ struct BackupRecord { BackupRecord(Backup& b, ArrayPool<Page32> & pp, ArrayPool<Table> & tp, ArrayPool<BackupFile> & bp, ArrayPool<TriggerRecord> & trp) : slaveState(b, validSlaveTransitions, validSlaveTransitionsCount,1) , tables(tp), triggers(trp), files(bp), pages(pp) , masterData(b), backup(b) { } Uint32 m_gsn; CompoundState slaveState; Uint32 clientRef; Uint32 clientData; Uint32 flags; Uint32 backupId; Uint32 backupKey[2]; Uint32 masterRef; Uint32 errorCode; NdbNodeBitmask nodes; Uint64 noOfBytes; Uint64 noOfRecords; Uint64 noOfLogBytes; Uint64 noOfLogRecords; Uint32 startGCP; Uint32 currGCP; Uint32 stopGCP; DLList<Table> tables; SLList<TriggerRecord> triggers; SLList<BackupFile> files; Uint32 ctlFilePtr; // Ptr.i to ctl-file Uint32 logFilePtr; // Ptr.i to log-file Uint32 dataFilePtr; // Ptr.i to first data-file Uint32 backupDataLen; // Used for (un)packing backup request Array<Page32> pages; // Used for (un)packing backup request SimpleProperties props;// Used for (un)packing backup request struct MasterData { MasterData(Backup & b) { } MutexHandle2<BACKUP_DEFINE_MUTEX> m_defineBackupMutex; MutexHandle2<DICT_COMMIT_TABLE_MUTEX> m_dictCommitTableMutex; Uint32 gsn; SignalCounter sendCounter; Uint32 errorCode; struct { Uint32 tableId; } createTrig; struct { Uint32 tableId; } dropTrig; struct { Uint32 tableId; } alterTrig; union { struct { Uint32 startBackup; } waitGCP; struct { Uint32 signalNo; Uint32 noOfSignals; Uint32 tablePtr; } startBackup; struct { Uint32 dummy; } stopBackup; }; } masterData; Uint32 nextList; union { Uint32 prevList; Uint32 nextPool; }; void setErrorCode(Uint32 errCode){ if(errorCode == 0) errorCode = errCode; } bool checkError() const { return errorCode != 0; } Backup & backup; BlockNumber number() const { return backup.number(); } void progError(int line, int cause, const char * extra) { backup.progError(line, cause, extra); } }; friend struct BackupRecord; typedef Ptr<BackupRecord> BackupRecordPtr; struct Config { Uint32 m_dataBufferSize; Uint32 m_logBufferSize; Uint32 m_minWriteSize; Uint32 m_maxWriteSize; }; /** * Variables */ Uint32 * c_startOfPages; NodeId c_masterNodeId; SLList<Node> c_nodes; NdbNodeBitmask c_aliveNodes; DLList<BackupRecord> c_backups; Config c_defaults; Uint32 m_diskless; STATIC_CONST(NO_OF_PAGES_META_FILE = 2); /** * Pools */ ArrayPool<Table> c_tablePool; ArrayPool<Attribute> c_attributePool; ArrayPool<BackupRecord> c_backupPool; ArrayPool<BackupFile> c_backupFilePool; ArrayPool<Page32> c_pagePool; ArrayPool<Fragment> c_fragmentPool; ArrayPool<Node> c_nodePool; ArrayPool<TriggerRecord> c_triggerPool; void checkFile(Signal*, BackupFilePtr); void checkScan(Signal*, BackupFilePtr); void fragmentCompleted(Signal*, BackupFilePtr); void backupAllData(Signal* signal, BackupRecordPtr); void getFragmentInfo(Signal*, BackupRecordPtr, TablePtr, Uint32 fragNo); void getFragmentInfoDone(Signal*, BackupRecordPtr); void openFiles(Signal* signal, BackupRecordPtr ptr); void openFilesReply(Signal*, BackupRecordPtr ptr, BackupFilePtr); void closeFiles(Signal*, BackupRecordPtr ptr); void closeFilesDone(Signal*, BackupRecordPtr ptr); void sendDefineBackupReq(Signal *signal, BackupRecordPtr ptr); void defineBackupReply(Signal* signal, BackupRecordPtr ptr, Uint32 nodeId); void createTrigReply(Signal* signal, BackupRecordPtr ptr); void alterTrigReply(Signal* signal, BackupRecordPtr ptr); void startBackupReply(Signal* signal, BackupRecordPtr ptr, Uint32, Uint32); void stopBackupReply(Signal* signal, BackupRecordPtr ptr, Uint32 nodeId); void defineBackupRef(Signal*, BackupRecordPtr, Uint32 errCode = 0); void backupFragmentRef(Signal * signal, BackupFilePtr filePtr); void nextFragment(Signal*, BackupRecordPtr); void sendCreateTrig(Signal*, BackupRecordPtr ptr, TablePtr tabPtr); void createAttributeMask(TablePtr tab, Bitmask<MAXNROFATTRIBUTESINWORDS>&); void sendStartBackup(Signal*, BackupRecordPtr, TablePtr); void sendAlterTrig(Signal*, BackupRecordPtr ptr); void sendDropTrig(Signal*, BackupRecordPtr ptr); void sendDropTrig(Signal* signal, BackupRecordPtr ptr, TablePtr tabPtr); void dropTrigReply(Signal*, BackupRecordPtr ptr); void sendSignalAllWait(BackupRecordPtr ptr, Uint32 gsn, Signal *signal, Uint32 signalLength, bool executeDirect = false); bool haveAllSignals(BackupRecordPtr ptr, Uint32 gsn, Uint32 nodeId); void sendStopBackup(Signal*, BackupRecordPtr ptr); void sendAbortBackupOrd(Signal* signal, BackupRecordPtr ptr, Uint32 errCode); void sendAbortBackupOrdSlave(Signal* signal, BackupRecordPtr ptr, Uint32 errCode); void masterAbort(Signal*, BackupRecordPtr ptr); void masterSendAbortBackup(Signal*, BackupRecordPtr ptr); void slaveAbort(Signal*, BackupRecordPtr ptr); void abortFile(Signal* signal, BackupRecordPtr ptr, BackupFilePtr filePtr); void abortFileHook(Signal* signal, BackupFilePtr filePtr, bool scanDone); bool verifyNodesAlive(BackupRecordPtr, const NdbNodeBitmask& aNodeBitMask); bool checkAbort(BackupRecordPtr ptr); void checkNodeFail(Signal* signal, BackupRecordPtr ptr, NodeId newCoord, Uint32 theFailedNodes[NodeBitmask::Size]); void masterTakeOver(Signal* signal, BackupRecordPtr ptr); NodeId getMasterNodeId() const { return c_masterNodeId; } bool findTable(const BackupRecordPtr &, TablePtr &, Uint32 tableId) const; TablePtr parseTableDescription(Signal*, BackupRecordPtr ptr, Uint32 len); bool insertFileHeader(BackupFormat::FileType, BackupRecord*, BackupFile*); void sendBackupRef(Signal* signal, BackupRecordPtr ptr, Uint32 errorCode); void sendBackupRef(BlockReference ref, Uint32 flags, Signal *signal, Uint32 senderData, Uint32 errorCode); void dumpUsedResources(); void cleanup(Signal*, BackupRecordPtr ptr); void abort_scan(Signal*, BackupRecordPtr ptr); void removeBackup(Signal*, BackupRecordPtr ptr); void sendSTTORRY(Signal*); void createSequence(Signal* signal); void createSequenceReply(Signal*, class UtilSequenceConf *);};inlinevoidBackup::OperationRecord::newRecord(Uint32 * p){ base = p; dst_Length = p; p += 1; dst_Bitmask = p; p += sz_Bitmask; dst_FixedAttribs = p; p += sz_FixedAttribs; dst_VariableData = (BackupFormat::DataFile::VariableData*)p; BitmaskImpl::clear(sz_Bitmask, dst_Bitmask); attrLeft = noOfAttributes; attrSzLeft = attrSzTotal = 0;}inlineUint32 *Backup::OperationRecord::newAttrib(Uint32 offset, Uint32 sz){ attrLeft--; attrSzLeft = sz; dst = dst_FixedAttribs + offset; return dst;}inlinevoidBackup::OperationRecord::nullAttribute(Uint32 offsetNull){ attrLeft --; BitmaskImpl::set(sz_Bitmask, dst_Bitmask, offsetNull);}inlineUint32 *Backup::OperationRecord::newNullable(Uint32 id, Uint32 sz){ attrLeft--; attrSzLeft = sz; dst = &dst_VariableData->Data[0]; dst_VariableData->Sz = htonl(sz); dst_VariableData->Id = htonl(id); dst_VariableData = (BackupFormat::DataFile::VariableData *)(dst + sz); // Clear all bits on newRecord -> dont need to clear this // BitmaskImpl::clear(sz_Bitmask, dst_Bitmask, offsetNull); return dst;}inlineUint32 *Backup::OperationRecord::newVariable(Uint32 id, Uint32 sz){ attrLeft--; attrSzLeft = sz; dst = &dst_VariableData->Data[0]; dst_VariableData->Sz = htonl(sz); dst_VariableData->Id = htonl(id); dst_VariableData = (BackupFormat::DataFile::VariableData *)(dst + sz); return dst;}inlineboolBackup::OperationRecord::finished(){ if(attrLeft != 0 || attrSzLeft != 0){ return false; } opLen += attrSzTotal; opNoDone++; scanStop = dst = (Uint32 *)dst_VariableData; const Uint32 len = (dst - base - 1); * dst_Length = htonl(len); noOfRecords++; return true;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -