vmInt.h 3.8 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
shm  
Shengliang Guan 已提交
19
#include "sync.h"
S
Shengliang Guan 已提交
20
#include "dnd.h"
S
shm  
Shengliang Guan 已提交
21
#include "vnode.h"
22 23 24 25 26

#ifdef __cplusplus
extern "C" {
#endif

S
shm  
Shengliang Guan 已提交
27
typedef struct SVnodesMgmt {
S
shm  
Shengliang Guan 已提交
28 29 30 31 32
  SHashObj     *hash;
  SRWLatch      latch;
  SVnodesStat   state;
  STfs         *pTfs;
  SQWorkerPool  queryPool;
S
Shengliang Guan 已提交
33
  SQWorkerPool  fetchPool;
S
shm  
Shengliang Guan 已提交
34 35
  SWWorkerPool  syncPool;
  SWWorkerPool  writePool;
L
Liu Jicong 已提交
36
  SWWorkerPool  mergePool;
S
shm  
Shengliang Guan 已提交
37 38 39
  const char   *path;
  SDnode       *pDnode;
  SMgmtWrapper *pWrapper;
S
Shengliang Guan 已提交
40
  SSingleWorker mgmtWorker;
S
shm  
Shengliang Guan 已提交
41 42
} SVnodesMgmt;

S
shm  
Shengliang Guan 已提交
43 44 45 46 47 48 49 50 51 52
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
shm  
Shengliang Guan 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66
  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;
L
Liu Jicong 已提交
67
  STaosQueue   *pMergeQ;
S
shm  
Shengliang Guan 已提交
68
  SMgmtWrapper *pWrapper;
S
shm  
Shengliang Guan 已提交
69 70 71 72 73 74 75
} SVnodeObj;

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

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

S
shm  
Shengliang Guan 已提交
87
// vmMsg.c
S
shm  
Shengliang Guan 已提交
88
void    vmInitMsgHandles(SMgmtWrapper *pWrapper);
S
shm  
Shengliang Guan 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessAlterVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessDropVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessSyncVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pReq);
int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pReq);

// vmFile.c
int32_t     vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
int32_t     vmWriteVnodesToFile(SVnodesMgmt *pMgmt);
SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes);

// vmWorker.c
int32_t vmStartWorker(SVnodesMgmt *pMgmt);
void    vmStopWorker(SVnodesMgmt *pMgmt);
int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
void    vmFreeQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);

S
shm  
Shengliang Guan 已提交
106
int32_t vmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
107 108
int32_t vmPutMsgToFetchQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
int32_t vmPutMsgToApplyQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
109
int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype);
S
shm  
Shengliang Guan 已提交
110

S
Shengliang Guan 已提交
111 112 113 114 115 116
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrappert, SNodeMsg *pMsg);
S
Shengliang Guan 已提交
117

118 119 120 121
#ifdef __cplusplus
}
#endif

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