提交 a86b9faa 编写于 作者: S Shengliang Guan

refact(cluster): node mgmt

上级 4fedc23b
......@@ -6,7 +6,7 @@ aux_source_directory(bm DNODE_SRC)
aux_source_directory(sm DNODE_SRC)
aux_source_directory(vm DNODE_SRC)
aux_source_directory(mm DNODE_SRC)
aux_source_directory(main DNODE_SRC)
aux_source_directory(implement/src DNODE_SRC)
add_library(dnode STATIC ${DNODE_SRC})
target_link_libraries(
dnode dnode_interface
......@@ -15,14 +15,15 @@ target_include_directories(
dnode
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mgmt"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface/inc"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/implement/inc"
)
aux_source_directory(exe EXEC_SRC)
add_executable(taosd ${EXEC_SRC})
target_include_directories(
taosd
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface/inc"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/implement/inc"
)
target_link_libraries(taosd dnode)
......
......@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndNode.h"
#include "tconfig.h"
static struct {
......@@ -129,14 +129,14 @@ static SDnodeOpt dndGetOpt() {
static int32_t dndInitLog() {
char logName[12] = {0};
snprintf(logName, sizeof(logName), "%slog", dndNodeLogStr(global.ntype));
snprintf(logName, sizeof(logName), "%slog", dndLogName(global.ntype));
return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0);
}
static void dndSetProcInfo(int32_t argc, char **argv) {
taosSetProcPath(argc, argv);
if (global.ntype != NODE_BEGIN && global.ntype != NODE_END) {
const char *name = dndNodeProcStr(global.ntype);
const char *name = dndProcName(global.ntype);
taosSetProcName(argc, argv, name);
}
}
......
/*
* 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/>.
*/
#ifndef _TD_DND_NODE_H_
#define _TD_DND_NODE_H_
#include "dndInt.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t dndOpenNode(SMgmtWrapper *pWrapper);
void dndCloseNode(SMgmtWrapper *pWrapper);
void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId);
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
void dndHandleEvent(SDnode *pDnode, EDndEvent event);
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
// dndTransport.c
int32_t dndInitTrans(SDnode *pDnode);
void dndCleanupTrans(SDnode *pDnode);
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper);
SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper);
int32_t dndInitMsgHandle(SDnode *pDnode);
void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
// mgmt
void dmSetMgmtFp(SMgmtWrapper *pWrapper);
void bmSetMgmtFp(SMgmtWrapper *pWrapper);
void qmSetMgmtFp(SMgmtWrapper *pMgmt);
void smSetMgmtFp(SMgmtWrapper *pWrapper);
void vmSetMgmtFp(SMgmtWrapper *pWrapper);
void mmSetMgmtFp(SMgmtWrapper *pMgmt);
void dmGetMnodeEpSet(SDnodeData *pMgmt, SEpSet *pEpSet);
void dmUpdateMnodeEpSet(SDnodeData *pMgmt, SEpSet *pEpSet);
void dmSendRedirectRsp(SDnodeData *pMgmt, const SRpcMsg *pMsg);
void dmGetMonitorSysInfo(SMonSysInfo *pInfo);
void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo);
void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo);
void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo);
void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo);
void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo);
void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo);
#ifdef __cplusplus
}
#endif
#endif /*_TD_DND_NODE_H_*/
\ No newline at end of file
......@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndNode.h"
#include "wal.h"
static int8_t once = DND_ENV_INIT;
......
......@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndNode.h"
static bool dndRequireNode(SMgmtWrapper *pWrapper) {
bool required = false;
......
......@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndNode.h"
static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
pDnode->data.supportVnodes = pOption->numOfSupportVnodes;
......
......@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndNode.h"
#define INTERNAL_USER "_dnd"
#define INTERNAL_CKEY "_key"
......
......@@ -16,7 +16,7 @@
#ifndef _TD_DND_BNODE_INT_H_
#define _TD_DND_BNODE_INT_H_
#include "dndInt.h"
#include "dndNode.h"
#include "bnode.h"
......
......@@ -16,7 +16,7 @@
#ifndef _TD_DND_DNODE_INT_H_
#define _TD_DND_DNODE_INT_H_
#include "dndInt.h"
#include "dndNode.h"
#ifdef __cplusplus
extern "C" {
......
......@@ -16,7 +16,7 @@
#ifndef _TD_DND_MNODE_INT_H_
#define _TD_DND_MNODE_INT_H_
#include "dndInt.h"
#include "dndNode.h"
#include "mnode.h"
#ifdef __cplusplus
......
......@@ -16,7 +16,7 @@
#ifndef _TD_DND_QNODE_INT_H_
#define _TD_DND_QNODE_INT_H_
#include "dndInt.h"
#include "dndNode.h"
#include "qnode.h"
#ifdef __cplusplus
......
......@@ -16,7 +16,7 @@
#ifndef _TD_DND_SNODE_INT_H_
#define _TD_DND_SNODE_INT_H_
#include "dndInt.h"
#include "dndNode.h"
#include "snode.h"
#ifdef __cplusplus
......
......@@ -17,7 +17,7 @@
#define _TD_DND_VNODES_INT_H_
#include "sync.h"
#include "dndInt.h"
#include "dndNode.h"
#include "vnode.h"
#ifdef __cplusplus
......
......@@ -23,11 +23,10 @@
extern "C" {
#endif
// dndEnv.c
const char *dndStatStr(EDndRunStatus stat);
const char *dndNodeLogStr(EDndNodeType ntype);
const char *dndNodeProcStr(EDndNodeType ntype);
const char *dndEventStr(EDndEvent ev);
const char *dndStatName(EDndRunStatus stat);
const char *dndLogName(EDndNodeType ntype);
const char *dndProcName(EDndNodeType ntype);
const char *dndEventName(EDndEvent ev);
// dndExec.c
int32_t dndOpenNode(SMgmtWrapper *pWrapper);
......
......@@ -23,7 +23,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
int64_t len = 0;
char content[MAXLEN + 1] = {0};
cJSON *root = NULL;
char file[PATH_MAX];
char file[PATH_MAX] = {0};
TdFilePtr pFile = NULL;
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
......@@ -165,13 +165,13 @@ int32_t dndReadShmFile(SDnode *pDnode) {
}
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
snprintf(itemName, sizeof(itemName), "%s_shmid", dndNodeProcStr(ntype));
snprintf(itemName, sizeof(itemName), "%s_shmid", dndProcName(ntype));
cJSON *shmid = cJSON_GetObjectItem(root, itemName);
if (shmid && shmid->type == cJSON_Number) {
pDnode->wrappers[ntype].procShm.id = shmid->valueint;
}
snprintf(itemName, sizeof(itemName), "%s_shmsize", dndNodeProcStr(ntype));
snprintf(itemName, sizeof(itemName), "%s_shmsize", dndProcName(ntype));
cJSON *shmsize = cJSON_GetObjectItem(root, itemName);
if (shmsize && shmsize->type == cJSON_Number) {
pDnode->wrappers[ntype].procShm.size = shmsize->valueint;
......@@ -228,11 +228,11 @@ int32_t dndWriteShmFile(SDnode *pDnode) {
len += snprintf(content + len, MAXLEN - len, "{\n");
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndNodeProcStr(ntype), pWrapper->procShm.id);
len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndProcName(ntype), pWrapper->procShm.id);
if (ntype == NODE_END - 1) {
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndNodeProcStr(ntype), pWrapper->procShm.size);
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndProcName(ntype), pWrapper->procShm.size);
} else {
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndNodeProcStr(ntype), pWrapper->procShm.size);
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndProcName(ntype), pWrapper->procShm.size);
}
}
len += snprintf(content + len, MAXLEN - len, "}\n");
......
......@@ -20,12 +20,12 @@ EDndRunStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; }
void dndSetStatus(SDnode *pDnode, EDndRunStatus status) {
if (pDnode->status != status) {
dDebug("dnode status set from %s to %s", dndStatStr(pDnode->status), dndStatStr(status));
dDebug("dnode status set from %s to %s", dndStatName(pDnode->status), dndStatName(status));
pDnode->status = status;
}
}
const char *dndStatStr(EDndRunStatus status) {
const char *dndStatName(EDndRunStatus status) {
switch (status) {
case DND_STAT_INIT:
return "init";
......@@ -38,7 +38,7 @@ const char *dndStatStr(EDndRunStatus status) {
}
}
const char *dndNodeLogStr(EDndNodeType ntype) {
const char *dndLogName(EDndNodeType ntype) {
switch (ntype) {
case VNODE:
return "vnode";
......@@ -55,7 +55,7 @@ const char *dndNodeLogStr(EDndNodeType ntype) {
}
}
const char *dndNodeProcStr(EDndNodeType ntype) {
const char *dndProcName(EDndNodeType ntype) {
switch (ntype) {
case VNODE:
return "taosv";
......@@ -72,7 +72,7 @@ const char *dndNodeProcStr(EDndNodeType ntype) {
}
}
const char *dndEventStr(EDndEvent ev) {
const char *dndEventName(EDndEvent ev) {
switch (ev) {
case DND_EVENT_START:
return "start";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册