TDengine/include/dnode/vnode/vnode.h

94 lines
2.4 KiB
C
Raw Normal View History

2021-09-22 05:21:07 +00:00
/*
* 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/>.
2021-09-22 12:29:24 +00:00
*/
#ifndef _TD_VNODE_H_
#define _TD_VNODE_H_
2021-11-01 11:49:44 +00:00
#include "os.h"
#include "taosmsg.h"
#include "trpc.h"
2021-09-22 12:29:24 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-11-01 11:49:44 +00:00
typedef struct SVnode SVnode;
typedef struct {
2021-11-05 08:04:02 +00:00
char db[TSDB_FULL_DB_NAME_LEN];
int32_t cacheBlockSize; // MB
int32_t totalBlocks;
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
int32_t minRowsPerFileBlock;
int32_t maxRowsPerFileBlock;
int8_t precision; // time resolution
int8_t compression;
int8_t cacheLastRow;
int8_t update;
int8_t quorum;
int8_t replica;
int8_t selfIndex;
int8_t walLevel;
int32_t fsyncPeriod; // millisecond
2021-11-05 07:42:19 +00:00
SReplica replicas[TSDB_MAX_REPLICA];
2021-11-01 11:49:44 +00:00
} SVnodeCfg;
2021-11-04 06:06:29 +00:00
typedef enum {
VN_MSG_TYPE_WRITE = 1,
VN_MSG_TYPE_APPLY,
VN_MSG_TYPE_SYNC,
VN_MSG_TYPE_QUERY,
VN_MSG_TYPE_FETCH
2021-11-04 10:39:12 +00:00
} EVnMsgType;
2021-11-04 06:06:29 +00:00
2021-11-04 06:18:03 +00:00
typedef struct {
2021-11-04 06:06:29 +00:00
int32_t curNum;
int32_t allocNum;
SRpcMsg rpcMsg[];
2021-11-01 11:49:44 +00:00
} SVnodeMsg;
2021-09-22 12:29:24 +00:00
2021-11-04 06:18:03 +00:00
typedef struct {
void (*SendMsgToDnode)(SEpSet *pEpSet, SRpcMsg *pMsg);
void (*SendMsgToMnode)(SRpcMsg *pMsg);
int32_t (*PutMsgIntoApplyQueue)(int32_t vgId, SVnodeMsg *pMsg);
} SVnodePara;
int32_t vnodeInit(SVnodePara);
2021-11-02 09:46:47 +00:00
void vnodeCleanup();
2021-11-01 11:49:44 +00:00
SVnode *vnodeOpen(int32_t vgId, const char *path);
void vnodeClose(SVnode *pVnode);
int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg);
SVnode *vnodeCreate(int32_t vgId, const char *path, const SVnodeCfg *pCfg);
2021-11-04 10:38:07 +00:00
void vnodeDrop(SVnode *pVnode);
2021-11-01 11:49:44 +00:00
int32_t vnodeCompact(SVnode *pVnode);
int32_t vnodeSync(SVnode *pVnode);
2021-09-22 12:29:24 +00:00
2021-11-04 10:38:07 +00:00
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
2021-11-04 06:06:29 +00:00
SVnodeMsg *vnodeInitMsg(int32_t msgNum);
int32_t vnodeAppendMsg(SVnodeMsg *pMsg, SRpcMsg *pRpcMsg);
void vnodeCleanupMsg(SVnodeMsg *pMsg);
2021-11-04 10:39:12 +00:00
void vnodeProcessMsg(SVnode *pVnode, SVnodeMsg *pMsg, EVnMsgType msgType);
2021-09-29 11:40:40 +00:00
2021-09-22 12:29:24 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TD_VNODE_H_*/