tglobal.c 47.8 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * 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"
#include "tulog.h"
#include "tconfig.h"
#include "tglobal.h"
#include "monitor.h"
#include "tsocket.h"
#include "tutil.h"
#include "tlocale.h"
#include "ttimezone.h"

S
Shengliang Guan 已提交
29 30 31 32 33 34
// 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 已提交
35
uint16_t tsServerPort = 6030;
J
jtao1735 已提交
36
uint16_t tsDnodeShellPort = 6030;  // udp[6035-6039] tcp[6035]
S
Shengliang Guan 已提交
37
uint16_t tsDnodeDnodePort = 6035;  // udp/tcp
J
jtao1735 已提交
38
uint16_t tsSyncPort = 6040;
H
Hui Li 已提交
39
uint16_t tsArbitratorPort = 6042;
S
Shengliang Guan 已提交
40 41
int32_t  tsStatusInterval = 1;  // second
int32_t  tsNumOfMnodes = 3;
S
Shengliang Guan 已提交
42 43
int8_t   tsEnableVnodeBak = 1;
int8_t   tsEnableTelemetryReporting = 1;
S
TD-2680  
Shengliang Guan 已提交
44
int8_t   tsArbOnline = 0;
H
Hui Li 已提交
45
char     tsEmail[TSDB_FQDN_LEN] = {0};
D
dapan1121 已提交
46
int32_t  tsDnodeId = 0;
H
Hui Li 已提交
47

S
Shengliang Guan 已提交
48
// common
H
Haojun Liao 已提交
49 50
int32_t tsRpcTimer       = 1000;
int32_t tsRpcMaxTime     = 600;  // seconds;
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
char    tsTimezone[TSDB_TIMEZONE_LEN] = {0};
S
Shengliang Guan 已提交
59 60
char    tsLocale[TSDB_LOCALE_LEN] = {0};
char    tsCharset[TSDB_LOCALE_LEN] = {0};  // default encode string
S
Shengliang Guan 已提交
61
int8_t  tsEnableCoreFile = 0;
S
Shengliang Guan 已提交
62
int32_t tsMaxBinaryDisplayWidth = 30;
S
slguan 已提交
63

S
Shengliang Guan 已提交
64 65 66 67 68 69 70 71 72 73 74
/*
 * 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.
 */
int32_t tsCompressMsgSize = -1;

// client
75
int32_t tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN;
S
Shengliang Guan 已提交
76
int8_t  tsTscEnableRecordSql = 0;
S
slguan 已提交
77

S
Shengliang Guan 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 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;

// 10 ms for interval time range, changed accordingly
int32_t tsMinIntervalTime = 10;

// 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
int32_t tsStreamCompRetryDelay = 10;

// The delayed computing ration. 10% of the whole computing time window by default.
98
float tsStreamComputDelayRatio = 0.1f;
S
Shengliang Guan 已提交
99 100 101 102

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

H
Haojun Liao 已提交
103 104 105 106 107
// 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;
108
int64_t tsQueryBufferSizeBytes = -1;
H
Haojun Liao 已提交
109

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

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

S
Shengliang Guan 已提交
116
// db parameters
S
slguan 已提交
117
int32_t tsCacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
H
hjxilinx 已提交
118 119 120
int32_t tsBlocksPerVnode = TSDB_DEFAULT_TOTAL_BLOCKS;
int16_t tsDaysPerFile    = TSDB_DEFAULT_DAYS_PER_FILE;
int32_t tsDaysToKeep     = TSDB_DEFAULT_KEEP;
S
slguan 已提交
121 122
int32_t tsMinRowsInFileBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK;
int32_t tsMaxRowsInFileBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK;
H
hjxilinx 已提交
123
int16_t tsCommitTime    = TSDB_DEFAULT_COMMIT_TIME;  // seconds
S
slguan 已提交
124
int32_t tsTimePrecision = TSDB_DEFAULT_PRECISION;
S
TD-1207  
Shengliang Guan 已提交
125 126
int8_t  tsCompression   = TSDB_DEFAULT_COMP_LEVEL;
int8_t  tsWAL           = TSDB_DEFAULT_WAL_LEVEL;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
127
int32_t tsFsyncPeriod   = TSDB_DEFAULT_FSYNC_PERIOD;
128
int32_t tsReplications  = TSDB_DEFAULT_DB_REPLICA_OPTION;
129
int32_t tsQuorum        = TSDB_DEFAULT_DB_QUORUM_OPTION;
S
TD-3130  
Shengliang Guan 已提交
130
int16_t tsPartitons     = TSDB_DEFAULT_DB_PARTITON_OPTION;
S
Shengliang Guan 已提交
131
int8_t  tsUpdate        = TSDB_DEFAULT_DB_UPDATE_OPTION;
S
TD-3220  
Shengliang Guan 已提交
132
int8_t  tsCacheLastRow  = TSDB_DEFAULT_CACHE_LAST_ROW;
133
int32_t tsMaxVgroupsPerDb  = 0;
S
slguan 已提交
134
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
135
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
136 137
int32_t tsTableIncStepPerVnode = TSDB_TABLES_STEP;

S
Shengliang Guan 已提交
138
// balance
S
Shengliang Guan 已提交
139 140 141
int8_t  tsEnableBalance = 1;
int8_t  tsAlternativeRole = 0;
int32_t tsBalanceInterval = 300;           // seconds
142
int32_t tsOfflineThreshold = 86400 * 10;  // seconds of 10 days
143
int32_t tsMnodeEqualVnodeNum = 4;
S
Shengliang Guan 已提交
144 145 146
int8_t  tsEnableFlowCtrl = 1;
int8_t  tsEnableSlaveQuery = 1;
int8_t  tsEnableAdjustMaster = 1;
S
slguan 已提交
147

