vnodeDef.h 2.0 KB
Newer Older
H
save  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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_VNODE_DEF_H_
#define _TD_VNODE_DEF_H_

H
refact  
Hongze Cheng 已提交
19
#include "mallocator.h"
H
Hongze Cheng 已提交
20
// #include "sync.h"
H
more  
Hongze Cheng 已提交
21
#include "tcoding.h"
H
Hongze Cheng 已提交
22
#include "tlist.h"
H
refact  
Hongze Cheng 已提交
23
#include "tlockfree.h"
H
Hongze Cheng 已提交
24
#include "tmacro.h"
H
refact  
Hongze Cheng 已提交
25
#include "wal.h"
H
Hongze Cheng 已提交
26
#include "tfs.h"
H
refact  
Hongze Cheng 已提交
27

H
save  
Hongze Cheng 已提交
28
#include "vnode.h"
H
Hongze Cheng 已提交
29

H
more  
Hongze Cheng 已提交
30
#include "vnodeBufferPool.h"
H
more  
Hongze Cheng 已提交
31
#include "vnodeCfg.h"
H
more  
Hongze Cheng 已提交
32
#include "vnodeCommit.h"
H
more  
Hongze Cheng 已提交
33
#include "vnodeFS.h"
H
more  
Hongze Cheng 已提交
34
#include "vnodeMemAllocator.h"
H
Hongze Cheng 已提交
35
#include "vnodeQuery.h"
H
more  
Hongze Cheng 已提交
36
#include "vnodeRequest.h"
H
more  
Hongze Cheng 已提交
37
#include "vnodeStateMgr.h"
H
refact  
Hongze Cheng 已提交
38
#include "vnodeSync.h"
H
save  
Hongze Cheng 已提交
39 40 41 42 43

#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
typedef struct SVnodeTask {
  TD_DLIST_NODE(SVnodeTask);
  void* arg;
  int (*execute)(void*);
} SVnodeTask;

typedef struct SVnodeMgr {
  td_mode_flag_t vnodeInitFlag;
  // For commit
  bool            stop;
  uint16_t        nthreads;
  pthread_t*      threads;
  pthread_mutex_t mutex;
  pthread_cond_t  hasTask;
  TD_DLIST(SVnodeTask) queue;
  // For vnode Mgmt
S
Shengliang Guan 已提交
60 61
  SDnode*           pDnode;
  PutReqToVQueryQFp putReqToVQueryQFp;
H
Hongze Cheng 已提交
62 63 64 65
} SVnodeMgr;

extern SVnodeMgr vnodeMgr;

H
save  
Hongze Cheng 已提交
66
struct SVnode {
H
Hongze Cheng 已提交
67
  int32_t     vgId;
H
refact  
Hongze Cheng 已提交
68 69 70 71 72 73 74 75 76 77
  char*       path;
  SVnodeCfg   config;
  SVState     state;
  SVBufPool*  pBufPool;
  SMeta*      pMeta;
  STsdb*      pTsdb;
  STQ*        pTq;
  SWal*       pWal;
  SVnodeSync* pSync;
  SVnodeFS*   pFs;
H
more  
Hongze Cheng 已提交
78
  tsem_t      canCommit;
D
dapan1121 已提交
79
  SQHandle*   pQuery;
S
Shengliang Guan 已提交
80
  SDnode*     pDnode;
H
save  
Hongze Cheng 已提交
81 82
};

H
Hongze Cheng 已提交
83 84
int vnodeScheduleTask(SVnodeTask* task);

S
Shengliang Guan 已提交
85
int32_t vnodePutReqToVQueryQ(SVnode *pVnode, struct SRpcMsg *pReq);
S
Shengliang Guan 已提交
86

H
save  
Hongze Cheng 已提交
87 88 89 90 91
#ifdef __cplusplus
}
#endif

#endif /*_TD_VNODE_DEF_H_*/