From aa1de8b34a564e2947f2f30414886ce101e1ca21 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Tue, 24 May 2022 14:46:22 +0800 Subject: [PATCH] enh(sync): add FpSnapshotRead FpSnapshotApply --- include/libs/sync/sync.h | 4 ++++ source/libs/sync/inc/syncInt.h | 4 ++-- source/libs/sync/src/syncMain.c | 4 ++-- source/libs/sync/test/syncConfigChangeTest.cpp | 4 +--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 2bf678fa48..50f8281c51 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -90,6 +90,10 @@ typedef struct SSyncFSM { void (*FpRestoreFinish)(struct SSyncFSM* pFsm); int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot); int32_t (*FpRestoreSnapshot)(struct SSyncFSM* pFsm, const SSnapshot* snapshot); + + void* (*FpSnapshotRead)(struct SSyncFSM* pFsm, const SSnapshot* snapshot, void* iter, char** ppBuf, int32_t* len); + int32_t (*FpSnapshotApply)(struct SSyncFSM* pFsm, const SSnapshot* snapshot, char* pBuf, int32_t len); + } SSyncFSM; // abstract definition of log store in raft diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 9246041b81..69549d2a7e 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -148,8 +148,8 @@ typedef struct SSyncNode { SSyncRespMgr* pSyncRespMgr; // restore state - bool restoreFinish; - //sem_t restoreSem; + bool restoreFinish; + // sem_t restoreSem; SSnapshot* pSnapshot; } SSyncNode; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index a233603adf..98d31471ed 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -513,7 +513,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { pSyncNode->pSnapshot = taosMemoryMalloc(sizeof(SSnapshot)); pSyncNode->pFsm->FpGetSnapshot(pSyncNode->pFsm, pSyncNode->pSnapshot); } - //tsem_init(&(pSyncNode->restoreSem), 0, 0); + // tsem_init(&(pSyncNode->restoreSem), 0, 0); // start in syncNodeStart // start raft @@ -610,7 +610,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { taosMemoryFree(pSyncNode->pSnapshot); } - //tsem_destroy(&pSyncNode->restoreSem); + // tsem_destroy(&pSyncNode->restoreSem); // free memory in syncFreeNode // taosMemoryFree(pSyncNode); diff --git a/source/libs/sync/test/syncConfigChangeTest.cpp b/source/libs/sync/test/syncConfigChangeTest.cpp index 0850ef6343..c8a9fba9bf 100644 --- a/source/libs/sync/test/syncConfigChangeTest.cpp +++ b/source/libs/sync/test/syncConfigChangeTest.cpp @@ -73,9 +73,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { return 0; } -void FpRestoreFinishCb(struct SSyncFSM* pFsm) { - sTrace("==callback== ==FpRestoreFinishCb=="); -} +void FpRestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==FpRestoreFinishCb=="); } SSyncFSM* createFsm() { SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM)); -- GitLab