S
Shengliang Guan 已提交
148
// restful
S
Shengliang Guan 已提交
149
int8_t   tsEnableHttpModule = 1;
S
Shengliang Guan 已提交
150
int32_t  tsRestRowLimit = 10240;
H
Hui Li 已提交
151
uint16_t tsHttpPort = 6041;  // only tcp, range tcp[6041]
S
Shengliang Guan 已提交
152
int32_t  tsHttpCacheSessions = 1000;
S
Shengliang Guan 已提交
153 154
int32_t  tsHttpSessionExpire = 36000;
int32_t  tsHttpMaxThreads = 2;
S
Shengliang Guan 已提交
155 156 157
int8_t   tsHttpEnableCompress = 1;
int8_t   tsHttpEnableRecordSql = 0;
int8_t   tsTelegrafUseFieldNum = 0;
S
Shengliang Guan 已提交
158 159

// mqtt
S
Shengliang Guan 已提交
160
int8_t tsEnableMqttModule = 0;  // not finished yet, not started it by default
S
TD-1310  
Shengliang Guan 已提交
161 162 163 164 165
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";
166
char    tsMqttTopic[TSDB_MQTT_TOPIC_LEN] = "/test"; // #
S
Shengliang Guan 已提交
167 168

// monitor
S
Shengliang Guan 已提交
169
int8_t  tsEnableMonitorModule = 1;
S
Shengliang Guan 已提交
170 171 172
char    tsMonitorDbName[TSDB_DB_NAME_LEN] = "log";
char    tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30;  // seconds
S
slguan 已提交
173

174
// stream
S
Shengliang Guan 已提交
175
int8_t  tsEnableStream = 1;
176

S
Shengliang Guan 已提交
177
// internal
S
Shengliang Guan 已提交
178 179 180 181 182 183 184 185
int8_t tsPrintAuth = 0;
int8_t tscEmbedded = 0;
char   configDir[TSDB_FILENAME_LEN] = {0};
char   tsVnodeDir[TSDB_FILENAME_LEN] = {0};
char   tsDnodeDir[TSDB_FILENAME_LEN] = {0};
char   tsMnodeDir[TSDB_FILENAME_LEN] = {0};
char   tsDataDir[TSDB_FILENAME_LEN] = {0};
char   tsScriptDir[TSDB_FILENAME_LEN] = {0};
S
TD-1207  
Shengliang Guan 已提交
186
char   tsTempDir[TSDB_FILENAME_LEN] = "/tmp/";
187

H
Hongze Cheng 已提交
188
int32_t  tsDiskCfgNum = 0;
S
TD-1767  
Shengliang Guan 已提交
189 190 191 192 193 194

#ifndef _STORAGE
SDiskCfg tsDiskCfg[1];
#else
SDiskCfg tsDiskCfg[TSDB_MAX_DISKS];
#endif
S
Shengliang Guan 已提交
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211

/*
 * minimum scale for whole system, millisecond by default
 * for TSDB_TIME_PRECISION_MILLI: 86400000L
 *     TSDB_TIME_PRECISION_MICRO: 86400000000L
 *     TSDB_TIME_PRECISION_NANO:  86400000000000L
 */
int64_t tsMsPerDay[] = {86400000L, 86400000000L, 86400000000000L};

// system info
char    tsOsName[10] = "Linux";
int64_t tsPageSize;
int64_t tsOpenMax;
int64_t tsStreamMax;
int32_t tsNumOfCores = 1;
float   tsTotalTmpDirGB = 0;
float   tsTotalDataDirGB = 0;
H
Haojun Liao 已提交
212
float   tsAvailTmpDirectorySpace = 0;
S
Shengliang Guan 已提交
213
float   tsAvailDataDirGB = 0;
214
float   tsUsedDataDirGB = 0;
S
Shengliang Guan 已提交
215
float   tsReservedTmpDirectorySpace = 1.0f;
216
float   tsMinimalDataDirGB = 2.0f;
S
Shengliang Guan 已提交
217
int32_t tsTotalMemoryMB = 0;
218
uint32_t tsVersion = 0;
S
slguan 已提交
219

S
Shengliang Guan 已提交
220
// log
S
slguan 已提交
221
int32_t tsNumOfLogLines = 10000000;
S
TD-2381  
Shengliang Guan 已提交
222 223
int32_t mDebugFlag = 131;
int32_t sdbDebugFlag = 131;
224
int32_t dDebugFlag = 135;
S
TD-2321  
Shengliang Guan 已提交
225
int32_t vDebugFlag = 135;
H
Haojun Liao 已提交
226
uint32_t cDebugFlag = 131;
guanshengliang's avatar
guanshengliang 已提交
227 228
int32_t jniDebugFlag = 131;
int32_t odbcDebugFlag = 131;
S
slguan 已提交
229
int32_t httpDebugFlag = 131;
230
int32_t mqttDebugFlag = 131;
S
Shengliang Guan 已提交
231
int32_t monDebugFlag = 131;
232
uint32_t qDebugFlag = 131;
S
Shengliang Guan 已提交
233
int32_t rpcDebugFlag = 131;
S
slguan 已提交
234
int32_t uDebugFlag = 131;
S
Shengliang Guan 已提交
235
int32_t debugFlag = 0;
236
int32_t sDebugFlag = 135;
S
Shengliang Guan 已提交
237
int32_t wDebugFlag = 135;
S
Shengliang Guan 已提交
238
int32_t tsdbDebugFlag = 131;
S
TD-2381  
Shengliang Guan 已提交
239
int32_t cqDebugFlag = 131;
H
Hongze Cheng 已提交
240
int32_t fsDebugFlag = 135;
S
slguan 已提交
241

