enh: refactor a func name as tsdbSnapGetDetails
This commit is contained in:
parent
9643799dc5
commit
29bbebc323
|
@ -295,7 +295,7 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr
|
|||
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
|
||||
int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback);
|
||||
// STsdbSnapReader ========================================
|
||||
int32_t tsdbSnapGetInfo(STsdb* pTsdb, SSnapshot* pSnap);
|
||||
int32_t tsdbSnapGetDetails(SVnode* pVnode, SSnapshot* pSnap);
|
||||
int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, void* pRanges,
|
||||
STsdbSnapReader** ppReader);
|
||||
int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader);
|
||||
|
|
|
@ -1507,13 +1507,15 @@ void tsdbSnapPartListDestroy(STsdbSnapPartList** ppList) {
|
|||
ppList[0] = NULL;
|
||||
}
|
||||
|
||||
int32_t tsdbSnapGetInfo(STsdb* pTsdb, SSnapshot* pSnap) {
|
||||
pSnap->state = pTsdb->pFS->fsstate;
|
||||
if (pSnap->type != TDMT_SYNC_PREP_SNAPSHOT && pSnap->type != TDMT_SYNC_PREP_SNAPSHOT_REPLY) {
|
||||
return 0;
|
||||
int32_t tsdbSnapGetDetails(SVnode* pVnode, SSnapshot* pSnap) {
|
||||
int code = -1;
|
||||
if (pVnode->pTsdb->pFS->fsstate == TSDB_FS_STATE_NORMAL) {
|
||||
pSnap->state = SYNC_FSM_STATE_NORMAL;
|
||||
} else {
|
||||
pSnap->state = SYNC_FSM_STATE_INCOMPLETE;
|
||||
}
|
||||
|
||||
int code = -1;
|
||||
STsdb* pTsdb = pVnode->pTsdb;
|
||||
STsdbSnapPartList* pList = tsdbGetSnapPartList(pTsdb->pFS);
|
||||
if (pList == NULL) goto _out;
|
||||
|
||||
|
@ -1522,6 +1524,7 @@ int32_t tsdbSnapGetInfo(STsdb* pTsdb, SSnapshot* pSnap) {
|
|||
|
||||
void* buf = NULL;
|
||||
int32_t tlen = 0;
|
||||
|
||||
// estimate data length encode
|
||||
int32_t bufLen = sizeof(SSyncTLV); // typ: TDMT_SYNC_PREP_SNAPSHOT or TDMT_SYNC_PREP_SNAPSOT_REPLY
|
||||
bufLen += sizeof(SSyncTLV); // subtyp: SNAP_DATA_TSDB
|
||||
|
|
|
@ -787,12 +787,13 @@ bool vnodeIsLeader(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
int32_t vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnap) {
|
||||
int code = 0;
|
||||
pSnap->lastApplyIndex = pVnode->state.committed;
|
||||
pSnap->lastApplyTerm = pVnode->state.commitTerm;
|
||||
pSnap->lastConfigIndex = -1;
|
||||
|
||||
int32_t code = tsdbSnapGetInfo(pVnode->pTsdb, pSnap);
|
||||
|
||||
pSnap->state = (pSnap->state == TSDB_FS_STATE_INCOMPLETE) ? SYNC_FSM_STATE_INCOMPLETE : SYNC_FSM_STATE_NORMAL;
|
||||
if (pSnap->type == TDMT_SYNC_PREP_SNAPSHOT || pSnap->type == TDMT_SYNC_PREP_SNAPSHOT_REPLY) {
|
||||
code = tsdbSnapGetDetails(pVnode, pSnap);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue