tglobal.c 48.5 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
S
Shengliang Guan 已提交
20
#include "ulog.h"
S
Shengliang Guan 已提交
21
#include "tlog.h"
S
slguan 已提交
22 23
#include "tconfig.h"
#include "tglobal.h"
S
Shengliang Guan 已提交
24
#include "tcompare.h"
S
slguan 已提交
25 26
#include "tutil.h"
#include "ttimezone.h"
S
Shengliang Guan 已提交
27
#include "tlocale.h"
28
#include "tep.h"
S
slguan 已提交
29

S
Shengliang Guan 已提交
30 31 32 33 34 35
// cluster
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
J
jtao1735 已提交
36
uint16_t tsServerPort = 6030;
S
Shengliang Guan 已提交
37
int32_t  tsStatusInterval = 1;  // second
38
int32_t  tsNumOfMnodes = 1;
S
Shengliang Guan 已提交
39
int8_t   tsEnableVnodeBak = 1;
S
Shengliang Guan 已提交
40
int8_t   tsEnableTelemetryReporting = 0;
S
TD-2680  
Shengliang Guan 已提交
41
int8_t   tsArbOnline = 0;
42
int64_t  tsArbOnlineTimestamp = TSDB_ARB_DUMMY_TIME;
H
Hui Li 已提交
43
char     tsEmail[TSDB_FQDN_LEN] = {0};
D
dapan1121 已提交
44
int32_t  tsDnodeId = 0;
45
int64_t  tsDnodeStartTime = 0;
H
Hui Li 已提交
46

S
Shengliang Guan 已提交
47
// common
Y
yihaoDeng 已提交
48
int32_t tsRpcTimer       = 300;
H
Haojun Liao 已提交
49
int32_t tsRpcMaxTime     = 600;  // seconds;
50
int32_t tsRpcForceTcp    = 1;  //disable this, means query, show command use udp protocol as default
Y
TD-3138  
yihaoDeng 已提交
51
int32_t tsMaxShellConns  = 50000;
S
Shengliang Guan 已提交
52
int32_t tsMaxConnections = 5000;
H
Haojun Liao 已提交
53 54
int32_t tsShellActivityTimer  = 3;  // second
float   tsNumOfThreadsPerCore = 1.0f;
55
int32_t tsNumOfCommitThreads = 4;
56
float   tsRatioOfQueryCores = 1.0f;
H
Haojun Liao 已提交
57
int8_t  tsDaylight       = 0;
S
Shengliang Guan 已提交
58
int8_t  tsEnableCoreFile = 0;
S
Shengliang Guan 已提交
59
int32_t tsMaxBinaryDisplayWidth = 30;
60
int64_t tsMaxVnodeQueuedBytes = 1024*1024*1024; //1GB
S
slguan 已提交
61

S
Shengliang Guan 已提交
62 63 64 65 66 67 68 69
/*
 * denote if the server needs to compress response message at the application layer to client, including query rsp,
 * metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
 *
 * 0: all data are compressed
 * -1: all data are not compressed
 * other values: if the message payload size is greater than the tsCompressMsgSize, the message will be compressed.
 */
D
dapan1121 已提交
70
int32_t tsCompressMsgSize = -1;
S
Shengliang Guan 已提交
71

72
/* denote if server needs to compress the retrieved column data before adding to the rpc response message body.
73 74
 * 0: all data are compressed
 * -1: all data are not compressed
75
 * other values: if any retrieved column size is greater than the tsCompressColData, all data will be compressed.
76
 */
77
int32_t tsCompressColData = -1;
78

79 80 81 82 83
/*
 * denote if 3.0 query pattern compatible for 2.0
 */
int32_t tsCompatibleModel = 1;

S
Shengliang Guan 已提交
84
// client
85
int32_t tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN;
86
int32_t tsMaxWildCardsLen = TSDB_PATTERN_STRING_DEFAULT_LEN;
87 88
int32_t tsMaxRegexStringLen = TSDB_REGEX_STRING_DEFAULT_LEN;

S
Shengliang Guan 已提交
89
int8_t  tsTscEnableRecordSql = 0;
S
slguan 已提交
90

S
Shengliang Guan 已提交
91 92 93 94 95 96 97
// the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp
int32_t tsMaxNumOfOrderedResults = 100000;

// 10 ms for sliding time, the value will changed in case of time precision changed
int32_t tsMinSlidingTime = 10;

98
// the maxinum number of distict query result
99 100
int32_t tsMaxNumOfDistinctResults  = 1000 * 10000;

101 102
// 1 us for interval time range, changed accordingly
int32_t tsMinIntervalTime = 1;
S
Shengliang Guan 已提交
103 104 105 106 107 108 109 110

// 20sec, the maximum value of stream computing delay, changed accordingly
int32_t tsMaxStreamComputDelay = 20000;

// 10sec, the first stream computing delay time after system launched successfully, changed accordingly
int32_t tsStreamCompStartDelay = 10000;

// the stream computing delay time after executing failed, change accordingly
111
int32_t tsRetryStreamCompDelay = 10*1000;
S
Shengliang Guan 已提交
112 113

// The delayed computing ration. 10% of the whole computing time window by default.
114
float tsStreamComputDelayRatio = 0.1f;
S
Shengliang Guan 已提交
115 116 117 118

int32_t tsProjectExecInterval = 10000;   // every 10sec, the projection will be executed once
int64_t tsMaxRetentWindow = 24 * 3600L;  // maximum time window tolerance

H
Haojun Liao 已提交
119 120 121 122 123
// the maximum allowed query buffer size during query processing for each data node.
// -1 no limit (default)
// 0  no query allowed, queries are disabled
// positive value (in MB)
int32_t tsQueryBufferSize = -1;
124
int64_t tsQueryBufferSizeBytes = -1;
H
Haojun Liao 已提交
125

H
Haojun Liao 已提交
126 127
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
int32_t tsRetrieveBlockingModel = 0;
128

129
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
S
Shengliang Guan 已提交
130
int8_t  tsKeepOriginalColumnName = 0;
131

S
Shengliang Guan 已提交
132
// db parameters
S
slguan 已提交
133
int32_t tsCacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
H
hjxilinx 已提交
134 135 136
int32_t tsBlocksPerVnode = TSDB_DEFAULT_TOTAL_BLOCKS;
int16_t tsDaysPerFile    = TSDB_DEFAULT_DAYS_PER_FILE;
int32_t tsDaysToKeep     = TSDB_DEFAULT_KEEP;
S
slguan 已提交
137 138
int32_t tsMinRowsInFileBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK;
int32_t tsMaxRowsInFileBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK;
H
hjxilinx 已提交
139
int16_t tsCommitTime    = TSDB_DEFAULT_COMMIT_TIME;  // seconds
S
slguan 已提交
140
int32_t tsTimePrecision = TSDB_DEFAULT_PRECISION;
S
TD-1207  
Shengliang Guan 已提交
141 142
int8_t  tsCompression   = TSDB_DEFAULT_COMP_LEVEL;
int8_t  tsWAL           = TSDB_DEFAULT_WAL_LEVEL;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
143
int32_t tsFsyncPeriod   = TSDB_DEFAULT_FSYNC_PERIOD;
144
int32_t tsReplications  = TSDB_DEFAULT_DB_REPLICA_OPTION;
145
int32_t tsQuorum        = TSDB_DEFAULT_DB_QUORUM_OPTION;
S
Shengliang Guan 已提交
146
int8_t  tsUpdate        = TSDB_DEFAULT_DB_UPDATE_OPTION;
S
TD-3220  
Shengliang Guan 已提交
147
int8_t  tsCacheLastRow  = TSDB_DEFAULT_CACHE_LAST_ROW;
148
int32_t tsMaxVgroupsPerDb  = 0;
149
int32_t tsTsdbMetaCompactRatio = TSDB_META_COMPACT_RATIO;
150

