vmInt.h 4.0 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 已提交
19
#include "dmUtil.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
typedef struct SVnodeMgmt {
29 30 31 32 33 34 35 36 37 38 39 40 41 42
  SDnodeData      *pData;
  SMsgCb           msgCb;
  const char      *path;
  const char      *name;
  SQWorkerPool     queryPool;
  SAutoQWorkerPool streamPool;
  SWWorkerPool     fetchPool;
  SSingleWorker    mgmtWorker;
  SHashObj        *hash;
  TdThreadRwlock   lock;
  SVnodesStat      state;
  STfs            *pTfs;
  TdThread         thread;
  bool             stop;
S
Shengliang 已提交
43
} SVnodeMgmt;
S
shm  
Shengliang Guan 已提交
44

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

typedef struct {
55 56 57 58
  int32_t       vgId;
  int32_t       vgVersion;
  int32_t       refCount;
  int8_t        dropped;
59
  int8_t        disable;
60
  int32_t       diskPrimary;
61
  int32_t       toVgId;
62 63 64 65
  char         *path;
  SVnode       *pImpl;
  SMultiWorker  pWriteW;
  SMultiWorker  pSyncW;
66
  SMultiWorker  pSyncRdW;
67 68 69 70
  SMultiWorker  pApplyW;
  STaosQueue   *pQueryQ;
  STaosQueue   *pStreamQ;
  STaosQueue   *pFetchQ;
S
shm  
Shengliang Guan 已提交
71 72 73 74 75 76
} SVnodeObj;

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

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

S
Shengliang Guan 已提交
92
// vmHandle.c
S
Shengliang 已提交
93
SArray *vmGetMsgHandles();
S
Shengliang Guan 已提交
94 95
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
96
int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
97
int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
98
int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
C
cadem 已提交
99
int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
S
shm  
Shengliang Guan 已提交
100 101

// vmFile.c
S
Shengliang 已提交
102 103 104
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 已提交
105 106

// vmWorker.c
S
Shengliang 已提交
107 108 109 110 111 112
int32_t vmStartWorker(SVnodeMgmt *pMgmt);
void    vmStopWorker(SVnodeMgmt *pMgmt);
int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
void    vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);

int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype);
S
Shengliang Guan 已提交
113
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
S
Shengliang 已提交
114

S
Shengliang Guan 已提交
115 116
int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
117
int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
118 119
int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
120
int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
121 122
int32_t vmPutMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
123

124 125 126 127
#ifdef __cplusplus
}
#endif

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