未验证 提交 feae2858 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2698 from taosdata/feature/vnode

Feature/vnode
......@@ -199,6 +199,9 @@ int32_t sDebugFlag = 135;
int32_t wDebugFlag = 135;
int32_t tsdbDebugFlag = 131;
int32_t (*monitorStartSystemFp)() = NULL;
void (*monitorStopSystemFp)() = NULL;
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
void taosSetAllDebugFlag() {
......@@ -248,11 +251,17 @@ bool taosCfgDynamicOptions(char *msg) {
*((int32_t *)cfg->ptr) = vint;
if (strncasecmp(cfg->option, "monitor", olen) == 0) {
// if (0 == vint) {
// monitorStartSystem();
// } else {
// monitorStopSystem();
// }
if (1 == vint) {
if (monitorStartSystemFp) {
(*monitorStartSystemFp)();
uInfo("monitor is enabled");
}
} else {
if (monitorStopSystemFp) {
(*monitorStopSystemFp)();
uInfo("monitor is disabled");
}
}
return true;
}
......
......@@ -452,10 +452,23 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
return grantCode;
}
char dnodeEp[TSDB_EP_LEN] = {0};
tstrncpy(dnodeEp, ep, TSDB_EP_LEN);
strtrim(dnodeEp);
char *temp = strchr(dnodeEp, ':');
if (!temp) {
int len = strlen(dnodeEp);
if (dnodeEp[len - 1] == ';') dnodeEp[len - 1] = 0;
len = strlen(dnodeEp);
snprintf(dnodeEp + len, TSDB_EP_LEN - len, ":%d", tsServerPort);
}
ep = dnodeEp;
SDnodeObj *pDnode = mnodeGetDnodeByEp(ep);
if (pDnode != NULL) {
mnodeDecDnodeRef(pDnode);
mError("dnode:%d is alredy exist, %s:%d", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodePort);
mError("dnode:%d is already exist, %s:%d", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodePort);
return TSDB_CODE_MND_DNODE_ALREADY_EXIST;
}
......@@ -507,8 +520,12 @@ int32_t mnodeDropDnode(SDnodeObj *pDnode, void *pMsg) {
static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) {
SDnodeObj *pDnode = mnodeGetDnodeByEp(ep);
if (pDnode == NULL) {
mError("dnode:%s, is not exist", ep);
return TSDB_CODE_MND_DNODE_NOT_EXIST;
int32_t dnodeId = (int32_t)strtol(ep, NULL, 10);
pDnode = mnodeGetDnode(dnodeId);
if (pDnode == NULL) {
mError("dnode:%s, is not exist", ep);
return TSDB_CODE_MND_DNODE_NOT_EXIST;
}
}
if (strcmp(pDnode->dnodeEp, mnodeGetMnodeMasterEp()) == 0) {
......
......@@ -76,6 +76,8 @@ static void monitorInitDatabase();
static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code);
static void monitorStartTimer();
static void monitorSaveSystemInfo();
extern int32_t (*monitorStartSystemFp)();
extern void (*monitorStopSystemFp)();
static void monitorCheckDiskUsage(void *para, void *unused) {
taosGetDisk();
......@@ -85,6 +87,8 @@ static void monitorCheckDiskUsage(void *para, void *unused) {
int32_t monitorInitSystem() {
taos_init();
taosTmrReset(monitorCheckDiskUsage, CHECK_INTERVAL, NULL, tscTmr, &tsMonitorConn.diskTimer);
monitorStartSystemFp = monitorStartSystem;
monitorStopSystemFp = monitorStopSystem;
return 0;
}
......
......@@ -21,7 +21,7 @@
#include "tutil.h"
#include "cJSON.h"
void simLogSql(char *sql) {
void simLogSql(char *sql, bool useSharp) {
static FILE *fp = NULL;
char filename[256];
sprintf(filename, "%s/sim.sql", tsScriptDir);
......@@ -32,7 +32,12 @@ void simLogSql(char *sql) {
return;
}
}
fprintf(fp, "%s;\n", sql);
if (useSharp) {
fprintf(fp, "# %s;\n", sql);
} else {
fprintf(fp, "%s;\n", sql);
}
fflush(fp);
}
......@@ -300,6 +305,7 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
sprintf(buf, "cd %s; ", tsScriptDir);
simVisuallizeOption(script, option, buf + strlen(buf));
simLogSql(buf, true);
int code = system(buf);
int repeatTimes = 0;
while (code < 0) {
......@@ -372,6 +378,10 @@ bool simExecuteSleepCmd(SScript *script, char *option) {
taosMsleep(delta);
simInfo("script:%s, sleep %dms finished", script->fileName, delta);
char sleepStr[32] = {0};
sprintf(sleepStr, "sleep %d", delta);
simLogSql(sleepStr, true);
script->linePos++;
return true;
}
......@@ -655,7 +665,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
TAOS_RES* pSql = NULL;
for (int attempt = 0; attempt < 3; ++attempt) {
simLogSql(rest);
simLogSql(rest, false);
pSql = taos_query(script->taos, rest);
ret = taos_errno(pSql);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册