Y
yihaoDeng 已提交
151 152 153 154
// tsdb config 
// For backward compatibility
bool tsdbForceKeepFile = false;

S
Shengliang Guan 已提交
155
// balance
S
Shengliang Guan 已提交
156 157 158
int8_t  tsEnableBalance = 1;
int8_t  tsAlternativeRole = 0;
int32_t tsBalanceInterval = 300;           // seconds
159
int32_t tsOfflineThreshold = 86400 * 10;  // seconds of 10 days
S
Shengliang Guan 已提交
160 161 162
int8_t  tsEnableFlowCtrl = 1;
int8_t  tsEnableSlaveQuery = 1;
int8_t  tsEnableAdjustMaster = 1;
S
slguan 已提交
163

S
Shengliang Guan 已提交
164 165
// restful
int32_t  tsRestRowLimit = 10240;
S
Shengliang Guan 已提交
166
int8_t   tsTelegrafUseFieldNum = 0;
S
Shengliang Guan 已提交
167 168

// mqtt
S
Shengliang Guan 已提交
169
int8_t tsEnableMqttModule = 0;  // not finished yet, not started it by default
S
TD-1310  
Shengliang Guan 已提交
170 171 172 173 174
char    tsMqttHostName[TSDB_MQTT_HOSTNAME_LEN] = "test.mosquitto.org";
char    tsMqttPort[TSDB_MQTT_PORT_LEN] = "1883";
char    tsMqttUser[TSDB_MQTT_USER_LEN] = {0};
char    tsMqttPass[TSDB_MQTT_PASS_LEN] = {0};
char    tsMqttClientId[TSDB_MQTT_CLIENT_ID_LEN] = "TDengineMqttSubscriber";
175
char    tsMqttTopic[TSDB_MQTT_TOPIC_LEN] = "/test"; // #
S
Shengliang Guan 已提交
176 177

// monitor
S
Shengliang Guan 已提交
178
int8_t  tsEnableMonitorModule = 1;
S
Shengliang Guan 已提交
179 180 181
char    tsMonitorDbName[TSDB_DB_NAME_LEN] = "log";
char    tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30;  // seconds
S
slguan 已提交
182

183
// stream
S
Shengliang Guan 已提交
184
int8_t  tsEnableStream = 1;
185

S
Shengliang Guan 已提交
186
// internal
187
int8_t tsCompactMnodeWal = 0;
S
Shengliang Guan 已提交
188
int8_t tsPrintAuth = 0;
T
tickduan 已提交
189 190 191
char   tsVnodeDir[PATH_MAX] = {0};
char   tsDnodeDir[PATH_MAX] = {0};
char   tsMnodeDir[PATH_MAX] = {0};
192

H
Hongze Cheng 已提交
193
int32_t  tsDiskCfgNum = 0;
194
int32_t tsTopicBianryLen = 16000;
S
TD-1767  
Shengliang Guan 已提交
195 196 197 198 199 200

#ifndef _STORAGE
SDiskCfg tsDiskCfg[1];
#else
SDiskCfg tsDiskCfg[TSDB_MAX_DISKS];
#endif
S
Shengliang Guan 已提交
201 202 203 204 205 206 207

/*
 * minimum scale for whole system, millisecond by default
 * for TSDB_TIME_PRECISION_MILLI: 86400000L
 *     TSDB_TIME_PRECISION_MICRO: 86400000000L
 *     TSDB_TIME_PRECISION_NANO:  86400000000000L
 */
208
int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L};
S
Shengliang Guan 已提交
209 210 211 212

// system info
float   tsTotalTmpDirGB = 0;
float   tsTotalDataDirGB = 0;
H
Haojun Liao 已提交
213
float   tsAvailTmpDirectorySpace = 0;
S
Shengliang Guan 已提交
214
float   tsAvailDataDirGB = 0;
215
float   tsUsedDataDirGB = 0;
S
Shengliang Guan 已提交
216
float   tsReservedTmpDirectorySpace = 1.0f;
217
float   tsMinimalDataDirGB = 2.0f;
S
Shengliang Guan 已提交
218
int32_t tsTotalMemoryMB = 0;
219
uint32_t tsVersion = 0;
S
slguan 已提交
220

T
tickduan 已提交
221
#ifdef TD_TSZ
T
tickduan 已提交
222 223 224 225 226 227 228
//
// lossy compress 6
//
char lossyColumns[32] = "";  // "float|double" means all float and double columns can be lossy compressed.  set empty can close lossy compress.
// below option can take effect when tsLossyColumns not empty 
double   fPrecision   = 1E-8;   // float column precision
double   dPrecision   = 1E-16;  // double column precision
T
tickduan 已提交
229 230
uint32_t maxRange     = 500;    // max range
uint32_t curRange     = 100;    // range
T
tickduan 已提交
231
char     Compressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR 
232
#endif
T
tickduan 已提交
233

234
// long query death-lock
235
int8_t tsDeadLockKillQuery = 0;
236

S
Shengliang Guan 已提交
237 238 239
int32_t (*monStartSystemFp)() = NULL;
void (*monStopSystemFp)() = NULL;
void (*monExecuteSQLFp)(char *sql) = NULL;
240

S
Shengliang Guan 已提交
241 242
char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"};

S
slguan 已提交
243 244 245
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;

void taosSetAllDebugFlag() {
S
Shengliang Guan 已提交
246
  if (debugFlag != 0) { 
guanshengliang's avatar
guanshengliang 已提交
247
    mDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
248 249 250
    sdbDebugFlag = debugFlag;
    dDebugFlag = debugFlag;
    vDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
251 252
    jniDebugFlag = debugFlag;
    odbcDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
253
    httpDebugFlag = debugFlag;
254
    mqttDebugFlag = debugFlag;
S
Shengliang Guan 已提交
255
    monDebugFlag = debugFlag;
S
TD-1520  
Shengliang Guan 已提交
256
    qDebugFlag = debugFlag;    
guanshengliang's avatar
guanshengliang 已提交
257 258 259
    rpcDebugFlag = debugFlag;
    uDebugFlag = debugFlag;
    sDebugFlag = debugFlag;
S
Shengliang Guan 已提交
260
    wDebugFlag = debugFlag;
261
    tsdbDebugFlag = debugFlag;
S
TD-1520  
Shengliang Guan 已提交
262
    cqDebugFlag = debugFlag;
S
Shengliang Guan 已提交
263
    uInfo("all debug flag are set to %d", debugFlag);
S
slguan 已提交
264 265 266
  }
}

