From 7e61fc1291164b47ad852622bf02fe64191e553d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 20 Oct 2020 07:54:39 +0000 Subject: [PATCH] more code --- src/dnode/CMakeLists.txt | 4 ++++ src/dnode/src/dnodeMain.c | 18 +++++++++++++++++- src/dnode/src/dnodeTier.c | 2 +- src/inc/taoserror.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index 5608cfd6d1..d0cbda48a0 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -36,6 +36,10 @@ IF (TD_LINUX) TARGET_LINK_LIBRARIES(taosd balance sync) ENDIF () + IF (TD_DNODE_PLUGINS) + TARGET_LINK_LIBRARIES(taosd dnodePlugins) + ENDIF() + SET(PREPARE_ENV_CMD "prepare_env_cmd") SET(PREPARE_ENV_TARGET "prepare_env_target") ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD} diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index d22cc93cb4..59c19554b0 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -170,6 +170,17 @@ static void dnodeCheckDataDirOpenned(char *dir) { } static int32_t dnodeInitStorage() { + pDnodeTier = dnodeNewTier(); + if (pDnodeTier == NULL) { + dError("failed to create new dnode tier since %s", tstrerror(terrno)); + return -1; + } + + if (dnodeAddDisks(pDnodeTier, NULL, 0) < 0) { + dError("failed to add disks to dnode tier since %s", tstrerror(terrno)); + return -1; + } + if (dnodeCreateDir(tsDataDir) < 0) { dError("failed to create dir: %s, reason: %s", tsDataDir, strerror(errno)); return -1; @@ -204,7 +215,12 @@ static int32_t dnodeInitStorage() { return 0; } -static void dnodeCleanupStorage() {} +static void dnodeCleanupStorage() { + if (pDnodeTier) { + dnodeCloseTier(pDnodeTier); + pDnodeTier = NULL; + } +} bool dnodeIsFirstDeploy() { return strcmp(tsFirst, tsLocalEp) == 0; diff --git a/src/dnode/src/dnodeTier.c b/src/dnode/src/dnodeTier.c index 310b65a17e..f7b3c1f49e 100644 --- a/src/dnode/src/dnodeTier.c +++ b/src/dnode/src/dnodeTier.c @@ -20,7 +20,7 @@ SDnodeTier *dnodeNewTier() { return NULL; } void * dnodeCloseTier(SDnodeTier *pDnodeTier) { return NULL; } -int dnodeAddDisks(SDnodeTier *pDnodeTier, SDiskCfg *pDiskCfgs, int ndisks); +int dnodeAddDisks(SDnodeTier *pDnodeTier, SDiskCfg *pDiskCfgs, int ndisks) { return 0; } int dnodeUpdateTiersInfo(SDnodeTier *pDnodeTier) { return 0; } int dnodeCheckTiers(SDnodeTier *pDnodeTier) { return 0; } SDisk * dnodeAssignDisk(SDnodeTier *pDnodeTier, int level) { return NULL; } diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index e5619e9267..baa5ef7760 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -187,6 +187,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_ALREADY_EXISTS, 0, 0x0406, "Disk alrea TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_NOT_DIRECTORY, 0, 0x0407, "Disk is not a directory") TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_SPACE, 0, 0x0408, "Dnode no disk space") TAOS_DEFINE_ERROR(TSDB_CODE_DND_DUPLICATE_PRIMARY_DISK, 0, 0x0409, "Duplicate primary disk") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_LACK_PRIMARY_DISK, 0, 0x040A, "Lack primary disk") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_AT_TIER, 0, 0x040B, "No disk at tier") // vnode TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress") -- GitLab