| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2017, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/arch0log.h |
| 29 |
Innodb interface for log archive |
| 30 |
|
| 31 |
*******************************************************/ |
| 32 |
|
| 33 |
#ifndef ARCH_LOG_INCLUDE |
| 34 |
#define ARCH_LOG_INCLUDE |
| 35 |
|
| 36 |
#include "arch0arch.h" |
| 37 |
|
| 38 |
/** File Node Iterator callback |
| 39 |
@param[in] file_name NULL terminated file name |
| 40 |
@param[in] file_size size of file in bytes |
| 41 |
@param[in] read_offset offset to start reading from |
| 42 |
@param[in] ctx context passed by caller |
| 43 |
@return error code */ |
| 44 |
using Log_Arch_Cbk = int(char *file_name, uint64_t file_size, |
| 45 |
uint64_t read_offset, void *ctx); |
| 46 |
|
| 47 |
/** Redo Log archiver client context */ |
| 48 |
class Log_Arch_Client_Ctx { |
| 49 |
public: |
| 50 |
/** Constructor: Initialize elementsf */ |
| 51 |
Log_Arch_Client_Ctx() |
| 52 |
: m_state(ARCH_CLIENT_STATE_INIT), |
| 53 |
m_group(nullptr), |
| 54 |
m_begin_lsn(LSN_MAX), |
| 55 |
m_end_lsn(LSN_MAX) {} |
| 56 |
|
| 57 |
/** Get redo file size for archived log file |
| 58 |
@return size of file in bytes */ |
| 59 |
os_offset_t get_archived_file_size() const; |
| 60 |
|
| 61 |
/** Get redo header and trailer size |
| 62 |
@param[out] header_sz redo header size |
| 63 |
@param[out] trailer_sz redo trailer size */ |
| 64 |
void get_header_size(uint &header_sz, uint &trailer_sz) const; |
| 65 |
|
| 66 |
/** Start redo log archiving |
| 67 |
@param[out] header buffer for redo header (caller must allocate) |
| 68 |
@param[in] len buffer length |
| 69 |
@return error code */ |
| 70 |
int start(byte *header, uint len); |
| 71 |
|
| 72 |
/** Stop redo log archiving. Exact trailer length is returned as out |
| 73 |
parameter which could be less than the redo block size. |
| 74 |
@param[out] trailer redo trailer. Caller must allocate buffer. |
| 75 |
@param[in,out] len trailer length |
| 76 |
@param[out] offset trailer block offset |
| 77 |
@return error code */ |
| 78 |
int stop(byte *trailer, uint32_t &len, uint64_t &offset); |
| 79 |
|
| 80 |
/** Get archived data file details |
| 81 |
@param[in] cbk_func callback called for each file |
| 82 |
@param[in] ctx callback function context |
| 83 |
@return error code */ |
| 84 |
int get_files(Log_Arch_Cbk *cbk_func, void *ctx); |
| 85 |
|
| 86 |
/** Release archived data so that system can purge it */ |
| 87 |
void release(); |
| 88 |
|
| 89 |
private: |
| 90 |
/** Archiver client state */ |
| 91 |
Arch_Client_State m_state; |
| 92 |
|
| 93 |
/** Archive group the client is attached to */ |
| 94 |
Arch_Group *m_group; |
| 95 |
|
| 96 |
/** Start LSN for archived data */ |
| 97 |
lsn_t m_begin_lsn; |
| 98 |
|
| 99 |
/** Stop LSN for archived data */ |
| 100 |
lsn_t m_end_lsn; |
| 101 |
}; |
| 102 |
|
| 103 |
#endif /* ARCH_LOG_INCLUDE */ |