S
Shengliang Guan 已提交
242 243 244
int32_t (*monStartSystemFp)() = NULL;
void (*monStopSystemFp)() = NULL;
void (*monExecuteSQLFp)(char *sql) = NULL;
245

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

S
slguan 已提交
248 249 250
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;

void taosSetAllDebugFlag() {
S
Shengliang Guan 已提交
251
  if (debugFlag != 0) { 
guanshengliang's avatar
guanshengliang 已提交
252
    mDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
253 254 255
    sdbDebugFlag = debugFlag;
    dDebugFlag = debugFlag;
    vDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
256 257 258
    cDebugFlag = debugFlag;
    jniDebugFlag = debugFlag;
    odbcDebugFlag = debugFlag;
guanshengliang's avatar
guanshengliang 已提交
259
    httpDebugFlag = debugFlag;
260
    mqttDebugFlag = debugFlag;
S
Shengliang Guan 已提交
261
    monDebugFlag = debugFlag;
S
TD-1520  
Shengliang Guan 已提交
262
    qDebugFlag = debugFlag;    
guanshengliang's avatar
guanshengliang 已提交
263 264 265
    rpcDebugFlag = debugFlag;
    uDebugFlag = debugFlag;
    sDebugFlag = debugFlag;
S
Shengliang Guan 已提交
266
    wDebugFlag = debugFlag;
267
    tsdbDebugFlag = debugFlag;
S
TD-1520  
Shengliang Guan 已提交
268
    cqDebugFlag = debugFlag;
S
Shengliang Guan 已提交
269
    uInfo("all debug flag are set to %d", debugFlag);
S
slguan 已提交
270 271 272 273 274 275 276 277 278
  }
}

bool taosCfgDynamicOptions(char *msg) {
  char *option, *value;
  int32_t   olen, vlen;
  int32_t   vint = 0;

  paGetToken(msg, &option, &olen);
Y
TD-2568  
yihaoDeng 已提交
279
  if (olen == 0) return false;;
S
slguan 已提交
280 281 282 283 284 285 286 287

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

288
  uInfo("change dynamic option: %s, value: %d", option, vint);
S
slguan 已提交
289 290 291

  for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
    SGlobalCfg *cfg = tsGlobalConfig + i;
292
    //if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
S
Shengliang Guan 已提交
293
    if (cfg->valType != TAOS_CFG_VTYPE_INT32 && cfg->valType != TAOS_CFG_VTYPE_INT8) continue;
294
    
S
Shengliang Guan 已提交
295
    int32_t cfgLen = (int32_t)strlen(cfg->option);
296
    if (cfgLen != olen) continue;
S
slguan 已提交
297
    if (strncasecmp(option, cfg->option, olen) != 0) continue;
298
    if (cfg->valType == TAOS_CFG_VTYPE_INT32) {
S
Shengliang Guan 已提交
299 300 301 302
      *((int32_t *)cfg->ptr) = vint;
    } else {
      *((int8_t *)cfg->ptr) = (int8_t)vint;
    }
S
slguan 已提交
303 304

    if (strncasecmp(cfg->option, "monitor", olen) == 0) {
305
      if (1 == vint) {
S
Shengliang Guan 已提交
306 307
        if (monStartSystemFp) {
          (*monStartSystemFp)();
308
          uInfo("monitor is enabled");
309 310
        } else {
          uError("monitor can't be updated, for monitor not initialized");
311 312
        }
      } else {
S
Shengliang Guan 已提交
313 314
        if (monStopSystemFp) {
          (*monStopSystemFp)();
315
          uInfo("monitor is disabled");
316 317
        } else {
          uError("monitor can't be updated, for monitor not initialized");
318 319
        }
      }
S
slguan 已提交
320 321
      return true;
    }
Y
yihaoDeng 已提交
322 323 324 325
    if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
       taosSetAllDebugFlag(); 
    }
    return true;
S
slguan 已提交
326 327 328 329 330 331 332 333 334
  }

  if (strncasecmp(option, "resetlog", 8) == 0) {
    taosResetLog();
    taosPrintGlobalCfg();
    return true;
  }

  if (strncasecmp(option, "resetQueryCache", 15) == 0) {
S
Shengliang Guan 已提交
335 336
    if (monExecuteSQLFp) {
      (*monExecuteSQLFp)("resetQueryCache");
337 338 339 340
      uInfo("resetquerycache is executed");
    } else {
      uError("resetquerycache can't be executed, for monitor not started");
    }
S
slguan 已提交
341 342 343 344 345
  }

  return false;
}

S
TD-1767  
Shengliang Guan 已提交
346 347 348 349 350 351 352 353 354
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 已提交
355 356 357 358 359 360
  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 已提交
361 362 363 364 365
}

void taosPrintDataDirCfg() {
  for (int i = 0; i < tsDiskCfgNum; ++i) {
    SDiskCfg *cfg = &tsDiskCfg[i];
S
TD-1767  
Shengliang Guan 已提交
366
    uInfo(" dataDir: %s", cfg->dir);
S
TD-1767  
Shengliang Guan 已提交
367 368
  }
}
S
TD-1767  
Shengliang Guan 已提交
369
#endif
S
TD-1767  
Shengliang Guan 已提交
370 371 372 373 374

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

