Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f7cf8229
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f7cf8229
编写于
4月 12, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact(cluster): node mgmt
上级
a86b9faa
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
106 addition
and
139 deletion
+106
-139
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+1
-1
source/dnode/mgmt/exe/dndMain.c
source/dnode/mgmt/exe/dndMain.c
+1
-1
source/dnode/mgmt/implement/inc/dndNode.h
source/dnode/mgmt/implement/inc/dndNode.h
+0
-8
source/dnode/mgmt/implement/src/dndObj.c
source/dnode/mgmt/implement/src/dndObj.c
+0
-68
source/dnode/mgmt/interface/inc/dndInt.h
source/dnode/mgmt/interface/inc/dndInt.h
+14
-48
source/dnode/mgmt/interface/src/dndEnv.c
source/dnode/mgmt/interface/src/dndEnv.c
+1
-1
source/dnode/mgmt/interface/src/dndFile.c
source/dnode/mgmt/interface/src/dndFile.c
+2
-1
source/dnode/mgmt/interface/src/dndInt.c
source/dnode/mgmt/interface/src/dndInt.c
+86
-10
source/dnode/mgmt/test/sut/src/server.cpp
source/dnode/mgmt/test/sut/src/server.cpp
+1
-1
未找到文件。
include/dnode/mgmt/dnode.h
浏览文件 @
f7cf8229
...
...
@@ -81,7 +81,7 @@ int32_t dndRun(SDnode *pDnode);
* @param pDnode The dnode object to close.
* @param event The event to handle.
*/
void
dnd
Handle
Event
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
dnd
Set
Event
(
SDnode
*
pDnode
,
EDndEvent
event
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/exe/dndMain.c
浏览文件 @
f7cf8229
...
...
@@ -32,7 +32,7 @@ static struct {
static
void
dndStopDnode
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
SDnode
*
pDnode
=
atomic_val_compare_exchange_ptr
(
&
global
.
pDnode
,
0
,
global
.
pDnode
);
if
(
pDnode
!=
NULL
)
{
dnd
Handle
Event
(
pDnode
,
DND_EVENT_STOP
);
dnd
Set
Event
(
pDnode
,
DND_EVENT_STOP
);
}
}
...
...
source/dnode/mgmt/implement/inc/dndNode.h
浏览文件 @
f7cf8229
...
...
@@ -25,14 +25,6 @@ extern "C" {
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
);
...
...
source/dnode/mgmt/implement/src/dndObj.c
浏览文件 @
f7cf8229
...
...
@@ -149,72 +149,4 @@ void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
}
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
pRetWrapper
;
}
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
||
(
pWrapper
->
procType
==
DND_PROC_PARENT
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
code
;
}
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taosRLockLatch
(
&
pWrapper
->
latch
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosRUnLockLatch
(
&
pWrapper
->
latch
);
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
pWrapper
->
msgVgIds
[
TMSG_INDEX
(
msgType
)]
=
vgId
;
}
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
}
static
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
};
rpcSendResponse
(
&
rpcRsp
);
}
\ No newline at end of file
source/dnode/mgmt/interface/inc/dndInt.h
浏览文件 @
f7cf8229
...
...
@@ -16,67 +16,33 @@
#ifndef _TD_DND_INT_H_
#define _TD_DND_INT_H_
#include "dndLog.h"
#include "dndDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
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
);
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
);
// dndFile.c
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
TdFilePtr
dndCheckRunning
(
const
char
*
dataDir
);
int32_t
dndReadShmFile
(
SDnode
*
pDnode
);
int32_t
dndWriteShmFile
(
SDnode
*
pDnode
);
// dndInt.c
EDndRunStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
stat
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
);
const
char
*
dndStatName
(
EDndRunStatus
stat
);
const
char
*
dndLogName
(
EDndNodeType
ntype
);
const
char
*
dndProcName
(
EDndNodeType
ntype
);
const
char
*
dndEventName
(
EDndEvent
ev
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
nType
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
EDndRunStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
stat
);
void
dndSetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
);
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
);
// dndFile.c
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
TdFilePtr
dndCheckRunning
(
const
char
*
dataDir
);
int32_t
dndReadShmFile
(
SDnode
*
pDnode
);
int32_t
dndWriteShmFile
(
SDnode
*
pDnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/i
mplement
/src/dndEnv.c
→
source/dnode/mgmt/i
nterface
/src/dndEnv.c
浏览文件 @
f7cf8229
...
...
@@ -14,7 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "dnd
Node
.h"
#include "dnd
Int
.h"
#include "wal.h"
static
int8_t
once
=
DND_ENV_INIT
;
...
...
source/dnode/mgmt/interface/src/dndFile.c
浏览文件 @
f7cf8229
...
...
@@ -232,7 +232,8 @@ int32_t dndWriteShmFile(SDnode *pDnode) {
if
(
ntype
==
NODE_END
-
1
)
{
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
"
,
dndProcName
(
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
"
);
...
...
source/dnode/mgmt/interface/src/dndInt.c
浏览文件 @
f7cf8229
...
...
@@ -16,15 +16,6 @@
#define _DEFAULT_SOURCE
#include "dndInt.h"
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"
,
dndStatName
(
pDnode
->
status
),
dndStatName
(
status
));
pDnode
->
status
=
status
;
}
}
const
char
*
dndStatName
(
EDndRunStatus
status
)
{
switch
(
status
)
{
case
DND_STAT_INIT
:
...
...
@@ -83,4 +74,89 @@ const char *dndEventName(EDndEvent ev) {
default:
return
"UNKNOWN"
;
}
}
\ No newline at end of file
}
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"
,
dndStatName
(
pDnode
->
status
),
dndStatName
(
status
));
pDnode
->
status
=
status
;
}
}
void
dndSetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
if
(
event
==
DND_EVENT_STOP
)
{
pDnode
->
event
=
event
;
}
}
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
pWrapper
->
msgVgIds
[
TMSG_INDEX
(
msgType
)]
=
vgId
;
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
pRetWrapper
;
}
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
||
(
pWrapper
->
procType
==
DND_PROC_PARENT
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
code
;
}
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taosRLockLatch
(
&
pWrapper
->
latch
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosRUnLockLatch
(
&
pWrapper
->
latch
);
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
}
static
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
};
rpcSendResponse
(
&
rpcRsp
);
}
source/dnode/mgmt/test/sut/src/server.cpp
浏览文件 @
f7cf8229
...
...
@@ -68,7 +68,7 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const
}
void
TestServer
::
Stop
()
{
dnd
Handle
Event
(
pDnode
,
DND_EVENT_STOP
);
dnd
Set
Event
(
pDnode
,
DND_EVENT_STOP
);
taosThreadJoin
(
threadId
,
NULL
);
if
(
pDnode
!=
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录