MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
log_handler.h
1/* Copyright (c) 2021-2022 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See 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
29class LogReplayer;
30class LogEntry;
31
40{
41public:
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
101private:
106 virtual RC _append(LSN &lsn, LogModule module, vector<char> &&data) = 0;
107};
描述一条日志
Definition: log_entry.h:44
对外提供服务的CLog模块
Definition: log_handler.h:40
virtual RC _append(LSN &lsn, LogModule module, vector< char > &&data)=0
写入一条日志
virtual RC await_termination()=0
等待日志模块停止
virtual RC iterate(function< RC(LogEntry &)> consumer, LSN start_lsn)=0
迭代日志
virtual RC wait_lsn(LSN lsn)=0
等待某个LSN的日志被刷新到磁盘
virtual RC stop()=0
停止日志模块
virtual RC replay(LogReplayer &replayer, LSN start_lsn)=0
回放日志
virtual RC init(const char *path)=0
初始化日志模块
virtual RC append(LSN &lsn, LogModule::Id module, span< const char > data)
写入一条日志
Definition: log_handler.cpp:22
virtual RC start()=0
启动日志模块
日志模块
Definition: log_module.h:24
Id
Definition: log_module.h:27
日志回放接口类
Definition: log_replayer.h:26