D
fix bug  
dapan1121 已提交
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
static int32_t taosCheckTmpDir(void) {
  if (strlen(tsTempDir) <= 0){
    uError("tempDir is not set");
    return -1;
  }

  DIR *dir = opendir(tsTempDir);
  if (dir == NULL) {
    uError("can not open tempDir:%s, error:%s", tsTempDir, strerror(errno));
    return -1;
  }

  closedir(dir);

  return 0;
}

396
static void doInitGlobalConfig(void) {
S
TD-1057  
Shengliang Guan 已提交
397
  osInit();
S
TD-1652  
Shengliang Guan 已提交
398 399
  srand(taosSafeRand());

S
slguan 已提交
400 401 402
  SGlobalCfg cfg = {0};
  
  // ip address
H
Hui Li 已提交
403
  cfg.option = "firstEp";
S
slguan 已提交
404 405
  cfg.ptr = tsFirst;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
406 407 408
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
409
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
410 411 412
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

H
Hui Li 已提交
413
  cfg.option = "secondEp";
J
jtao1735 已提交
414
  cfg.ptr = tsSecond;
S
slguan 已提交
415
  cfg.valType = TAOS_CFG_VTYPE_STRING;
S
slguan 已提交
416 417 418
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
419
  cfg.ptrLength = TSDB_EP_LEN;
S
slguan 已提交
420 421 422
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

423 424 425 426 427 428 429 430 431 432
  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);

S
slguan 已提交
433
  // port
J
jtao1735 已提交
434 435
  cfg.option = "serverPort";
  cfg.ptr = &tsServerPort;
436
  cfg.valType = TAOS_CFG_VTYPE_UINT16;
S
slguan 已提交
437 438
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
  cfg.minValue = 1;
439
  cfg.maxValue = 65056;
S
slguan 已提交
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  // 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;
  taosInitConfigOption(cfg);

  cfg.option = "logDir";
S
slguan 已提交
456
  cfg.ptr = tsLogDir;
S
slguan 已提交
457 458
  cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_LOG;
459 460 461 462 463 464
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
465
  cfg.option = "scriptDir";
S
slguan 已提交
466
  cfg.ptr = tsScriptDir;
S
slguan 已提交
467 468 469 470 471 472 473 474 475
  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;
  taosInitConfigOption(cfg);

  cfg.option = "dataDir";
S
slguan 已提交
476
  cfg.ptr = tsDataDir;
S
TD-1767  
Shengliang Guan 已提交
477
  cfg.valType = TAOS_CFG_VTYPE_DATA_DIRCTORY;
S
slguan 已提交
478 479 480 481 482 483 484
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_FILENAME_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

J
jtao1735 已提交
485 486
  cfg.option = "arbitrator";
  cfg.ptr = tsArbitrator;
S
slguan 已提交
487
  cfg.valType = TAOS_CFG_VTYPE_STRING;
488
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
J
jtao1735 已提交
489 490
  cfg.minValue = 0;
  cfg.maxValue = 0;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
491
  cfg.ptrLength = TSDB_EP_LEN;
J
jtao1735 已提交
492 493 494
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
495 496 497 498 499 500 501 502 503 504 505
  // 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;
  taosInitConfigOption(cfg);

S
TD-2067  
Shengliang Guan 已提交
506 507 508 509 510 511 512 513 514 515
  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;
  taosInitConfigOption(cfg);

516 517
  cfg.option = "ratioOfQueryCores";
  cfg.ptr = &tsRatioOfQueryCores;
S
slguan 已提交
518 519
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
520 521
  cfg.minValue = 0.0f;
  cfg.maxValue = 2.0f;
S
slguan 已提交
522 523 524 525
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

526 527
  cfg.option = "numOfMnodes";
  cfg.ptr = &tsNumOfMnodes;
S
slguan 已提交
528 529 530 531 532 533 534 535
  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;
  taosInitConfigOption(cfg);

H
Hui Li 已提交
536 537
  cfg.option = "vnodeBak";
  cfg.ptr = &tsEnableVnodeBak;
S
Shengliang Guan 已提交
538
  cfg.valType = TAOS_CFG_VTYPE_INT8;
H
Hui Li 已提交
539 540 541 542 543 544 545
  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;
  taosInitConfigOption(cfg);

B
Bomin Zhang 已提交
546 547
  cfg.option = "telemetryReporting";
  cfg.ptr = &tsEnableTelemetryReporting;
S
Shengliang Guan 已提交
548
  cfg.valType = TAOS_CFG_VTYPE_INT8;
B
Bomin Zhang 已提交
549 550 551 552 553 554 555
  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;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
556 557
  cfg.option = "balance";
  cfg.ptr = &tsEnableBalance;
S
Shengliang Guan 已提交
558
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
559 560 561 562 563 564 565
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
566
  cfg.option = "balanceInterval";
S
slguan 已提交
567
  cfg.ptr = &tsBalanceInterval;
S
slguan 已提交
568 569 570 571 572 573 574 575
  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;
  taosInitConfigOption(cfg);

576
  // 0-any; 1-mnode; 2-vnode
S
Shengliang Guan 已提交
577
  cfg.option = "role";
S
slguan 已提交
578
  cfg.ptr = &tsAlternativeRole;
S
Shengliang Guan 已提交
579
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
580 581 582 583 584 585 586 587 588
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 2;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  // timer
  cfg.option = "maxTmrCtrl";