S
Shengliang Guan 已提交
267
int32_t taosCfgDynamicOptions(char *msg) {
S
slguan 已提交
268 269 270 271 272
  char *option, *value;
  int32_t   olen, vlen;
  int32_t   vint = 0;

  paGetToken(msg, &option, &olen);
S
Shengliang Guan 已提交
273
  if (olen == 0) return -1;;
S
slguan 已提交
274 275 276 277 278 279 280 281

  paGetToken(option + olen + 1, &value, &vlen);
  if (vlen == 0)
    vint = 135;
  else {
    vint = atoi(value);
  }

282
  uInfo("change dynamic option: %s, value: %d", option, vint);
S
slguan 已提交
283 284 285

  for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
    SGlobalCfg *cfg = tsGlobalConfig + i;
286
    //if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
S
Shengliang Guan 已提交
287
    if (cfg->valType != TAOS_CFG_VTYPE_INT32 && cfg->valType != TAOS_CFG_VTYPE_INT8) continue;
288
    
S
Shengliang Guan 已提交
289
    int32_t cfgLen = (int32_t)strlen(cfg->option);
290
    if (cfgLen != olen) continue;
T
tickduan 已提交
291 292 293 294 295 296
    if (strncasecmp(option, cfg->option, olen) != 0) continue;
    if (cfg->valType == TAOS_CFG_VTYPE_INT32) {
      *((int32_t *)cfg->ptr) = vint;
    } else {
      *((int8_t *)cfg->ptr) = (int8_t)vint;
    }
T
tickduan 已提交
297

S
slguan 已提交
298
    if (strncasecmp(cfg->option, "monitor", olen) == 0) {
299
      if (1 == vint) {
S
Shengliang Guan 已提交
300 301
        if (monStartSystemFp) {
          (*monStartSystemFp)();
302
          uInfo("monitor is enabled");
303 304
        } else {
          uError("monitor can't be updated, for monitor not initialized");
305 306
        }
      } else {
S
Shengliang Guan 已提交
307 308
        if (monStopSystemFp) {
          (*monStopSystemFp)();
309
          uInfo("monitor is disabled");
310 311
        } else {
          uError("monitor can't be updated, for monitor not initialized");
312 313
        }
      }
S
Shengliang Guan 已提交
314
      return 0;
S
slguan 已提交
315
    }
Y
yihaoDeng 已提交
316 317 318
    if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
       taosSetAllDebugFlag(); 
    }
S
Shengliang Guan 已提交
319
    return 0;
S
slguan 已提交
320 321 322 323
  }

  if (strncasecmp(option, "resetlog", 8) == 0) {
    taosResetLog();
324
    taosPrintCfg();
S
Shengliang Guan 已提交
325
    return 0;
S
slguan 已提交
326 327 328
  }

  if (strncasecmp(option, "resetQueryCache", 15) == 0) {
S
Shengliang Guan 已提交
329 330
    if (monExecuteSQLFp) {
      (*monExecuteSQLFp)("resetQueryCache");
331 332 333 334
      uInfo("resetquerycache is executed");
    } else {
      uError("resetquerycache can't be executed, for monitor not started");
    }
S
slguan 已提交
335 336 337 338 339
  }

  return false;
}

S
TD-1767  
Shengliang Guan 已提交
340 341 342 343 344 345 346 347 348
void taosAddDataDir(int index, char *v1, int level, int primary) {
  tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
  tsDiskCfg[index].level = level;
  tsDiskCfg[index].primary = primary;
  uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
}

#ifndef _STORAGE
void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
S
TD-1767  
Shengliang Guan 已提交
349 350 351 352 353 354
  if (tsDiskCfgNum == 1) {
    SDiskCfg *cfg = &tsDiskCfg[0];
    uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
  }
  taosAddDataDir(0, v1, 0, 1);
  tsDiskCfgNum = 1;
S
TD-1767  
Shengliang Guan 已提交
355 356 357 358 359
}

void taosPrintDataDirCfg() {
  for (int i = 0; i < tsDiskCfgNum; ++i) {
    SDiskCfg *cfg = &tsDiskCfg[i];
S
TD-1767  
Shengliang Guan 已提交
360
    uInfo(" dataDir: %s", cfg->dir);
S
TD-1767  
Shengliang Guan 已提交
361 362
  }
}
S
TD-1767  
Shengliang Guan 已提交
363
#endif
S
TD-1767  
Shengliang Guan 已提交
364 365 366 367 368

static void taosCheckDataDirCfg() {
  if (tsDiskCfgNum <= 0) {
    taosAddDataDir(0, tsDataDir, 0, 1);
    tsDiskCfgNum = 1;
S
TD-1767  
Shengliang Guan 已提交
369
    uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
S
TD-1767  
Shengliang Guan 已提交
370 371 372
  }
}

