diff --git a/include/util/taoserror.h b/include/util/taoserror.h index f6940b28958112d569c33b6f2b856c3231ca126f..add8f33cc24a3fcb973df596e20222b1512dbace 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -632,6 +632,10 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TMQ_CONSUMER_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x4001) #define TSDB_CODE_TMQ_CONSUMER_CLOSED TAOS_DEF_ERROR_CODE(0, 0x4002) +// TDLite +#define TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS TAOS_DEF_ERROR_CODE(0, 0x4100) +#define TSDB_CODE_TDLITE_IVLD_OPEN_DIR TAOS_DEF_ERROR_CODE(0, 0x4101) + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 616aa39bdf4c41514cc133d7505a97e81a4e9f1c..414834e2eb12fb4d383f6d78f5b9b08b07ddaf55 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -28,13 +28,24 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { } // create vnode env - if (tfsMkdirAt(pTfs, path, (SDiskID){0}) < 0) { - vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno)); - return -1; + if (pTfs) { + if (tfsMkdirAt(pTfs, path, (SDiskID){0}) < 0) { + vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + } else { + if (taosMkDir(path)) { + return TAOS_SYSTEM_ERROR(errno); + } + strcpy(dir, path); + } + + if (pCfg) { + info.config = *pCfg; + } else { + info.config = vnodeCfgDefault; } - - snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); - info.config = *pCfg; info.state.committed = -1; info.state.applied = -1; info.state.commitID = 0; @@ -44,7 +55,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { return -1; } - vInfo("vgId:%d, vnode is created", pCfg->vgId); + vInfo("vgId:%d, vnode is created", info.config.vgId); return 0; } @@ -58,7 +69,11 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { char tdir[TSDB_FILENAME_LEN * 2]; int ret; - snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + if (pTfs) { + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + } else { + snprintf(dir, TSDB_FILENAME_LEN, "%s", path); + } info.config = vnodeCfgDefault; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 1906a771275d16f1aa90841db28b69eb0a401b2e..eb13a08be442ea0365a5e71d01cf1e5f1d999d04 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -633,6 +633,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_MSG, "Invalid message") TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_MISMATCH, "Consumer mismatch") TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_CLOSED, "Consumer closed") +// TDLite +TAOS_DEFINE_ERROR(TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS, "Invalid TDLite open flags") +TAOS_DEFINE_ERROR(TSDB_CODE_TDLITE_IVLD_OPEN_DIR, "Invalid TDLite open directory") + #ifdef TAOS_ERROR_C }; #endif