📄 backup.hpp
字号:
/* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef BACKUP_H#define BACKUP_H#include <ndb_limits.h>#include <SimulatedBlock.hpp>#include "FsBuffer.hpp"#include "BackupFormat.hpp"#include <NodeBitmask.hpp>#include <SimpleProperties.hpp>#include <SLList.hpp>#include <ArrayList.hpp>#include <SignalCounter.hpp>#include <blocks/mutexes.hpp>#include <NdbTCP.h>/** * Backup - This block manages database backup and restore */class Backup : public SimulatedBlock{public: Backup(const Configuration & conf); virtual ~Backup(); BLOCK_DEFINES(Backup); protected: void execSTTOR(Signal* signal); void execREAD_CONFIG_REQ(Signal* signal); void execDUMP_STATE_ORD(Signal* signal); void execREAD_NODESCONF(Signal* signal); void execNODE_FAILREP(Signal* signal); void execINCL_NODEREQ(Signal* signal); void execCONTINUEB(Signal* signal); /** * Testing */ void execBACKUP_REF(Signal* signal); void execBACKUP_CONF(Signal* signal); void execBACKUP_ABORT_REP(Signal* signal); void execBACKUP_COMPLETE_REP(Signal* signal); /** * Signals sent from master */ void execDEFINE_BACKUP_REQ(Signal* signal); void execBACKUP_DATA(Signal* signal); void execSTART_BACKUP_REQ(Signal* signal); void execBACKUP_FRAGMENT_REQ(Signal* signal); void execSTOP_BACKUP_REQ(Signal* signal); void execBACKUP_STATUS_REQ(Signal* signal); void execABORT_BACKUP_ORD(Signal* signal); /** * The actual scan */ void execSCAN_HBREP(Signal* signal); void execTRANSID_AI(Signal* signal); void execSCAN_FRAGREF(Signal* signal); void execSCAN_FRAGCONF(Signal* signal); /** * Trigger logging */ void execBACKUP_TRIG_REQ(Signal* signal); void execTRIG_ATTRINFO(Signal* signal); void execFIRE_TRIG_ORD(Signal* signal); /** * DICT signals */ void execLIST_TABLES_CONF(Signal* signal); void execGET_TABINFOREF(Signal* signal); void execGET_TABINFO_CONF(Signal* signal); void execCREATE_TRIG_REF(Signal* signal); void execCREATE_TRIG_CONF(Signal* signal); void execALTER_TRIG_REF(Signal* signal); void execALTER_TRIG_CONF(Signal* signal); void execDROP_TRIG_REF(Signal* signal); void execDROP_TRIG_CONF(Signal* signal); /** * DIH signals */ void execDI_FCOUNTCONF(Signal* signal); void execDIGETPRIMCONF(Signal* signal); /** * FS signals */ void execFSOPENREF(Signal* signal); void execFSOPENCONF(Signal* signal); void execFSCLOSEREF(Signal* signal); void execFSCLOSECONF(Signal* signal); void execFSAPPENDREF(Signal* signal); void execFSAPPENDCONF(Signal* signal); void execFSREMOVEREF(Signal* signal); void execFSREMOVECONF(Signal* signal); /** * Master functinallity */ void execBACKUP_REQ(Signal* signal); void execABORT_BACKUP_REQ(Signal* signal); void execDEFINE_BACKUP_REF(Signal* signal); void execDEFINE_BACKUP_CONF(Signal* signal); void execSTART_BACKUP_REF(Signal* signal); void execSTART_BACKUP_CONF(Signal* signal); void execBACKUP_FRAGMENT_REF(Signal* signal); void execBACKUP_FRAGMENT_CONF(Signal* signal); void execSTOP_BACKUP_REF(Signal* signal); void execSTOP_BACKUP_CONF(Signal* signal); void execBACKUP_STATUS_CONF(Signal* signal); void execUTIL_SEQUENCE_REF(Signal* signal); void execUTIL_SEQUENCE_CONF(Signal* signal); void execWAIT_GCP_REF(Signal* signal); void execWAIT_GCP_CONF(Signal* signal); private: void defineBackupMutex_locked(Signal* signal, Uint32 ptrI,Uint32 retVal); void dictCommitTableMutex_locked(Signal* signal, Uint32 ptrI,Uint32 retVal);public: struct Node { Uint32 nodeId; Uint32 alive; Uint32 nextList; union { Uint32 prevList; Uint32 nextPool; }; }; typedef Ptr<Node> NodePtr;#define BACKUP_WORDS_PER_PAGE 8191 struct Page32 { Uint32 data[BACKUP_WORDS_PER_PAGE]; Uint32 nextPool; }; typedef Ptr<Page32> Page32Ptr; struct Attribute { struct Data { Uint8 nullable; Uint8 fixed; Uint8 unused; Uint8 unused2; Uint32 sz32; // No of 32 bit words Uint32 offset; // Relative DataFixedAttributes/DataFixedKeys Uint32 offsetNull; // In NullBitmask } data; Uint32 nextPool; }; typedef Ptr<Attribute> AttributePtr; struct Fragment { Uint32 tableId; Uint32 node; Uint16 scanned; // 0 = not scanned x = scanned by node x Uint16 scanning; // 0 = not scanning x = scanning on node x Uint32 nextPool; }; typedef Ptr<Fragment> FragmentPtr; struct Table { Table(ArrayPool<Attribute> &, ArrayPool<Fragment> &); Uint32 tableId; Uint32 schemaVersion; Uint32 tableType; Uint32 noOfNull; Uint32 noOfAttributes; Uint32 noOfVariable; Uint32 sz_FixedAttributes; Uint32 triggerIds[3]; bool triggerAllocated[3]; Array<Attribute> attributes; Array<Fragment> fragments; Uint32 nextList; union { Uint32 nextPool; Uint32 prevList; }; }; typedef Ptr<Table> TablePtr; struct OperationRecord { public: OperationRecord(Backup & b) : backup(b) {} /** * Once per table */ void init(const TablePtr & ptr); /** * Once per fragment */ bool newFragment(Uint32 tableId, Uint32 fragNo); bool fragComplete(Uint32 tableId, Uint32 fragNo); /** * Once per scan frag (next) req/conf */ bool newScan(); bool scanConf(Uint32 noOfOps, Uint32 opLen); bool closeScan(); /** * Per record */ void newRecord(Uint32 * base); bool finished(); /** * Per attribute */ void nullAttribute(Uint32 nullOffset); Uint32 * newNullable(Uint32 attrId, Uint32 sz); Uint32 * newAttrib(Uint32 offset, Uint32 sz); Uint32 * newVariable(Uint32 id, Uint32 sz); private: Uint32* base; Uint32* dst_Length; Uint32* dst_Bitmask; Uint32* dst_FixedAttribs; BackupFormat::DataFile::VariableData* dst_VariableData; Uint32 noOfAttributes; // No of Attributes Uint32 attrLeft; // No of attributes left Uint32 opNoDone; Uint32 opNoConf; Uint32 opLen; public: Uint32* dst; Uint32 attrSzLeft; // No of words missing for current attribute Uint32 attrSzTotal; // No of AI words received Uint32 tablePtr; // Ptr.i to current table FsBuffer dataBuffer; Uint32 noOfRecords; Uint32 noOfBytes; Uint32 maxRecordSize; private: Uint32* scanStart; Uint32* scanStop; /** * sizes of part */ Uint32 sz_Bitmask; Uint32 sz_FixedAttribs; public: union { Uint32 nextPool; Uint32 nextList; }; Uint32 prevList; private: Backup & backup; BlockNumber number() const { return backup.number(); } void progError(int line, int cause, const char * extra) { backup.progError(line, cause, extra); } }; friend struct OperationRecord; struct TriggerRecord { TriggerRecord() { event = ~0;} OperationRecord * operation; BackupFormat::LogFile::LogEntry * logEntry; Uint32 maxRecordSize; Uint32 tableId; Uint32 tab_ptr_i; Uint32 event; Uint32 backupPtr; Uint32 errorCode; union { Uint32 nextPool; Uint32 nextList; }; }; typedef Ptr<TriggerRecord> TriggerPtr; /** * BackupFile - At least 3 per backup */ struct BackupFile { BackupFile(Backup & backup, ArrayPool<Page32> & pp) : operation(backup), pages(pp) {} Uint32 backupPtr; // Pointer to backup record Uint32 tableId; Uint32 fragmentNo; Uint32 filePointer; Uint32 errorCode; BackupFormat::FileType fileType; OperationRecord operation; Array<Page32> pages; Uint32 nextList; union { Uint32 prevList; Uint32 nextPool; }; Uint8 fileOpened; Uint8 fileRunning; Uint8 fileClosing; Uint8 scanRunning; }; typedef Ptr<BackupFile> BackupFilePtr; /** * State for BackupRecord */ enum State { INITIAL, DEFINING, // Defining backup content and parameters
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -