Skip to content

Commit

Permalink
Merge pull request #2250 from taosdata/enhance/fqdn
Browse files Browse the repository at this point in the history
add option "fqdn" to configure local FQDN
  • Loading branch information
guanshengliang committed Jun 12, 2020
2 parents cae80f4 + a65ebce commit a4018dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/common/inc/tglobal.h
Expand Up @@ -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;
Expand Down
21 changes: 18 additions & 3 deletions src/common/src/tglobal.c
Expand Up @@ -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]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a4018dc

Please sign in to comment.