373
static void doInitGlobalConfig(void) {
S
TD-1057  
Shengliang Guan 已提交
374
  osInit();
S
TD-1652  
Shengliang Guan 已提交
375 376
  srand(taosSafeRand());

S
slguan 已提交
377 378 379
  SGlobalCfg cfg = {0};
  
  // ip address
H
Hui Li 已提交
380
  cfg.option = "firstEp";
S
slguan 已提交
381 382
  cfg.ptr = tsFirst;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
383 384 385
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
386
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
387
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
388
  taosAddConfigOption(cfg);
S
slguan 已提交
389

H
Hui Li 已提交
390
  cfg.option = "secondEp";
J
jtao1735 已提交
391
  cfg.ptr = tsSecond;
S
slguan 已提交
392
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
393 394 395
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
396
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
397
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
398
  taosAddConfigOption(cfg);
S
slguan 已提交
399

400 401 402 403 404 405 406 407
  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;
408
  taosAddConfigOption(cfg);
409

S
slguan 已提交
410
  // port
J
jtao1735 已提交
411 412
  cfg.option = "serverPort";
  cfg.ptr = &tsServerPort;
413
  cfg.valType = TAOS_CFG_VTYPE_UINT16;
S
slguan 已提交
414 415
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
416
  cfg.maxValue = 65056;
S
slguan 已提交
417 418
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
419
  taosAddConfigOption(cfg);
S
slguan 已提交
420 421 422 423 424 425 426 427 428 429

  // directory
  cfg.option = "configDir";
  cfg.ptr = configDir;
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
430
  taosAddConfigOption(cfg);
S
slguan 已提交
431 432

  cfg.option = "logDir";
S
slguan 已提交
433
  cfg.ptr = tsLogDir;
S
slguan 已提交
434 435
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_LOG;
436 437 438 439
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
440
  taosAddConfigOption(cfg);
441

S
slguan 已提交
442
  cfg.option = "scriptDir";
S
slguan 已提交
443
  cfg.ptr = tsScriptDir;
S
slguan 已提交
444 445 446 447 448 449
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
450
  taosAddConfigOption(cfg);
S
slguan 已提交
451 452

  cfg.option = "dataDir";
S
slguan 已提交
453
  cfg.ptr = tsDataDir;
S
TD-1767  
Shengliang Guan 已提交
454
  cfg.valType = TAOS_CFG_VTYPE_DATA_DIRCTORY;
S
slguan 已提交
455 456 457 458 459
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
460
  taosAddConfigOption(cfg);
S
slguan 已提交
461

J
jtao1735 已提交
462 463
  cfg.option = "arbitrator";
  cfg.ptr = tsArbitrator;
S
slguan 已提交
464
  cfg.valType = TAOS_CFG_VTYPE_STRING;
465
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
J
jtao1735 已提交
466 467
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
468
  cfg.ptrLength = TSDB_EP_LEN;
J
jtao1735 已提交
469
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
470
  taosAddConfigOption(cfg);
J
jtao1735 已提交
471

S
slguan 已提交
472 473 474 475 476 477 478 479 480
  // dnode configs
  cfg.option = "numOfThreadsPerCore";
  cfg.ptr = &tsNumOfThreadsPerCore;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 10;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
481
  taosAddConfigOption(cfg);
S
slguan 已提交
482

S
TD-2067  
Shengliang Guan 已提交
483 484 485 486 487 488 489 490
  cfg.option = "numOfCommitThreads";
  cfg.ptr = &tsNumOfCommitThreads;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 1;
  cfg.maxValue = 100;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
491
  taosAddConfigOption(cfg);
S
TD-2067  
Shengliang Guan 已提交
492

493 494
  cfg.option = "ratioOfQueryCores";
  cfg.ptr = &tsRatioOfQueryCores;
S
slguan 已提交
495 496
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
497 498
  cfg.minValue = 0.0f;
  cfg.maxValue = 2.0f;
S
slguan 已提交
499 500
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
501
  taosAddConfigOption(cfg);
S
slguan 已提交
502

503 504 505 506 507 508 509 510
  cfg.option = "maxNumOfDistinctRes";
  cfg.ptr = &tsMaxNumOfDistinctResults;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 10*10000;
  cfg.maxValue = 10000*10000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
511
  taosAddConfigOption(cfg);
512
  
513 514
  cfg.option = "numOfMnodes";
  cfg.ptr = &tsNumOfMnodes;
S
slguan 已提交
515 516 517 518 519 520
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1;
  cfg.maxValue = 3;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
521
  taosAddConfigOption(cfg);
S
slguan 已提交
522

H
Hui Li 已提交
523 524
  cfg.option = "vnodeBak";
  cfg.ptr = &tsEnableVnodeBak;
S
Shengliang Guan 已提交
525
  cfg.valType = TAOS_CFG_VTYPE_INT8;
H
Hui Li 已提交
526 527 528 529 530
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
531
  taosAddConfigOption(cfg);
H
Hui Li 已提交
532

B
Bomin Zhang 已提交
533 534
  cfg.option = "telemetryReporting";
  cfg.ptr = &tsEnableTelemetryReporting;
S
Shengliang Guan 已提交
535
  cfg.valType = TAOS_CFG_VTYPE_INT8;
B
Bomin Zhang 已提交
536 537 538 539 540
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
541
  taosAddConfigOption(cfg);
B
Bomin Zhang 已提交
542

S
Shengliang Guan 已提交
543 544
  cfg.option = "balance";
  cfg.ptr = &tsEnableBalance;
S
Shengliang Guan 已提交
545
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
546 547 548 549 550
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
551
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
552

S
slguan 已提交
553
  cfg.option = "balanceInterval";
S
slguan 已提交
554
  cfg.ptr = &tsBalanceInterval;
S
slguan 已提交
555 556 557 558 559 560
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1;
  cfg.maxValue = 30000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
561
  taosAddConfigOption(cfg);
S
slguan 已提交
562

563
  // 0-any; 1-mnode; 2-vnode
S
Shengliang Guan 已提交
564
  cfg.option = "role";
S
slguan 已提交
565
  cfg.ptr = &tsAlternativeRole;
S
Shengliang Guan 已提交
566
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
567 568 569 570 571
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 2;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
572
  taosAddConfigOption(cfg);
S
slguan 已提交
573 574 575

  // timer
  cfg.option = "maxTmrCtrl";
S
Shengliang Guan 已提交
576
  cfg.ptr = &tsMaxTmrCtrl;
S
slguan 已提交
577 578 579 580 581 582
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 8;
  cfg.maxValue = 2048;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
583
  taosAddConfigOption(cfg);
S
slguan 已提交
584 585 586 587 588 589 590 591 592

  cfg.option = "monitorInterval";
  cfg.ptr = &tsMonitorInterval;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 1;
  cfg.maxValue = 600;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
593
  taosAddConfigOption(cfg);
S
slguan 已提交
594 595 596 597 598

  cfg.option = "offlineThreshold";
  cfg.ptr = &tsOfflineThreshold;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
TD-2513  
Shengliang Guan 已提交
599
  cfg.minValue = 3;
600
  cfg.maxValue = 86400 * 365;
S
slguan 已提交
601 602
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
603
  taosAddConfigOption(cfg);
S
slguan 已提交
604 605 606 607 608 609 610 611 612

  cfg.option = "rpcTimer";
  cfg.ptr = &tsRpcTimer;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 100;
  cfg.maxValue = 3000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
613
  taosAddConfigOption(cfg);
S
slguan 已提交
614

张宏权 已提交
615 616 617 618 619 620 621 622
  cfg.option = "rpcForceTcp";
  cfg.ptr = &tsRpcForceTcp;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
623
  taosAddConfigOption(cfg);
张宏权 已提交
624

S
slguan 已提交
625 626 627 628 629 630 631 632
  cfg.option = "rpcMaxTime";
  cfg.ptr = &tsRpcMaxTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 100;
  cfg.maxValue = 7200;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
633
  taosAddConfigOption(cfg);
S
slguan 已提交
634 635 636 637 638 639 640 641 642

  cfg.option = "statusInterval";
  cfg.ptr = &tsStatusInterval;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1;
  cfg.maxValue = 10;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
643
  taosAddConfigOption(cfg);
S
slguan 已提交
644 645 646 647 648 649 650 651 652

  cfg.option = "shellActivityTimer";
  cfg.ptr = &tsShellActivityTimer;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
  cfg.maxValue = 120;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
653
  taosAddConfigOption(cfg);
S
slguan 已提交
654 655 656 657 658 659 660 661 662

  cfg.option = "minSlidingTime";
  cfg.ptr = &tsMinSlidingTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
663
  taosAddConfigOption(cfg);
S
slguan 已提交
664 665 666 667 668

  cfg.option = "minIntervalTime";
  cfg.ptr = &tsMinIntervalTime;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
H
Haojun Liao 已提交
669
  cfg.minValue = 1;
S
slguan 已提交
670 671 672
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
673
  taosAddConfigOption(cfg);
S
slguan 已提交
674 675 676 677 678 679 680 681 682

  cfg.option = "maxStreamCompDelay";
  cfg.ptr = &tsMaxStreamComputDelay;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
683
  taosAddConfigOption(cfg);
S
slguan 已提交
684 685 686 687 688 689 690 691 692

  cfg.option = "maxFirstStreamCompDelay";
  cfg.ptr = &tsStreamCompStartDelay;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 1000;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
693
  taosAddConfigOption(cfg);
S
slguan 已提交
694 695

  cfg.option = "retryStreamCompDelay";
696
  cfg.ptr = &tsRetryStreamCompDelay;
S
slguan 已提交
697 698 699 700 701 702 703
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 1000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;

704
  taosAddConfigOption(cfg);
S
slguan 已提交
705 706 707 708
  cfg.option = "streamCompDelayRatio";
  cfg.ptr = &tsStreamComputDelayRatio;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
709 710
  cfg.minValue = 0.1f;
  cfg.maxValue = 0.9f;
S
slguan 已提交
711 712
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
713
  taosAddConfigOption(cfg);
S
slguan 已提交
714

715 716 717 718 719 720 721 722
  cfg.option = "maxVgroupsPerDb";
  cfg.ptr = &tsMaxVgroupsPerDb;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 8192;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
723
  taosAddConfigOption(cfg);
724

S
slguan 已提交
725 726 727
  cfg.option = "cache";
  cfg.ptr = &tsCacheBlockSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
S
slguan 已提交
728
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
729 730
  cfg.minValue = TSDB_MIN_CACHE_BLOCK_SIZE;
  cfg.maxValue = TSDB_MAX_CACHE_BLOCK_SIZE;
S
slguan 已提交
731
  cfg.ptrLength = 0;
H
Haojun Liao 已提交
732
  cfg.unitType = TAOS_CFG_UTYPE_MB;
733
  taosAddConfigOption(cfg);
S
slguan 已提交
734 735

  cfg.option = "blocks";
H
hjxilinx 已提交
736
  cfg.ptr = &tsBlocksPerVnode;
S
slguan 已提交
737 738 739 740 741
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_TOTAL_BLOCKS;
  cfg.maxValue = TSDB_MAX_TOTAL_BLOCKS;
  cfg.ptrLength = 0;
H
Hongze Cheng 已提交
742
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
743
  taosAddConfigOption(cfg);
S
slguan 已提交
744 745 746 747 748

  cfg.option = "days";
  cfg.ptr = &tsDaysPerFile;
  cfg.valType = TAOS_CFG_VTYPE_INT16;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
749 750
  cfg.minValue = TSDB_MIN_DAYS_PER_FILE;
  cfg.maxValue = TSDB_MAX_DAYS_PER_FILE;
S
slguan 已提交
751 752
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
753
  taosAddConfigOption(cfg);
S
slguan 已提交
754 755 756 757 758

  cfg.option = "keep";
  cfg.ptr = &tsDaysToKeep;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
759 760
  cfg.minValue = TSDB_MIN_KEEP;
  cfg.maxValue = TSDB_MAX_KEEP;
S
slguan 已提交
761 762
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
763
  taosAddConfigOption(cfg);
S
slguan 已提交
764

S
slguan 已提交
765 766
  cfg.option = "minRows";
  cfg.ptr = &tsMinRowsInFileBlock;
S
slguan 已提交
767 768
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
769 770
  cfg.minValue = TSDB_MIN_MIN_ROW_FBLOCK;
  cfg.maxValue = TSDB_MAX_MIN_ROW_FBLOCK;
S
slguan 已提交
771 772
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
773
  taosAddConfigOption(cfg);
S
slguan 已提交
774

S
slguan 已提交
775 776
  cfg.option = "maxRows";
  cfg.ptr = &tsMaxRowsInFileBlock;
S
slguan 已提交
777 778
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
779 780
  cfg.minValue = TSDB_MIN_MAX_ROW_FBLOCK;
  cfg.maxValue = TSDB_MAX_MAX_ROW_FBLOCK;
S
slguan 已提交
781 782
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
783
  taosAddConfigOption(cfg);
S
slguan 已提交
784

785 786 787 788 789 790 791 792
  cfg.option = "precision";
  cfg.ptr = &tsTimePrecision;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_PRECISION;
  cfg.maxValue = TSDB_MAX_PRECISION;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
793
  taosAddConfigOption(cfg);
794

S
slguan 已提交
795 796
  cfg.option = "comp";
  cfg.ptr = &tsCompression;
S
TD-1207  
Shengliang Guan 已提交
797
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
798 799 800 801 802
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_COMP_LEVEL;
  cfg.maxValue = TSDB_MAX_COMP_LEVEL;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
803
  taosAddConfigOption(cfg);
S
slguan 已提交
804

805
  cfg.option = "walLevel";
H
hjxilinx 已提交
806
  cfg.ptr = &tsWAL;
S
TD-1207  
Shengliang Guan 已提交
807
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
808
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
H
hjxilinx 已提交
809 810
  cfg.minValue = TSDB_MIN_WAL_LEVEL;
  cfg.maxValue = TSDB_MAX_WAL_LEVEL;
S
slguan 已提交
811 812
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
813
  taosAddConfigOption(cfg);
S
slguan 已提交
814

815
  cfg.option = "fsync";
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
816 817 818 819 820 821 822
  cfg.ptr = &tsFsyncPeriod;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_FSYNC_PERIOD;
  cfg.maxValue = TSDB_MAX_FSYNC_PERIOD;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
823
  taosAddConfigOption(cfg);
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
824

S
slguan 已提交
825 826
  cfg.option = "replica";
  cfg.ptr = &tsReplications;
S
slguan 已提交
827 828
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
829 830
  cfg.minValue = TSDB_MIN_DB_REPLICA_OPTION;
  cfg.maxValue = TSDB_MAX_DB_REPLICA_OPTION;
S
slguan 已提交
831 832
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
833
  taosAddConfigOption(cfg);
S
slguan 已提交
834

835 836 837 838
  cfg.option = "quorum";
  cfg.ptr = &tsQuorum;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
TD-2677  
Shengliang Guan 已提交
839 840
  cfg.minValue = TSDB_MIN_DB_QUORUM_OPTION;
  cfg.maxValue = TSDB_MAX_DB_QUORUM_OPTION;
841 842
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
843
  taosAddConfigOption(cfg);
844

S
Shengliang Guan 已提交
845 846
  cfg.option = "update";
  cfg.ptr = &tsUpdate;
S
Shengliang Guan 已提交
847
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
848 849 850 851
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_DB_UPDATE;
  cfg.maxValue = TSDB_MAX_DB_UPDATE;
  cfg.ptrLength = 0;
852
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
853
  taosAddConfigOption(cfg);
854 855 856 857 858 859 860 861

  cfg.option = "cachelast";
  cfg.ptr = &tsCacheLastRow;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_DB_CACHE_LAST_ROW;
  cfg.maxValue = TSDB_MAX_DB_CACHE_LAST_ROW;
  cfg.ptrLength = 0;
S
Shengliang Guan 已提交
862
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
863
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
864

S
TD-1310  
Shengliang Guan 已提交
865 866
  cfg.option = "mqttHostName";
  cfg.ptr = tsMqttHostName;
867
  cfg.valType = TAOS_CFG_VTYPE_STRING;
868
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
869 870
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
TD-1310  
Shengliang Guan 已提交
871
  cfg.ptrLength = TSDB_MQTT_HOSTNAME_LEN;
872
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
873
  taosAddConfigOption(cfg);
874

S
TD-1310  
Shengliang Guan 已提交
875 876
  cfg.option = "mqttPort";
  cfg.ptr = tsMqttPort;
877
  cfg.valType = TAOS_CFG_VTYPE_STRING;
878
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
879 880
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
TD-1310  
Shengliang Guan 已提交
881
  cfg.ptrLength = TSDB_MQTT_PORT_LEN;
882
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
883
  taosAddConfigOption(cfg);
S
TD-1310  
Shengliang Guan 已提交
884 885 886 887

  cfg.option = "mqttTopic";
  cfg.ptr = tsMqttTopic;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
888
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
S
TD-1310  
Shengliang Guan 已提交
889 890 891 892
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_MQTT_TOPIC_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
893
  taosAddConfigOption(cfg);
S
TD-1310  
Shengliang Guan 已提交
894

S
slguan 已提交
895 896 897 898 899
  cfg.option = "compressMsgSize";
  cfg.ptr = &tsCompressMsgSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
D
dapan1121 已提交
900
  cfg.maxValue = 100000000.0f;
S
slguan 已提交
901 902
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
903
  taosAddConfigOption(cfg);
S
slguan 已提交
904

905 906
  cfg.option = "compressColData";
  cfg.ptr = &tsCompressColData;
907 908 909 910
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
  cfg.maxValue = 100000000.0f;
911 912
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
913
  taosAddConfigOption(cfg);
914

S
slguan 已提交
915 916 917 918 919 920 921 922
  cfg.option = "maxSQLLength";
  cfg.ptr = &tsMaxSQLStringLen;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MAX_SQL_LEN;
  cfg.maxValue = TSDB_MAX_ALLOWED_SQL_LEN;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
923
  taosAddConfigOption(cfg);
S
slguan 已提交
924

925 926
  cfg.option = "maxWildCardsLength";
  cfg.ptr = &tsMaxWildCardsLen;
927 928 929
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
930
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
931 932
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
933
  taosAddConfigOption(cfg);
934

935 936 937 938 939 940 941 942
  cfg.option = "maxRegexStringLen";
  cfg.ptr = &tsMaxRegexStringLen;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = TSDB_MAX_FIELD_LEN;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
943
  taosAddConfigOption(cfg);
944

S
slguan 已提交
945 946 947 948 949 950 951 952
  cfg.option = "maxNumOfOrderedRes";
  cfg.ptr = &tsMaxNumOfOrderedResults;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MAX_SQL_LEN;
  cfg.maxValue = TSDB_MAX_ALLOWED_SQL_LEN;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
953
  taosAddConfigOption(cfg);
S
slguan 已提交
954

H
Haojun Liao 已提交
955 956 957 958 959
  cfg.option = "queryBufferSize";
  cfg.ptr = &tsQueryBufferSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = -1;
H
Haojun Liao 已提交
960
  cfg.maxValue = 500000000000.0f;
H
Haojun Liao 已提交
961 962
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
963
  taosAddConfigOption(cfg);
H
Haojun Liao 已提交
964

H
Haojun Liao 已提交
965 966
  cfg.option = "retrieveBlockingModel";
  cfg.ptr = &tsRetrieveBlockingModel;
967 968 969 970 971 972
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
973
  taosAddConfigOption(cfg);
974

975 976
  cfg.option = "keepColumnName";
  cfg.ptr = &tsKeepOriginalColumnName;
S
Shengliang Guan 已提交
977
  cfg.valType = TAOS_CFG_VTYPE_INT8;
978 979 980 981 982
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
983
  taosAddConfigOption(cfg);
984

S
slguan 已提交
985 986 987 988
  // locale & charset
  cfg.option = "timezone";
  cfg.ptr = tsTimezone;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
989
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
990 991
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
992
  cfg.ptrLength = TSDB_TIMEZONE_LEN;
S
slguan 已提交
993
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
994
  taosAddConfigOption(cfg);
S
slguan 已提交
995 996 997 998

  cfg.option = "locale";
  cfg.ptr = tsLocale;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
999
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
1000 1001
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
1002
  cfg.ptrLength = TSDB_LOCALE_LEN;
S
slguan 已提交
1003
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1004
  taosAddConfigOption(cfg);
S
slguan 已提交
1005 1006 1007 1008

  cfg.option = "charset";
  cfg.ptr = tsCharset;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
1009
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
1010 1011
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
1012
  cfg.ptrLength = TSDB_LOCALE_LEN;
S
slguan 已提交
1013
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1014
  taosAddConfigOption(cfg);
S
slguan 已提交
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024

  // connect configs
  cfg.option = "maxShellConns";
  cfg.ptr = &tsMaxShellConns;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 10;
  cfg.maxValue = 50000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1025
  taosAddConfigOption(cfg);
S
slguan 已提交
1026

1027 1028
  cfg.option = "maxConnections";
  cfg.ptr = &tsMaxConnections;
S
slguan 已提交
1029 1030
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1031
  cfg.minValue = 1;
1032
  cfg.maxValue = 100000;
S
slguan 已提交
1033 1034
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1035
  taosAddConfigOption(cfg);
S
slguan 已提交
1036 1037 1038 1039 1040

  cfg.option = "minimalLogDirGB";
  cfg.ptr = &tsMinimalLogDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1041
  cfg.minValue = 0.001f;
S
slguan 已提交
1042 1043 1044
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
1045
  taosAddConfigOption(cfg);
S
slguan 已提交
1046 1047

  cfg.option = "minimalTmpDirGB";
H
Haojun Liao 已提交
1048
  cfg.ptr = &tsReservedTmpDirectorySpace;
S
slguan 已提交
1049 1050
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1051
  cfg.minValue = 0.001f;
S
slguan 已提交
1052 1053 1054
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
1055
  taosAddConfigOption(cfg);
S
slguan 已提交
1056 1057 1058 1059 1060

  cfg.option = "minimalDataDirGB";
  cfg.ptr = &tsMinimalDataDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1061
  cfg.minValue = 0.001f;
S
slguan 已提交
1062 1063 1064
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
1065
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
1066 1067 1068

    // module configs
  cfg.option = "flowctrl";
S
TD-2498  
Shengliang Guan 已提交
1069
  cfg.ptr = &tsEnableFlowCtrl;
S
Shengliang Guan 已提交
1070
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
TD-2498  
Shengliang Guan 已提交
1071 1072 1073 1074 1075
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1076
  taosAddConfigOption(cfg);
S
TD-2498  
Shengliang Guan 已提交
1077 1078 1079

  cfg.option = "slaveQuery";
  cfg.ptr = &tsEnableSlaveQuery;
S
Shengliang Guan 已提交
1080 1081 1082 1083 1084 1085
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1086
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
1087 1088 1089 1090

  cfg.option = "adjustMaster";
  cfg.ptr = &tsEnableAdjustMaster;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
1091 1092 1093 1094 1095
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1096
  taosAddConfigOption(cfg);
S
slguan 已提交
1097

1098 1099
  cfg.option = "mqtt";
  cfg.ptr = &tsEnableMqttModule;
S
Shengliang Guan 已提交
1100
  cfg.valType = TAOS_CFG_VTYPE_INT8;
1101 1102 1103 1104 1105
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1106
  taosAddConfigOption(cfg);
1107

S
slguan 已提交
1108 1109
  cfg.option = "monitor";
  cfg.ptr = &tsEnableMonitorModule;
S
Shengliang Guan 已提交
1110
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1111 1112 1113 1114 1115
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1116
  taosAddConfigOption(cfg);
S
slguan 已提交
1117

1118 1119
  cfg.option = "stream";
  cfg.ptr = &tsEnableStream;
S
Shengliang Guan 已提交
1120
  cfg.valType = TAOS_CFG_VTYPE_INT8;
1121 1122 1123 1124 1125
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1126
  taosAddConfigOption(cfg);
1127

1128 1129 1130 1131 1132 1133 1134 1135
  cfg.option = "topicBianryLen";
  cfg.ptr = &tsTopicBianryLen;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 16;
  cfg.maxValue = 16000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1136
  taosAddConfigOption(cfg);
S
slguan 已提交
1137 1138 1139

  cfg.option = "telegrafUseFieldNum";
  cfg.ptr = &tsTelegrafUseFieldNum;
S
Shengliang Guan 已提交
1140
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1141 1142 1143 1144 1145
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1146
  taosAddConfigOption(cfg);
S
slguan 已提交
1147 1148 1149 1150 1151 1152 1153 1154 1155

  cfg.option = "restfulRowLimit";
  cfg.ptr = &tsRestRowLimit;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 1;
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1156
  taosAddConfigOption(cfg);
1157

S
slguan 已提交
1158 1159 1160 1161 1162
  // debug flag
  cfg.option = "numOfLogLines";
  cfg.ptr = &tsNumOfLogLines;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
S
TD-1263  
Shengliang Guan 已提交
1163
  cfg.minValue = 1000;
S
slguan 已提交
1164 1165 1166
  cfg.maxValue = 2000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1167
  taosAddConfigOption(cfg);
S
slguan 已提交
1168

1169
  cfg.option = "logKeepDays";
S
TD-1263  
Shengliang Guan 已提交
1170
  cfg.ptr = &tsLogKeepDays;
1171 1172
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
S
TD-1574  
Shengliang Guan 已提交
1173
  cfg.minValue = -365000;
S
TD-1263  
Shengliang Guan 已提交
1174
  cfg.maxValue = 365000;
1175 1176
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1177
  taosAddConfigOption(cfg);
1178

S
slguan 已提交
1179 1180
  cfg.option = "asyncLog";
  cfg.ptr = &tsAsyncLog;
S
Shengliang Guan 已提交
1181
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1182 1183 1184 1185 1186
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1187
  taosAddConfigOption(cfg);
S
slguan 已提交
1188 1189 1190 1191 1192 1193 1194 1195 1196

  cfg.option = "debugFlag";
  cfg.ptr = &debugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1197
  taosAddConfigOption(cfg);
S
slguan 已提交
1198 1199

  cfg.option = "mDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1200
  cfg.ptr = &mDebugFlag;
S
slguan 已提交
1201 1202 1203 1204 1205 1206
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1207
  taosAddConfigOption(cfg);
S
slguan 已提交
1208 1209

  cfg.option = "dDebugFlag";
1210
  cfg.ptr = &dDebugFlag;
S
slguan 已提交
1211 1212 1213 1214 1215 1216
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1217
  taosAddConfigOption(cfg);
S
slguan 已提交
1218

J
jtao1735 已提交
1219 1220 1221 1222 1223 1224 1225 1226
  cfg.option = "sDebugFlag";
  cfg.ptr = &sDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1227
  taosAddConfigOption(cfg);
J
jtao1735 已提交
1228

S
Shengliang Guan 已提交
1229 1230 1231 1232 1233 1234 1235 1236
  cfg.option = "wDebugFlag";
  cfg.ptr = &wDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1237
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
1238 1239


S
slguan 已提交
1240 1241 1242 1243 1244 1245 1246 1247
  cfg.option = "sdbDebugFlag";
  cfg.ptr = &sdbDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1248
  taosAddConfigOption(cfg);
S
slguan 已提交
1249 1250 1251 1252 1253 1254 1255 1256 1257

  cfg.option = "rpcDebugFlag";
  cfg.ptr = &rpcDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1258
  taosAddConfigOption(cfg);
S
slguan 已提交
1259 1260 1261 1262 1263 1264 1265 1266 1267

  cfg.option = "tmrDebugFlag";
  cfg.ptr = &tmrDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1268
  taosAddConfigOption(cfg);
S
slguan 已提交
1269 1270

  cfg.option = "cDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1271
  cfg.ptr = &cDebugFlag;
S
slguan 已提交
1272 1273 1274 1275 1276 1277
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1278
  taosAddConfigOption(cfg);
S
slguan 已提交
1279 1280

  cfg.option = "jniDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1281
  cfg.ptr = &jniDebugFlag;
S
slguan 已提交
1282 1283 1284 1285 1286 1287
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1288
  taosAddConfigOption(cfg);
S
slguan 已提交
1289 1290

  cfg.option = "odbcDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1291
  cfg.ptr = &odbcDebugFlag;
S
slguan 已提交
1292 1293 1294 1295 1296 1297
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1298
  taosAddConfigOption(cfg);
S
slguan 已提交
1299 1300 1301 1302 1303 1304 1305 1306 1307

  cfg.option = "uDebugFlag";
  cfg.ptr = &uDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1308
  taosAddConfigOption(cfg);
S
slguan 已提交
1309 1310 1311 1312 1313 1314 1315 1316 1317

  cfg.option = "httpDebugFlag";
  cfg.ptr = &httpDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1318
  taosAddConfigOption(cfg);
S
slguan 已提交
1319

1320 1321 1322 1323 1324 1325 1326 1327
  cfg.option = "mqttDebugFlag";
  cfg.ptr = &mqttDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1328
  taosAddConfigOption(cfg);
1329

S
Shengliang Guan 已提交
1330 1331
  cfg.option = "monDebugFlag";
  cfg.ptr = &monDebugFlag;
S
slguan 已提交
1332 1333 1334 1335 1336 1337
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1338
  taosAddConfigOption(cfg);
S
slguan 已提交
1339 1340

  cfg.option = "qDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1341
  cfg.ptr = &qDebugFlag;
S
slguan 已提交
1342 1343 1344 1345 1346 1347
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1348
  taosAddConfigOption(cfg);
S
slguan 已提交
1349

S
Shengliang Guan 已提交
1350 1351 1352 1353 1354 1355 1356 1357
  cfg.option = "vDebugFlag";
  cfg.ptr = &vDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1358
  taosAddConfigOption(cfg);
S
Shengliang Guan 已提交
1359

1360 1361 1362 1363 1364 1365 1366 1367
  cfg.option = "tsdbDebugFlag";
  cfg.ptr = &tsdbDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1368
  taosAddConfigOption(cfg);
1369

S
TD-1520  
Shengliang Guan 已提交
1370 1371 1372 1373 1374 1375 1376 1377
  cfg.option = "cqDebugFlag";
  cfg.ptr = &cqDebugFlag;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
  cfg.minValue = 0;
  cfg.maxValue = 255;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1378
  taosAddConfigOption(cfg);
S
TD-1520  
Shengliang Guan 已提交
1379

1380
  cfg.option = "enableRecordSql";
S
slguan 已提交
1381
  cfg.ptr = &tsTscEnableRecordSql;
S
Shengliang Guan 已提交
1382
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1383 1384 1385 1386 1387
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1388
  taosAddConfigOption(cfg);
S
slguan 已提交
1389 1390 1391

  cfg.option = "enableCoreFile";
  cfg.ptr = &tsEnableCoreFile;
S
Shengliang Guan 已提交
1392
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1393 1394 1395 1396 1397
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1398
  taosAddConfigOption(cfg);
S
slguan 已提交
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408

  // version info
  cfg.option = "gitinfo";
  cfg.ptr = gitinfo;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1409
  taosAddConfigOption(cfg);
S
slguan 已提交
1410 1411 1412 1413 1414 1415 1416 1417 1418

  cfg.option = "gitinfoOfInternal";
  cfg.ptr = gitinfoOfInternal;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1419
  taosAddConfigOption(cfg);
S
slguan 已提交
1420 1421 1422 1423 1424 1425 1426 1427 1428

  cfg.option = "buildinfo";
  cfg.ptr = buildinfo;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1429
  taosAddConfigOption(cfg);
S
slguan 已提交
1430 1431 1432 1433 1434 1435 1436 1437 1438

  cfg.option = "version";
  cfg.ptr = version;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1439
  taosAddConfigOption(cfg);
1440 1441 1442 1443 1444 1445

  cfg.option = "maxBinaryDisplayWidth";
  cfg.ptr = &tsMaxBinaryDisplayWidth;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
1446
  cfg.maxValue = 65536;
1447 1448
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1449
  taosAddConfigOption(cfg);
1450 1451 1452 1453 1454 1455 1456

  cfg.option = "tempDir";
  cfg.ptr = tsTempDir;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
Shengliang Guan 已提交
1457
  cfg.ptrLength = PATH_MAX;
1458
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1459
  taosAddConfigOption(cfg);
T
tickduan 已提交
1460

1461 1462 1463 1464 1465 1466 1467 1468
  cfg.option = "tsdbMetaCompactRatio";
  cfg.ptr = &tsTsdbMetaCompactRatio;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 100;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1469
  taosAddConfigOption(cfg);
1470

1471 1472 1473 1474 1475 1476 1477 1478 1479
   // enable kill long query
  cfg.option = "deadLockKillQuery";
  cfg.ptr = &tsDeadLockKillQuery;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 1;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1480
  taosAddConfigOption(cfg);
1481

T
tickduan 已提交
1482
#ifdef TD_TSZ
T
tickduan 已提交
1483
  // lossy compress
T
tickduan 已提交
1484
  cfg.option = "lossyColumns";
T
tickduan 已提交
1485 1486 1487 1488 1489 1490 1491
  cfg.ptr = lossyColumns;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = tListLen(lossyColumns);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1492
  taosAddConfigOption(cfg);
T
tickduan 已提交
1493 1494 1495 1496 1497

  cfg.option = "fPrecision";
  cfg.ptr = &fPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1498 1499
  cfg.minValue = MIN_FLOAT;
  cfg.maxValue = MAX_FLOAT;
T
tickduan 已提交
1500 1501
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
T
tickduan 已提交
1502 1503

  
1504
  taosAddConfigOption(cfg);
T
tickduan 已提交
1505 1506 1507 1508 1509

  cfg.option = "dPrecision";
  cfg.ptr = &dPrecision;
  cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
T
tickduan 已提交
1510 1511
  cfg.minValue = MIN_FLOAT;
  cfg.maxValue = MAX_FLOAT;
T
tickduan 已提交
1512 1513
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1514
  taosAddConfigOption(cfg);
T
tickduan 已提交
1515

T
tickduan 已提交
1516 1517
  cfg.option = "maxRange";
  cfg.ptr = &maxRange;
T
tickduan 已提交
1518 1519 1520 1521 1522 1523
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 65536;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1524
  taosAddConfigOption(cfg);
T
tickduan 已提交
1525

T
tickduan 已提交
1526
  cfg.option = "range";
T
tickduan 已提交
1527
  cfg.ptr = &curRange;
T
tickduan 已提交
1528 1529 1530 1531 1532 1533
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 65536;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
1534
  taosAddConfigOption(cfg);
1535 1536
  assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM);
