refactor: adjust vnode header file
This commit is contained in:
parent
0f9cd43027
commit
f2a84eda09
|
@ -45,20 +45,20 @@ typedef struct SVnodeCfg SVnodeCfg;
|
||||||
|
|
||||||
extern const SVnodeCfg vnodeCfgDefault;
|
extern const SVnodeCfg vnodeCfgDefault;
|
||||||
|
|
||||||
int vnodeInit(int nthreads);
|
int32_t vnodeInit(int32_t nthreads);
|
||||||
void vnodeCleanup();
|
void vnodeCleanup();
|
||||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
||||||
void vnodeDestroy(const char *path, STfs *pTfs);
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||||
void vnodeClose(SVnode *pVnode);
|
void vnodeClose(SVnode *pVnode);
|
||||||
int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version);
|
int32_t vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version);
|
||||||
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
||||||
int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
int vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
||||||
|
|
||||||
int32_t vnodeStart(SVnode *pVnode);
|
int32_t vnodeStart(SVnode *pVnode);
|
||||||
void vnodeStop(SVnode *pVnode);
|
void vnodeStop(SVnode *pVnode);
|
||||||
|
@ -74,8 +74,8 @@ typedef struct SMetaEntry SMetaEntry;
|
||||||
|
|
||||||
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags);
|
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags);
|
||||||
void metaReaderClear(SMetaReader *pReader);
|
void metaReaderClear(SMetaReader *pReader);
|
||||||
int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
||||||
int metaReadNext(SMetaReader *pReader);
|
int32_t metaReadNext(SMetaReader *pReader);
|
||||||
const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t cid);
|
const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t cid);
|
||||||
|
|
||||||
#if 1 // refact APIs below (TODO)
|
#if 1 // refact APIs below (TODO)
|
||||||
|
@ -86,7 +86,7 @@ typedef struct SMTbCursor SMTbCursor;
|
||||||
|
|
||||||
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
|
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
|
||||||
void metaCloseTbCursor(SMTbCursor *pTbCur);
|
void metaCloseTbCursor(SMTbCursor *pTbCur);
|
||||||
int metaTbCursorNext(SMTbCursor *pTbCur);
|
int32_t metaTbCursorNext(SMTbCursor *pTbCur);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
|
@ -124,8 +124,8 @@ typedef struct STqReadHandle STqReadHandle;
|
||||||
STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta);
|
STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta);
|
||||||
|
|
||||||
void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList);
|
void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList);
|
||||||
int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
int32_t tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||||
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
int32_t tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||||
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
||||||
bool tqNextDataBlock(STqReadHandle *pHandle);
|
bool tqNextDataBlock(STqReadHandle *pHandle);
|
||||||
bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids);
|
bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids);
|
||||||
|
@ -207,15 +207,15 @@ struct SMetaReader {
|
||||||
SDecoder coder;
|
SDecoder coder;
|
||||||
SMetaEntry me;
|
SMetaEntry me;
|
||||||
void *pBuf;
|
void *pBuf;
|
||||||
int szBuf;
|
int32_t szBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMTbCursor {
|
struct SMTbCursor {
|
||||||
TBC *pDbc;
|
TBC *pDbc;
|
||||||
void *pKey;
|
void *pKey;
|
||||||
void *pVal;
|
void *pVal;
|
||||||
int kLen;
|
int32_t kLen;
|
||||||
int vLen;
|
int32_t vLen;
|
||||||
SMetaReader mr;
|
SMetaReader mr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vnodeDebug ====================
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
||||||
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
||||||
|
@ -34,17 +33,17 @@ extern "C" {
|
||||||
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
|
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// vnodeCfg ====================
|
// vnodeCfg.c
|
||||||
extern const SVnodeCfg vnodeCfgDefault;
|
extern const SVnodeCfg vnodeCfgDefault;
|
||||||
|
|
||||||
int vnodeCheckCfg(const SVnodeCfg*);
|
int32_t vnodeCheckCfg(const SVnodeCfg*);
|
||||||
int vnodeEncodeConfig(const void* pObj, SJson* pJson);
|
int32_t vnodeEncodeConfig(const void* pObj, SJson* pJson);
|
||||||
int vnodeDecodeConfig(const SJson* pJson, void* pObj);
|
int32_t vnodeDecodeConfig(const SJson* pJson, void* pObj);
|
||||||
|
|
||||||
// vnodeModule ====================
|
// vnodeModule.c
|
||||||
int vnodeScheduleTask(int (*execute)(void*), void* arg);
|
int32_t vnodeScheduleTask(int32_t (*execute)(void*), void* arg);
|
||||||
|
|
||||||
// vnodeBufPool ====================
|
// vnodeBufPool.c
|
||||||
typedef struct SVBufPoolNode SVBufPoolNode;
|
typedef struct SVBufPoolNode SVBufPoolNode;
|
||||||
struct SVBufPoolNode {
|
struct SVBufPoolNode {
|
||||||
SVBufPoolNode* prev;
|
SVBufPoolNode* prev;
|
||||||
|
@ -62,37 +61,29 @@ struct SVBufPool {
|
||||||
SVBufPoolNode node;
|
SVBufPoolNode node;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
||||||
int vnodeCloseBufPool(SVnode* pVnode);
|
int32_t vnodeCloseBufPool(SVnode* pVnode);
|
||||||
void vnodeBufPoolReset(SVBufPool* pPool);
|
void vnodeBufPoolReset(SVBufPool* pPool);
|
||||||
|
|
||||||
// vnodeQuery ====================
|
// vnodeQuery.c
|
||||||
int vnodeQueryOpen(SVnode* pVnode);
|
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||||
void vnodeQueryClose(SVnode* pVnode);
|
void vnodeQueryClose(SVnode* pVnode);
|
||||||
int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
|
|
||||||
// vnodeCommit ====================
|
// vnodeCommit.c
|
||||||
int vnodeBegin(SVnode* pVnode);
|
int32_t vnodeBegin(SVnode* pVnode);
|
||||||
int vnodeShouldCommit(SVnode* pVnode);
|
int32_t vnodeShouldCommit(SVnode* pVnode);
|
||||||
int vnodeCommit(SVnode* pVnode);
|
int32_t vnodeCommit(SVnode* pVnode);
|
||||||
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||||
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||||
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
int32_t vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
||||||
int vnodeSyncCommit(SVnode* pVnode);
|
int32_t vnodeSyncCommit(SVnode* pVnode);
|
||||||
int vnodeAsyncCommit(SVnode* pVnode);
|
int32_t vnodeAsyncCommit(SVnode* pVnode);
|
||||||
|
|
||||||
// vnodeCommit ====================
|
// vnodeSync.c
|
||||||
int32_t vnodeSyncOpen(SVnode* pVnode, char* path);
|
int32_t vnodeSyncOpen(SVnode* pVnode, char* path);
|
||||||
int32_t vnodeSyncStart(SVnode* pVnode);
|
void vnodeSyncStart(SVnode* pVnode);
|
||||||
void vnodeSyncClose(SVnode* pVnode);
|
void vnodeSyncClose(SVnode* pVnode);
|
||||||
void vnodeSyncSetMsgCb(SVnode* pVnode);
|
|
||||||
int32_t vnodeSyncEqMsg(const SMsgCb* msgcb, SRpcMsg* pMsg);
|
|
||||||
int32_t vnodeSyncSendMsg(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
|
||||||
void vnodeSyncCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
|
||||||
void vnodeSyncPreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
|
||||||
void vnodeSyncRollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
|
||||||
int32_t vnodeSyncGetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
|
||||||
SSyncFSM* syncVnodeMakeFsm();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,10 +674,10 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
syncUtilraftId2EpSet(destRaftId, &epSet);
|
syncUtilraftId2EpSet(destRaftId, &epSet);
|
||||||
if (pSyncNode->FpSendMsg != NULL) {
|
if (pSyncNode->FpSendMsg != NULL) {
|
||||||
pMsg->info.noResp = 1;
|
|
||||||
// htonl
|
// htonl
|
||||||
syncUtilMsgHtoN(pMsg->pCont);
|
syncUtilMsgHtoN(pMsg->pCont);
|
||||||
|
|
||||||
|
pMsg->info.noResp = 1;
|
||||||
pSyncNode->FpSendMsg(&epSet, pMsg);
|
pSyncNode->FpSendMsg(&epSet, pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("syncNodeSendMsgById pSyncNode->FpSendMsg is NULL");
|
sTrace("syncNodeSendMsgById pSyncNode->FpSendMsg is NULL");
|
||||||
|
@ -689,10 +689,10 @@ int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, S
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
syncUtilnodeInfo2EpSet(nodeInfo, &epSet);
|
syncUtilnodeInfo2EpSet(nodeInfo, &epSet);
|
||||||
if (pSyncNode->FpSendMsg != NULL) {
|
if (pSyncNode->FpSendMsg != NULL) {
|
||||||
pMsg->info.noResp = 1;
|
|
||||||
// htonl
|
// htonl
|
||||||
syncUtilMsgHtoN(pMsg->pCont);
|
syncUtilMsgHtoN(pMsg->pCont);
|
||||||
|
|
||||||
|
pMsg->info.noResp = 1;
|
||||||
pSyncNode->FpSendMsg(&epSet, pMsg);
|
pSyncNode->FpSendMsg(&epSet, pMsg);
|
||||||
} else {
|
} else {
|
||||||
sTrace("syncNodeSendMsgByInfo pSyncNode->FpSendMsg is NULL");
|
sTrace("syncNodeSendMsgByInfo pSyncNode->FpSendMsg is NULL");
|
||||||
|
|
|
@ -97,11 +97,12 @@ int main(int argc, char** argv) {
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
SyncPingReply* pSyncMsg =
|
SyncPingReply* pSyncMsg =
|
||||||
syncPingReplyBuild2(&pSyncNode->myRaftId, &pSyncNode->myRaftId, 1000, "syncIOSendMsgTest");
|
syncPingReplyBuild2(&pSyncNode->myRaftId, &pSyncNode->myRaftId, 1000, "syncIOSendMsgTest");
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg = {0};
|
||||||
syncPingReply2RpcMsg(pSyncMsg, &rpcMsg);
|
syncPingReply2RpcMsg(pSyncMsg, &rpcMsg);
|
||||||
|
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
syncUtilnodeInfo2EpSet(&pSyncNode->myNodeInfo, &epSet);
|
syncUtilnodeInfo2EpSet(&pSyncNode->myNodeInfo, &epSet);
|
||||||
|
rpcMsg.info.noResp = 1;
|
||||||
pSyncNode->FpSendMsg(&epSet, &rpcMsg);
|
pSyncNode->FpSendMsg(&epSet, &rpcMsg);
|
||||||
|
|
||||||
taosMsleep(1000);
|
taosMsleep(1000);
|
||||||
|
|
Loading…
Reference in New Issue