S
Shengliang Guan 已提交
589
  cfg.ptr = &tsMaxTmrCtrl;
S
slguan 已提交
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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 已提交
612
  cfg.minValue = 3;
613
  cfg.maxValue = 86400 * 365;
S
slguan 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_SECOND;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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 已提交
672
  cfg.minValue = 1;
S
slguan 已提交
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_MS;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  cfg.option = "retryStreamCompDelay";
  cfg.ptr = &tsStreamCompRetryDelay;
  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;

  taosInitConfigOption(cfg);
  cfg.option = "streamCompDelayRatio";
  cfg.ptr = &tsStreamComputDelayRatio;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
712 713
  cfg.minValue = 0.1f;
  cfg.maxValue = 0.9f;
S
slguan 已提交
714 715 716 717
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

718 719 720 721 722 723 724 725 726 727
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
728
  // database configs
S
Shengliang Guan 已提交
729
  cfg.option = "maxTablesPerVnode";
H
hjxilinx 已提交
730
  cfg.ptr = &tsMaxTablePerVnode;
S
slguan 已提交
731
  cfg.valType = TAOS_CFG_VTYPE_INT32;
S
slguan 已提交
732
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
733 734
  cfg.minValue = TSDB_MIN_TABLES;
  cfg.maxValue = TSDB_MAX_TABLES;
S
slguan 已提交
735 736 737 738
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
  cfg.option = "minTablesPerVnode";
  cfg.ptr = &tsMinTablePerVnode;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_TABLES;
  cfg.maxValue = TSDB_MAX_TABLES;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "tableIncStepPerVnode";
  cfg.ptr = &tsTableIncStepPerVnode;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_TABLES;
  cfg.maxValue = TSDB_MAX_TABLES;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
759 760 761
  cfg.option = "cache";
  cfg.ptr = &tsCacheBlockSize;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
S
slguan 已提交
762
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
763 764
  cfg.minValue = TSDB_MIN_CACHE_BLOCK_SIZE;
  cfg.maxValue = TSDB_MAX_CACHE_BLOCK_SIZE;
S
slguan 已提交
765
  cfg.ptrLength = 0;
H
Haojun Liao 已提交
766
  cfg.unitType = TAOS_CFG_UTYPE_MB;
S
slguan 已提交
767 768 769
  taosInitConfigOption(cfg);

  cfg.option = "blocks";
H
hjxilinx 已提交
770
  cfg.ptr = &tsBlocksPerVnode;
S
slguan 已提交
771 772 773 774 775
  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 已提交
776
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
S
slguan 已提交
777 778 779 780 781 782
  taosInitConfigOption(cfg);

  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 已提交
783 784
  cfg.minValue = TSDB_MIN_DAYS_PER_FILE;
  cfg.maxValue = TSDB_MAX_DAYS_PER_FILE;
S
slguan 已提交
785 786 787 788 789 790 791 792
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  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 已提交
793 794
  cfg.minValue = TSDB_MIN_KEEP;
  cfg.maxValue = TSDB_MAX_KEEP;
S
slguan 已提交
795 796 797 798
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
799 800
  cfg.option = "minRows";
  cfg.ptr = &tsMinRowsInFileBlock;
S
slguan 已提交
801 802
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
803 804
  cfg.minValue = TSDB_MIN_MIN_ROW_FBLOCK;
  cfg.maxValue = TSDB_MAX_MIN_ROW_FBLOCK;
S
slguan 已提交
805 806 807 808
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
809 810
  cfg.option = "maxRows";
  cfg.ptr = &tsMaxRowsInFileBlock;
S
slguan 已提交
811 812
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
S
slguan 已提交
813 814
  cfg.minValue = TSDB_MIN_MAX_ROW_FBLOCK;
  cfg.maxValue = TSDB_MAX_MAX_ROW_FBLOCK;
S
slguan 已提交
815 816 817 818
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
819 820
  cfg.option = "comp";
  cfg.ptr = &tsCompression;
S
TD-1207  
Shengliang Guan 已提交
821
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
822 823 824 825 826 827 828
  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;
  taosInitConfigOption(cfg);

829
  cfg.option = "walLevel";
H
hjxilinx 已提交
830
  cfg.ptr = &tsWAL;
S
TD-1207  
Shengliang Guan 已提交
831
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
832
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
H
hjxilinx 已提交
833 834
  cfg.minValue = TSDB_MIN_WAL_LEVEL;
  cfg.maxValue = TSDB_MAX_WAL_LEVEL;
S
slguan 已提交
835 836 837 838
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

839
  cfg.option = "fsync";
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
840 841 842 843 844 845 846 847 848
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
849 850
  cfg.option = "replica";
  cfg.ptr = &tsReplications;
S
slguan 已提交
851 852
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
853 854
  cfg.minValue = TSDB_MIN_DB_REPLICA_OPTION;
  cfg.maxValue = TSDB_MAX_DB_REPLICA_OPTION;
S
slguan 已提交
855 856 857 858
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
859 860 861 862 863 864 865 866 867 868
  cfg.option = "partitions";
  cfg.ptr = &tsPartitons;
  cfg.valType = TAOS_CFG_VTYPE_INT16;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = TSDB_MIN_DB_PARTITON_OPTION;
  cfg.maxValue = TSDB_MAX_DB_PARTITON_OPTION;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

869 870 871 872
  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 已提交
873 874
  cfg.minValue = TSDB_MIN_DB_QUORUM_OPTION;
  cfg.maxValue = TSDB_MAX_DB_QUORUM_OPTION;
