shm
This commit is contained in:
parent
b2405a0098
commit
dd94e2da5a
|
@ -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,14 +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;
|
||||||
int8_t node;
|
char envFile[PATH_MAX];
|
||||||
char envFile[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
SArray *pArgs; // SConfigPair
|
||||||
SDnode *pDnode;
|
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) {
|
||||||
|
@ -64,7 +65,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
} 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) {
|
} else if (strcmp(argv[i], "-n") == 0) {
|
||||||
global.node = atoi(argv[++i]);
|
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) {
|
||||||
|
@ -97,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};
|
||||||
|
|
||||||
|
@ -113,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());
|
||||||
|
@ -162,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;
|
||||||
}
|
}
|
||||||
|
@ -179,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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue