shm
This commit is contained in:
parent
bf2226f09f
commit
58b64fcff2
|
@ -36,7 +36,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
SendReqToDnodeFp sendReqFp;
|
||||||
SendReqToMnodeFp sendReqToMnodeFp;
|
SendReqToMnodeFp sendReqToMnodeFp;
|
||||||
SendRedirectRspFp sendRedirectRspFp;
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
} SBnodeOpt;
|
} SBnodeOpt;
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef struct {
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
PutReqToMWriteQFp putReqToMWriteQFp;
|
PutReqToMWriteQFp putReqToMWriteQFp;
|
||||||
PutReqToMReadQFp putReqToMReadQFp;
|
PutReqToMReadQFp putReqToMReadQFp;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
SendReqToDnodeFp sendReqFp;
|
||||||
SendReqToMnodeFp sendReqToMnodeFp;
|
SendReqToMnodeFp sendReqToMnodeFp;
|
||||||
SendRedirectRspFp sendRedirectRspFp;
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
} SMnodeOpt;
|
} SMnodeOpt;
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
SendReqToDnodeFp sendReqFp;
|
||||||
SendReqToMnodeFp sendReqToMnodeFp;
|
SendReqToMnodeFp sendReqToMnodeFp;
|
||||||
SendRedirectRspFp sendRedirectRspFp;
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
} SQnodeOpt;
|
} SQnodeOpt;
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
SendReqToDnodeFp sendReqFp;
|
||||||
SendReqToMnodeFp sendReqToMnodeFp;
|
SendReqToMnodeFp sendReqToMnodeFp;
|
||||||
SendRedirectRspFp sendRedirectRspFp;
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
} SSnodeOpt;
|
} SSnodeOpt;
|
||||||
|
|
|
@ -49,10 +49,10 @@ typedef struct {
|
||||||
} SQWorkerStat;
|
} SQWorkerStat;
|
||||||
|
|
||||||
typedef int32_t (*putReqToQueryQFp)(void *, struct SRpcMsg *);
|
typedef int32_t (*putReqToQueryQFp)(void *, struct SRpcMsg *);
|
||||||
typedef int32_t (*sendReqToDnodeFp)(void *, struct SEpSet *, struct SRpcMsg *);
|
typedef int32_t (*sendReqFp)(void *, struct SEpSet *, struct SRpcMsg *);
|
||||||
|
|
||||||
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, void *nodeObj,
|
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, void *nodeObj,
|
||||||
putReqToQueryQFp fp1, sendReqToDnodeFp fp2);
|
putReqToQueryQFp fp1, sendReqFp fp2);
|
||||||
|
|
||||||
int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
|
int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ void tfsClosedir(STfsDir *pDir);
|
||||||
* @param pTfs The fs object.
|
* @param pTfs The fs object.
|
||||||
* @param pInfo The info object.
|
* @param pInfo The info object.
|
||||||
*/
|
*/
|
||||||
int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo);
|
void tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ static void dndStopBnodeWorker(SDnode *pDnode) {
|
||||||
|
|
||||||
static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
|
static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
|
||||||
pOption->pDnode = pDnode;
|
pOption->pDnode = pDnode;
|
||||||
pOption->sendReqToDnodeFp = dndSendReqToDnode;
|
pOption->sendReqFp = dndSendReqToDnode;
|
||||||
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
||||||
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
||||||
pOption->dnodeId = dmGetDnodeId(pDnode);
|
pOption->dnodeId = dmGetDnodeId(pDnode);
|
||||||
|
|
|
@ -25,7 +25,9 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
|
||||||
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
||||||
pInfo->tempdir.size = tsTempSpace.size;
|
pInfo->tempdir.size = tsTempSpace.size;
|
||||||
|
|
||||||
return vmGetTfsMonitorInfo(dndGetWrapper(pDnode, VNODES), pInfo);
|
vmGetTfsMonitorInfo(dndGetWrapper(pDnode, VNODES), pInfo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||||
|
@ -48,7 +50,7 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
||||||
taosGetCardInfo(&pInfo->net_in, &pInfo->net_out);
|
taosGetCardInfo(&pInfo->net_in, &pInfo->net_out);
|
||||||
taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
||||||
|
|
||||||
vmGetVndMonitorInfo(dndGetWrapper(pDnode, VNODES), pInfo);
|
vmGetVnodeReqs(dndGetWrapper(pDnode, VNODES), pInfo);
|
||||||
pInfo->has_mnode = (dndGetWrapper(pDnode, MNODE)->required);
|
pInfo->has_mnode = (dndGetWrapper(pDnode, MNODE)->required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pMgmt->latch);
|
||||||
|
|
||||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||||
vmGetVnodeLoads(pDnode, req.pVloads);
|
vmGetVnodeLoads(dndGetWrapper(pDnode, VNODES), req.pVloads);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
|
|
@ -99,21 +99,6 @@ static void dmProcessQueue(SDnode *pDnode, SNodeMsg *pNodeMsg) {
|
||||||
case TDMT_MND_GRANT_RSP:
|
case TDMT_MND_GRANT_RSP:
|
||||||
dmProcessGrantRsp(pDnode, pMsg);
|
dmProcessGrantRsp(pDnode, pMsg);
|
||||||
break;
|
break;
|
||||||
case TDMT_DND_CREATE_VNODE:
|
|
||||||
code = vmProcessCreateVnodeReq(pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
case TDMT_DND_ALTER_VNODE:
|
|
||||||
code = vmProcessAlterVnodeReq(pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
case TDMT_DND_DROP_VNODE:
|
|
||||||
code = vmProcessDropVnodeReq(pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
case TDMT_DND_SYNC_VNODE:
|
|
||||||
code = vmProcessSyncVnodeReq(pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
case TDMT_DND_COMPACT_VNODE:
|
|
||||||
code = vmProcessCompactVnodeReq(pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
code = -1;
|
code = -1;
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mmInitMsgHandles(SMgmtWrapper *pWrapper);
|
void mmInitMsgHandles(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
int32_t mmProcessCreateReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
int32_t mmProcessCreateReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
||||||
int32_t mmProcessAlterReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
int32_t mmProcessAlterReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
||||||
int32_t mmProcessDropReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
int32_t mmProcessDropReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
SDnode *pDnode = pMgmt->pDnode;
|
||||||
|
|
||||||
pOption->pDnode = pDnode;
|
pOption->pDnode = pDnode;
|
||||||
pOption->sendReqToDnodeFp = dndSendReqToDnode;
|
pOption->sendReqFp = dndSendReqToDnode;
|
||||||
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
||||||
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
||||||
pOption->putReqToMWriteQFp = mmPutMsgToWriteQueue;
|
pOption->putReqToMWriteQFp = mmPutMsgToWriteQueue;
|
||||||
|
|
|
@ -183,7 +183,7 @@ static void dndStopQnodeWorker(SDnode *pDnode) {
|
||||||
|
|
||||||
static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
|
static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
|
||||||
pOption->pDnode = pDnode;
|
pOption->pDnode = pDnode;
|
||||||
pOption->sendReqToDnodeFp = dndSendReqToDnode;
|
pOption->sendReqFp = dndSendReqToDnode;
|
||||||
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
||||||
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
||||||
pOption->dnodeId = dmGetDnodeId(pDnode);
|
pOption->dnodeId = dmGetDnodeId(pDnode);
|
||||||
|
|
|
@ -208,7 +208,7 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
|
||||||
|
|
||||||
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
||||||
pOption->pDnode = pDnode;
|
pOption->pDnode = pDnode;
|
||||||
pOption->sendReqToDnodeFp = dndSendReqToDnode;
|
pOption->sendReqFp = dndSendReqToDnode;
|
||||||
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
pOption->sendReqToMnodeFp = dndSendReqToMnode;
|
||||||
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
pOption->sendRedirectRspFp = dmSendRedirectRsp;
|
||||||
pOption->dnodeId = dmGetDnodeId(pDnode);
|
pOption->dnodeId = dmGetDnodeId(pDnode);
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
||||||
int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt);
|
int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt);
|
||||||
|
SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,9 @@ typedef struct {
|
||||||
|
|
||||||
// interface
|
// interface
|
||||||
void vmGetMgmtFp(SMgmtWrapper *pWrapper);
|
void vmGetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
|
void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads);
|
||||||
|
void vmGetTfsMonitorInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo);
|
||||||
|
void vmGetVnodeReqs(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo);
|
||||||
|
|
||||||
// vmInt.h
|
// vmInt.h
|
||||||
SVnodeObj *vmAcquireVnode(SVnodesMgmt *pMgmt, int32_t vgId);
|
SVnodeObj *vmAcquireVnode(SVnodesMgmt *pMgmt, int32_t vgId);
|
||||||
|
@ -93,23 +96,11 @@ void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
|
int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
|
||||||
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
|
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
|
|
||||||
int32_t dndInitVnodes(SDnode *pDnode);
|
|
||||||
void dndCleanupVnodes(SDnode *pDnode);
|
|
||||||
void vmGetVnodeLoads(SDnode *pDnode, SArray *pLoads);
|
|
||||||
void dndProcessVnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
void dndProcessVnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dndProcessVnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
void dndProcessVnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dndProcessVnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
void dndProcessVnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dndProcessVnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
void dndProcessVnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
|
||||||
int32_t vmProcessCreateVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
int32_t vmProcessAlterVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
int32_t vmProcessDropVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
int32_t dndProcessAuthVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
int32_t vmProcessSyncVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
int32_t vmProcessCompactVnodeReq(SDnode *pDnode, SRpcMsg *pReq);
|
|
||||||
|
|
||||||
int32_t vmGetTfsMonitorInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo);
|
|
||||||
void vmGetVndMonitorInfo(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vmInitMsgHandles(SMgmtWrapper *pWrapper);
|
void vmInitMsgHandles(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
||||||
int32_t vmProcessAlterVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessAlterVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
||||||
int32_t vmProcessDropVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessDropVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
||||||
int32_t dndProcessAuthVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
|
||||||
int32_t vmProcessSyncVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessSyncVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
||||||
int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq);
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,11 @@ extern "C" {
|
||||||
|
|
||||||
int32_t vmStartWorker(SVnodesMgmt *pMgmt);
|
int32_t vmStartWorker(SVnodesMgmt *pMgmt);
|
||||||
void vmStopWorker(SVnodesMgmt *pMgmt);
|
void vmStopWorker(SVnodesMgmt *pMgmt);
|
||||||
|
int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
|
void vmFreeQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
|
|
||||||
void vmInitMsgFp(SMnodeMgmt *pMgmt);
|
int32_t vmPutMsgToQueryQueue(SVnodesMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
void vmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet);
|
int32_t vmPutMsgToApplyQueue(SVnodesMgmt *pMgmt, int32_t vgId, SRpcMsg *pMsg);
|
||||||
int32_t vmPutMsgToWriteQueue(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
|
||||||
int32_t vmPutMsgToReadQueue(SDnode *pDnode, SRpcMsg *pRpcMsg);
|
|
||||||
void vmConsumeChildQueue(SDnode *pDnode, SNodeMsg *pMsg, int32_t msgLen, void *pCont, int32_t contLen);
|
|
||||||
void vmConsumeParentQueue(SDnode *pDnode, SRpcMsg *pMsg, int32_t msgLen, void *pCont, int32_t contLen);
|
|
||||||
|
|
||||||
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "vmFile.h"
|
#include "vmFile.h"
|
||||||
|
|
||||||
static SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes) {
|
SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosRLockLatch(&pMgmt->latch);
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "vmFile.h"
|
#include "vmFile.h"
|
||||||
#include "vmMsg.h"
|
#include "vmMsg.h"
|
||||||
#include "vmWorker.h"
|
#include "vmWorker.h"
|
||||||
|
#include "sync.h"
|
||||||
|
|
||||||
SVnodeObj *vmAcquireVnode(SVnodesMgmt *pMgmt, int32_t vgId) {
|
SVnodeObj *vmAcquireVnode(SVnodesMgmt *pMgmt, int32_t vgId) {
|
||||||
SVnodeObj *pVnode = NULL;
|
SVnodeObj *pVnode = NULL;
|
||||||
|
@ -41,7 +42,6 @@ SVnodeObj *vmAcquireVnode(SVnodesMgmt *pMgmt, int32_t vgId) {
|
||||||
void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
if (pVnode == NULL) return;
|
if (pVnode == NULL) return;
|
||||||
|
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosRLockLatch(&pMgmt->latch);
|
||||||
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pMgmt->latch);
|
||||||
|
@ -70,7 +70,7 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndAllocVnodeQueue(pDnode, pVnode) != 0) {
|
if (vmAllocQueue(pMgmt, pVnode) != 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,6 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosWLockLatch(&pMgmt->latch);
|
||||||
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosWUnLockLatch(&pMgmt->latch);
|
||||||
|
@ -99,7 +98,7 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
while (!taosQueueEmpty(pVnode->pQueryQ)) taosMsleep(10);
|
while (!taosQueueEmpty(pVnode->pQueryQ)) taosMsleep(10);
|
||||||
while (!taosQueueEmpty(pVnode->pFetchQ)) taosMsleep(10);
|
while (!taosQueueEmpty(pVnode->pFetchQ)) taosMsleep(10);
|
||||||
|
|
||||||
dndFreeVnodeQueue(pDnode, pVnode);
|
vmFreeQueue(pMgmt, pVnode);
|
||||||
vnodeClose(pVnode->pImpl);
|
vnodeClose(pVnode->pImpl);
|
||||||
pVnode->pImpl = NULL;
|
pVnode->pImpl = NULL;
|
||||||
|
|
||||||
|
@ -131,13 +130,13 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||||
dndReportStartup(pDnode, "open-vnodes", stepDesc);
|
dndReportStartup(pDnode, "open-vnodes", stepDesc);
|
||||||
|
|
||||||
SVnodeCfg cfg = {.pDnode = pDnode, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
SVnodeCfg cfg = {.pMgmt = pMgmt, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
||||||
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
dError("vgId:%d, failed to open vnode by thread:%d", pCfg->vgId, pThread->threadIndex);
|
dError("vgId:%d, failed to open vnode by thread:%d", pCfg->vgId, pThread->threadIndex);
|
||||||
pThread->failed++;
|
pThread->failed++;
|
||||||
} else {
|
} else {
|
||||||
vmOpenVnode(pDnode, pCfg, pImpl);
|
vmOpenVnode(pMgmt, pCfg, pImpl);
|
||||||
dDebug("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex);
|
dDebug("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex);
|
||||||
pThread->opened++;
|
pThread->opened++;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +162,7 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) {
|
||||||
|
|
||||||
SWrapperCfg *pCfgs = NULL;
|
SWrapperCfg *pCfgs = NULL;
|
||||||
int32_t numOfVnodes = 0;
|
int32_t numOfVnodes = 0;
|
||||||
if (vmGetVnodesFromFile(pDnode, &pCfgs, &numOfVnodes) != 0) {
|
if (vmGetVnodesFromFile(pMgmt, &pCfgs, &numOfVnodes) != 0) {
|
||||||
dInfo("failed to get vnode list from disk since %s", terrstr());
|
dInfo("failed to get vnode list from disk since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -229,10 +228,10 @@ static void vmCloseVnodes(SVnodesMgmt *pMgmt) {
|
||||||
dInfo("start to close all vnodes");
|
dInfo("start to close all vnodes");
|
||||||
|
|
||||||
int32_t numOfVnodes = 0;
|
int32_t numOfVnodes = 0;
|
||||||
SVnodeObj **pVnodes = dndGetVnodesFromHash(pDnode, &numOfVnodes);
|
SVnodeObj **pVnodes = vmGetVnodesFromHash(pMgmt, &numOfVnodes);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
vmCloseVnode(pDnode, pVnodes[i]);
|
vmCloseVnode(pMgmt, pVnodes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnodes != NULL) {
|
if (pVnodes != NULL) {
|
||||||
|
@ -261,6 +260,10 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("vnodes-mgmt is cleaned up");
|
dInfo("vnodes-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t vmSendReqToDnode(SVnodesMgmt *pMgmt, struct SEpSet *epSet, struct SRpcMsg *rpcMsg) {
|
||||||
|
return dndSendReqToDnode(pMgmt->pDnode, epSet, rpcMsg);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
SVnodesMgmt *pMgmt = calloc(1, sizeof(SVnodesMgmt));
|
SVnodesMgmt *pMgmt = calloc(1, sizeof(SVnodesMgmt));
|
||||||
|
@ -298,8 +301,8 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeOpt.nthreads = tsNumOfCommitThreads;
|
vnodeOpt.nthreads = tsNumOfCommitThreads;
|
||||||
vnodeOpt.putReqToVQueryQFp = dndPutReqToVQueryQ;
|
vnodeOpt.putToQueryQFp = (VndPutToQueryQFp)vmPutMsgToQueryQueue;
|
||||||
vnodeOpt.sendReqToDnodeFp = dndSendReqToDnode;
|
vnodeOpt.sendReqFp = (VndSendReqFp)vmSendReqToDnode;
|
||||||
if (vnodeInit(&vnodeOpt) != 0) {
|
if (vnodeInit(&vnodeOpt) != 0) {
|
||||||
dError("failed to init vnode since %s", terrstr());
|
dError("failed to init vnode since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -339,15 +342,14 @@ void vmGetMgmtFp(SMgmtWrapper *pWrapper) {
|
||||||
pWrapper->fp = mgmtFp;
|
pWrapper->fp = mgmtFp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmGetTfsMonitorInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo) {
|
void vmGetTfsMonitorInfo(SMgmtWrapper *pWrapper, SMonDiskInfo *pInfo) {
|
||||||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
if (pMgmt == NULL) return -1;
|
if (pMgmt == NULL) return;
|
||||||
|
|
||||||
return tfsGetMonitorInfo(pMgmt->pTfs, pInfo);
|
tfsGetMonitorInfo(pMgmt->pTfs, pInfo);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmGetVndMonitorInfo(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo) {
|
void vmGetVnodeReqs(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo) {
|
||||||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
if (pMgmt == NULL) return;
|
if (pMgmt == NULL) return;
|
||||||
|
|
||||||
|
@ -362,9 +364,9 @@ void vmGetVndMonitorInfo(SMgmtWrapper *pWrapper, SMonDnodeInfo *pInfo) {
|
||||||
pInfo->masters = pStat->masterNum;
|
pInfo->masters = pStat->masterNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmGetVnodeLoads(SDnode *pDnode, SArray *pLoads) {
|
void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SArray *pLoads) {
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SVnodesStat *pStat = &pMgmt->stat;
|
SVnodesStat *pStat = &pMgmt->state;
|
||||||
int32_t totalVnodes = 0;
|
int32_t totalVnodes = 0;
|
||||||
int32_t masterNum = 0;
|
int32_t masterNum = 0;
|
||||||
int64_t numOfSelectReqs = 0;
|
int64_t numOfSelectReqs = 0;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "vmMsg.h"
|
#include "vmMsg.h"
|
||||||
#include "vmFile.h"
|
#include "vmFile.h"
|
||||||
#include "vmWorker.h"
|
#include "vmWorker.h"
|
||||||
|
#include "dmInt.h"
|
||||||
|
|
||||||
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->vgId = pCreate->vgId;
|
pCfg->vgId = pCreate->vgId;
|
||||||
|
@ -83,7 +84,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeCfg.pDnode = pMgmt->pDnode;
|
vnodeCfg.pMgmt = pMgmt;
|
||||||
vnodeCfg.pTfs = pMgmt->pTfs;
|
vnodeCfg.pTfs = pMgmt->pTfs;
|
||||||
vnodeCfg.dbId = wrapperCfg.dbUid;
|
vnodeCfg.dbId = wrapperCfg.dbUid;
|
||||||
SVnode *pImpl = vnodeOpen(wrapperCfg.path, &vnodeCfg);
|
SVnode *pImpl = vnodeOpen(wrapperCfg.path, &vnodeCfg);
|
||||||
|
@ -262,4 +263,10 @@ void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, vmProcessFetchMsg);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, vmProcessFetchMsg);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, vmProcessFetchMsg);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, vmProcessFetchMsg);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, vmProcessFetchMsg);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, vmProcessFetchMsg);
|
||||||
|
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessCreateVnodeReq);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessAlterVnodeReq);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessDropVnodeReq);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessSyncVnodeReq);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessCompactVnodeReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "vmWorker.h"
|
#include "vmWorker.h"
|
||||||
|
|
||||||
static void dndProcessVnodeQueryQueue(SVnodeObj *pVnode, SRpcMsg *pMsg) { vnodeProcessQueryMsg(pVnode->pImpl, pMsg); }
|
static void vmProcessQueryQueue(SVnodeObj *pVnode, SRpcMsg *pMsg) { vnodeProcessQueryMsg(pVnode->pImpl, pMsg); }
|
||||||
|
|
||||||
static void dndProcessVnodeFetchQueue(SVnodeObj *pVnode, SRpcMsg *pMsg) { vnodeProcessFetchMsg(pVnode->pImpl, pMsg); }
|
static void vmProcessFetchQueue(SVnodeObj *pVnode, SRpcMsg *pMsg) { vnodeProcessFetchMsg(pVnode->pImpl, pMsg); }
|
||||||
|
|
||||||
static void dndProcessVnodeWriteQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessWriteQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *));
|
SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *));
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
|
@ -56,7 +56,7 @@ static void dndProcessVnodeWriteQueue(SVnodeObj *pVnode, STaosQall *qall, int32_
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessVnodeApplyQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessApplyQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SRpcMsg *pMsg = NULL;
|
SRpcMsg *pMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
|
@ -68,7 +68,7 @@ static void dndProcessVnodeApplyQueue(SVnodeObj *pVnode, STaosQall *qall, int32_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessVnodeSyncQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessSyncQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SRpcMsg *pMsg = NULL;
|
SRpcMsg *pMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
|
@ -80,7 +80,7 @@ static void dndProcessVnodeSyncQueue(SVnodeObj *pVnode, STaosQall *qall, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndWriteRpcMsgToVnodeQueue(STaosQueue *pQueue, SRpcMsg *pRpcMsg, bool sendRsp) {
|
static int32_t vmWriteMsgToQueue(STaosQueue *pQueue, SRpcMsg *pRpcMsg, bool sendRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pQueue == NULL) {
|
if (pQueue == NULL) {
|
||||||
|
@ -108,7 +108,7 @@ static int32_t dndWriteRpcMsgToVnodeQueue(STaosQueue *pQueue, SRpcMsg *pRpcMsg,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SVnodeObj *dndAcquireVnodeFromMsg(SDnode *pDnode, SRpcMsg *pMsg) {
|
static SVnodeObj *vmAcquireFromMsg(SVnodesMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
pHead->contLen = htonl(pHead->contLen);
|
pHead->contLen = htonl(pHead->contLen);
|
||||||
pHead->vgId = htonl(pHead->vgId);
|
pHead->vgId = htonl(pHead->vgId);
|
||||||
|
@ -126,51 +126,55 @@ static SVnodeObj *dndAcquireVnodeFromMsg(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
return pVnode;
|
return pVnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessVnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SVnodeObj *pVnode = dndAcquireVnodeFromMsg(pDnode, pMsg);
|
// SVnodeObj *pVnode = vmAcquireFromMsg(pDnode, pMsg);
|
||||||
if (pVnode != NULL) {
|
// if (pVnode != NULL) {
|
||||||
(void)dndWriteRpcMsgToVnodeQueue(pVnode->pWriteQ, pMsg, true);
|
// (void)vmWriteMsgToQueue(pVnode->pWriteQ, pMsg, true);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
// vmReleaseVnode(pMgmt, pVnode);
|
||||||
}
|
// }
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessVnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SVnodeObj *pVnode = dndAcquireVnodeFromMsg(pDnode, pMsg);
|
// SVnodeObj *pVnode = vmAcquireFromMsg(pDnode, pMsg);
|
||||||
if (pVnode != NULL) {
|
// if (pVnode != NULL) {
|
||||||
(void)dndWriteRpcMsgToVnodeQueue(pVnode->pSyncQ, pMsg, true);
|
// (void)vmWriteMsgToQueue(pVnode->pSyncQ, pMsg, true);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
// vmReleaseVnode(pMgmt, pVnode);
|
||||||
}
|
// }
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessVnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SVnodeObj *pVnode = dndAcquireVnodeFromMsg(pDnode, pMsg);
|
// SVnodeObj *pVnode = vmAcquireFromMsg(pDnode, pMsg);
|
||||||
if (pVnode != NULL) {
|
// if (pVnode != NULL) {
|
||||||
(void)dndWriteRpcMsgToVnodeQueue(pVnode->pQueryQ, pMsg, true);
|
// (void)vmWriteMsgToQueue(pVnode->pQueryQ, pMsg, true);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
// vmReleaseVnode(pMgmt, pVnode);
|
||||||
}
|
// }
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessVnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg){
|
||||||
SVnodeObj *pVnode = dndAcquireVnodeFromMsg(pDnode, pMsg);
|
// SVnodeObj *pVnode = vmAcquireFromMsg(pDnode, pMsg);
|
||||||
if (pVnode != NULL) {
|
// if (pVnode != NULL) {
|
||||||
(void)dndWriteRpcMsgToVnodeQueue(pVnode->pFetchQ, pMsg, true);
|
// (void)vmWriteMsgToQueue(pVnode->pFetchQ, pMsg, true);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
// vmReleaseVnode(pMgmt, pVnode);
|
||||||
}
|
// }
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndPutReqToVQueryQ(SDnode *pDnode, SRpcMsg *pMsg) {
|
int32_t vmPutMsgToQueryQueue(SVnodesMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
// pHead->vgId = htonl(pHead->vgId);
|
// pHead->vgId = htonl(pHead->vgId);
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||||
if (pVnode == NULL) return -1;
|
if (pVnode == NULL) return -1;
|
||||||
|
|
||||||
int32_t code = dndWriteRpcMsgToVnodeQueue(pVnode->pQueryQ, pMsg, false);
|
int32_t code = vmWriteMsgToQueue(pVnode->pQueryQ, pMsg, false);
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndPutMsgIntoVnodeApplyQueue(SDnode *pDnode, int32_t vgId, SRpcMsg *pMsg) {
|
int32_t vmPutMsgToApplyQueue(SVnodesMgmt *pMgmt, int32_t vgId, SRpcMsg *pMsg) {
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId);
|
||||||
if (pVnode == NULL) return -1;
|
if (pVnode == NULL) return -1;
|
||||||
|
|
||||||
|
@ -179,14 +183,12 @@ static int32_t dndPutMsgIntoVnodeApplyQueue(SDnode *pDnode, int32_t vgId, SRpcMs
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndAllocVnodeQueue(SDnode *pDnode, SVnodeObj *pVnode) {
|
int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessWriteQueue);
|
||||||
|
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessApplyQueue);
|
||||||
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)dndProcessVnodeWriteQueue);
|
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)vmProcessSyncQueue);
|
||||||
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)dndProcessVnodeApplyQueue);
|
pVnode->pFetchQ = tFWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItem)vmProcessFetchQueue);
|
||||||
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)dndProcessVnodeSyncQueue);
|
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||||
pVnode->pFetchQ = tFWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItem)dndProcessVnodeFetchQueue);
|
|
||||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)dndProcessVnodeQueryQueue);
|
|
||||||
|
|
||||||
if (pVnode->pApplyQ == NULL || pVnode->pWriteQ == NULL || pVnode->pSyncQ == NULL || pVnode->pFetchQ == NULL ||
|
if (pVnode->pApplyQ == NULL || pVnode->pWriteQ == NULL || pVnode->pSyncQ == NULL || pVnode->pFetchQ == NULL ||
|
||||||
pVnode->pQueryQ == NULL) {
|
pVnode->pQueryQ == NULL) {
|
||||||
|
@ -197,8 +199,7 @@ static int32_t dndAllocVnodeQueue(SDnode *pDnode, SVnodeObj *pVnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndFreeVnodeQueue(SDnode *pDnode, SVnodeObj *pVnode) {
|
void vmFreeQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
|
||||||
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
||||||
tFWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
tFWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
||||||
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pWriteQ);
|
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pWriteQ);
|
||||||
|
|
|
@ -119,7 +119,7 @@ typedef struct SMnode {
|
||||||
SHashObj *infosMeta;
|
SHashObj *infosMeta;
|
||||||
SGrantInfo grant;
|
SGrantInfo grant;
|
||||||
MndMsgFp msgFp[TDMT_MAX];
|
MndMsgFp msgFp[TDMT_MAX];
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
SendReqToDnodeFp sendReqFp;
|
||||||
SendReqToMnodeFp sendReqToMnodeFp;
|
SendReqToMnodeFp sendReqToMnodeFp;
|
||||||
SendRedirectRspFp sendRedirectRspFp;
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
PutReqToMWriteQFp putReqToMWriteQFp;
|
PutReqToMWriteQFp putReqToMWriteQFp;
|
||||||
|
|
|
@ -44,16 +44,16 @@
|
||||||
#define TELEM_TIMER_MS 86400000
|
#define TELEM_TIMER_MS 86400000
|
||||||
|
|
||||||
int32_t mndSendReqToDnode(SMnode *pMnode, SEpSet *pEpSet, SRpcMsg *pMsg) {
|
int32_t mndSendReqToDnode(SMnode *pMnode, SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
if (pMnode == NULL || pMnode->sendReqToDnodeFp == NULL) {
|
if (pMnode == NULL || pMnode->sendReqFp == NULL) {
|
||||||
terrno = TSDB_CODE_MND_NOT_READY;
|
terrno = TSDB_CODE_MND_NOT_READY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*pMnode->sendReqToDnodeFp)(pMnode->pDnode, pEpSet, pMsg);
|
return (*pMnode->sendReqFp)(pMnode->pDnode, pEpSet, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSendReqToMnode(SMnode *pMnode, SRpcMsg *pMsg) {
|
int32_t mndSendReqToMnode(SMnode *pMnode, SRpcMsg *pMsg) {
|
||||||
if (pMnode == NULL || pMnode->sendReqToDnodeFp == NULL) {
|
if (pMnode == NULL || pMnode->sendReqFp == NULL) {
|
||||||
terrno = TSDB_CODE_MND_NOT_READY;
|
terrno = TSDB_CODE_MND_NOT_READY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -289,11 +289,11 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||||
pMnode->pDnode = pOption->pDnode;
|
pMnode->pDnode = pOption->pDnode;
|
||||||
pMnode->putReqToMWriteQFp = pOption->putReqToMWriteQFp;
|
pMnode->putReqToMWriteQFp = pOption->putReqToMWriteQFp;
|
||||||
pMnode->putReqToMReadQFp = pOption->putReqToMReadQFp;
|
pMnode->putReqToMReadQFp = pOption->putReqToMReadQFp;
|
||||||
pMnode->sendReqToDnodeFp = pOption->sendReqToDnodeFp;
|
pMnode->sendReqFp = pOption->sendReqFp;
|
||||||
pMnode->sendReqToMnodeFp = pOption->sendReqToMnodeFp;
|
pMnode->sendReqToMnodeFp = pOption->sendReqToMnodeFp;
|
||||||
pMnode->sendRedirectRspFp = pOption->sendRedirectRspFp;
|
pMnode->sendRedirectRspFp = pOption->sendRedirectRspFp;
|
||||||
|
|
||||||
if (pMnode->sendReqToDnodeFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL ||
|
if (pMnode->sendReqFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL ||
|
||||||
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0) {
|
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -30,7 +30,7 @@ SQnode *qndOpen(const SQnodeOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, NULL, (void **)&pQnode->pQuery, pQnode,
|
if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, NULL, (void **)&pQnode->pQuery, pQnode,
|
||||||
(putReqToQueryQFp)qnodePutReqToVQueryQ, (sendReqToDnodeFp)qnodeSendReqToDnode)) {
|
(putReqToQueryQFp)qnodePutReqToVQueryQ, (sendReqFp)qnodeSendReqToDnode)) {
|
||||||
tfree(pQnode);
|
tfree(pQnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,8 @@ extern "C" {
|
||||||
|
|
||||||
/* ------------------------ TYPES EXPOSED ------------------------ */
|
/* ------------------------ TYPES EXPOSED ------------------------ */
|
||||||
typedef struct SVnode SVnode;
|
typedef struct SVnode SVnode;
|
||||||
typedef struct SDnode SDnode;
|
typedef int32_t (*VndPutToQueryQFp)(void *pMgmt, struct SRpcMsg *pReq);
|
||||||
typedef int32_t (*PutReqToVQueryQFp)(SDnode *pDnode, struct SRpcMsg *pReq);
|
typedef int32_t (*VndSendReqFp)(void *pMgmt, struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
||||||
typedef int32_t (*SendReqToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -43,7 +42,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
SDnode *pDnode;
|
void *pMgmt;
|
||||||
STfs *pTfs;
|
STfs *pTfs;
|
||||||
uint64_t wsize;
|
uint64_t wsize;
|
||||||
uint64_t ssize;
|
uint64_t ssize;
|
||||||
|
@ -63,9 +62,9 @@ typedef struct {
|
||||||
} SVnodeCfg;
|
} SVnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t nthreads; // number of commit threads. 0 for no threads and a schedule queue should be given (TODO)
|
uint16_t nthreads; // number of commit threads. 0 for no threads and a schedule queue should be given (TODO)
|
||||||
PutReqToVQueryQFp putReqToVQueryQFp;
|
VndPutToQueryQFp putToQueryQFp;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
VndSendReqFp sendReqFp;
|
||||||
} SVnodeOpt;
|
} SVnodeOpt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -53,9 +53,8 @@ typedef struct SVnodeMgr {
|
||||||
pthread_cond_t hasTask;
|
pthread_cond_t hasTask;
|
||||||
TD_DLIST(SVnodeTask) queue;
|
TD_DLIST(SVnodeTask) queue;
|
||||||
// For vnode Mgmt
|
// For vnode Mgmt
|
||||||
SDnode* pDnode;
|
VndPutToQueryQFp putToQueryQFp;
|
||||||
PutReqToVQueryQFp putReqToVQueryQFp;
|
VndSendReqFp sendReqFp;
|
||||||
SendReqToDnodeFp sendReqToDnodeFp;
|
|
||||||
} SVnodeMgr;
|
} SVnodeMgr;
|
||||||
|
|
||||||
extern SVnodeMgr vnodeMgr;
|
extern SVnodeMgr vnodeMgr;
|
||||||
|
@ -79,7 +78,7 @@ struct SVnode {
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
tsem_t canCommit;
|
tsem_t canCommit;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
SDnode* pDnode;
|
void* pMgmt;
|
||||||
STfs* pTfs;
|
STfs* pTfs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
|
||||||
SVnodeCfg cfg = defaultVnodeOptions;
|
SVnodeCfg cfg = defaultVnodeOptions;
|
||||||
if (pVnodeCfg != NULL) {
|
if (pVnodeCfg != NULL) {
|
||||||
cfg.vgId = pVnodeCfg->vgId;
|
cfg.vgId = pVnodeCfg->vgId;
|
||||||
cfg.pDnode = pVnodeCfg->pDnode;
|
cfg.pMgmt = pVnodeCfg->pMgmt;
|
||||||
cfg.pTfs = pVnodeCfg->pTfs;
|
cfg.pTfs = pVnodeCfg->pTfs;
|
||||||
cfg.dbId = pVnodeCfg->dbId;
|
cfg.dbId = pVnodeCfg->dbId;
|
||||||
cfg.hashBegin = pVnodeCfg->hashBegin;
|
cfg.hashBegin = pVnodeCfg->hashBegin;
|
||||||
|
@ -79,7 +79,7 @@ static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->vgId = pVnodeCfg->vgId;
|
pVnode->vgId = pVnodeCfg->vgId;
|
||||||
pVnode->pDnode = pVnodeCfg->pDnode;
|
pVnode->pMgmt = pVnodeCfg->pMgmt;
|
||||||
pVnode->pTfs = pVnodeCfg->pTfs;
|
pVnode->pTfs = pVnodeCfg->pTfs;
|
||||||
pVnode->path = strdup(path);
|
pVnode->path = strdup(path);
|
||||||
vnodeOptionsCopy(&(pVnode->config), pVnodeCfg);
|
vnodeOptionsCopy(&(pVnode->config), pVnodeCfg);
|
||||||
|
|
|
@ -25,8 +25,8 @@ int vnodeInit(const SVnodeOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeMgr.stop = false;
|
vnodeMgr.stop = false;
|
||||||
vnodeMgr.putReqToVQueryQFp = pOption->putReqToVQueryQFp;
|
vnodeMgr.putToQueryQFp = pOption->putToQueryQFp;
|
||||||
vnodeMgr.sendReqToDnodeFp = pOption->sendReqToDnodeFp;
|
vnodeMgr.sendReqFp = pOption->sendReqFp;
|
||||||
|
|
||||||
// Start commit handers
|
// Start commit handers
|
||||||
if (pOption->nthreads > 0) {
|
if (pOption->nthreads > 0) {
|
||||||
|
@ -90,15 +90,15 @@ int vnodeScheduleTask(SVnodeTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodePutReqToVQueryQ(SVnode* pVnode, struct SRpcMsg* pReq) {
|
int32_t vnodePutReqToVQueryQ(SVnode* pVnode, struct SRpcMsg* pReq) {
|
||||||
if (pVnode == NULL || pVnode->pDnode == NULL || vnodeMgr.putReqToVQueryQFp == NULL) {
|
if (pVnode == NULL || pVnode->pMeta == NULL || vnodeMgr.putToQueryQFp == NULL) {
|
||||||
terrno = TSDB_CODE_VND_APP_ERROR;
|
terrno = TSDB_CODE_VND_APP_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return (*vnodeMgr.putReqToVQueryQFp)(pVnode->pDnode, pReq);
|
return (*vnodeMgr.putToQueryQFp)(pVnode->pMgmt, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeSendReqToDnode(SVnode* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) {
|
void vnodeSendReqToDnode(SVnode* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) {
|
||||||
(*vnodeMgr.sendReqToDnodeFp)(pVnode->pDnode, epSet, pReq);
|
(*vnodeMgr.sendReqFp)(pVnode->pMgmt, epSet, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
||||||
|
|
|
@ -21,7 +21,7 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
int vnodeQueryOpen(SVnode *pVnode) {
|
int vnodeQueryOpen(SVnode *pVnode) {
|
||||||
return qWorkerInit(NODE_TYPE_VNODE, pVnode->vgId, NULL, (void **)&pVnode->pQuery, pVnode,
|
return qWorkerInit(NODE_TYPE_VNODE, pVnode->vgId, NULL, (void **)&pVnode->pQuery, pVnode,
|
||||||
(putReqToQueryQFp)vnodePutReqToVQueryQ, (sendReqToDnodeFp)vnodeSendReqToDnode);
|
(putReqToQueryQFp)vnodePutReqToVQueryQ, (sendReqFp)vnodeSendReqToDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeQueryClose(SVnode *pVnode) {
|
void vnodeQueryClose(SVnode *pVnode) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ typedef struct SQWorkerMgmt {
|
||||||
SHashObj *ctxHash; //key: queryId+taskId, value: SQWTaskCtx
|
SHashObj *ctxHash; //key: queryId+taskId, value: SQWTaskCtx
|
||||||
void *nodeObj;
|
void *nodeObj;
|
||||||
putReqToQueryQFp putToQueueFp;
|
putReqToQueryQFp putToQueueFp;
|
||||||
sendReqToDnodeFp sendReqFp;
|
sendReqFp sendReqFp;
|
||||||
} SQWorkerMgmt;
|
} SQWorkerMgmt;
|
||||||
|
|
||||||
#define QW_FPARAMS_DEF SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId
|
#define QW_FPARAMS_DEF SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId
|
||||||
|
|
|
@ -1443,7 +1443,7 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, void *nodeObj,
|
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qWorkerMgmt, void *nodeObj,
|
||||||
putReqToQueryQFp fp1, sendReqToDnodeFp fp2) {
|
putReqToQueryQFp fp1, sendReqFp fp2) {
|
||||||
if (NULL == qWorkerMgmt || NULL == nodeObj || NULL == fp1 || NULL == fp2) {
|
if (NULL == qWorkerMgmt || NULL == nodeObj || NULL == fp1 || NULL == fp2) {
|
||||||
qError("invalid param to init qworker");
|
qError("invalid param to init qworker");
|
||||||
QW_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
|
|
@ -539,9 +539,9 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) {
|
||||||
return pDisk;
|
return pDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {
|
void tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {
|
||||||
pInfo->datadirs = taosArrayInit(32, sizeof(SMonDiskDesc));
|
pInfo->datadirs = taosArrayInit(32, sizeof(SMonDiskDesc));
|
||||||
if (pInfo->datadirs == NULL) return -1;
|
if (pInfo->datadirs == NULL) return;
|
||||||
|
|
||||||
tfsUpdateSize(pTfs);
|
tfsUpdateSize(pTfs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue