twal.h 1.8 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

S
Shengliang Guan 已提交
22 23 24 25 26
typedef enum {
  TAOS_WAL_NOLOG = 0,
  TAOS_WAL_WRITE = 1,
  TAOS_WAL_FSYNC = 2
} EWalType;
27

S
Shengliang Guan 已提交
28 29 30 31 32
typedef enum {
  TAOS_WAL_NOT_KEEP = 0,
  TAOS_WAL_KEEP = 1
} EWalKeep;

陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
33
typedef struct {
34
  int8_t   msgType;
S
Shengliang Guan 已提交
35 36
  int8_t   sver;
  int8_t   reserved[2];
37 38 39 40 41
  int32_t  len;
  uint64_t version;
  uint32_t signature;
  uint32_t cksum;
  char     cont[];
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
42 43
} SWalHead;

J
Jeff Tao 已提交
44
typedef struct {
S
Shengliang Guan 已提交
45 46 47 48
  int32_t  vgId;
  int32_t  fsyncPeriod;  // millisecond
  EWalType walLevel;     // wal level
  EWalKeep keep;         // keep the wal file when closed
J
Jeff Tao 已提交
49 50
} SWalCfg;

S
TD-1918  
Shengliang Guan 已提交
51 52
typedef void *  twalh;  // WAL HANDLE
typedef int32_t FWalWrite(void *ahandle, void *pHead, int32_t qtype, void *pMsg);
J
Jeff Tao 已提交
53

S
Shengliang Guan 已提交
54 55 56 57
int32_t walInit();
void    walCleanUp();

twalh   walOpen(char *path, SWalCfg *pCfg);
S
TD-1846  
Shengliang Guan 已提交
58
int32_t walAlter(twalh pWal, SWalCfg *pCfg);
S
TD-1894  
Shengliang Guan 已提交
59
void    walStop(twalh);
J
Jeff Tao 已提交
60
void    walClose(twalh);
S
TD-1846  
Shengliang Guan 已提交
61
int32_t walRenew(twalh);
S
TD-1949  
Shengliang Guan 已提交
62
void    walRemoveOldFiles(twalh);
S
TD-1846  
Shengliang Guan 已提交
63
int32_t walWrite(twalh, SWalHead *);
S
TD-1948  
Shengliang Guan 已提交
64
void    walFsync(twalh, bool forceFsync);
S
TD-1846  
Shengliang Guan 已提交
65 66
int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp);
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId);
67
uint64_t walGetVersion(twalh);
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
68

H
hzcheng 已提交
69 70 71 72 73
#ifdef __cplusplus
}
#endif

#endif  // _TD_WAL_H_