vmInt.h 3.9 KB
Newer Older
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/>.
 */

S
shm  
Shengliang Guan 已提交
16 17
#ifndef _TD_DND_VNODES_INT_H_
#define _TD_DND_VNODES_INT_H_
S
shm  
Shengliang Guan 已提交
18

S
Shengliang Guan 已提交
19
#include "dmInt.h"
S
Shengliang Guan 已提交
20

S
shm  
Shengliang Guan 已提交
21
#include "sync.h"
S
shm  
Shengliang Guan 已提交
22
#include "vnode.h"
23 24 25 26 27

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang 已提交
28 29
typedef struct SVnodeMgmt {
  SMsgCb        msgCb;
S
Shengliang Guan 已提交
30
  const char   *path;
S
Shengliang 已提交
31 32
  const char   *name;
  int32_t       dnodeId;
S
shm  
Shengliang Guan 已提交
33
  SQWorkerPool  queryPool;
S
Shengliang Guan 已提交
34
  SQWorkerPool  fetchPool;
S
shm  
Shengliang Guan 已提交
35 36
  SWWorkerPool  syncPool;
  SWWorkerPool  writePool;
L
Liu Jicong 已提交
37
  SWWorkerPool  mergePool;
S
Shengliang Guan 已提交
38
  SSingleWorker mgmtWorker;
39
  SSingleWorker monitorWorker;
S
Shengliang 已提交
40 41 42 43 44
  SHashObj     *hash;
  SRWLatch      latch;
  SVnodesStat   state;
  STfs         *pTfs;
} SVnodeMgmt;
S
shm  
Shengliang Guan 已提交
45

S
shm  
Shengliang Guan 已提交
46 47 48 49 50 51 52 53 54 55
typedef struct {
  int32_t  vgId;
  int32_t  vgVersion;
  int8_t   dropped;
  uint64_t dbUid;
  char     db[TSDB_DB_FNAME_LEN];
  char     path[PATH_MAX + 20];
} SWrapperCfg;

typedef struct {
S
Shengliang 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  int32_t     vgId;
  int32_t     refCount;
  int32_t     vgVersion;
  int8_t      dropped;
  int8_t      accessState;
  uint64_t    dbUid;
  char       *db;
  char       *path;
  SVnode     *pImpl;
  STaosQueue *pWriteQ;
  STaosQueue *pSyncQ;
  STaosQueue *pApplyQ;
  STaosQueue *pQueryQ;
  STaosQueue *pFetchQ;
  STaosQueue *pMergeQ;
S
shm  
Shengliang Guan 已提交
71 72 73 74 75 76 77
} SVnodeObj;

typedef struct {
  int32_t      vnodeNum;
  int32_t      opened;
  int32_t      failed;
  int32_t      threadIndex;
S
Shengliang Guan 已提交
78
  TdThread     thread;
S
Shengliang 已提交
79
  SVnodeMgmt  *pMgmt;
S
shm  
Shengliang Guan 已提交
80 81 82
  SWrapperCfg *pCfgs;
} SVnodeThread;

S
shm  
Shengliang Guan 已提交
83
// vmInt.c
S
Shengliang 已提交
84 85 86 87
SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId);
void       vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
int32_t    vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
void       vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
S
shm  
Shengliang Guan 已提交
88

S
Shengliang Guan 已提交
89
// vmHandle.c
S
Shengliang 已提交
90 91 92 93 94
SArray *vmGetMsgHandles();
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SNodeMsg *pReq);
S
shm  
Shengliang Guan 已提交
95 96

// vmFile.c
S
Shengliang 已提交
97 98 99
int32_t     vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
int32_t     vmWriteVnodeListToFile(SVnodeMgmt *pMgmt);
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes);
S
shm  
Shengliang Guan 已提交
100 101

// vmWorker.c
S
Shengliang 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
int32_t vmStartWorker(SVnodeMgmt *pMgmt);
void    vmStopWorker(SVnodeMgmt *pMgmt);
int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
void    vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);

int32_t vmPutRpcMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutRpcMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutRpcMsgToApplyQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutRpcMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutRpcMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutRpcMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype);

int32_t vmPutNodeMsgToWriteQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToSyncQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToQueryQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToFetchQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToMergeQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToMgmtQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
int32_t vmPutNodeMsgToMonitorQueue(SVnodeMgmt *pMgmt, SNodeMsg *pMsg);
S
Shengliang Guan 已提交
122

123 124 125 126
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
127
#endif /*_TD_DND_VNODES_INT_H_*/