diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 30a33fcdb4..18fd17f018 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -195,6 +195,20 @@ if (TD_LINUX) ELSE() set(TD_DEPS_DIR "x86") ENDIF() +elseif (TD_DARWIN) + IF (TD_ARM_64 OR TD_ARM_32) + set(TD_DEPS_DIR "darwin/arm") + ELSE () + set(TD_DEPS_DIR "darwin/x64") + ENDIF () +elseif (TD_WINDOWS) + IF (TD_WINDOWS_64) + set(TD_DEPS_DIR "win/x64") + ELSEIF (TD_WINDOWS_32) + set(TD_DEPS_DIR "win/i386") + ENDIF () +else () + MESSAGE(FATAL_ERROR "unsupported platform") endif() MESSAGE(STATUS "DEPS_DIR: " ${TD_DEPS_DIR}) diff --git a/cmake/curl_CMakeLists.txt.in b/cmake/curl_CMakeLists.txt.in index d02e9d5bbf..c632b4ef8e 100644 --- a/cmake/curl_CMakeLists.txt.in +++ b/cmake/curl_CMakeLists.txt.in @@ -1,6 +1,7 @@ # curl ExternalProject_Add(curl URL https://curl.se/download/curl-8.2.1.tar.gz + URL_HASH MD5 b25588a43556068be05e1624e0e74d41 DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download" #GIT_REPOSITORY https://github.com/curl/curl.git diff --git a/deps/arm/dm_static/libdmodule.a b/deps/arm/dm_static/libdmodule.a new file mode 100644 index 0000000000..49084af930 Binary files /dev/null and b/deps/arm/dm_static/libdmodule.a differ diff --git a/deps/darwin/arm/dm_static/libdmodule.a b/deps/darwin/arm/dm_static/libdmodule.a new file mode 100644 index 0000000000..b9dc621e1c Binary files /dev/null and b/deps/darwin/arm/dm_static/libdmodule.a differ diff --git a/deps/darwin/x64/dm_static/libdmodule.a b/deps/darwin/x64/dm_static/libdmodule.a new file mode 100644 index 0000000000..a87b333738 Binary files /dev/null and b/deps/darwin/x64/dm_static/libdmodule.a differ diff --git a/deps/win/x64/dm_static/dmodule.lib b/deps/win/x64/dm_static/dmodule.lib new file mode 100644 index 0000000000..cf3b4d99c6 Binary files /dev/null and b/deps/win/x64/dm_static/dmodule.lib differ diff --git a/deps/x86/dm_static/libdmodule.a b/deps/x86/dm_static/libdmodule.a new file mode 100644 index 0000000000..c4561fbd48 Binary files /dev/null and b/deps/x86/dm_static/libdmodule.a differ diff --git a/source/dnode/mgmt/mgmt_dnode/CMakeLists.txt b/source/dnode/mgmt/mgmt_dnode/CMakeLists.txt index fdd0830a58..f7920d3d8e 100644 --- a/source/dnode/mgmt/mgmt_dnode/CMakeLists.txt +++ b/source/dnode/mgmt/mgmt_dnode/CMakeLists.txt @@ -3,11 +3,22 @@ add_library(mgmt_dnode STATIC ${MGMT_DNODE}) if (DEFINED GRANT_CFG_INCLUDE_DIR) add_definitions(-DGRANTS_CFG) endif() + +IF (NOT BUILD_DM_MODULE) + MESSAGE(STATUS "NOT BUILD_DM_MODULE") + target_link_directories( + mgmt_dnode + PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/dm_static" + ) +ELSE() + MESSAGE(STATUS "BUILD_DM_MODULE") +ENDIF() + target_include_directories( mgmt_dnode PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" PUBLIC "${GRANT_CFG_INCLUDE_DIR}" ) target_link_libraries( - mgmt_dnode node_util + mgmt_dnode node_util dmodule ) \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c index fd9f4fccbe..d5d05565b5 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "dmInt.h" +#include "libs/function/tudf.h" static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) { if (dmStartStatusThread(pMgmt) != 0) { diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c index 3b425a0b49..8a042da078 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "qmInt.h" +#include "libs/function/tudf.h" static int32_t qmRequire(const SMgmtInputOpt *pInput, bool *required) { return dmReadFile(pInput->path, pInput->name, required); diff --git a/source/dnode/mgmt/mgmt_snode/src/smInt.c b/source/dnode/mgmt/mgmt_snode/src/smInt.c index e222349767..47c2993014 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smInt.c +++ b/source/dnode/mgmt/mgmt_snode/src/smInt.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "smInt.h" #include "libs/function/function.h" +#include "libs/function/tudf.h" static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) { return dmReadFile(pInput->path, pInput->name, required); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index f0ab703b8a..963bfa3197 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -17,6 +17,7 @@ #include "vmInt.h" #include "tfs.h" #include "vnd.h" +#include "libs/function/tudf.h" int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) { STfs *pTfs = pMgmt->pTfs; diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index 1c6625ba1a..3cf7a360f9 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -95,6 +95,10 @@ void dmCleanupDnode(SDnode *pDnode); SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType); int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); +int32_t dmInitVars(SDnode *pDnode); +void dmClearVars(SDnode *pDnode); +int32_t dmInitModule(SDnode *pDnode); +bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper); SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 8815647047..d560ba1644 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -16,24 +16,7 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" #include "audit.h" - -#define STR_CASE_CMP(s, d) (0 == strcasecmp((s), (d))) -#define STR_STR_CMP(s, d) (strstr((s), (d))) -#define STR_INT_CMP(s, d, c) (taosStr2Int32(s, 0, 10) c(d)) -#define STR_STR_SIGN ("ia") -#define DM_INIT_MON() \ - do { \ - code = (int32_t)(2147483648 | 298); \ - strncpy(stName, tsVersionName, 64); \ - monCfg.maxLogs = tsMonitorMaxLogs; \ - monCfg.port = tsMonitorPort; \ - monCfg.server = tsMonitorFqdn; \ - monCfg.comp = tsMonitorComp; \ - if (monInit(&monCfg) != 0) { \ - if (terrno != 0) code = terrno; \ - goto _exit; \ - } \ - } while (0) +#include "libs/function/tudf.h" #define DM_INIT_AUDIT() \ do { \ @@ -45,15 +28,7 @@ } \ } while (0) -#define DM_ERR_RTN(c) \ - do { \ - code = (c); \ - goto _exit; \ - } while (0) - static SDnode globalDnode = {0}; -static const char *dmOS[10] = {"Ubuntu", "CentOS Linux", "Red Hat", "Debian GNU", "CoreOS", - "FreeBSD", "openSUSE", "SLES", "Fedora", "macOS"}; SDnode *dmInstance() { return &globalDnode; } @@ -76,30 +51,14 @@ static int32_t dmInitSystem() { static int32_t dmInitMonitor() { int32_t code = 0; SMonCfg monCfg = {0}; - char reName[64] = {0}; - char stName[64] = {0}; - char ver[64] = {0}; - DM_INIT_MON(); - - if (STR_STR_CMP(stName, STR_STR_SIGN)) { - DM_ERR_RTN(0); - } - if (taosGetOsReleaseName(reName, stName, ver, 64) != 0) { - DM_ERR_RTN(code); - } - if (STR_CASE_CMP(stName, dmOS[0])) { - if (STR_INT_CMP(ver, 17, >)) { - DM_ERR_RTN(0); - } - } else if (STR_CASE_CMP(stName, dmOS[1])) { - if (STR_INT_CMP(ver, 6, >)) { - DM_ERR_RTN(0); - } - } else if (STR_STR_CMP(stName, dmOS[2]) || STR_STR_CMP(stName, dmOS[3]) || STR_STR_CMP(stName, dmOS[4]) || - STR_STR_CMP(stName, dmOS[5]) || STR_STR_CMP(stName, dmOS[6]) || STR_STR_CMP(stName, dmOS[7]) || - STR_STR_CMP(stName, dmOS[8]) || STR_STR_CMP(stName, dmOS[9])) { - DM_ERR_RTN(0); + monCfg.maxLogs = tsMonitorMaxLogs; + monCfg.port = tsMonitorPort; + monCfg.server = tsMonitorFqdn; + monCfg.comp = tsMonitorComp; + if (monInit(&monCfg) != 0) { + if (terrno != 0) code = terrno; + goto _exit; } _exit: diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index dedd588c53..15697dc448 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -24,88 +24,6 @@ #include "tcompression.h" #endif -static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) { - SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); - - bool required = false; - int32_t code = (*pWrapper->func.requiredFp)(&input, &required); - if (!required) { - dDebug("node:%s, does not require startup", pWrapper->name); - } else { - dDebug("node:%s, required to startup", pWrapper->name); - } - - return required; -} - -static int32_t dmInitVars(SDnode *pDnode) { - SDnodeData *pData = &pDnode->data; - pData->dnodeId = 0; - pData->clusterId = 0; - pData->dnodeVer = 0; - pData->updateTime = 0; - pData->rebootTime = taosGetTimestampMs(); - pData->dropped = 0; - pData->stopped = 0; - - pData->dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - if (pData->dnodeHash == NULL) { - dError("failed to init dnode hash"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - if (dmReadEps(pData) != 0) { - dError("failed to read file since %s", terrstr()); - return -1; - } - - if (pData->dropped) { - dError("dnode will not start since its already dropped"); - return -1; - } - - taosThreadRwlockInit(&pData->lock, NULL); - taosThreadMutexInit(&pDnode->mutex, NULL); - return 0; -} - -static void dmClearVars(SDnode *pDnode) { - for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - taosMemoryFreeClear(pWrapper->path); - taosThreadRwlockDestroy(&pWrapper->lock); - } - if (pDnode->lockfile != NULL) { - taosUnLockFile(pDnode->lockfile); - taosCloseFile(&pDnode->lockfile); - pDnode->lockfile = NULL; - } - - SDnodeData *pData = &pDnode->data; - taosThreadRwlockWrlock(&pData->lock); - if (pData->oldDnodeEps != NULL) { - if (dmWriteEps(pData) == 0) { - dmRemoveDnodePairs(pData); - } - taosArrayDestroy(pData->oldDnodeEps); - pData->oldDnodeEps = NULL; - } - if (pData->dnodeEps != NULL) { - taosArrayDestroy(pData->dnodeEps); - pData->dnodeEps = NULL; - } - if (pData->dnodeHash != NULL) { - taosHashCleanup(pData->dnodeHash); - pData->dnodeHash = NULL; - } - taosThreadRwlockUnlock(&pData->lock); - - taosThreadRwlockDestroy(&pData->lock); - taosThreadMutexDestroy(&pDnode->mutex); - memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); -} - int32_t dmInitDnode(SDnode *pDnode) { dDebug("start to create dnode"); int32_t code = -1; @@ -143,22 +61,12 @@ int32_t dmInitDnode(SDnode *pDnode) { pWrapper->required = dmRequireNode(pDnode, pWrapper); } - if (dmInitMsgHandle(pDnode) != 0) { - dError("failed to init msg handles since %s", terrstr()); - goto _OVER; - } - pDnode->lockfile = dmCheckRunning(tsDataDir); if (pDnode->lockfile == NULL) { goto _OVER; } - if (dmInitServer(pDnode) != 0) { - dError("failed to init transport since %s", terrstr()); - goto _OVER; - } - - if (dmInitClient(pDnode) != 0) { + if(dmInitModule(pDnode) != 0) { goto _OVER; } diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 9d97e6ae9f..0a52c578a5 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -40,7 +40,6 @@ #include "tfs.h" #include "wal.h" -#include "libs/function/tudf.h" #ifdef __cplusplus extern "C" { #endif @@ -94,6 +93,7 @@ typedef int32_t (*ProcessAlterNodeTypeFp)(EDndNodeType ntype, SRpcMsg *pMsg); typedef struct { int32_t dnodeId; + int32_t engineVer; int64_t clusterId; int64_t dnodeVer; int64_t updateTime; @@ -172,6 +172,9 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed); int32_t dmWriteFile(const char *path, const char *name, bool deployed); TdFilePtr dmCheckRunning(const char *dataDir); +// dmodule.c +int32_t dmInitDndInfo(SDnodeData *pData); + // dmEps.c int32_t dmReadEps(SDnodeData *pData); int32_t dmWriteEps(SDnodeData *pData); diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 88f6b5da40..3e948678a4 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -57,6 +57,8 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) { if (code < 0) return -1; tjsonGetNumberValue(pJson, "dnodeVer", pData->dnodeVer, code); if (code < 0) return -1; + tjsonGetNumberValue(pJson, "engineVer", pData->engineVer, code); + if (code < 0) return -1; tjsonGetNumberValue(pJson, "clusterId", pData->clusterId, code); if (code < 0) return -1; tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code); @@ -96,7 +98,8 @@ int32_t dmReadEps(SDnodeData *pData) { pData->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp)); if (pData->dnodeEps == NULL) { - dError("failed to calloc dnodeEp array since %s", strerror(errno)); + code = terrno; + dError("failed to calloc dnodeEp array since %s", terrstr()); goto _OVER; } @@ -184,6 +187,7 @@ _OVER: static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) { if (tjsonAddDoubleToObject(pJson, "dnodeId", pData->dnodeId) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "dnodeVer", pData->dnodeVer) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1; if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1; @@ -218,8 +222,11 @@ int32_t dmWriteEps(SDnodeData *pData) { snprintf(realfile, sizeof(realfile), "%s%sdnode%sdnode.json", tsDataDir, TD_DIRSEP, TD_DIRSEP); terrno = TSDB_CODE_OUT_OF_MEMORY; + + if((code == dmInitDndInfo(pData)) != 0) goto _OVER; pJson = tjsonCreateObject(); if (pJson == NULL) goto _OVER; + pData->engineVer = tsVersion; if (dmEncodeEps(pJson, pData) != 0) goto _OVER; buffer = tjsonToString(pJson); if (buffer == NULL) goto _OVER;