Merge pull request #17316 from taosdata/feat/tdlite
refact: adjust some code for further dev
This commit is contained in:
commit
69b7348efc
|
@ -17,11 +17,12 @@ include(${TD_SUPPORT_DIR}/cmake.platform)
|
|||
include(${TD_SUPPORT_DIR}/cmake.define)
|
||||
include(${TD_SUPPORT_DIR}/cmake.options)
|
||||
include(${TD_SUPPORT_DIR}/cmake.version)
|
||||
include(${TD_SUPPORT_DIR}/cmake.install)
|
||||
|
||||
# contrib
|
||||
add_subdirectory(contrib)
|
||||
|
||||
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES OFF)
|
||||
|
||||
# api
|
||||
add_library(api INTERFACE)
|
||||
target_include_directories(api INTERFACE "include/client")
|
||||
|
@ -36,8 +37,7 @@ add_subdirectory(source)
|
|||
add_subdirectory(tools)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(examples/c)
|
||||
include(${TD_SUPPORT_DIR}/cmake.install)
|
||||
|
||||
# docs
|
||||
add_subdirectory(docs/doxgen)
|
||||
|
||||
# tests (TODO)
|
||||
add_subdirectory(docs/doxgen)
|
|
@ -35,7 +35,11 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
|||
*ppMeta = NULL;
|
||||
|
||||
// create handle
|
||||
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
||||
if (pVnode->pTfs) {
|
||||
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
||||
} else {
|
||||
slen = strlen(pVnode->path) + strlen(VNODE_META_DIR) + 2;
|
||||
}
|
||||
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
|
@ -43,8 +47,12 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
|||
|
||||
metaInitLock(pMeta);
|
||||
pMeta->path = (char *)&pMeta[1];
|
||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||
VNODE_META_DIR);
|
||||
if (pVnode->pTfs) {
|
||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||
VNODE_META_DIR);
|
||||
} else {
|
||||
sprintf(pMeta->path, "%s%s%s", pVnode->path, TD_DIRSEP, VNODE_META_DIR);
|
||||
}
|
||||
taosRealPath(pMeta->path, NULL, slen);
|
||||
pMeta->pVnode = pVnode;
|
||||
|
||||
|
|
|
@ -417,6 +417,7 @@ _err:
|
|||
// EXPOSED APIS ====================================================================================
|
||||
int32_t tsdbFSOpen(STsdb *pTsdb) {
|
||||
int32_t code = 0;
|
||||
SVnode *pVnode = pTsdb->pVnode;
|
||||
|
||||
// open handle
|
||||
pTsdb->fs.pDelFile = NULL;
|
||||
|
@ -429,8 +430,12 @@ int32_t tsdbFSOpen(STsdb *pTsdb) {
|
|||
// load fs or keep empty
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP,
|
||||
pTsdb->path, TD_DIRSEP);
|
||||
if (pVnode->pTfs) {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP,
|
||||
pTsdb->path, TD_DIRSEP);
|
||||
} else {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%sCURRENT", pTsdb->path, TD_DIRSEP);
|
||||
}
|
||||
|
||||
if (!taosCheckExistFile(fname)) {
|
||||
// empty one
|
||||
|
|
|
@ -57,10 +57,13 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
} else {
|
||||
memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg));
|
||||
}
|
||||
// pTsdb->fs = tsdbNewFS(REPO_KEEP_CFG(pTsdb));
|
||||
|
||||
// create dir
|
||||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
if (pVnode->pTfs) {
|
||||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
} else {
|
||||
taosMkDir(pTsdb->path);
|
||||
}
|
||||
|
||||
// open tsdb
|
||||
if (tsdbFSOpen(pTsdb) < 0) {
|
||||
|
|
|
@ -227,7 +227,11 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
info.state.committed = pVnode->state.applied;
|
||||
info.state.commitTerm = pVnode->state.applyTerm;
|
||||
info.state.commitID = pVnode->state.commitID;
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
if (pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &info) < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
|
|
|
@ -138,12 +138,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||
|
||||
// for test tsdb snapshot
|
||||
#if 0
|
||||
pVnode->config.walCfg.segSize = 200;
|
||||
pVnode->config.walCfg.retentionSize = 2000;
|
||||
#endif
|
||||
|
||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||
if (pVnode->pWal == NULL) {
|
||||
vError("vgId:%d, failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
|
@ -159,12 +153,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
#if !VNODE_AS_LIB
|
||||
// open query
|
||||
if (vnodeQueryOpen(pVnode)) {
|
||||
vError("vgId:%d, failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
#endif
|
||||
|
||||
// vnode begin
|
||||
if (vnodeBegin(pVnode) < 0) {
|
||||
|
@ -173,11 +169,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
#if !VNODE_AS_LIB
|
||||
// open sync
|
||||
if (vnodeSyncOpen(pVnode, dir)) {
|
||||
vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
#endif
|
||||
|
||||
return pVnode;
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
add_subdirectory(transport)
|
||||
add_subdirectory(sync)
|
||||
add_subdirectory(tdb)
|
||||
add_subdirectory(index)
|
||||
add_subdirectory(cache)
|
||||
add_subdirectory(transport)
|
||||
add_subdirectory(wal)
|
||||
add_subdirectory(monitor)
|
||||
add_subdirectory(tfs)
|
||||
add_subdirectory(sync)
|
||||
add_subdirectory(qcom)
|
||||
add_subdirectory(nodes)
|
||||
add_subdirectory(catalog)
|
||||
|
||||
add_subdirectory(scalar)
|
||||
add_subdirectory(function)
|
||||
add_subdirectory(index)
|
||||
add_subdirectory(parser)
|
||||
add_subdirectory(scheduler)
|
||||
add_subdirectory(cache)
|
||||
add_subdirectory(catalog)
|
||||
add_subdirectory(executor)
|
||||
add_subdirectory(stream)
|
||||
add_subdirectory(planner)
|
||||
add_subdirectory(function)
|
||||
add_subdirectory(qcom)
|
||||
add_subdirectory(qworker)
|
||||
add_subdirectory(tfs)
|
||||
add_subdirectory(monitor)
|
||||
add_subdirectory(nodes)
|
||||
add_subdirectory(scalar)
|
||||
add_subdirectory(command)
|
|
@ -14,7 +14,14 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
function
|
||||
PRIVATE os util common nodes scalar qcom transport stream
|
||||
PRIVATE os
|
||||
PRIVATE util
|
||||
PRIVATE common
|
||||
PRIVATE nodes
|
||||
PRIVATE qcom
|
||||
PRIVATE scalar
|
||||
PRIVATE transport
|
||||
PRIVATE stream
|
||||
PUBLIC uv_a
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ target_include_directories(
|
|||
|
||||
target_link_libraries(
|
||||
qcom
|
||||
PRIVATE os util transport nodes
|
||||
PRIVATE os util transport
|
||||
)
|
||||
|
||||
if(${BUILD_TEST})
|
||||
|
|
|
@ -8,8 +8,14 @@ target_include_directories(
|
|||
)
|
||||
|
||||
target_link_libraries(scalar
|
||||
PRIVATE os util common nodes function qcom vnode
|
||||
)
|
||||
PRIVATE os
|
||||
PRIVATE util
|
||||
PRIVATE common
|
||||
PRIVATE nodes
|
||||
PRIVATE function
|
||||
PRIVATE qcom
|
||||
PRIVATE vnode
|
||||
)
|
||||
|
||||
if(${BUILD_TEST})
|
||||
ADD_SUBDIRECTORY(test)
|
||||
|
|
|
@ -16,11 +16,6 @@ target_link_libraries(
|
|||
)
|
||||
if (${BUILD_WITH_UV_TRANS})
|
||||
if (${BUILD_WITH_UV})
|
||||
target_include_directories(
|
||||
transport
|
||||
PUBLIC "${TD_SOURCE_DIR}/contrib/libuv/include"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
transport
|
||||
PUBLIC uv_a
|
||||
|
|
Loading…
Reference in New Issue