commit
2725164e34
|
@ -42,6 +42,9 @@ extern "C" {
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#if defined(DARWIN)
|
#if defined(DARWIN)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -18,13 +18,15 @@
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
bool generateGrant;
|
bool generateGrant;
|
||||||
bool printAuth;
|
bool printAuth;
|
||||||
bool printVersion;
|
bool printVersion;
|
||||||
char envFile[PATH_MAX];
|
char envFile[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
SDnode *pDnode;
|
SArray *pArgs; // SConfigPair
|
||||||
|
SDnode *pDnode;
|
||||||
|
ENodeType ntype;
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
||||||
|
@ -62,6 +64,8 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
tstrncpy(global.envFile, argv[++i], PATH_MAX);
|
tstrncpy(global.envFile, argv[++i], PATH_MAX);
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
global.generateGrant = true;
|
global.generateGrant = true;
|
||||||
|
} else if (strcmp(argv[i], "-n") == 0) {
|
||||||
|
global.ntype = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-C") == 0) {
|
} else if (strcmp(argv[i], "-C") == 0) {
|
||||||
global.dumpConfig = true;
|
global.dumpConfig = true;
|
||||||
} else if (strcmp(argv[i], "-V") == 0) {
|
} else if (strcmp(argv[i], "-V") == 0) {
|
||||||
|
@ -75,6 +79,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
|
|
||||||
static void dndGenerateGrant() {
|
static void dndGenerateGrant() {
|
||||||
// grantParseParameter();
|
// grantParseParameter();
|
||||||
|
printf("this feature is not implemented yet\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndPrintVersion() {
|
static void dndPrintVersion() {
|
||||||
|
@ -93,7 +98,7 @@ static void dndDumpCfg() {
|
||||||
cfgDumpCfg(pCfg, 0, 1);
|
cfgDumpCfg(pCfg, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeOpt dndGetOpt() {
|
static SDnodeOpt dndGetOpt() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
SDnodeOpt option = {0};
|
SDnodeOpt option = {0};
|
||||||
|
|
||||||
|
@ -109,6 +114,20 @@ SDnodeOpt dndGetOpt() {
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t dndInitLog() {
|
||||||
|
char logName[12] = {0};
|
||||||
|
snprintf(logName, sizeof(logName), "%slog", dndNodeLogStr(global.ntype));
|
||||||
|
return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndSetProcName(char **argv) {
|
||||||
|
if (global.ntype != 0) {
|
||||||
|
const char *name = dndNodeProcStr(global.ntype);
|
||||||
|
prctl(PR_SET_NAME, name);
|
||||||
|
strcpy(argv[0], name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t dndRunDnode() {
|
static int32_t dndRunDnode() {
|
||||||
if (dndInit() != 0) {
|
if (dndInit() != 0) {
|
||||||
dError("failed to initialize environment since %s", terrstr());
|
dError("failed to initialize environment since %s", terrstr());
|
||||||
|
@ -116,8 +135,7 @@ static int32_t dndRunDnode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeOpt option = dndGetOpt();
|
SDnodeOpt option = dndGetOpt();
|
||||||
|
SDnode *pDnode = dndCreate(&option);
|
||||||
SDnode *pDnode = dndCreate(&option);
|
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
dError("failed to to create dnode object since %s", terrstr());
|
dError("failed to to create dnode object since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -126,9 +144,9 @@ static int32_t dndRunDnode() {
|
||||||
dndSetSignalHandle();
|
dndSetSignalHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("start the TDengine service");
|
dInfo("start the service");
|
||||||
int32_t code = dndRun(pDnode);
|
int32_t code = dndRun(pDnode);
|
||||||
dInfo("start shutting down the TDengine service");
|
dInfo("start shutting down the service");
|
||||||
|
|
||||||
global.pDnode = NULL;
|
global.pDnode = NULL;
|
||||||
dndClose(pDnode);
|
dndClose(pDnode);
|
||||||
|
@ -159,12 +177,12 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosCreateLog("taosdlog", 1, configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
if (dndInitLog() != 0) {
|
||||||
printf("failed to start since read log config error\n");
|
printf("failed to start since init log error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosInitCfg(configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
if (taosInitCfg(configDir, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
||||||
dError("failed to start since read config error");
|
dError("failed to start since read config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -176,5 +194,6 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dndSetProcName((char **)argv);
|
||||||
return dndRunDnode();
|
return dndRunDnode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,11 +131,13 @@ typedef struct SDnode {
|
||||||
SMgmtWrapper wrappers[NODE_MAX];
|
SMgmtWrapper wrappers[NODE_MAX];
|
||||||
} SDnode;
|
} SDnode;
|
||||||
|
|
||||||
EDndStatus dndGetStatus(SDnode *pDnode);
|
const char *dndNodeLogStr(ENodeType ntype);
|
||||||
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
const char *dndNodeProcStr(ENodeType ntype);
|
||||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
EDndStatus dndGetStatus(SDnode *pDnode);
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
||||||
void dndSendMonitorReport(SDnode *pDnode);
|
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
||||||
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||||
|
void dndSendMonitorReport(SDnode *pDnode);
|
||||||
|
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg);
|
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
|
|
|
@ -80,19 +80,6 @@ void dndSetStatus(SDnode *pDnode, EDndStatus status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dndStatStr(EDndStatus status) {
|
|
||||||
switch (status) {
|
|
||||||
case DND_STAT_INIT:
|
|
||||||
return "init";
|
|
||||||
case DND_STAT_RUNNING:
|
|
||||||
return "running";
|
|
||||||
case DND_STAT_STOPPED:
|
|
||||||
return "stopped";
|
|
||||||
default:
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
||||||
SStartupReq *pStartup = &pDnode->startup;
|
SStartupReq *pStartup = &pDnode->startup;
|
||||||
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* 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 "dndInt.h"
|
||||||
|
|
||||||
|
const char *dndStatStr(EDndStatus status) {
|
||||||
|
switch (status) {
|
||||||
|
case DND_STAT_INIT:
|
||||||
|
return "init";
|
||||||
|
case DND_STAT_RUNNING:
|
||||||
|
return "running";
|
||||||
|
case DND_STAT_STOPPED:
|
||||||
|
return "stopped";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dndNodeLogStr(ENodeType ntype) {
|
||||||
|
switch (ntype) {
|
||||||
|
case VNODES:
|
||||||
|
return "vnode";
|
||||||
|
case QNODE:
|
||||||
|
return "qnode";
|
||||||
|
case SNODE:
|
||||||
|
return "snode";
|
||||||
|
case MNODE:
|
||||||
|
return "mnode";
|
||||||
|
case BNODE:
|
||||||
|
return "bnode";
|
||||||
|
default:
|
||||||
|
return "taosd";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dndNodeProcStr(ENodeType ntype) {
|
||||||
|
switch (ntype) {
|
||||||
|
case VNODES:
|
||||||
|
return "taosv";
|
||||||
|
case QNODE:
|
||||||
|
return "taosq";
|
||||||
|
case SNODE:
|
||||||
|
return "taoss";
|
||||||
|
case MNODE:
|
||||||
|
return "taosm";
|
||||||
|
case BNODE:
|
||||||
|
return "taosb";
|
||||||
|
default:
|
||||||
|
return "taosd";
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,10 +19,6 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
|
|
||||||
// todo
|
|
||||||
#include <sys/shm.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#define SHM_DEFAULT_SIZE (20 * 1024 * 1024)
|
#define SHM_DEFAULT_SIZE (20 * 1024 * 1024)
|
||||||
typedef void *(*ProcThreadFp)(void *param);
|
typedef void *(*ProcThreadFp)(void *param);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG
|
||||||
echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG
|
echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG
|
||||||
echo "fqdn ${HOSTNAME}" >> $TAOS_CFG
|
echo "fqdn ${HOSTNAME}" >> $TAOS_CFG
|
||||||
echo "serverPort ${NODE}" >> $TAOS_CFG
|
echo "serverPort ${NODE}" >> $TAOS_CFG
|
||||||
echo "supportVnodes 128" >> $TAOS_CFG
|
echo "supportVnodes 128" >> $TAOS_CFG
|
||||||
echo "dataDir $DATA_DIR" >> $TAOS_CFG
|
echo "dataDir $DATA_DIR" >> $TAOS_CFG
|
||||||
echo "logDir $LOG_DIR" >> $TAOS_CFG
|
echo "logDir $LOG_DIR" >> $TAOS_CFG
|
||||||
echo "debugFlag 0" >> $TAOS_CFG
|
echo "debugFlag 0" >> $TAOS_CFG
|
||||||
|
@ -133,20 +133,17 @@ echo "dDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "vDebugFlag 143" >> $TAOS_CFG
|
echo "vDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "tsdbDebugFlag 143" >> $TAOS_CFG
|
echo "tsdbDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "cDebugFlag 143" >> $TAOS_CFG
|
echo "cDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "jnidebugFlag 143" >> $TAOS_CFG
|
echo "jniDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "qdebugFlag 143" >> $TAOS_CFG
|
echo "qDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "rpcDebugFlag 143" >> $TAOS_CFG
|
echo "rpcDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
||||||
echo "udebugFlag 143" >> $TAOS_CFG
|
echo "uDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "sdebugFlag 143" >> $TAOS_CFG
|
echo "sDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "wdebugFlag 143" >> $TAOS_CFG
|
echo "wDebugFlag 143" >> $TAOS_CFG
|
||||||
echo "slaveQuery 0" >> $TAOS_CFG
|
|
||||||
echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG
|
|
||||||
echo "defaultPass taosdata" >> $TAOS_CFG
|
|
||||||
echo "numOfLogLines 20000000" >> $TAOS_CFG
|
echo "numOfLogLines 20000000" >> $TAOS_CFG
|
||||||
echo "statusInterval 1" >> $TAOS_CFG
|
echo "statusInterval 1" >> $TAOS_CFG
|
||||||
echo "asyncLog 0" >> $TAOS_CFG
|
echo "asyncLog 0" >> $TAOS_CFG
|
||||||
echo "locale en_US.UTF-8" >> $TAOS_CFG
|
echo "locale en_US.UTF-8" >> $TAOS_CFG
|
||||||
echo "fsync 0" >> $TAOS_CFG
|
|
||||||
echo "telemetryReporting 0" >> $TAOS_CFG
|
echo "telemetryReporting 0" >> $TAOS_CFG
|
||||||
|
echo "multiProcess 0" >> $TAOS_CFG
|
||||||
echo " " >> $TAOS_CFG
|
echo " " >> $TAOS_CFG
|
||||||
|
|
Loading…
Reference in New Issue