#else
1537
  //assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM - 5);
1538
#endif
T
tickduan 已提交
1539

S
slguan 已提交
1540 1541 1542 1543 1544 1545
}

void taosInitGlobalCfg() {
  pthread_once(&tsInitGlobalCfgOnce, doInitGlobalConfig);
}

1546
int32_t taosCheckAndPrintCfg() {
R
root 已提交
1547
  char fqdn[TSDB_FQDN_LEN];
1548 1549
  uint16_t port;

S
Shengliang Guan 已提交
1550
  if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
guanshengliang's avatar
guanshengliang 已提交
1551 1552 1553
    taosSetAllDebugFlag();
  }
  
H
Hui Li 已提交
1554 1555 1556 1557
  if (tsLocalFqdn[0] == 0) {
    taosGetFqdn(tsLocalFqdn);
  }

R
root 已提交
1558
  snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
1559
  uInfo("localEp is: %s", tsLocalEp);
S
slguan 已提交
1560

S
slguan 已提交
1561 1562
  if (tsFirst[0] == 0) {
    strcpy(tsFirst, tsLocalEp);
1563 1564
  } else {
    taosGetFqdnPortFromEp(tsFirst, fqdn, &port);
R
root 已提交
1565
    snprintf(tsFirst, sizeof(tsFirst), "%s:%u", fqdn, port);
S
slguan 已提交
1566 1567
  }

