TDengine/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h

138 lines
4.5 KiB
C
Raw Normal View History

/*
* 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/>.
*/
2022-03-16 02:48:22 +00:00
#ifndef _TD_DND_VNODES_INT_H_
#define _TD_DND_VNODES_INT_H_
2022-03-14 03:50:02 +00:00
2022-05-11 13:19:33 +00:00
#include "dmUtil.h"
2022-04-12 11:43:42 +00:00
2022-03-16 11:39:43 +00:00
#include "sync.h"
2022-03-18 09:01:00 +00:00
#include "vnode.h"
#ifdef __cplusplus
extern "C" {
#endif
2022-05-11 10:23:08 +00:00
typedef struct SVnodeMgmt {
2024-06-24 10:28:56 +00:00
SDnodeData *pData;
SMsgCb msgCb;
const char *path;
const char *name;
SQueryAutoQWorkerPool queryPool;
SAutoQWorkerPool streamPool;
SWWorkerPool fetchPool;
SSingleWorker mgmtWorker;
2024-07-10 10:22:40 +00:00
SSingleWorker mgmtMultiWorker;
2024-06-24 10:28:56 +00:00
SHashObj *hash;
TdThreadRwlock lock;
SVnodesStat state;
STfs *pTfs;
TdThread thread;
bool stop;
2024-07-10 10:22:40 +00:00
TdThreadMutex createLock;
2022-05-11 10:23:08 +00:00
} SVnodeMgmt;
2022-03-14 11:31:39 +00:00
2022-03-16 02:48:22 +00:00
typedef struct {
2022-06-02 10:26:29 +00:00
int32_t vgId;
int32_t vgVersion;
int8_t dropped;
int32_t diskPrimary;
int32_t toVgId;
2022-06-02 10:26:29 +00:00
char path[PATH_MAX + 20];
2022-03-16 02:48:22 +00:00
} SWrapperCfg;
typedef struct {
2024-07-16 10:01:09 +00:00
int32_t vgId;
int32_t vgVersion;
int32_t refCount;
int8_t dropped;
int8_t failed;
int8_t disable;
int32_t diskPrimary;
int32_t toVgId;
char *path;
SVnode *pImpl;
SMultiWorker pWriteW;
SMultiWorker pSyncW;
SMultiWorker pSyncRdW;
SMultiWorker pApplyW;
STaosQueue *pQueryQ;
STaosQueue *pStreamQ;
STaosQueue *pFetchQ;
STaosQueue *pMultiMgmQ;
2022-03-16 02:48:22 +00:00
} SVnodeObj;
typedef struct {
int32_t vnodeNum;
int32_t opened;
int32_t failed;
bool updateVnodesList;
2022-03-16 02:48:22 +00:00
int32_t threadIndex;
2022-03-20 02:19:14 +00:00
TdThread thread;
2022-05-11 10:23:08 +00:00
SVnodeMgmt *pMgmt;
2022-03-16 02:48:22 +00:00
SWrapperCfg *pCfgs;
2022-09-22 12:28:38 +00:00
SVnodeObj **ppVnodes;
2022-03-16 02:48:22 +00:00
} SVnodeThread;
2022-03-16 11:39:43 +00:00
// vmInt.c
int32_t vmGetPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId);
int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId);
2022-05-11 10:23:08 +00:00
SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId);
SVnodeObj *vmAcquireVnodeImpl(SVnodeMgmt *pMgmt, int32_t vgId, bool strict);
2022-05-11 10:23:08 +00:00
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
2023-01-31 02:35:27 +00:00
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal);
2022-03-13 12:48:33 +00:00
2022-04-02 15:45:28 +00:00
// vmHandle.c
2022-05-11 10:23:08 +00:00
SArray *vmGetMsgHandles();
2022-05-19 08:56:50 +00:00
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2023-01-30 08:33:17 +00:00
int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2023-01-30 05:54:15 +00:00
int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2023-01-30 08:33:17 +00:00
int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2023-04-18 11:03:45 +00:00
int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2023-07-18 08:09:38 +00:00
int32_t vmProcessCheckLearnCatchupReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2022-03-16 11:39:43 +00:00
// vmFile.c
2024-07-16 10:01:09 +00:00
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt);
int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes);
2022-03-16 11:39:43 +00:00
// vmWorker.c
2022-05-11 10:23:08 +00:00
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);
2022-06-02 10:26:29 +00:00
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
2022-05-11 10:23:08 +00:00
2022-06-02 09:43:03 +00:00
int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2022-06-02 09:43:03 +00:00
int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2022-07-13 08:26:22 +00:00
int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2022-06-02 09:43:03 +00:00
int32_t vmPutMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2024-07-10 10:22:40 +00:00
int32_t vmPutMsgToMultiMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
2022-01-12 01:07:34 +00:00
#ifdef __cplusplus
}
#endif
2022-03-25 12:19:09 +00:00
#endif /*_TD_DND_VNODES_INT_H_*/