diff --git a/source/dnode/mgmt/exec/inc/dndExec.h b/source/dnode/mgmt/exec/inc/dndExec.h index 6bb4b84b2a..72523e52ad 100644 --- a/source/dnode/mgmt/exec/inc/dndExec.h +++ b/source/dnode/mgmt/exec/inc/dndExec.h @@ -14,12 +14,13 @@ * along with this program. If not, see . */ -#ifndef _TD_DMN_INT_H_ -#define _TD_DMN_INT_H_ +#ifndef _TD_DND_EXEC_H_ +#define _TD_DND_EXEC_H_ -#include "tconfig.h" #include "dnode.h" + #include "taoserror.h" +#include "tconfig.h" #include "tglobal.h" #include "tlog.h" #include "version.h" @@ -35,14 +36,14 @@ extern "C" { #define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} #define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} -void dmnDumpCfg(); -void dmnPrintVersion(); -void dmnGenerateGrant(); +void dndDumpCfg(); +void dndPrintVersion(); +void dndGenerateGrant(); -SDnodeObjCfg dmnGetObjCfg(); +SDnodeObjCfg dndGetObjCfg(); #ifdef __cplusplus } #endif -#endif /*_TD_DMN_INT_H_*/ +#endif /*_TD_DND_EXEC_H_*/ diff --git a/source/dnode/mgmt/exec/src/dndCfg.c b/source/dnode/mgmt/exec/src/dndCfg.c index afb9ffbdd0..64cc48afe5 100644 --- a/source/dnode/mgmt/exec/src/dndCfg.c +++ b/source/dnode/mgmt/exec/src/dndCfg.c @@ -14,10 +14,9 @@ */ #define _DEFAULT_SOURCE -#include "dmnInt.h" -#include "tconfig.h" +#include "dndExec.h" -SDnodeObjCfg dmnGetObjCfg() { +SDnodeObjCfg dndGetObjCfg() { SConfig *pCfg = taosGetCfg(); SDnodeObjCfg objCfg = {0}; @@ -33,7 +32,7 @@ SDnodeObjCfg dmnGetObjCfg() { return objCfg; } -void dmnDumpCfg() { +void dndDumpCfg() { SConfig *pCfg = taosGetCfg(); cfgDumpCfg(pCfg, 0, 1); } \ No newline at end of file diff --git a/source/dnode/mgmt/exec/src/dndMain.c b/source/dnode/mgmt/exec/src/dndMain.c index 3c2460e607..2576c80ff5 100644 --- a/source/dnode/mgmt/exec/src/dndMain.c +++ b/source/dnode/mgmt/exec/src/dndMain.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dmnInt.h" +#include "dndExec.h" static struct { bool dumpConfig; @@ -24,22 +24,22 @@ static struct { char envFile[PATH_MAX]; char apolloUrl[PATH_MAX]; SDnode *pDnode; -} dmn = {0}; +} global = {0}; -static void dmnSigintHandle(int signum, void *info, void *ctx) { +static void dndSigintHandle(int signum, void *info, void *ctx) { dInfo("singal:%d is received", signum); - dndeHandleEvent(dmn.pDnode, DND_EVENT_STOP); + dndeHandleEvent(global.pDnode, DND_EVENT_STOP); } -static void dmnSetSignalHandle() { - taosSetSignal(SIGTERM, dmnSigintHandle); - taosSetSignal(SIGHUP, dmnSigintHandle); - taosSetSignal(SIGINT, dmnSigintHandle); - taosSetSignal(SIGABRT, dmnSigintHandle); - taosSetSignal(SIGBREAK, dmnSigintHandle); +static void dndSetSignalHandle() { + taosSetSignal(SIGTERM, dndSigintHandle); + taosSetSignal(SIGHUP, dndSigintHandle); + taosSetSignal(SIGINT, dndSigintHandle); + taosSetSignal(SIGABRT, dndSigintHandle); + taosSetSignal(SIGBREAK, dndSigintHandle); } -static int32_t dmnParseOption(int32_t argc, char const *argv[]) { +static int32_t dndParseOption(int32_t argc, char const *argv[]) { for (int32_t i = 1; i < argc; ++i) { if (strcmp(argv[i], "-c") == 0) { if (i < argc - 1) { @@ -53,11 +53,11 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) { return -1; } } else if (strcmp(argv[i], "-C") == 0) { - dmn.dumpConfig = true; + global.dumpConfig = true; } else if (strcmp(argv[i], "-k") == 0) { - dmn.generateGrant = true; + global.generateGrant = true; } else if (strcmp(argv[i], "-V") == 0) { - dmn.printVersion = true; + global.printVersion = true; } else { } } @@ -65,19 +65,20 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) { return 0; } -int32_t dmnRunDnode() { +static int32_t dndRunDnode() { if (dndInit() != 0) { dInfo("failed to initialize dnode environment since %s", terrstr()); return -1; } - SDnodeObjCfg objCfg = dmnGetObjCfg(); + SDnodeObjCfg objCfg = dndGetObjCfg(); SDnode *pDnode = dndCreate(&objCfg); if (pDnode == NULL) { dError("failed to to create dnode object since %s", terrstr()); return -1; } else { - dmn.pDnode = pDnode; + global.pDnode = pDnode; + dndSetSignalHandle(); } dInfo("start the TDengine service"); @@ -97,36 +98,36 @@ int main(int argc, char const *argv[]) { return -1; } - if (dmnParseOption(argc, argv) != 0) { + if (dndParseOption(argc, argv) != 0) { return -1; } - if (dmn.generateGrant) { - dmnGenerateGrant(); + if (global.generateGrant) { + dndGenerateGrant(); return 0; } - if (dmn.printVersion) { - dmnPrintVersion(); + if (global.printVersion) { + dndPrintVersion(); return 0; } - if (taosCreateLog("taosdlog", 1, configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) { + if (taosCreateLog("taosdlog", 1, configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) { dError("failed to start TDengine since read log config error"); return -1; } - if (taosInitCfg(configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) { + if (taosInitCfg(configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) { dError("failed to start TDengine since read config error"); return -1; } - if (dmn.dumpConfig) { - dmnDumpCfg(); + if (global.dumpConfig) { + dndDumpCfg(); taosCleanupCfg(); taosCloseLog(); return 0; } - return dmnRunDnode(); + return dndRunDnode(); } diff --git a/source/dnode/mgmt/exec/src/dndUtil.c b/source/dnode/mgmt/exec/src/dndUtil.c index d58a5968c0..f0f613da17 100644 --- a/source/dnode/mgmt/exec/src/dndUtil.c +++ b/source/dnode/mgmt/exec/src/dndUtil.c @@ -14,15 +14,15 @@ */ #define _DEFAULT_SOURCE -#include "dmnInt.h" +#include "dndExec.h" -void dmnGenerateGrant() { +void dndGenerateGrant() { #if 0 grantParseParameter(); #endif } -void dmnPrintVersion() { +void dndPrintVersion() { #ifdef TD_ENTERPRISE char *releaseName = "enterprise"; #else