1 /* 2 Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef BACKUP_HPP 26 #define BACKUP_HPP 27 28 #include "SignalData.hpp" 29 #include <NodeBitmask.hpp> 30 31 /** 32 * Request to start a backup 33 */ 34 class BackupReq { 35 /** 36 * Sender(s) 37 */ 38 friend class MgmtSrvr; 39 40 /** 41 * Reciver(s) 42 */ 43 friend class Backup; 44 45 friend bool printBACKUP_REQ(FILE *, const Uint32 *, Uint32, Uint16); 46 public: 47 STATIC_CONST( SignalLength = 4 ); 48 STATIC_CONST( WAITCOMPLETED = 0x3 ); 49 STATIC_CONST( USE_UNDO_LOG = 0x4 ); 50 51 private: 52 Uint32 senderData; 53 Uint32 backupDataLen; 54 /* & 0x3 - waitCompleted 55 * & 0x4 - use undo log 56 */ 57 Uint32 flags; 58 Uint32 inputBackupId; 59 }; 60 61 class BackupData { 62 /** 63 * Sender(s) 64 */ 65 friend class BackupMaster; 66 67 /** 68 * Reciver(s) 69 */ 70 friend class Backup; 71 72 friend bool printBACKUP_DATA(FILE *, const Uint32 *, Uint32, Uint16); 73 public: 74 STATIC_CONST( SignalLength = 25 ); 75 76 enum KeyValues { 77 /** 78 * Buffer(s) and stuff 79 */ 80 BufferSize = 1, // In MB 81 BlockSize = 2, // Write in chunks of this (in bytes) 82 MinWrite = 3, // Minimum write as multiple of blocksize 83 MaxWrite = 4, // Maximum write as multiple of blocksize 84 85 // Max throughput 86 // Parallell files 87 88 NoOfTables = 1000, 89 TableName = 1001 // char* 90 }; 91 private: 92 enum RequestType { 93 ClientToMaster = 1, 94 MasterToSlave = 2 95 }; 96 Uint32 requestType; 97 98 union { 99 Uint32 backupPtr; 100 Uint32 senderData; 101 }; 102 Uint32 backupId; 103 104 /** 105 * totalLen = totalLen_offset >> 16 106 * offset = totalLen_offset & 0xFFFF 107 */ 108 Uint32 totalLen_offset; 109 110 /** 111 * Length in this = signal->length() - 3 112 * Sender block ref = signal->senderBlockRef() 113 */ 114 Uint32 backupData[21]; 115 }; 116 117 /** 118 * The request to start a backup was refused 119 */ 120 class BackupRef { 121 /** 122 * Sender(s) 123 */ 124 friend class Backup; 125 126 /** 127 * Reciver(s) 128 */ 129 friend class MgmtSrvr; 130 131 friend bool printBACKUP_REF(FILE *, const Uint32 *, Uint32, Uint16); 132 public: 133 STATIC_CONST( SignalLength = 3 ); 134 135 private: 136 enum ErrorCodes { 137 Undefined = 1300, 138 IAmNotMaster = 1301, 139 OutOfBackupRecord = 1302, 140 OutOfResources = 1303, 141 SequenceFailure = 1304, 142 BackupDefinitionNotImplemented = 1305, 143 CannotBackupDiskless = 1306 144 }; 145 Uint32 senderData; 146 Uint32 errorCode; 147 union { 148 Uint32 masterRef; 149 }; 150 }; 151 152 /** 153 * The backup has started 154 */ 155 class BackupConf { 156 /** 157 * Sender(s) 158 */ 159 friend class Backup; 160 161 /** 162 * Reciver(s) 163 */ 164 friend class MgmtSrvr; 165 166 friend bool printBACKUP_CONF(FILE *, const Uint32 *, Uint32, Uint16); 167 public: 168 STATIC_CONST( SignalLength = 2 + NdbNodeBitmask::Size ); 169 170 private: 171 Uint32 senderData; 172 Uint32 backupId; 173 NdbNodeBitmaskPOD nodes; 174 }; 175 176 /** 177 * A backup has been aborted 178 */ 179 class BackupAbortRep { 180 /** 181 * Sender(s) 182 */ 183 friend class Backup; 184 185 /** 186 * Reciver(s) 187 */ 188 friend class MgmtSrvr; 189 190 friend bool printBACKUP_ABORT_REP(FILE *, const Uint32 *, Uint32, Uint16); 191 public: 192 STATIC_CONST( SignalLength = 3 ); 193 194 private: 195 Uint32 senderData; 196 Uint32 backupId; 197 Uint32 reason; 198 }; 199 200 /** 201 * A backup has been completed 202 */ 203 class BackupCompleteRep { 204 /** 205 * Sender(s) 206 */ 207 friend class Backup; 208 209 /** 210 * Reciver(s) 211 */ 212 friend class MgmtSrvr; 213 214 friend bool printBACKUP_COMPLETE_REP(FILE *, const Uint32 *, Uint32, Uint16); 215 public: 216 STATIC_CONST( SignalLength = 10 + NdbNodeBitmask::Size ); 217 private: 218 Uint32 senderData; 219 Uint32 backupId; 220 Uint32 startGCP; 221 Uint32 stopGCP; 222 Uint32 noOfBytesLow; 223 Uint32 noOfRecordsLow; 224 Uint32 noOfLogBytes; 225 Uint32 noOfLogRecords; 226 NdbNodeBitmaskPOD nodes; 227 Uint32 noOfBytesHigh; 228 Uint32 noOfRecordsHigh; 229 }; 230 231 /** 232 * A master has finished taking-over backup responsiblility 233 */ 234 class BackupNFCompleteRep { 235 friend bool printBACKUP_NF_COMPLETE_REP(FILE*, const Uint32*, Uint32, Uint16); 236 }; 237 238 /** 239 * Abort of backup 240 */ 241 class AbortBackupOrd { 242 /** 243 * Sender / Reciver 244 */ 245 friend class Backup; 246 friend class MgmtSrvr; 247 248 friend bool printABORT_BACKUP_ORD(FILE *, const Uint32 *, Uint32, Uint16); 249 public: 250 STATIC_CONST( SignalLength = 3 ); 251 252 enum RequestType { 253 ClientAbort = 1321, 254 BackupComplete = 1322, 255 BackupFailure = 1323, // General backup failure coordinator -> slave 256 LogBufferFull = 1324, // slave -> coordinator 257 FileOrScanError = 1325, // slave -> coordinator 258 BackupFailureDueToNodeFail = 1326, // slave -> slave 259 OkToClean = 1327 // master -> slave 260 261 ,AbortScan = 1328 262 ,IncompatibleVersions = 1329 263 }; 264 private: 265 Uint32 requestType; 266 Uint32 backupId; 267 union { 268 Uint32 backupPtr; 269 Uint32 senderData; 270 }; 271 }; 272 273 #endif 274