twal.h 1.7 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _TD_WAL_H_
H
modify  
Hongze Cheng 已提交
16 17
#define _TD_WAL_H_

H
hzcheng 已提交
18 19 20
#ifdef __cplusplus
extern "C" {
#endif
H
modify  
Hongze Cheng 已提交
21

陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
22 23 24 25 26 27 28 29 30
#define TAOS_WAL_NOLOG   0
#define TAOS_WAL_WRITE   1
#define TAOS_WAL_FSYNC   2
 
typedef struct {
  int8_t    msgType;
  int8_t    reserved[3];
  int32_t   len;
  uint64_t  version;
31 32
  uint32_t  signature;
  uint32_t  cksum;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
33 34 35
  char      cont[];
} SWalHead;

J
Jeff Tao 已提交
36
typedef struct {
H
hjxilinx 已提交
37
  int8_t    walLevel;  // wal level
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
38
  int32_t   fsyncPeriod; // millisecond
J
Jeff Tao 已提交
39
  int8_t    wals;      // number of WAL files;
J
Jeff Tao 已提交
40
  int8_t    keep;      // keep the wal file when closed
J
Jeff Tao 已提交
41 42
} SWalCfg;

J
Jeff Tao 已提交
43 44 45
typedef void* twalh;  // WAL HANDLE
typedef int (*FWalWrite)(void *ahandle, void *pHead, int type);

J
Jeff Tao 已提交
46
twalh   walOpen(const char *path, const SWalCfg *pCfg);
S
TD-1388  
Shengliang Guan 已提交
47
int     walAlter(twalh pWal, const SWalCfg *pCfg);
J
Jeff Tao 已提交
48 49 50 51 52 53
void    walClose(twalh);
int     walRenew(twalh);
int     walWrite(twalh, SWalHead *);
void    walFsync(twalh);
int     walRestore(twalh, void *pVnode, FWalWrite writeFp);
int     walGetWalFile(twalh, char *name, uint32_t *index);
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
54 55

extern int wDebugFlag;
H
modify  
Hongze Cheng 已提交
56

H
hzcheng 已提交
57 58 59 60 61 62

#ifdef __cplusplus
}
#endif

#endif  // _TD_WAL_H_