875 876 877 878
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
879 880
  cfg.option = "update";
  cfg.ptr = &tsUpdate;
S
Shengliang Guan 已提交
881
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
882 883 884 885 886 887 888
  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;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
TD-1310  
Shengliang Guan 已提交
889 890
  cfg.option = "mqttHostName";
  cfg.ptr = tsMqttHostName;
891
  cfg.valType = TAOS_CFG_VTYPE_STRING;
892
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
893 894
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
TD-1310  
Shengliang Guan 已提交
895
  cfg.ptrLength = TSDB_MQTT_HOSTNAME_LEN;
896 897
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);
898

S
TD-1310  
Shengliang Guan 已提交
899 900
  cfg.option = "mqttPort";
  cfg.ptr = tsMqttPort;
901
  cfg.valType = TAOS_CFG_VTYPE_STRING;
902
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
903 904
  cfg.minValue = 0;
  cfg.maxValue = 0;
S
TD-1310  
Shengliang Guan 已提交
905
  cfg.ptrLength = TSDB_MQTT_PORT_LEN;
906 907
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);
S
TD-1310  
Shengliang Guan 已提交
908 909 910 911

  cfg.option = "mqttTopic";
  cfg.ptr = tsMqttTopic;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
912
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT;
S
TD-1310  
Shengliang Guan 已提交
913 914 915 916 917 918
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = TSDB_MQTT_TOPIC_LEN;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948
  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;
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

H
Haojun Liao 已提交
949 950 951 952 953
  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 已提交
954
  cfg.maxValue = 500000000000.0f;
H
Haojun Liao 已提交
955 956 957 958
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_BYTE;
  taosInitConfigOption(cfg);

H
Haojun Liao 已提交
959 960
  cfg.option = "retrieveBlockingModel";
  cfg.ptr = &tsRetrieveBlockingModel;
961 962 963 964 965 966 967 968
  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;
  taosInitConfigOption(cfg);

969 970
  cfg.option = "keepColumnName";
  cfg.ptr = &tsKeepOriginalColumnName;
S
Shengliang Guan 已提交
971
  cfg.valType = TAOS_CFG_VTYPE_INT8;
972 973 974 975 976 977 978
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
979 980 981 982
  // locale & charset
  cfg.option = "timezone";
  cfg.ptr = tsTimezone;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
983
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
984 985 986 987 988 989 990 991 992
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = tListLen(tsTimezone);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "locale";
  cfg.ptr = tsLocale;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
993
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
994 995 996 997 998 999 1000 1001 1002
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = tListLen(tsLocale);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "charset";
  cfg.ptr = tsCharset;
  cfg.valType = TAOS_CFG_VTYPE_STRING;
1003
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
S
slguan 已提交
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
  cfg.minValue = 0;
  cfg.maxValue = 0;
  cfg.ptrLength = tListLen(tsCharset);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  // 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;
  taosInitConfigOption(cfg);

1021 1022
  cfg.option = "maxConnections";
  cfg.ptr = &tsMaxConnections;
S
slguan 已提交
1023 1024
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1025
  cfg.minValue = 1;
1026
  cfg.maxValue = 100000;
S
slguan 已提交
1027 1028 1029 1030 1031 1032 1033 1034
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "minimalLogDirGB";
  cfg.ptr = &tsMinimalLogDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1035
  cfg.minValue = 0.001f;
S
slguan 已提交
1036 1037 1038 1039 1040 1041
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
  taosInitConfigOption(cfg);

  cfg.option = "minimalTmpDirGB";
H
Haojun Liao 已提交
1042
  cfg.ptr = &tsReservedTmpDirectorySpace;
S
slguan 已提交
1043 1044
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1045
  cfg.minValue = 0.001f;
S
slguan 已提交
1046 1047 1048 1049 1050 1051 1052 1053 1054
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
  taosInitConfigOption(cfg);

  cfg.option = "minimalDataDirGB";
  cfg.ptr = &tsMinimalDataDirGB;
  cfg.valType = TAOS_CFG_VTYPE_FLOAT;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
1055
  cfg.minValue = 0.001f;
S
slguan 已提交
1056 1057 1058 1059 1060 1061
  cfg.maxValue = 10000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_GB;
  taosInitConfigOption(cfg);

  // module configs
S
Shengliang Guan 已提交
1062
  cfg.option = "mnodeEqualVnodeNum";
1063
  cfg.ptr = &tsMnodeEqualVnodeNum;
S
slguan 已提交
1064 1065 1066 1067 1068 1069
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
  cfg.minValue = 0;
  cfg.maxValue = 1000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
S
Shengliang Guan 已提交
1070 1071 1072 1073
  taosInitConfigOption(cfg);

    // module configs
  cfg.option = "flowctrl";
S
TD-2498  
Shengliang Guan 已提交
1074
  cfg.ptr = &tsEnableFlowCtrl;
S
Shengliang Guan 已提交
1075
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
TD-2498  
Shengliang Guan 已提交
1076 1077 1078 1079 1080 1081 1082 1083 1084
  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;
  taosInitConfigOption(cfg);

  cfg.option = "slaveQuery";
  cfg.ptr = &tsEnableSlaveQuery;
S
Shengliang Guan 已提交
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
  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;
  taosInitConfigOption(cfg);

  cfg.option = "adjustMaster";
  cfg.ptr = &tsEnableAdjustMaster;
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
Shengliang Guan 已提交
1096 1097 1098 1099 1100
  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;
