1 /* 2 Copyright (c) 2003, 2021, Oracle and/or its affiliates. 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 #define JAM_FILE_ID 101 32 33 34 /** 35 * Request to start a backup 36 */ 37 class BackupReq { 38 /** 39 * Sender(s) 40 */ 41 friend class MgmtSrvr; 42 43 /** 44 * Reciver(s) 45 */ 46 friend class Backup; 47 48 friend bool printBACKUP_REQ(FILE *, const Uint32 *, Uint32, Uint16); 49 public: 50 STATIC_CONST( SignalLength = 4 ); 51 STATIC_CONST( WAITCOMPLETED = 0x3 ); 52 STATIC_CONST( USE_UNDO_LOG = 0x4 ); 53 54 private: 55 Uint32 senderData; 56 Uint32 backupDataLen; 57 /* & 0x3 - waitCompleted 58 * & 0x4 - use undo log 59 */ 60 Uint32 flags; 61 Uint32 inputBackupId; 62 }; 63 64 class BackupData { 65 /** 66 * Sender(s) 67 */ 68 friend class BackupMaster; 69 70 /** 71 * Reciver(s) 72 */ 73 friend class Backup; 74 75 friend bool printBACKUP_DATA(FILE *, const Uint32 *, Uint32, Uint16); 76 public: 77 STATIC_CONST( SignalLength = 25 ); 78 79 enum KeyValues { 80 /** 81 * Buffer(s) and stuff 82 */ 83 BufferSize = 1, // In MB 84 BlockSize = 2, // Write in chunks of this (in bytes) 85 MinWrite = 3, // Minimum write as multiple of blocksize 86 MaxWrite = 4, // Maximum write as multiple of blocksize 87 88 // Max throughput 89 // Parallell files 90 91 NoOfTables = 1000, 92 TableName = 1001 // char* 93 }; 94 private: 95 enum RequestType { 96 ClientToMaster = 1, 97 MasterToSlave = 2 98 }; 99 Uint32 requestType; 100 101 union { 102 Uint32 backupPtr; 103 Uint32 senderData; 104 }; 105 Uint32 backupId; 106 107 /** 108 * totalLen = totalLen_offset >> 16 109 * offset = totalLen_offset & 0xFFFF 110 */ 111 Uint32 totalLen_offset; 112 113 /** 114 * Length in this = signal->length() - 3 115 * Sender block ref = signal->senderBlockRef() 116 */ 117 Uint32 backupData[21]; 118 }; 119 120 /** 121 * The request to start a backup was refused 122 */ 123 class BackupRef { 124 /** 125 * Sender(s) 126 */ 127 friend class Backup; 128 129 /** 130 * Reciver(s) 131 */ 132 friend class MgmtSrvr; 133 134 friend bool printBACKUP_REF(FILE *, const Uint32 *, Uint32, Uint16); 135 public: 136 STATIC_CONST( SignalLength = 3 ); 137 138 private: 139 enum ErrorCodes { 140 Undefined = 1300, 141 IAmNotMaster = 1301, 142 OutOfBackupRecord = 1302, 143 OutOfResources = 1303, 144 SequenceFailure = 1304, 145 BackupDefinitionNotImplemented = 1305, 146 CannotBackupDiskless = 1306 147 }; 148 Uint32 senderData; 149 Uint32 errorCode; 150 union { 151 Uint32 masterRef; 152 }; 153 }; 154 155 /** 156 * The backup has started 157 */ 158 class BackupConf { 159 /** 160 * Sender(s) 161 */ 162 friend class Backup; 163 164 /** 165 * Reciver(s) 166 */ 167 friend class MgmtSrvr; 168 169 friend bool printBACKUP_CONF(FILE *, const Uint32 *, Uint32, Uint16); 170 public: 171 STATIC_CONST( SignalLength = 2 + NdbNodeBitmask::Size ); 172 173 private: 174 Uint32 senderData; 175 Uint32 backupId; 176 NdbNodeBitmaskPOD nodes; 177 }; 178 179 /** 180 * A backup has been aborted 181 */ 182 class BackupAbortRep { 183 /** 184 * Sender(s) 185 */ 186 friend class Backup; 187 188 /** 189 * Reciver(s) 190 */ 191 friend class MgmtSrvr; 192 193 friend bool printBACKUP_ABORT_REP(FILE *, const Uint32 *, Uint32, Uint16); 194 public: 195 STATIC_CONST( SignalLength = 3 ); 196 197 private: 198 Uint32 senderData; 199 Uint32 backupId; 200 Uint32 reason; 201 }; 202 203 /** 204 * A backup has been completed 205 */ 206 class BackupCompleteRep { 207 /** 208 * Sender(s) 209 */ 210 friend class Backup; 211 212 /** 213 * Reciver(s) 214 */ 215 friend class MgmtSrvr; 216 217 friend bool printBACKUP_COMPLETE_REP(FILE *, const Uint32 *, Uint32, Uint16); 218 public: 219 STATIC_CONST( SignalLength = 10 + NdbNodeBitmask::Size ); 220 private: 221 Uint32 senderData; 222 Uint32 backupId; 223 Uint32 startGCP; 224 Uint32 stopGCP; 225 Uint32 noOfBytesLow; 226 Uint32 noOfRecordsLow; 227 Uint32 noOfLogBytes; 228 Uint32 noOfLogRecords; 229 NdbNodeBitmaskPOD nodes; 230 Uint32 noOfBytesHigh; 231 Uint32 noOfRecordsHigh; 232 }; 233 234 /** 235 * A master has finished taking-over backup responsiblility 236 */ 237 class BackupNFCompleteRep { 238 friend bool printBACKUP_NF_COMPLETE_REP(FILE*, const Uint32*, Uint32, Uint16); 239 }; 240 241 /** 242 * Abort of backup 243 */ 244 class AbortBackupOrd { 245 /** 246 * Sender / Reciver 247 */ 248 friend class Backup; 249 friend class MgmtSrvr; 250 251 friend bool printABORT_BACKUP_ORD(FILE *, const Uint32 *, Uint32, Uint16); 252 public: 253 STATIC_CONST( SignalLength = 3 ); 254 255 enum RequestType { 256 ClientAbort = 1321, 257 BackupComplete = 1322, 258 BackupFailure = 1323, // General backup failure coordinator -> slave 259 LogBufferFull = 1324, // slave -> coordinator 260 FileOrScanError = 1325, // slave -> coordinator 261 BackupFailureDueToNodeFail = 1326, // slave -> slave 262 OkToClean = 1327 // master -> slave 263 264 ,AbortScan = 1328 265 ,IncompatibleVersions = 1329 266 }; 267 private: 268 Uint32 requestType; 269 Uint32 backupId; 270 union { 271 Uint32 backupPtr; 272 Uint32 senderData; 273 }; 274 }; 275 276 277 #undef JAM_FILE_ID 278 279 #endif 280