J
jtao1735 已提交
1568 1569
  if (tsSecond[0] == 0) {
    strcpy(tsSecond, tsLocalEp);
1570 1571
  } else {
    taosGetFqdnPortFromEp(tsSecond, fqdn, &port);
R
root 已提交
1572
    snprintf(tsSecond, sizeof(tsSecond), "%s:%u", fqdn, port);
S
slguan 已提交
1573
  }
1574

S
TD-1767  
Shengliang Guan 已提交
1575
  taosCheckDataDirCfg();
D
fix bug  
dapan1121 已提交
1576

1577
  if (taosDirExist(tsTempDir) != 0) {
D
fix bug  
dapan1121 已提交
1578 1579 1580
    return -1;
  }
  
S
slguan 已提交
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593
  taosGetSystemInfo();

  tsSetLocale();

  SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
  if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
    tsSetTimeZone();
  }

  if (tsNumOfCores <= 0) {
    tsNumOfCores = 1;
  }

1594
  if (tsQueryBufferSize >= 0) {
D
fix bug  
dapan1121 已提交
1595
    tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
1596 1597
  }

1598 1599
  uInfo("   check global cfg completed");
  uInfo("==================================");
1600
  taosPrintCfg();
S
TD-1663  
Shengliang Guan 已提交
1601

S
TD-1663  
Shengliang Guan 已提交
1602
  return 0;
S
slguan 已提交
1603
}
J
jtao1735 已提交
1604

1605 1606 1607 1608
/*
 * alter dnode 1 balance "vnode:1-dnode:2"
 */

S
Shengliang Guan 已提交
1609
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
1610
  int len = (int)strlen(option);
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
  if (strncasecmp(option, "vnode:", 6) != 0) {
    return false;
  }

  int pos = 0;
  for (; pos < len; ++pos) {
    if (option[pos] == '-') break;
  }

  if (++pos >= len) return false;
  if (strncasecmp(option + pos, "dnode:", 6) != 0) {
    return false;
  }

S
Shengliang Guan 已提交
1625 1626 1627
  *vnodeId = strtol(option + 6, NULL, 10);
  *dnodeId = strtol(option + pos + 6, NULL, 10);
  if (*vnodeId <= 1 || *dnodeId <= 0) {
1628 1629 1630 1631
    return false;
  }

  return true;
1632
}
D
dapan1121 已提交
1633