S
slguan 已提交
1101 1102 1103 1104
  taosInitConfigOption(cfg);

  cfg.option = "http";
  cfg.ptr = &tsEnableHttpModule;
S
Shengliang Guan 已提交
1105
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1106 1107 1108 1109 1110 1111 1112
  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;
  taosInitConfigOption(cfg);

1113 1114
  cfg.option = "mqtt";
  cfg.ptr = &tsEnableMqttModule;
S
Shengliang Guan 已提交
1115
  cfg.valType = TAOS_CFG_VTYPE_INT8;
1116 1117 1118 1119 1120 1121 1122
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
1123 1124
  cfg.option = "monitor";
  cfg.ptr = &tsEnableMonitorModule;
S
Shengliang Guan 已提交
1125
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1126 1127 1128 1129 1130 1131 1132
  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;
  taosInitConfigOption(cfg);

1133 1134
  cfg.option = "stream";
  cfg.ptr = &tsEnableStream;
S
Shengliang Guan 已提交
1135
  cfg.valType = TAOS_CFG_VTYPE_INT8;
1136 1137 1138 1139 1140 1141 1142
  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;
  taosInitConfigOption(cfg);

S
slguan 已提交
1143 1144
  cfg.option = "httpEnableRecordSql";
  cfg.ptr = &tsHttpEnableRecordSql;
S
Shengliang Guan 已提交
1145
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1146 1147 1148 1149 1150 1151 1152 1153 1154
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "telegrafUseFieldNum";
  cfg.ptr = &tsTelegrafUseFieldNum;
S
Shengliang Guan 已提交
1155
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
  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;
  taosInitConfigOption(cfg);

  cfg.option = "httpMaxThreads";
  cfg.ptr = &tsHttpMaxThreads;
  cfg.valType = TAOS_CFG_VTYPE_INT32;
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
1167
  cfg.minValue = 2;
S
slguan 已提交
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
  cfg.maxValue = 1000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  // 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 已提交
1188
  cfg.minValue = 1000;
S
slguan 已提交
1189 1190 1191 1192 1193
  cfg.maxValue = 2000000000;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

1194
  cfg.option = "logKeepDays";
S
TD-1263  
Shengliang Guan 已提交
1195
  cfg.ptr = &tsLogKeepDays;
1196 1197
  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 已提交
1198
  cfg.minValue = -365000;
S
TD-1263  
Shengliang Guan 已提交
1199
  cfg.maxValue = 365000;
1200 1201 1202 1203
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

S
slguan 已提交
1204 1205
  cfg.option = "asyncLog";
  cfg.ptr = &tsAsyncLog;
S
Shengliang Guan 已提交
1206
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  cfg.option = "mDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1225
  cfg.ptr = &mDebugFlag;
S
slguan 已提交
1226 1227 1228 1229 1230 1231 1232 1233 1234
  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;
  taosInitConfigOption(cfg);

  cfg.option = "dDebugFlag";
1235
  cfg.ptr = &dDebugFlag;
S
slguan 已提交
1236 1237 1238 1239 1240 1241 1242 1243
  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;
  taosInitConfigOption(cfg);

J
jtao1735 已提交
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
  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;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
  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;
  taosInitConfigOption(cfg);


S
slguan 已提交
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  cfg.option = "cDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1296
  cfg.ptr = &cDebugFlag;
S
slguan 已提交
1297 1298 1299 1300 1301 1302 1303 1304 1305
  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;
  taosInitConfigOption(cfg);

  cfg.option = "jniDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1306
  cfg.ptr = &jniDebugFlag;
S
slguan 已提交
1307 1308 1309 1310 1311 1312 1313 1314 1315
  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;
  taosInitConfigOption(cfg);

  cfg.option = "odbcDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1316
  cfg.ptr = &odbcDebugFlag;
S
slguan 已提交
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
  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;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
1355 1356
  cfg.option = "monDebugFlag";
  cfg.ptr = &monDebugFlag;
S
slguan 已提交
1357 1358 1359 1360 1361 1362 1363 1364 1365
  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;
  taosInitConfigOption(cfg);

  cfg.option = "qDebugFlag";
guanshengliang's avatar
guanshengliang 已提交
1366
  cfg.ptr = &qDebugFlag;
S
slguan 已提交
1367 1368 1369 1370 1371 1372 1373 1374
  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;
  taosInitConfigOption(cfg);

S
Shengliang Guan 已提交
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384
  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;
  taosInitConfigOption(cfg);

1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
  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;
  taosInitConfigOption(cfg);

S
TD-1520  
Shengliang Guan 已提交
1395 1396 1397 1398 1399 1400 1401 1402 1403 1404
  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;
  taosInitConfigOption(cfg);

1405
  cfg.option = "enableRecordSql";
S
slguan 已提交
1406
  cfg.ptr = &tsTscEnableRecordSql;
S
Shengliang Guan 已提交
1407
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1408 1409 1410 1411 1412 1413 1414 1415 1416
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  cfg.option = "enableCoreFile";
  cfg.ptr = &tsEnableCoreFile;
S
Shengliang Guan 已提交
1417
  cfg.valType = TAOS_CFG_VTYPE_INT8;
S
slguan 已提交
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
  cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
  cfg.minValue = 0;
  cfg.maxValue = 1;
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);

  // 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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);

  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;
  taosInitConfigOption(cfg);
1465 1466 1467 1468 1469 1470

  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;
1471
  cfg.maxValue = 65536;
