From a65ebcee11b187bf6c6c01c9f8df859547919d80 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Fri, 12 Jun 2020 01:09:41 +0000 Subject: [PATCH] add option "fqdn" to configure local FQDN --- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 39144c3083..53d821b3d8 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -53,6 +53,7 @@ extern int64_t tsMsPerDay[3]; extern char tsFirst[]; extern char tsSecond[]; +extern char tsLocalFqdn[]; extern char tsLocalEp[]; extern uint16_t tsServerPort; extern uint16_t tsDnodeShellPort; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 0cd0e48fbf..f44af78e9a 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -65,6 +65,7 @@ int64_t tsMsPerDay[] = {86400000L, 86400000000L, 86400000000000L}; char tsFirst[TSDB_EP_LEN] = {0}; char tsSecond[TSDB_EP_LEN] = {0}; char tsArbitrator[TSDB_EP_LEN] = {0}; +char tsLocalFqdn[TSDB_FQDN_LEN] = {0}; char tsLocalEp[TSDB_EP_LEN] = {0}; // Local End Point, hostname:port uint16_t tsServerPort = 6030; uint16_t tsDnodeShellPort = 6030; // udp[6035-6039] tcp[6035] @@ -305,6 +306,16 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "fqdn"; + cfg.ptr = tsLocalFqdn; + cfg.valType = TAOS_CFG_VTYPE_STRING; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 0; + cfg.ptrLength = TSDB_FQDN_LEN; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // port cfg.option = "serverPort"; cfg.ptr = &tsServerPort; @@ -1251,9 +1262,13 @@ bool taosCheckGlobalCfg() { taosSetAllDebugFlag(); } - taosGetFqdn(tsLocalEp); - sprintf(tsLocalEp + strlen(tsLocalEp), ":%d", tsServerPort); - uPrint("localEp is %s", tsLocalEp); + if (tsLocalFqdn[0] == 0) + taosGetFqdn(tsLocalEp); + else + strcpy(tsLocalEp, tsLocalFqdn); + + snprintf(tsLocalEp + strlen(tsLocalEp), sizeof(tsLocalEp), ":%d", tsServerPort); + uPrint("localEp is: %s", tsLocalEp); if (tsFirst[0] == 0) { strcpy(tsFirst, tsLocalEp); -- GitLab