From 32c3cecf2abb11c782db49862c66dd50ba4d06f3 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Sun, 10 Jul 2022 11:33:28 +0800 Subject: [PATCH] refactor(sync): add snapshot writer --- source/dnode/vnode/src/vnd/vnodeSync.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index a2f5fa6dbb..8d0ae4785b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -469,11 +469,24 @@ static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void ** return code; } -static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) { return 0; } +static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) { + SVnode *pVnode = pFsm->data; + SSnapshotParam *pSnapshotParam = pParam; + int32_t code = vnodeSnapWriterOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapWriter **)ppWriter); + return code; +} -static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { return 0; } +static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { + SVnode *pVnode = pFsm->data; + int32_t code = vnodeSnapWriterClose(pWriter, isApply); + return code; +} -static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { return 0; } +static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { + SVnode *pVnode = pFsm->data; + int32_t code = vnodeSnapWrite(pWriter, pBuf, len); + return code; +} static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); -- GitLab