1472 1473 1474
  cfg.ptrLength = 0;
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484

  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;
  cfg.ptrLength = tListLen(tsTempDir);
  cfg.unitType = TAOS_CFG_UTYPE_NONE;
  taosInitConfigOption(cfg);
S
slguan 已提交
1485 1486 1487 1488 1489 1490
}

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

S
TD-1663  
Shengliang Guan 已提交
1491
int32_t taosCheckGlobalCfg() {
R
root 已提交
1492
  char fqdn[TSDB_FQDN_LEN];
1493 1494
  uint16_t port;

S
Shengliang Guan 已提交
1495
  if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
guanshengliang's avatar
guanshengliang 已提交
1496 1497 1498
    taosSetAllDebugFlag();
  }
  
H
Hui Li 已提交
1499 1500 1501 1502
  if (tsLocalFqdn[0] == 0) {
    taosGetFqdn(tsLocalFqdn);
  }

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

S
slguan 已提交
1506 1507
  if (tsFirst[0] == 0) {
    strcpy(tsFirst, tsLocalEp);
1508 1509
  } else {
    taosGetFqdnPortFromEp(tsFirst, fqdn, &port);
R
root 已提交
1510
    snprintf(tsFirst, sizeof(tsFirst), "%s:%u", fqdn, port);
S
slguan 已提交
1511 1512
  }

J
jtao1735 已提交
1513 1514
  if (tsSecond[0] == 0) {
    strcpy(tsSecond, tsLocalEp);
1515 1516
  } else {
    taosGetFqdnPortFromEp(tsSecond, fqdn, &port);
R
root 已提交
1517
    snprintf(tsSecond, sizeof(tsSecond), "%s:%u", fqdn, port);
S
slguan 已提交
1518
  }
1519

S
TD-1767  
Shengliang Guan 已提交
1520
  taosCheckDataDirCfg();
D
fix bug  
dapan1121 已提交
1521 1522 1523 1524 1525

  if (taosCheckTmpDir()) {
    return -1;
  }
  
S
slguan 已提交
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538
  taosGetSystemInfo();

  tsSetLocale();

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

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

1539 1540 1541 1542 1543 1544 1545
  if (tsHttpMaxThreads == 2) {
    int32_t halfNumOfCores = tsNumOfCores >> 1;
    if (halfNumOfCores > 2) {
      tsHttpMaxThreads = halfNumOfCores;
    }
  }

1546 1547 1548 1549 1550 1551
  if (tsMaxTablePerVnode < tsMinTablePerVnode) {
    uError("maxTablesPerVnode(%d) < minTablesPerVnode(%d), reset to minTablesPerVnode(%d)",
	   tsMaxTablePerVnode, tsMinTablePerVnode, tsMinTablePerVnode);
    tsMaxTablePerVnode = tsMinTablePerVnode;
  }

S
slguan 已提交
1552 1553
  // todo refactor
  tsVersion = 0;
1554
  for (int ver = 0, i = 0; i < TSDB_VERSION_LEN; ++i) {
S
slguan 已提交
1555
    if (version[i] >= '0' && version[i] <= '9') {
1556 1557 1558 1559 1560 1561
      ver = ver * 10 + (version[i] - '0');
    } else if (version[i] == '.') {
      tsVersion |= ver & 0xFF;
      tsVersion <<= 8;

      ver = 0;
S
slguan 已提交
1562
    } else if (version[i] == 0) {
1563 1564
      tsVersion |= ver & 0xFF;

S
slguan 已提交
1565 1566 1567 1568
      break;
    }
  }

J
jtao1735 已提交
1569
  tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL;  // udp[6035-6039] tcp[6035]
J
jtao1735 已提交
1570
  tsDnodeDnodePort = tsServerPort + TSDB_PORT_DNODEDNODE;   // udp/tcp
J
jtao1735 已提交
1571
  tsSyncPort = tsServerPort + TSDB_PORT_SYNC;
1572
  tsHttpPort = tsServerPort + TSDB_PORT_HTTP;
J
jtao1735 已提交
1573

1574
  if (tsQueryBufferSize >= 0) {
D
fix bug  
dapan1121 已提交
1575
    tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
1576 1577
  }

1578 1579
  uInfo("   check global cfg completed");
  uInfo("==================================");
S
TD-1663  
Shengliang Guan 已提交
1580
  taosPrintGlobalCfg();
S
TD-1663  
Shengliang Guan 已提交
1581

S
TD-1663  
Shengliang Guan 已提交
1582
  return 0;
S
slguan 已提交
1583
}
J
jtao1735 已提交
1584

1585
int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) {
J
jtao1735 已提交
1586 1587 1588 1589 1590 1591 1592 1593 1594
  *port = 0;
  strcpy(fqdn, ep);

  char *temp = strchr(fqdn, ':');
  if (temp) {   
    *temp = 0;
    *port = atoi(temp+1);
  } 
  
H
Hui Li 已提交
1595 1596 1597 1598
  if (*port == 0) {
    *port = tsServerPort;
    return -1;
  }
J
jtao1735 已提交
1599 1600 1601

  return 0; 
}
1602 1603 1604 1605 1606

/*
 * alter dnode 1 balance "vnode:1-dnode:2"
 */

S
Shengliang Guan 已提交
1607
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
1608
  int len = (int)strlen(option);
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622
  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 已提交
1623 1624 1625
  *vnodeId = strtol(option + 6, NULL, 10);
  *dnodeId = strtol(option + pos + 6, NULL, 10);
  if (*vnodeId <= 1 || *dnodeId <= 0) {
1626 1627 1628 1629
    return false;
  }

  return true;
1630
}