MiniOB
1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
src
observer
storage
clog
log_handler.h
1
/* Copyright (c) 2021-2022 OceanBase and/or its affiliates. All rights reserved.
2
miniob is licensed under Mulan PSL v2.
3
You can use this software according to the terms and conditions of the Mulan PSL v2.
4
You may obtain a copy of Mulan PSL v2 at:
5
http://license.coscl.org.cn/MulanPSL2
6
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9
See the Mulan PSL v2 for more details. */
10
11
//
12
// Created by wangyunlai on 2024/01/30
13
//
14
15
#pragma once
16
17
#include "common/sys/rc.h"
18
#include "common/types.h"
19
#include "common/lang/functional.h"
20
#include "common/lang/memory.h"
21
#include "common/lang/span.h"
22
#include "common/lang/vector.h"
23
#include "storage/clog/log_module.h"
24
29
class
LogReplayer
;
30
class
LogEntry
;
31
39
class
LogHandler
40
{
41
public
:
42
LogHandler
() =
default
;
43
virtual
~LogHandler
() =
default
;
44
50
virtual
RC
init
(
const
char
*path) = 0;
51
55
virtual
RC
start
() = 0;
56
60
virtual
RC
stop
() = 0;
61
65
virtual
RC
await_termination
() = 0;
66
72
virtual
RC
replay
(
LogReplayer
&replayer, LSN start_lsn) = 0;
73
79
virtual
RC
iterate
(function<RC(
LogEntry
&)> consumer, LSN start_lsn) = 0;
80
88
virtual
RC
append
(LSN &lsn,
LogModule::Id
module, span<const char> data);
89
virtual
RC
append
(LSN &lsn,
LogModule::Id
module, vector<char> &&data);
90
95
virtual
RC
wait_lsn
(LSN lsn) = 0;
96
97
virtual
LSN current_lsn()
const
= 0;
98
99
static
RC create(
const
char
*name,
LogHandler
*&handler);
100
101
private
:
106
virtual
RC
_append
(LSN &lsn,
LogModule
module, vector<char> &&data) = 0;
107
};
LogEntry
描述一条日志
Definition:
log_entry.h:44
LogHandler
对外提供服务的CLog模块
Definition:
log_handler.h:40
LogHandler::_append
virtual RC _append(LSN &lsn, LogModule module, vector< char > &&data)=0
写入一条日志
LogHandler::await_termination
virtual RC await_termination()=0
等待日志模块停止
LogHandler::iterate
virtual RC iterate(function< RC(LogEntry &)> consumer, LSN start_lsn)=0
迭代日志
LogHandler::wait_lsn
virtual RC wait_lsn(LSN lsn)=0
等待某个LSN的日志被刷新到磁盘
LogHandler::stop
virtual RC stop()=0
停止日志模块
LogHandler::replay
virtual RC replay(LogReplayer &replayer, LSN start_lsn)=0
回放日志
LogHandler::init
virtual RC init(const char *path)=0
初始化日志模块
LogHandler::append
virtual RC append(LSN &lsn, LogModule::Id module, span< const char > data)
写入一条日志
Definition:
log_handler.cpp:22
LogHandler::start
virtual RC start()=0
启动日志模块
LogModule
日志模块
Definition:
log_module.h:24
LogModule::Id
Id
Definition:
log_module.h:27
LogReplayer
日志回放接口类
Definition:
log_replayer.h:26
制作者
1.9.5