Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
318d774b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
318d774b
编写于
4月 13, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact(cluster): node mgmt
上级
271264f6
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
645 addition
and
662 deletion
+645
-662
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+6
-6
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-0
source/dnode/mgmt/exe/dmMain.c
source/dnode/mgmt/exe/dmMain.c
+42
-42
source/dnode/mgmt/implement/inc/dmImp.h
source/dnode/mgmt/implement/inc/dmImp.h
+29
-31
source/dnode/mgmt/implement/src/dmEps.c
source/dnode/mgmt/implement/src/dmEps.c
+50
-54
source/dnode/mgmt/implement/src/dmExec.c
source/dnode/mgmt/implement/src/dmExec.c
+44
-44
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+88
-103
source/dnode/mgmt/implement/src/dmMonitor.c
source/dnode/mgmt/implement/src/dmMonitor.c
+22
-18
source/dnode/mgmt/implement/src/dmObj.c
source/dnode/mgmt/implement/src/dmObj.c
+15
-22
source/dnode/mgmt/implement/src/dmTransport.c
source/dnode/mgmt/implement/src/dmTransport.c
+62
-68
source/dnode/mgmt/implement/src/dmWorker.c
source/dnode/mgmt/implement/src/dmWorker.c
+44
-32
source/dnode/mgmt/interface/inc/dmDef.h
source/dnode/mgmt/interface/inc/dmDef.h
+6
-5
source/dnode/mgmt/interface/inc/dmInt.h
source/dnode/mgmt/interface/inc/dmInt.h
+26
-26
source/dnode/mgmt/interface/inc/dmLog.h
source/dnode/mgmt/interface/inc/dmLog.h
+3
-3
source/dnode/mgmt/interface/src/dmEnv.c
source/dnode/mgmt/interface/src/dmEnv.c
+2
-2
source/dnode/mgmt/interface/src/dmFile.c
source/dnode/mgmt/interface/src/dmFile.c
+10
-11
source/dnode/mgmt/interface/src/dmInt.c
source/dnode/mgmt/interface/src/dmInt.c
+17
-19
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
+4
-4
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
+3
-3
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+88
-88
source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
+13
-13
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
+3
-3
source/dnode/mgmt/mgmt_snode/src/smHandle.c
source/dnode/mgmt/mgmt_snode/src/smHandle.c
+6
-6
source/dnode/mgmt/mgmt_snode/src/smInt.c
source/dnode/mgmt/mgmt_snode/src/smInt.c
+3
-3
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+49
-49
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+1
-1
source/dnode/mgmt/test/sut/src/server.cpp
source/dnode/mgmt/test/sut/src/server.cpp
+4
-4
source/dnode/mgmt/test/sut/src/sut.cpp
source/dnode/mgmt/test/sut/src/sut.cpp
+2
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
318d774b
...
...
@@ -759,6 +759,7 @@ typedef struct {
int32_t
tSerializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
);
int32_t
tDeserializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
);
void
tFreeSStatusReq
(
SStatusReq
*
pReq
);
typedef
struct
{
int32_t
dnodeId
;
...
...
include/dnode/mgmt/dnode.h
浏览文件 @
318d774b
...
...
@@ -30,12 +30,12 @@ typedef struct SDnode SDnode;
*
* @return int32_t 0 for success and -1 for failure
*/
int32_t
d
nd
Init
();
int32_t
d
m
Init
();
/**
* @brief Clear the environment
*/
void
d
nd
Cleanup
();
void
d
m
Cleanup
();
/* ------------------------ SDnode ----------------------- */
typedef
struct
{
...
...
@@ -59,21 +59,21 @@ typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_CHILD } EDndEvent;
* @param pOption Option of the dnode.
* @return SDnode* The dnode object.
*/
SDnode
*
d
nd
Create
(
const
SDnodeOpt
*
pOption
);
SDnode
*
d
m
Create
(
const
SDnodeOpt
*
pOption
);
/**
* @brief Stop and cleanup the dnode.
*
* @param pDnode The dnode object to close.
*/
void
d
nd
Close
(
SDnode
*
pDnode
);
void
d
m
Close
(
SDnode
*
pDnode
);
/**
* @brief Run dnode until specific event is receive.
*
* @param pDnode The dnode object to run.
*/
int32_t
d
nd
Run
(
SDnode
*
pDnode
);
int32_t
d
m
Run
(
SDnode
*
pDnode
);
/**
* @brief Handle event in the dnode.
...
...
@@ -81,7 +81,7 @@ int32_t dndRun(SDnode *pDnode);
* @param pDnode The dnode object to close.
* @param event The event to handle.
*/
void
d
nd
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
d
m
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
#ifdef __cplusplus
}
...
...
source/common/src/tmsg.c
浏览文件 @
318d774b
...
...
@@ -958,6 +958,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
return
0
;
}
void
tFreeSStatusReq
(
SStatusReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pVloads
);
}
int32_t
tSerializeSStatusRsp
(
void
*
buf
,
int32_t
bufLen
,
SStatusRsp
*
pRsp
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/dnode/mgmt/exe/dmMain.c
浏览文件 @
318d774b
...
...
@@ -18,32 +18,32 @@
#include "tconfig.h"
static
struct
{
bool
dumpConfig
;
bool
generateGrant
;
bool
printAuth
;
bool
printVersion
;
char
envFile
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
SArray
*
pArgs
;
// SConfigPair
SDnode
*
pDnode
;
bool
dumpConfig
;
bool
generateGrant
;
bool
printAuth
;
bool
printVersion
;
char
envFile
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
SArray
*
pArgs
;
// SConfigPair
SDnode
*
pDnode
;
EDndNodeType
ntype
;
}
global
=
{
0
};
static
void
d
nd
StopDnode
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
static
void
d
m
StopDnode
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
SDnode
*
pDnode
=
atomic_val_compare_exchange_ptr
(
&
global
.
pDnode
,
0
,
global
.
pDnode
);
if
(
pDnode
!=
NULL
)
{
d
nd
SetEvent
(
pDnode
,
DND_EVENT_STOP
);
d
m
SetEvent
(
pDnode
,
DND_EVENT_STOP
);
}
}
static
void
d
nd
SetSignalHandle
()
{
taosSetSignal
(
SIGTERM
,
d
nd
StopDnode
);
taosSetSignal
(
SIGHUP
,
d
nd
StopDnode
);
taosSetSignal
(
SIGINT
,
d
nd
StopDnode
);
taosSetSignal
(
SIGTSTP
,
d
nd
StopDnode
);
taosSetSignal
(
SIGABRT
,
d
nd
StopDnode
);
taosSetSignal
(
SIGBREAK
,
d
nd
StopDnode
);
taosSetSignal
(
SIGQUIT
,
d
nd
StopDnode
);
static
void
d
m
SetSignalHandle
()
{
taosSetSignal
(
SIGTERM
,
d
m
StopDnode
);
taosSetSignal
(
SIGHUP
,
d
m
StopDnode
);
taosSetSignal
(
SIGINT
,
d
m
StopDnode
);
taosSetSignal
(
SIGTSTP
,
d
m
StopDnode
);
taosSetSignal
(
SIGABRT
,
d
m
StopDnode
);
taosSetSignal
(
SIGBREAK
,
d
m
StopDnode
);
taosSetSignal
(
SIGQUIT
,
d
m
StopDnode
);
if
(
!
tsMultiProcess
)
{
}
else
if
(
global
.
ntype
==
NODE_BEGIN
||
global
.
ntype
==
NODE_END
)
{
...
...
@@ -53,7 +53,7 @@ static void dndSetSignalHandle() {
}
}
static
int32_t
d
nd
ParseArgs
(
int32_t
argc
,
char
const
*
argv
[])
{
static
int32_t
d
m
ParseArgs
(
int32_t
argc
,
char
const
*
argv
[])
{
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
...
...
@@ -89,12 +89,12 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
return
0
;
}
static
void
d
nd
GenerateGrant
()
{
static
void
d
m
GenerateGrant
()
{
// grantParseParameter();
printf
(
"this feature is not implemented yet
\n
"
);
}
static
void
d
nd
PrintVersion
()
{
static
void
d
m
PrintVersion
()
{
#ifdef TD_ENTERPRISE
char
*
releaseName
=
"enterprise"
;
#else
...
...
@@ -105,12 +105,12 @@ static void dndPrintVersion() {
printf
(
"buildInfo: %s
\n
"
,
buildinfo
);
}
static
void
d
nd
DumpCfg
()
{
static
void
d
m
DumpCfg
()
{
SConfig
*
pCfg
=
taosGetCfg
();
cfgDumpCfg
(
pCfg
,
0
,
1
);
}
static
SDnodeOpt
d
nd
GetOpt
()
{
static
SDnodeOpt
d
m
GetOpt
()
{
SConfig
*
pCfg
=
taosGetCfg
();
SDnodeOpt
option
=
{
0
};
...
...
@@ -127,43 +127,43 @@ static SDnodeOpt dndGetOpt() {
return
option
;
}
static
int32_t
d
nd
InitLog
()
{
static
int32_t
d
m
InitLog
()
{
char
logName
[
12
]
=
{
0
};
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
d
nd
LogName
(
global
.
ntype
));
snprintf
(
logName
,
sizeof
(
logName
),
"%slog"
,
d
m
LogName
(
global
.
ntype
));
return
taosCreateLog
(
logName
,
1
,
configDir
,
global
.
envFile
,
global
.
apolloUrl
,
global
.
pArgs
,
0
);
}
static
void
d
nd
SetProcInfo
(
int32_t
argc
,
char
**
argv
)
{
static
void
d
m
SetProcInfo
(
int32_t
argc
,
char
**
argv
)
{
taosSetProcPath
(
argc
,
argv
);
if
(
global
.
ntype
!=
NODE_BEGIN
&&
global
.
ntype
!=
NODE_END
)
{
const
char
*
name
=
d
nd
ProcName
(
global
.
ntype
);
const
char
*
name
=
d
m
ProcName
(
global
.
ntype
);
taosSetProcName
(
argc
,
argv
,
name
);
}
}
static
int32_t
d
nd
RunDnode
()
{
if
(
d
nd
Init
()
!=
0
)
{
static
int32_t
d
m
RunDnode
()
{
if
(
d
m
Init
()
!=
0
)
{
dError
(
"failed to init environment since %s"
,
terrstr
());
return
-
1
;
}
SDnodeOpt
option
=
d
nd
GetOpt
();
SDnode
*
pDnode
=
d
nd
Create
(
&
option
);
SDnodeOpt
option
=
d
m
GetOpt
();
SDnode
*
pDnode
=
d
m
Create
(
&
option
);
if
(
pDnode
==
NULL
)
{
dError
(
"failed to to create dnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
global
.
pDnode
=
pDnode
;
d
nd
SetSignalHandle
();
d
m
SetSignalHandle
();
}
dInfo
(
"start the service"
);
int32_t
code
=
d
nd
Run
(
pDnode
);
int32_t
code
=
d
m
Run
(
pDnode
);
dInfo
(
"start shutting down the service"
);
global
.
pDnode
=
NULL
;
d
nd
Close
(
pDnode
);
d
nd
Cleanup
();
d
m
Close
(
pDnode
);
d
m
Cleanup
();
taosCloseLog
();
taosCleanupCfg
();
return
code
;
...
...
@@ -175,22 +175,22 @@ int main(int argc, char const *argv[]) {
return
-
1
;
}
if
(
d
nd
ParseArgs
(
argc
,
argv
)
!=
0
)
{
if
(
d
m
ParseArgs
(
argc
,
argv
)
!=
0
)
{
printf
(
"failed to start since parse args error
\n
"
);
return
-
1
;
}
if
(
global
.
generateGrant
)
{
d
nd
GenerateGrant
();
d
m
GenerateGrant
();
return
0
;
}
if
(
global
.
printVersion
)
{
d
nd
PrintVersion
();
d
m
PrintVersion
();
return
0
;
}
if
(
d
nd
InitLog
()
!=
0
)
{
if
(
d
m
InitLog
()
!=
0
)
{
printf
(
"failed to start since init log error
\n
"
);
return
-
1
;
}
...
...
@@ -201,12 +201,12 @@ int main(int argc, char const *argv[]) {
}
if
(
global
.
dumpConfig
)
{
d
nd
DumpCfg
();
d
m
DumpCfg
();
taosCleanupCfg
();
taosCloseLog
();
return
0
;
}
d
nd
SetProcInfo
(
argc
,
(
char
**
)
argv
);
return
d
nd
RunDnode
();
d
m
SetProcInfo
(
argc
,
(
char
**
)
argv
);
return
d
m
RunDnode
();
}
source/dnode/mgmt/implement/inc/dmImp.h
浏览文件 @
318d774b
...
...
@@ -22,48 +22,32 @@
extern
"C"
{
#endif
int32_t
d
nd
OpenNode
(
SMgmtWrapper
*
pWrapper
);
void
d
nd
CloseNode
(
SMgmtWrapper
*
pWrapper
);
int32_t
d
m
OpenNode
(
SMgmtWrapper
*
pWrapper
);
void
d
m
CloseNode
(
SMgmtWrapper
*
pWrapper
);
// d
nd
Transport.c
// d
m
Transport.c
int32_t
dmInitTrans
(
SDnode
*
pDnode
);
void
dndCleanupTrans
(
SDnode
*
pDnode
);
SProcCfg
dndGenProcCfg
(
SMgmtWrapper
*
pWrapper
);
int32_t
dndInitMsgHandle
(
SDnode
*
pDnode
);
int32_t
dndSendMsgToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
);
void
dndSendRecv
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
void
dmCleanupTrans
(
SDnode
*
pDnode
);
SProcCfg
dmGenProcCfg
(
SMgmtWrapper
*
pWrapper
);
int32_t
dmInitMsgHandle
(
SDnode
*
pDnode
);
void
dmSendRecv
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
void
dmSendToMnodeRecv
(
SDnode
*
pDnode
,
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
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
);
// dmFile.c
int32_t
dmReadFile
(
SDnodeData
*
pMgmt
);
int32_t
dmWriteFile
(
SDnodeData
*
pMgmt
);
void
dmUpdateDnodeEps
(
SDnodeData
*
pMgmt
,
SArray
*
pDnodeEps
);
// dmEps.c
int32_t
dmReadEps
(
SDnode
*
pDnode
);
int32_t
dmWriteEps
(
SDnode
*
pDnode
);
void
dmUpdateEps
(
SDnode
*
pDnode
,
SArray
*
pDnodeEps
);
// dmHandle.c
void
dmSendStatusReq
(
SDnode
*
pDnode
);
int32_t
dmProcessConfigReq
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessStatusRsp
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessAuthRsp
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessGrantRsp
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessCDnodeReq
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessCreateNodeReq
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessDropNodeReq
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
);
// dmMonitor.c
void
dmGetVnodeLoads
(
S
MgmtWrapper
*
pWrapper
,
SMonVloadInfo
*
pInfo
);
void
dmGetVnodeLoads
(
S
Dnode
*
pDnode
,
SMonVloadInfo
*
pInfo
);
void
dmSendMonitorReport
(
SDnode
*
pDnode
);
// dmWorker.c
...
...
@@ -71,12 +55,26 @@ int32_t dmStartStatusThread(SDnode *pDnode);
void
dmStopStatusThread
(
SDnode
*
pDnode
);
int32_t
dmStartMonitorThread
(
SDnode
*
pDnode
);
void
dmStopMonitorThread
(
SDnode
*
pDnode
);
int32_t
dmStartWorker
(
SDnode
*
pDnode
);
void
dmStopWorker
(
SDnode
*
pDnode
);
int32_t
dmProcessMgmtMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
dmProcessStatusMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
// mgmt nodes
void
dmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
void
bmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
void
qmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
void
smSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
void
vmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
void
mmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
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
...
...
source/dnode/mgmt/implement/src/dmEps.c
浏览文件 @
318d774b
...
...
@@ -16,15 +16,14 @@
#define _DEFAULT_SOURCE
#include "dmImp.h"
static
void
dmPrint
Dnodes
(
SDnodeData
*
pMgmt
);
static
bool
dmIsEpChanged
(
SDnode
Data
*
pMgmt
,
int32_t
dnodeId
,
const
char
*
ep
);
static
void
dmReset
Dnodes
(
SDnodeData
*
pMgmt
,
SArray
*
dnodeEps
);
static
void
dmPrint
Eps
(
SDnode
*
pDnode
);
static
bool
dmIsEpChanged
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
const
char
*
ep
);
static
void
dmReset
Eps
(
SDnode
*
pDnode
,
SArray
*
dnodeEps
);
void
dmGetDnodeEp
(
SMgmtWrapper
*
pWrapper
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
SDnodeData
*
pMgmt
=
pWrapper
->
pMgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
static
void
dmGetDnodeEp
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
taosRLockLatch
(
&
pDnode
->
data
.
latch
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Mgmt
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Dnode
->
data
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
if
(
pPort
!=
NULL
)
{
*
pPort
=
pDnodeEp
->
ep
.
port
;
...
...
@@ -37,10 +36,10 @@ void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqd
}
}
taosRUnLockLatch
(
&
p
Mgmt
->
latch
);
taosRUnLockLatch
(
&
p
Dnode
->
data
.
latch
);
}
int32_t
dmRead
File
(
SDnodeData
*
pMgmt
)
{
int32_t
dmRead
Eps
(
SDnode
*
pDnode
)
{
int32_t
code
=
TSDB_CODE_INVALID_JSON_FORMAT
;
int32_t
len
=
0
;
int32_t
maxLen
=
256
*
1024
;
...
...
@@ -48,15 +47,14 @@ int32_t dmReadFile(SDnodeData *pMgmt) {
cJSON
*
root
=
NULL
;
char
file
[
PATH_MAX
];
TdFilePtr
pFile
=
NULL
;
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
p
Mgmt
->
dnodeEps
=
taosArrayInit
(
1
,
sizeof
(
SDnodeEp
));
if
(
p
Mgmt
->
dnodeEps
==
NULL
)
{
p
Dnode
->
data
.
dnodeEps
=
taosArrayInit
(
1
,
sizeof
(
SDnodeEp
));
if
(
p
Dnode
->
data
.
dnodeEps
==
NULL
)
{
dError
(
"failed to calloc dnodeEp array since %s"
,
strerror
(
errno
));
goto
PRASE_DNODE_OVER
;
}
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json"
,
p
Mgmt
->
path
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json"
,
p
Dnode
->
data
.
path
,
TD_DIRSEP
);
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
if
(
pFile
==
NULL
)
{
dDebug
(
"file %s not exist"
,
file
);
...
...
@@ -146,41 +144,39 @@ int32_t dmReadFile(SDnodeData *pMgmt) {
}
dnodeEp
.
isMnode
=
isMnode
->
valueint
;
taosArrayPush
(
p
Mgmt
->
dnodeEps
,
&
dnodeEp
);
taosArrayPush
(
p
Dnode
->
data
.
dnodeEps
,
&
dnodeEp
);
}
code
=
0
;
dDebug
(
"succcessed to read file %s"
,
file
);
dmPrint
Dnodes
(
pMgmt
);
dmPrint
Eps
(
pDnode
);
PRASE_DNODE_OVER:
if
(
content
!=
NULL
)
taosMemoryFree
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
if
(
dmIsEpChanged
(
p
Mgmt
,
pDnode
->
data
.
dnodeId
,
pDnode
->
data
.
localEp
))
{
if
(
dmIsEpChanged
(
p
Dnode
,
pDnode
->
data
.
dnodeId
,
pDnode
->
data
.
localEp
))
{
dError
(
"localEp %s different with %s and need reconfigured"
,
pDnode
->
data
.
localEp
,
file
);
return
-
1
;
}
if
(
taosArrayGetSize
(
p
Mgmt
->
dnodeEps
)
==
0
)
{
if
(
taosArrayGetSize
(
p
Dnode
->
data
.
dnodeEps
)
==
0
)
{
SDnodeEp
dnodeEp
=
{
0
};
dnodeEp
.
isMnode
=
1
;
taosGetFqdnPortFromEp
(
pDnode
->
data
.
firstEp
,
&
dnodeEp
.
ep
);
taosArrayPush
(
p
Mgmt
->
dnodeEps
,
&
dnodeEp
);
taosArrayPush
(
p
Dnode
->
data
.
dnodeEps
,
&
dnodeEp
);
}
dmReset
Dnodes
(
pMgmt
,
pMgmt
->
dnodeEps
);
dmReset
Eps
(
pDnode
,
pDnode
->
data
.
dnodeEps
);
terrno
=
code
;
return
code
;
}
int32_t
dmWriteFile
(
SDnodeData
*
pMgmt
)
{
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
int32_t
dmWriteEps
(
SDnode
*
pDnode
)
{
char
file
[
PATH_MAX
];
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json.bak"
,
p
Mgmt
->
path
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json.bak"
,
p
Dnode
->
data
.
path
,
TD_DIRSEP
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
...
...
@@ -199,9 +195,9 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dropped
\"
: %d,
\n
"
,
pDnode
->
data
.
dropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodes
\"
: [{
\n
"
);
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
p
Mgmt
->
dnodeEps
);
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
p
Dnode
->
data
.
dnodeEps
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
++
i
)
{
SDnodeEp
*
pDnodeEp
=
taosArrayGet
(
p
Mgmt
->
dnodeEps
,
i
);
SDnodeEp
*
pDnodeEp
=
taosArrayGet
(
p
Dnode
->
data
.
dnodeEps
,
i
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pDnodeEp
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pDnodeEp
->
ep
.
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u,
\n
"
,
pDnodeEp
->
ep
.
port
);
...
...
@@ -220,7 +216,7 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
taosMemoryFree
(
content
);
char
realfile
[
PATH_MAX
];
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode.json"
,
p
Mgmt
->
path
,
TD_DIRSEP
);
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode.json"
,
p
Dnode
->
data
.
path
,
TD_DIRSEP
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -228,41 +224,41 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
return
-
1
;
}
p
Mgmt
->
updateTime
=
taosGetTimestampMs
();
p
Dnode
->
data
.
updateTime
=
taosGetTimestampMs
();
dDebug
(
"successed to write %s"
,
realfile
);
return
0
;
}
void
dmUpdate
DnodeEps
(
SDnodeData
*
pMgmt
,
SArray
*
dnodeE
ps
)
{
int32_t
numOfEps
=
taosArrayGetSize
(
dnodeE
ps
);
void
dmUpdate
Eps
(
SDnode
*
pDnode
,
SArray
*
e
ps
)
{
int32_t
numOfEps
=
taosArrayGetSize
(
e
ps
);
if
(
numOfEps
<=
0
)
return
;
taosWLockLatch
(
&
p
Mgmt
->
latch
);
taosWLockLatch
(
&
p
Dnode
->
data
.
latch
);
int32_t
numOfEpsOld
=
(
int32_t
)
taosArrayGetSize
(
p
Mgmt
->
dnodeEps
);
int32_t
numOfEpsOld
=
(
int32_t
)
taosArrayGetSize
(
p
Dnode
->
data
.
dnodeEps
);
if
(
numOfEps
!=
numOfEpsOld
)
{
dmReset
Dnodes
(
pMgmt
,
dnodeE
ps
);
dmWrite
File
(
pMgmt
);
dmReset
Eps
(
pDnode
,
e
ps
);
dmWrite
Eps
(
pDnode
);
}
else
{
int32_t
size
=
numOfEps
*
sizeof
(
SDnodeEp
);
if
(
memcmp
(
p
Mgmt
->
dnodeEps
->
pData
,
dnodeE
ps
->
pData
,
size
)
!=
0
)
{
dmReset
Dnodes
(
pMgmt
,
dnodeE
ps
);
dmWrite
File
(
pMgmt
);
if
(
memcmp
(
p
Dnode
->
data
.
dnodeEps
->
pData
,
e
ps
->
pData
,
size
)
!=
0
)
{
dmReset
Eps
(
pDnode
,
e
ps
);
dmWrite
Eps
(
pDnode
);
}
}
taosWUnLockLatch
(
&
p
Mgmt
->
latch
);
taosWUnLockLatch
(
&
p
Dnode
->
data
.
latch
);
}
static
void
dmReset
Dnodes
(
SDnodeData
*
pMgmt
,
SArray
*
dnodeEps
)
{
if
(
p
Mgmt
->
dnodeEps
!=
dnodeEps
)
{
SArray
*
tmp
=
p
Mgmt
->
dnodeEps
;
p
Mgmt
->
dnodeEps
=
taosArrayDup
(
dnodeEps
);
static
void
dmReset
Eps
(
SDnode
*
pDnode
,
SArray
*
dnodeEps
)
{
if
(
p
Dnode
->
data
.
dnodeEps
!=
dnodeEps
)
{
SArray
*
tmp
=
p
Dnode
->
data
.
dnodeEps
;
p
Dnode
->
data
.
dnodeEps
=
taosArrayDup
(
dnodeEps
);
taosArrayDestroy
(
tmp
);
}
p
Mgmt
->
mnodeEpSet
.
inUse
=
0
;
p
Mgmt
->
mnodeEpSet
.
numOfEps
=
0
;
p
Dnode
->
data
.
mnodeEps
.
inUse
=
0
;
p
Dnode
->
data
.
mnodeEps
.
numOfEps
=
0
;
int32_t
mIndex
=
0
;
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
dnodeEps
);
...
...
@@ -271,40 +267,40 @@ static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps) {
SDnodeEp
*
pDnodeEp
=
taosArrayGet
(
dnodeEps
,
i
);
if
(
!
pDnodeEp
->
isMnode
)
continue
;
if
(
mIndex
>=
TSDB_MAX_REPLICA
)
continue
;
p
Mgmt
->
mnodeEpSet
.
numOfEps
++
;
p
Dnode
->
data
.
mnodeEps
.
numOfEps
++
;
p
Mgmt
->
mnodeEpSet
.
eps
[
mIndex
]
=
pDnodeEp
->
ep
;
p
Dnode
->
data
.
mnodeEps
.
eps
[
mIndex
]
=
pDnodeEp
->
ep
;
mIndex
++
;
}
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
i
++
)
{
SDnodeEp
*
pDnodeEp
=
taosArrayGet
(
dnodeEps
,
i
);
taosHashPut
(
p
Mgmt
->
dnodeHash
,
&
pDnodeEp
->
id
,
sizeof
(
int32_t
),
pDnodeEp
,
sizeof
(
SDnodeEp
));
taosHashPut
(
p
Dnode
->
data
.
dnodeHash
,
&
pDnodeEp
->
id
,
sizeof
(
int32_t
),
pDnodeEp
,
sizeof
(
SDnodeEp
));
}
dmPrint
Dnodes
(
pMgmt
);
dmPrint
Eps
(
pDnode
);
}
static
void
dmPrint
Dnodes
(
SDnodeData
*
pMgmt
)
{
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
p
Mgmt
->
dnodeEps
);
static
void
dmPrint
Eps
(
SDnode
*
pDnode
)
{
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
p
Dnode
->
data
.
dnodeEps
);
dDebug
(
"print dnode ep list, num:%d"
,
numOfEps
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
i
++
)
{
SDnodeEp
*
pEp
=
taosArrayGet
(
p
Mgmt
->
dnodeEps
,
i
);
SDnodeEp
*
pEp
=
taosArrayGet
(
p
Dnode
->
data
.
dnodeEps
,
i
);
dDebug
(
"dnode:%d, fqdn:%s port:%u isMnode:%d"
,
pEp
->
id
,
pEp
->
ep
.
fqdn
,
pEp
->
ep
.
port
,
pEp
->
isMnode
);
}
}
static
bool
dmIsEpChanged
(
SDnode
Data
*
pMgmt
,
int32_t
dnodeId
,
const
char
*
ep
)
{
static
bool
dmIsEpChanged
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
const
char
*
ep
)
{
bool
changed
=
false
;
taosRLockLatch
(
&
p
Mgmt
->
latch
);
taosRLockLatch
(
&
p
Dnode
->
data
.
latch
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Mgmt
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Dnode
->
data
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
char
epstr
[
TSDB_EP_LEN
+
1
];
snprintf
(
epstr
,
TSDB_EP_LEN
,
"%s:%u"
,
pDnodeEp
->
ep
.
fqdn
,
pDnodeEp
->
ep
.
port
);
changed
=
strcmp
(
ep
,
epstr
)
!=
0
;
}
taosRUnLockLatch
(
&
p
Mgmt
->
latch
);
taosRUnLockLatch
(
&
p
Dnode
->
data
.
latch
);
return
changed
;
}
source/dnode/mgmt/implement/src/dmExec.c
浏览文件 @
318d774b
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmImp.h"
static
bool
d
nd
RequireNode
(
SMgmtWrapper
*
pWrapper
)
{
static
bool
d
m
RequireNode
(
SMgmtWrapper
*
pWrapper
)
{
bool
required
=
false
;
int32_t
code
=
(
*
pWrapper
->
fp
.
requiredFp
)(
pWrapper
,
&
required
);
if
(
!
required
)
{
...
...
@@ -27,7 +27,7 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) {
return
required
;
}
static
int32_t
d
nd
InitNodeProc
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
d
m
InitNodeProc
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
shmsize
=
tsMnodeShmSize
;
if
(
pWrapper
->
ntype
==
VNODE
)
{
shmsize
=
tsVnodeShmSize
;
...
...
@@ -50,7 +50,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
}
dInfo
(
"node:%s, shm:%d is created, size:%d"
,
pWrapper
->
name
,
pWrapper
->
procShm
.
id
,
shmsize
);
SProcCfg
cfg
=
d
nd
GenProcCfg
(
pWrapper
);
SProcCfg
cfg
=
d
m
GenProcCfg
(
pWrapper
);
cfg
.
isChild
=
false
;
pWrapper
->
procType
=
DND_PROC_PARENT
;
pWrapper
->
procObj
=
taosProcInit
(
&
cfg
);
...
...
@@ -62,7 +62,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
return
0
;
}
static
int32_t
d
nd
NewNodeProc
(
SMgmtWrapper
*
pWrapper
,
EDndNodeType
n
)
{
static
int32_t
d
m
NewNodeProc
(
SMgmtWrapper
*
pWrapper
,
EDndNodeType
n
)
{
char
tstr
[
8
]
=
{
0
};
char
*
args
[
6
]
=
{
0
};
snprintf
(
tstr
,
sizeof
(
tstr
),
"%d"
,
n
);
...
...
@@ -84,11 +84,11 @@ static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) {
return
0
;
}
static
int32_t
d
nd
RunNodeProc
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
d
m
RunNodeProc
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
->
pDnode
->
ntype
==
NODE_END
)
{
dInfo
(
"node:%s, should be started manually"
,
pWrapper
->
name
);
}
else
{
if
(
d
nd
NewNodeProc
(
pWrapper
,
pWrapper
->
ntype
)
!=
0
)
{
if
(
d
m
NewNodeProc
(
pWrapper
,
pWrapper
->
ntype
)
!=
0
)
{
return
-
1
;
}
}
...
...
@@ -101,7 +101,7 @@ static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) {
return
0
;
}
static
int32_t
d
nd
OpenNodeImp
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
d
m
OpenNodeImp
(
SMgmtWrapper
*
pWrapper
)
{
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"node:%s, failed to create dir:%s since %s"
,
pWrapper
->
name
,
pWrapper
->
path
,
terrstr
());
...
...
@@ -118,19 +118,19 @@ static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) {
return
0
;
}
int32_t
d
nd
OpenNode
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
d
m
OpenNode
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
if
(
pDnode
->
ptype
==
DND_PROC_SINGLE
)
{
return
d
nd
OpenNodeImp
(
pWrapper
);
return
d
m
OpenNodeImp
(
pWrapper
);
}
else
if
(
pDnode
->
ptype
==
DND_PROC_PARENT
)
{
if
(
d
nd
InitNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
if
(
d
nd
WriteShmFile
(
pDnode
)
!=
0
)
return
-
1
;
if
(
d
nd
RunNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
if
(
d
m
InitNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
if
(
d
m
WriteShmFile
(
pDnode
)
!=
0
)
return
-
1
;
if
(
d
m
RunNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
}
return
0
;
}
static
void
d
nd
CloseNodeImp
(
SMgmtWrapper
*
pWrapper
)
{
static
void
d
m
CloseNodeImp
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"node:%s, mgmt start to close"
,
pWrapper
->
name
);
pWrapper
->
required
=
false
;
taosWLockLatch
(
&
pWrapper
->
latch
);
...
...
@@ -151,7 +151,7 @@ static void dndCloseNodeImp(SMgmtWrapper *pWrapper) {
dDebug
(
"node:%s, mgmt has been closed"
,
pWrapper
->
name
);
}
void
d
nd
CloseNode
(
SMgmtWrapper
*
pWrapper
)
{
void
d
m
CloseNode
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
->
pDnode
->
ptype
==
DND_PROC_PARENT
)
{
if
(
pWrapper
->
procId
>
0
&&
taosProcExist
(
pWrapper
->
procId
))
{
dInfo
(
"node:%s, send kill signal to the child process:%d"
,
pWrapper
->
name
,
pWrapper
->
procId
);
...
...
@@ -161,31 +161,31 @@ void dndCloseNode(SMgmtWrapper *pWrapper) {
dInfo
(
"node:%s, child process:%d is stopped"
,
pWrapper
->
name
,
pWrapper
->
procId
);
}
}
d
nd
CloseNodeImp
(
pWrapper
);
d
m
CloseNodeImp
(
pWrapper
);
}
static
void
d
nd
ProcessProcHandle
(
void
*
handle
)
{
static
void
d
m
ProcessProcHandle
(
void
*
handle
)
{
dWarn
(
"handle:%p, the child process dies and send an offline rsp"
,
handle
);
SRpcMsg
rpcMsg
=
{.
handle
=
handle
,
.
code
=
TSDB_CODE_NODE_OFFLINE
};
rpcSendResponse
(
&
rpcMsg
);
}
static
int32_t
d
nd
RunInSingleProcess
(
SDnode
*
pDnode
)
{
static
int32_t
d
m
RunInSingleProcess
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode run in single process"
);
pDnode
->
ptype
=
DND_PROC_SINGLE
;
for
(
EDndNodeType
n
=
NODE_BEGIN
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
pWrapper
->
required
=
d
nd
RequireNode
(
pWrapper
);
pWrapper
->
required
=
d
m
RequireNode
(
pWrapper
);
if
(
!
pWrapper
->
required
)
continue
;
if
(
d
nd
OpenNodeImp
(
pWrapper
)
!=
0
)
{
if
(
d
m
OpenNodeImp
(
pWrapper
)
!=
0
)
{
dError
(
"node:%s, failed to start since %s"
,
pWrapper
->
name
,
terrstr
());
return
-
1
;
}
}
d
nd
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
d
m
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
for
(
EDndNodeType
n
=
0
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
...
...
@@ -198,11 +198,11 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
}
dInfo
(
"TDengine initialized successfully"
);
d
nd
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
d
m
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
while
(
1
)
{
if
(
pDnode
->
event
==
DND_EVENT_STOP
)
{
dInfo
(
"dnode is about to stop"
);
d
nd
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
d
m
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
break
;
}
taosMsleep
(
100
);
...
...
@@ -211,24 +211,24 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
return
0
;
}
static
int32_t
d
nd
RunInParentProcess
(
SDnode
*
pDnode
)
{
static
int32_t
d
m
RunInParentProcess
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode run in parent process"
);
pDnode
->
ptype
=
DND_PROC_PARENT
;
SMgmtWrapper
*
pDWrapper
=
&
pDnode
->
wrappers
[
NODE_BEGIN
];
if
(
d
nd
OpenNodeImp
(
pDWrapper
)
!=
0
)
{
if
(
d
m
OpenNodeImp
(
pDWrapper
)
!=
0
)
{
dError
(
"node:%s, failed to start since %s"
,
pDWrapper
->
name
,
terrstr
());
return
-
1
;
}
for
(
EDndNodeType
n
=
NODE_BEGIN
+
1
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
pWrapper
->
required
=
d
nd
RequireNode
(
pWrapper
);
pWrapper
->
required
=
d
m
RequireNode
(
pWrapper
);
if
(
!
pWrapper
->
required
)
continue
;
if
(
d
nd
InitNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
if
(
d
m
InitNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
}
if
(
d
nd
WriteShmFile
(
pDnode
)
!=
0
)
{
if
(
d
m
WriteShmFile
(
pDnode
)
!=
0
)
{
dError
(
"failed to write runtime file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -236,10 +236,10 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
for
(
EDndNodeType
n
=
NODE_BEGIN
+
1
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
if
(
!
pWrapper
->
required
)
continue
;
if
(
d
nd
RunNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
if
(
d
m
RunNodeProc
(
pWrapper
)
!=
0
)
return
-
1
;
}
d
nd
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
d
m
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
if
((
*
pDWrapper
->
fp
.
startFp
)(
pDWrapper
)
!=
0
)
{
dError
(
"node:%s, failed to start since %s"
,
pDWrapper
->
name
,
terrstr
());
...
...
@@ -247,12 +247,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
}
dInfo
(
"TDengine initialized successfully"
);
d
nd
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
d
m
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
while
(
1
)
{
if
(
pDnode
->
event
==
DND_EVENT_STOP
)
{
dInfo
(
"dnode is about to stop"
);
d
nd
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
d
m
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
for
(
EDndNodeType
n
=
NODE_BEGIN
+
1
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
...
...
@@ -276,8 +276,8 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
if
(
pWrapper
->
procId
<=
0
||
!
taosProcExist
(
pWrapper
->
procId
))
{
dWarn
(
"node:%s, process:%d is killed and needs to be restarted"
,
pWrapper
->
name
,
pWrapper
->
procId
);
taosProcCloseHandles
(
pWrapper
->
procObj
,
d
nd
ProcessProcHandle
);
d
nd
NewNodeProc
(
pWrapper
,
n
);
taosProcCloseHandles
(
pWrapper
->
procObj
,
d
m
ProcessProcHandle
);
d
m
NewNodeProc
(
pWrapper
,
n
);
}
}
}
...
...
@@ -288,12 +288,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
return
0
;
}
static
int32_t
d
nd
RunInChildProcess
(
SDnode
*
pDnode
)
{
static
int32_t
d
m
RunInChildProcess
(
SDnode
*
pDnode
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
pDnode
->
ntype
];
dInfo
(
"%s run in child process"
,
pWrapper
->
name
);
pDnode
->
ptype
=
DND_PROC_CHILD
;
pWrapper
->
required
=
d
nd
RequireNode
(
pWrapper
);
pWrapper
->
required
=
d
m
RequireNode
(
pWrapper
);
if
(
!
pWrapper
->
required
)
{
dError
(
"%s does not require startup"
,
pWrapper
->
name
);
return
-
1
;
...
...
@@ -303,12 +303,12 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
tmsgSetDefaultMsgCb
(
&
msgCb
);
pWrapper
->
procType
=
DND_PROC_CHILD
;
if
(
d
nd
OpenNodeImp
(
pWrapper
)
!=
0
)
{
if
(
d
m
OpenNodeImp
(
pWrapper
)
!=
0
)
{
dError
(
"node:%s, failed to start since %s"
,
pWrapper
->
name
,
terrstr
());
return
-
1
;
}
SProcCfg
cfg
=
d
nd
GenProcCfg
(
pWrapper
);
SProcCfg
cfg
=
d
m
GenProcCfg
(
pWrapper
);
cfg
.
isChild
=
true
;
pWrapper
->
procObj
=
taosProcInit
(
&
cfg
);
if
(
pWrapper
->
procObj
==
NULL
)
{
...
...
@@ -323,7 +323,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
}
}
d
nd
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
d
m
SetStatus
(
pDnode
,
DND_STAT_RUNNING
);
if
(
taosProcRun
(
pWrapper
->
procObj
)
!=
0
)
{
dError
(
"node:%s, failed to run proc since %s"
,
pWrapper
->
name
,
terrstr
());
...
...
@@ -331,11 +331,11 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
}
dInfo
(
"TDengine initialized successfully"
);
d
nd
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
d
m
ReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
while
(
1
)
{
if
(
pDnode
->
event
==
DND_EVENT_STOP
)
{
dInfo
(
"%s is about to stop"
,
pWrapper
->
name
);
d
nd
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
d
m
SetStatus
(
pDnode
,
DND_STAT_STOPPED
);
break
;
}
taosMsleep
(
100
);
...
...
@@ -344,13 +344,13 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
return
0
;
}
int32_t
d
nd
Run
(
SDnode
*
pDnode
)
{
int32_t
d
m
Run
(
SDnode
*
pDnode
)
{
if
(
!
tsMultiProcess
)
{
return
d
nd
RunInSingleProcess
(
pDnode
);
return
d
m
RunInSingleProcess
(
pDnode
);
}
else
if
(
pDnode
->
ntype
==
NODE_BEGIN
||
pDnode
->
ntype
==
NODE_END
)
{
return
d
nd
RunInParentProcess
(
pDnode
);
return
d
m
RunInParentProcess
(
pDnode
);
}
else
{
return
d
nd
RunInChildProcess
(
pDnode
);
return
d
m
RunInChildProcess
(
pDnode
);
}
return
0
;
...
...
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
318d774b
...
...
@@ -16,22 +16,31 @@
#define _DEFAULT_SOURCE
#include "dmImp.h"
static
int32_t
dmProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pRsp
)
{
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
static
void
dmUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
if
(
pDnode
->
data
.
dnodeId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
pDnode
->
data
.
dnodeId
=
pCfg
->
dnodeId
;
pDnode
->
data
.
clusterId
=
pCfg
->
clusterId
;
dmWriteEps
(
pDnode
);
taosWUnLockLatch
(
&
pDnode
->
data
.
latch
);
}
}
static
int32_t
dmProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRsp
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pDnode
->
data
.
dropped
&&
pDnode
->
data
.
dnodeId
>
0
)
{
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pDnode
->
data
.
dnodeId
);
pDnode
->
data
.
dropped
=
1
;
dmWrite
File
(
pMgmt
);
dmWrite
Eps
(
pDnode
);
}
}
else
{
SStatusRsp
statusRsp
=
{
0
};
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
!=
0
&&
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
>
0
&&
tDeserializeSStatusRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
statusRsp
)
==
0
)
{
p
Mgmt
->
dnodeVer
=
statusRsp
.
dnodeVer
;
dmUpdateDnodeCfg
(
p
Mgmt
,
&
statusRsp
.
dnodeCfg
);
dmUpdate
DnodeEps
(
pMgmt
,
statusRsp
.
pDnodeEps
);
p
Dnode
->
data
.
dnodeVer
=
statusRsp
.
dnodeVer
;
dmUpdateDnodeCfg
(
p
Dnode
,
&
statusRsp
.
dnodeCfg
);
dmUpdate
Eps
(
pDnode
,
statusRsp
.
pDnodeEps
);
}
tFreeSStatusRsp
(
&
statusRsp
);
}
...
...
@@ -44,11 +53,11 @@ void dmSendStatusReq(SDnode *pDnode) {
taosRLockLatch
(
&
pDnode
->
data
.
latch
);
req
.
sver
=
tsVersion
;
req
.
dnodeVer
=
p
Mgmt
->
dnodeVer
;
req
.
dnodeVer
=
p
Dnode
->
data
.
dnodeVer
;
req
.
dnodeId
=
pDnode
->
data
.
dnodeId
;
req
.
clusterId
=
pDnode
->
data
.
clusterId
;
req
.
rebootTime
=
pDnode
->
data
.
rebootTime
;
req
.
updateTime
=
p
Mgmt
->
updateTime
;
req
.
updateTime
=
p
Dnode
->
data
.
updateTime
;
req
.
numOfCores
=
tsNumOfCores
;
req
.
numOfSupportVnodes
=
pDnode
->
data
.
supportVnodes
;
tstrncpy
(
req
.
dnodeEp
,
pDnode
->
data
.
localEp
,
TSDB_EP_LEN
);
...
...
@@ -62,68 +71,52 @@ void dmSendStatusReq(SDnode *pDnode) {
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
taosRUnLockLatch
(
&
pDnode
->
data
.
latch
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
VNODE
);
if
(
pWrapper
!=
NULL
)
{
SMonVloadInfo
info
=
{
0
};
dmGetVnodeLoads
(
pWrapper
,
&
info
);
req
.
pVloads
=
info
.
pVloads
;
dndReleaseWrapper
(
pWrapper
);
}
SMonVloadInfo
info
=
{
0
};
dmGetVnodeLoads
(
pDnode
,
&
info
);
req
.
pVloads
=
info
.
pVloads
;
int32_t
contLen
=
tSerializeSStatusReq
(
NULL
,
0
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
tSerializeSStatusReq
(
pHead
,
contLen
,
&
req
);
t
aosArrayDestroy
(
req
.
pVloads
);
t
FreeSStatusReq
(
&
req
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pHead
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
ahandle
=
(
void
*
)
0x9527
};
SRpcMsg
r
spMsg
=
{
0
};
SRpcMsg
r
pcRsp
=
{
0
};
dTrace
(
"send req:%s to mnode, app:%p"
,
TMSG_INFO
(
rpcMsg
.
msgType
),
rpcMsg
.
ahandle
);
dmSendToMnodeRecv
(
pDnode
,
rpcMsg
,
&
rpcRsp
);
dmSendToMnodeRecv
(
pDnode
,
&
rpcMsg
,
&
rpcRsp
);
dmProcessStatusRsp
(
pDnode
,
&
rpcRsp
);
}
static
void
dmUpdateDnodeCfg
(
SDnodeData
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
if
(
pDnode
->
data
.
dnodeId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
pDnode
->
data
.
dnodeId
=
pCfg
->
dnodeId
;
pDnode
->
data
.
clusterId
=
pCfg
->
clusterId
;
dmWriteFile
(
pMgmt
);
taosWUnLockLatch
(
&
pDnode
->
data
.
latch
);
}
}
int32_t
dmProcessAuthRsp
(
SDnodeData
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
int32_t
dmProcessAuthRsp
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
SRpcMsg
*
pRsp
=
&
pMsg
->
rpcMsg
;
dError
(
"auth rsp is received, but not supported yet"
);
return
0
;
}
int32_t
dmProcessGrantRsp
(
SDnode
Data
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
int32_t
dmProcessGrantRsp
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
SRpcMsg
*
pRsp
=
&
pMsg
->
rpcMsg
;
dError
(
"grant rsp is received, but not supported yet"
);
return
0
;
}
int32_t
dmProcessConfigReq
(
SDnode
Data
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
int32_t
dmProcessConfigReq
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
SRpcMsg
*
pReq
=
&
pMsg
->
rpcMsg
;
SDCfgDnodeReq
*
pCfg
=
pReq
->
pCont
;
dError
(
"config req is received, but not supported yet"
);
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
static
int32_t
dmProcessCreateNodeMsg
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
d
nd
AcquireWrapper
(
pDnode
,
ntype
);
int32_t
dmProcessCreateNodeReq
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
d
m
AcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
!=
NULL
)
{
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
dError
(
"failed to create node since %s"
,
terrstr
());
return
-
1
;
}
taosWLockLatch
(
&
pDnode
->
wrapperLock
);
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
...
...
@@ -134,17 +127,20 @@ static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeM
int32_t
code
=
(
*
pWrapper
->
fp
.
createFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
dError
(
"node:%s, failed to
open
since %s"
,
pWrapper
->
name
,
terrstr
());
dError
(
"node:%s, failed to
create
since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
dDebug
(
"node:%s, has been opened"
,
pWrapper
->
name
);
dDebug
(
"node:%s, has been created"
,
pWrapper
->
name
);
pWrapper
->
required
=
true
;
pWrapper
->
deployed
=
true
;
(
void
)
dmOpenNode
(
pWrapper
);
}
taosWUnLockLatch
(
&
pDnode
->
wrapperLock
);
return
code
;
}
static
int32_t
dmProcessDropNodeMsg
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
d
nd
AcquireWrapper
(
pDnode
,
ntype
);
int32_t
dmProcessDropNodeReq
(
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
d
m
AcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
==
NULL
)
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
dError
(
"failed to drop node since %s"
,
terrstr
());
...
...
@@ -152,68 +148,57 @@ static int32_t dmProcessDropNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg
}
taosWLockLatch
(
&
pWrapper
->
latch
);
pWrapper
->
deployed
=
false
;
int32_t
code
=
(
*
pWrapper
->
fp
.
dropFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
pWrapper
->
deployed
=
true
;
dError
(
"node:%s, failed to drop since %s"
,
pWrapper
->
name
,
terrstr
());
pWrapper
->
required
=
true
;
pWrapper
->
deployed
=
true
;
}
else
{
pWrapper
->
deployed
=
false
;
dDebug
(
"node:%s, has been dropped"
,
pWrapper
->
name
);
pWrapper
->
required
=
false
;
pWrapper
->
deployed
=
false
;
dmCloseNode
(
pWrapper
);
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
dndReleaseWrapper
(
pWrapper
);
return
code
;
}
int32_t
dmProcessCDnodeReq
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
switch
(
pMsg
->
rpcMsg
.
msgType
)
{
case
TDMT_DND_CREATE_MNODE
:
return
dmProcessCreateNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_DROP_MNODE
:
return
dmProcessDropNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_CREATE_QNODE
:
return
dmProcessCreateNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_DROP_QNODE
:
return
dmProcessDropNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_CREATE_SNODE
:
return
dmProcessCreateNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_DROP_SNODE
:
return
dmProcessDropNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_CREATE_BNODE
:
return
dmProcessCreateNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
case
TDMT_DND_DROP_BNODE
:
return
dmProcessDropNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
return
-
1
;
}
dmReleaseWrapper
(
pWrapper
);
return
0
;
}
static
void
dmSetMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
static
void
dmSetM
gmtM
sgHandle
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
// Requests handled by MNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
dmProcessMgmtMsg
,
DEFAULT_HANDLE
);
}
static
int32_t
dmStart
(
SMgmtWrapper
*
pWrapper
)
{
return
dmStartStatusThread
(
pWrapper
->
pDnode
);
}
static
int32_t
dmStartMgmt
(
SMgmtWrapper
*
pWrapper
)
{
if
(
dmStartStatusThread
(
pWrapper
->
pDnode
)
!=
0
)
{
return
-
1
;
}
if
(
dmStartMonitorThread
(
pWrapper
->
pDnode
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
void
dmStop
(
SMgmtWrapper
*
pWrapper
)
{
dmStopThread
(
pWrapper
->
pDnode
);
}
static
void
dmStopMgmt
(
SMgmtWrapper
*
pWrapper
)
{
dmStopMonitorThread
(
pWrapper
->
pDnode
);
dmStopStatusThread
(
pWrapper
->
pDnode
);
}
static
int32_t
dmInit
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
dmInit
Mgmt
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"dnode-data start to init"
);
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
...
...
@@ -224,7 +209,7 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) {
return
-
1
;
}
if
(
dmRead
File
(
pDnode
)
!=
0
)
{
if
(
dmRead
Eps
(
pDnode
)
!=
0
)
{
dError
(
"failed to read file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -247,40 +232,40 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) {
return
0
;
}
static
void
dmCleanup
(
SMgmtWrapper
*
pWrapper
)
{
static
void
dmCleanup
Mgmt
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"dnode-data start to clean up"
);
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
dmStopWorker
(
pDnode
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
if
(
p
Mgmt
->
dnodeEps
!=
NULL
)
{
taosArrayDestroy
(
p
Mgmt
->
dnodeEps
);
p
Mgmt
->
dnodeEps
=
NULL
;
if
(
p
Dnode
->
data
.
dnodeEps
!=
NULL
)
{
taosArrayDestroy
(
p
Dnode
->
data
.
dnodeEps
);
p
Dnode
->
data
.
dnodeEps
=
NULL
;
}
if
(
p
Mgmt
->
dnodeHash
!=
NULL
)
{
taosHashCleanup
(
p
Mgmt
->
dnodeHash
);
p
Mgmt
->
dnodeHash
=
NULL
;
if
(
p
Dnode
->
data
.
dnodeHash
!=
NULL
)
{
taosHashCleanup
(
p
Dnode
->
data
.
dnodeHash
);
p
Dnode
->
data
.
dnodeHash
=
NULL
;
}
taosWUnLockLatch
(
&
pDnode
->
data
.
latch
);
d
nd
CleanupTrans
(
pDnode
);
d
m
CleanupTrans
(
pDnode
);
dInfo
(
"dnode-data is cleaned up"
);
}
static
int32_t
dmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
static
int32_t
dmRequire
Mgmt
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
*
required
=
true
;
return
0
;
}
void
dmSetMgmtFp
(
SMgmtWrapper
*
pWrapper
)
{
SMgmtFp
mgmtFp
=
{
0
};
mgmtFp
.
openFp
=
dmInit
;
mgmtFp
.
closeFp
=
dmCleanup
;
mgmtFp
.
startFp
=
dmStart
;
mgmtFp
.
stopFp
=
dmStop
;
mgmtFp
.
requiredFp
=
dmRequire
;
mgmtFp
.
openFp
=
dmInit
Mgmt
;
mgmtFp
.
closeFp
=
dmCleanup
Mgmt
;
mgmtFp
.
startFp
=
dmStart
Mgmt
;
mgmtFp
.
stopFp
=
dmStop
Mgmt
;
mgmtFp
.
requiredFp
=
dmRequire
Mgmt
;
dmSetMsgHandle
(
pWrapper
);
dmSetM
gmtM
sgHandle
(
pWrapper
);
pWrapper
->
name
=
"dnode"
;
pWrapper
->
fp
=
mgmtFp
;
}
source/dnode/mgmt/implement/src/dmMonitor.c
浏览文件 @
318d774b
...
...
@@ -37,7 +37,7 @@ static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
static
void
dmGetMonitorInfo
(
SDnode
*
pDnode
,
SMonDmInfo
*
pInfo
)
{
dmGetMonitorBasicInfo
(
pDnode
,
&
pInfo
->
basic
);
d
nd
GetMonitorSysInfo
(
&
pInfo
->
sys
);
d
m
GetMonitorSysInfo
(
&
pInfo
->
sys
);
dmGetMonitorDnodeInfo
(
pDnode
,
&
pInfo
->
dnode
);
}
...
...
@@ -64,14 +64,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
bool
getFromAPI
=
!
tsMultiProcess
;
pWrapper
=
&
pDnode
->
wrappers
[
MNODE
];
if
(
getFromAPI
)
{
if
(
d
nd
MarkWrapper
(
pWrapper
)
==
0
)
{
if
(
d
m
MarkWrapper
(
pWrapper
)
==
0
)
{
mmGetMonitorInfo
(
pWrapper
,
&
mmInfo
);
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
}
else
{
if
(
pWrapper
->
required
)
{
req
.
msgType
=
TDMT_MON_MM_INFO
;
d
nd
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
m
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonMmInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
&
mmInfo
);
}
...
...
@@ -81,14 +81,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
VNODE
];
if
(
getFromAPI
)
{
if
(
d
nd
MarkWrapper
(
pWrapper
)
==
0
)
{
if
(
d
m
MarkWrapper
(
pWrapper
)
==
0
)
{
vmGetMonitorInfo
(
pWrapper
,
&
vmInfo
);
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
}
else
{
if
(
pWrapper
->
required
)
{
req
.
msgType
=
TDMT_MON_VM_INFO
;
d
nd
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
m
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonVmInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
&
vmInfo
);
}
...
...
@@ -98,14 +98,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
QNODE
];
if
(
getFromAPI
)
{
if
(
d
nd
MarkWrapper
(
pWrapper
)
==
0
)
{
if
(
d
m
MarkWrapper
(
pWrapper
)
==
0
)
{
qmGetMonitorInfo
(
pWrapper
,
&
qmInfo
);
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
}
else
{
if
(
pWrapper
->
required
)
{
req
.
msgType
=
TDMT_MON_QM_INFO
;
d
nd
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
m
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonQmInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
&
qmInfo
);
}
...
...
@@ -115,14 +115,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
SNODE
];
if
(
getFromAPI
)
{
if
(
d
nd
MarkWrapper
(
pWrapper
)
==
0
)
{
if
(
d
m
MarkWrapper
(
pWrapper
)
==
0
)
{
smGetMonitorInfo
(
pWrapper
,
&
smInfo
);
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
}
else
{
if
(
pWrapper
->
required
)
{
req
.
msgType
=
TDMT_MON_SM_INFO
;
d
nd
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
m
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonSmInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
&
smInfo
);
}
...
...
@@ -132,14 +132,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
pWrapper
=
&
pDnode
->
wrappers
[
BNODE
];
if
(
getFromAPI
)
{
if
(
d
nd
MarkWrapper
(
pWrapper
)
==
0
)
{
if
(
d
m
MarkWrapper
(
pWrapper
)
==
0
)
{
bmGetMonitorInfo
(
pWrapper
,
&
bmInfo
);
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
}
else
{
if
(
pWrapper
->
required
)
{
req
.
msgType
=
TDMT_MON_BM_INFO
;
d
nd
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
m
SendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonBmInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
&
bmInfo
);
}
...
...
@@ -161,7 +161,10 @@ void dmSendMonitorReport(SDnode *pDnode) {
monSendReport
();
}
void
dmGetVnodeLoads
(
SMgmtWrapper
*
pWrapper
,
SMonVloadInfo
*
pInfo
)
{
void
dmGetVnodeLoads
(
SDnode
*
pDnode
,
SMonVloadInfo
*
pInfo
)
{
SMgmtWrapper
*
pWrapper
=
dmAcquireWrapper
(
pDnode
,
VNODE
);
if
(
pWrapper
==
NULL
)
return
;
bool
getFromAPI
=
!
tsMultiProcess
;
if
(
getFromAPI
)
{
vmGetVnodeLoads
(
pWrapper
,
pInfo
);
...
...
@@ -172,10 +175,11 @@ void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) {
tstrncpy
(
epset
.
eps
[
0
].
fqdn
,
tsLocalFqdn
,
TSDB_FQDN_LEN
);
epset
.
eps
[
0
].
port
=
tsServerPort
;
d
ndSendRecv
(
pWrapper
->
pDnode
,
&
epset
,
&
req
,
&
rsp
);
d
mSendRecv
(
pDnode
,
&
epset
,
&
req
,
&
rsp
);
if
(
rsp
.
code
==
0
&&
rsp
.
contLen
>
0
)
{
tDeserializeSMonVloadInfo
(
rsp
.
pCont
,
rsp
.
contLen
,
pInfo
);
}
rpcFreeCont
(
rsp
.
pCont
);
}
dmReleaseWrapper
(
pWrapper
);
}
source/dnode/mgmt/implement/src/dmObj.c
浏览文件 @
318d774b
...
...
@@ -16,12 +16,10 @@
#define _DEFAULT_SOURCE
#include "dmImp.h"
static
int32_t
dndInitVars
(
SDnode
*
pDnode
,
const
SDnodeOpt
*
pOption
)
{
static
int32_t
dmInitVars
(
SDnode
*
pDnode
,
const
SDnodeOpt
*
pOption
)
{
pDnode
->
data
.
dnodeId
=
0
;
pDnode
->
data
.
dropped
=
0
;
pDnode
->
data
.
clusterId
=
0
;
pDnode
->
data
.
supportVnodes
=
pOption
->
numOfSupportVnodes
;
pDnode
->
data
.
serverPort
=
pOption
->
serverPort
;
pDnode
->
data
.
dataDir
=
strdup
(
pOption
->
dataDir
);
...
...
@@ -34,24 +32,25 @@ static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
pDnode
->
ntype
=
pOption
->
ntype
;
pDnode
->
data
.
rebootTime
=
taosGetTimestampMs
();
if
(
pDnode
->
data
.
dataDir
==
NULL
||
pDnode
->
data
.
localEp
==
NULL
||
pDnode
->
data
.
localFqdn
==
NULL
||
pDnode
->
data
.
firstEp
==
NULL
||
pDnode
->
data
.
secondEp
==
NULL
)
{
if
(
pDnode
->
data
.
dataDir
==
NULL
||
pDnode
->
data
.
localEp
==
NULL
||
pDnode
->
data
.
localFqdn
==
NULL
||
pDnode
->
data
.
firstEp
==
NULL
||
pDnode
->
data
.
secondEp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
!
tsMultiProcess
||
pDnode
->
ntype
==
NODE_BEGIN
||
pDnode
->
ntype
==
NODE_END
)
{
pDnode
->
data
.
lockfile
=
d
nd
CheckRunning
(
pDnode
->
data
.
dataDir
);
pDnode
->
data
.
lockfile
=
d
m
CheckRunning
(
pDnode
->
data
.
dataDir
);
if
(
pDnode
->
data
.
lockfile
==
NULL
)
{
return
-
1
;
}
}
taosInitRWLatch
(
&
pDnode
->
data
.
latch
);
taosInitRWLatch
(
&
pDnode
->
wrapperLock
);
return
0
;
}
static
void
d
nd
ClearVars
(
SDnode
*
pDnode
)
{
static
void
d
m
ClearVars
(
SDnode
*
pDnode
)
{
for
(
EDndNodeType
n
=
0
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pMgmt
=
&
pDnode
->
wrappers
[
n
];
taosMemoryFreeClear
(
pMgmt
->
path
);
...
...
@@ -70,7 +69,7 @@ static void dndClearVars(SDnode *pDnode) {
dDebug
(
"dnode memory is cleared, data:%p"
,
pDnode
);
}
SDnode
*
d
nd
Create
(
const
SDnodeOpt
*
pOption
)
{
SDnode
*
d
m
Create
(
const
SDnodeOpt
*
pOption
)
{
dDebug
(
"start to create dnode object"
);
int32_t
code
=
-
1
;
char
path
[
PATH_MAX
]
=
{
0
};
...
...
@@ -82,12 +81,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
goto
_OVER
;
}
if
(
d
nd
InitVars
(
pDnode
,
pOption
)
!=
0
)
{
if
(
d
m
InitVars
(
pDnode
,
pOption
)
!=
0
)
{
dError
(
"failed to init variables since %s"
,
terrstr
());
goto
_OVER
;
}
d
nd
SetStatus
(
pDnode
,
DND_STAT_INIT
);
d
m
SetStatus
(
pDnode
,
DND_STAT_INIT
);
dmSetMgmtFp
(
&
pDnode
->
wrappers
[
NODE_BEGIN
]);
mmSetMgmtFp
(
&
pDnode
->
wrappers
[
MNODE
]);
vmSetMgmtFp
(
&
pDnode
->
wrappers
[
VNODE
]);
...
...
@@ -111,12 +110,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
taosInitRWLatch
(
&
pWrapper
->
latch
);
}
if
(
d
nd
InitMsgHandle
(
pDnode
)
!=
0
)
{
if
(
d
m
InitMsgHandle
(
pDnode
)
!=
0
)
{
dError
(
"failed to init msg handles since %s"
,
terrstr
());
goto
_OVER
;
}
if
(
d
nd
ReadShmFile
(
pDnode
)
!=
0
)
{
if
(
d
m
ReadShmFile
(
pDnode
)
!=
0
)
{
dError
(
"failed to read shm file since %s"
,
terrstr
());
goto
_OVER
;
}
...
...
@@ -129,7 +128,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
_OVER:
if
(
code
!=
0
&&
pDnode
)
{
d
nd
ClearVars
(
pDnode
);
d
m
ClearVars
(
pDnode
);
pDnode
=
NULL
;
dError
(
"failed to create dnode since %s"
,
terrstr
());
}
...
...
@@ -137,20 +136,14 @@ _OVER:
return
pDnode
;
}
void
d
nd
Close
(
SDnode
*
pDnode
)
{
void
d
m
Close
(
SDnode
*
pDnode
)
{
if
(
pDnode
==
NULL
)
return
;
for
(
EDndNodeType
n
=
0
;
n
<
NODE_END
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
d
nd
CloseNode
(
pWrapper
);
d
m
CloseNode
(
pWrapper
);
}
d
nd
ClearVars
(
pDnode
);
d
m
ClearVars
(
pDnode
);
dInfo
(
"dnode is closed, data:%p"
,
pDnode
);
}
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
if
(
event
==
DND_EVENT_STOP
)
{
pDnode
->
event
=
event
;
}
}
source/dnode/mgmt/implement/src/dmTransport.c
浏览文件 @
318d774b
...
...
@@ -20,17 +20,17 @@
#define INTERNAL_CKEY "_key"
#define INTERNAL_SECRET "_pwd"
static
void
d
nd
GetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
static
void
d
m
GetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
taosRLockLatch
(
&
pDnode
->
data
.
latch
);
*
pEpSet
=
pDnode
->
data
.
mnodeEp
Set
;
*
pEpSet
=
pDnode
->
data
.
mnodeEp
s
;
taosRUnLockLatch
(
&
pDnode
->
data
.
latch
);
}
static
void
d
nd
SetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
static
void
d
m
SetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
dInfo
(
"mnode is changed, num:%d use:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
pDnode
->
data
.
mnodeEp
Set
=
*
pEpSet
;
pDnode
->
data
.
mnodeEp
s
=
*
pEpSet
;
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
eps
[
i
].
fqdn
,
pEpSet
->
eps
[
i
].
port
);
}
...
...
@@ -38,7 +38,7 @@ static void dndSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
taosWUnLockLatch
(
&
pDnode
->
data
.
latch
);
}
static
inline
NodeMsgFp
d
nd
GetMsgFp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
static
inline
NodeMsgFp
d
m
GetMsgFp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
NodeMsgFp
msgFp
=
pWrapper
->
msgFps
[
TMSG_INDEX
(
pRpc
->
msgType
)];
if
(
msgFp
==
NULL
)
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
...
...
@@ -47,7 +47,7 @@ static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
return
msgFp
;
}
static
inline
int32_t
d
nd
BuildMsg
(
SNodeMsg
*
pMsg
,
SRpcMsg
*
pRpc
)
{
static
inline
int32_t
d
m
BuildMsg
(
SNodeMsg
*
pMsg
,
SRpcMsg
*
pRpc
)
{
SRpcConnInfo
connInfo
=
{
0
};
if
((
pRpc
->
msgType
&
1U
)
&&
rpcGetConnInfo
(
pRpc
->
handle
,
&
connInfo
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
...
@@ -62,20 +62,20 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
return
0
;
}
static
void
d
nd
ProcessRpcMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
static
void
d
m
ProcessRpcMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
int32_t
code
=
-
1
;
SNodeMsg
*
pMsg
=
NULL
;
NodeMsgFp
msgFp
=
NULL
;
uint16_t
msgType
=
pRpc
->
msgType
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
msgType
==
TDMT_MND_STATUS_RSP
)
{
d
nd
SetMnodeEpSet
(
pWrapper
->
pDnode
,
pEpSet
);
d
m
SetMnodeEpSet
(
pWrapper
->
pDnode
,
pEpSet
);
}
if
(
d
nd
MarkWrapper
(
pWrapper
)
!=
0
)
goto
_OVER
;
if
((
msgFp
=
d
nd
GetMsgFp
(
pWrapper
,
pRpc
))
==
NULL
)
goto
_OVER
;
if
(
d
m
MarkWrapper
(
pWrapper
)
!=
0
)
goto
_OVER
;
if
((
msgFp
=
d
m
GetMsgFp
(
pWrapper
,
pRpc
))
==
NULL
)
goto
_OVER
;
if
((
pMsg
=
taosAllocateQitem
(
sizeof
(
SNodeMsg
)))
==
NULL
)
goto
_OVER
;
if
(
d
nd
BuildMsg
(
pMsg
,
pRpc
)
!=
0
)
goto
_OVER
;
if
(
d
m
BuildMsg
(
pMsg
,
pRpc
)
!=
0
)
goto
_OVER
;
if
(
pWrapper
->
procType
==
DND_PROC_SINGLE
)
{
dTrace
(
"msg:%p, is created, handle:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pMsg
->
user
);
...
...
@@ -114,10 +114,10 @@ _OVER:
rpcFreeCont
(
pRpc
->
pCont
);
}
d
nd
ReleaseWrapper
(
pWrapper
);
d
m
ReleaseWrapper
(
pWrapper
);
}
static
void
d
nd
ProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
void
d
m
ProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
tmsg_t
msgType
=
pMsg
->
msgType
;
bool
isReq
=
msgType
&
1u
;
...
...
@@ -126,11 +126,11 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
if
(
msgType
==
TDMT_DND_NETWORK_TEST
)
{
dTrace
(
"network test req will be processed, handle:%p, app:%p"
,
pMsg
->
handle
,
pMsg
->
ahandle
);
d
nd
ProcessStartupReq
(
pDnode
,
pMsg
);
d
m
ProcessStartupReq
(
pDnode
,
pMsg
);
return
;
}
if
(
dndGetStatus
(
pDnode
)
!=
DND_STAT_RUNNING
)
{
if
(
pDnode
->
status
!=
DND_STAT_RUNNING
)
{
dError
(
"msg:%s ignored since dnode not running, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pMsg
->
handle
,
pMsg
->
ahandle
);
if
(
isReq
)
{
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_APP_NOT_READY
,
.
ahandle
=
pMsg
->
ahandle
};
...
...
@@ -168,10 +168,10 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
}
dTrace
(
"msg:%s will be processed by %s, app:%p"
,
TMSG_INFO
(
msgType
),
pWrapper
->
name
,
pMsg
->
ahandle
);
d
nd
ProcessRpcMsg
(
pWrapper
,
pMsg
,
pEpSet
);
d
m
ProcessRpcMsg
(
pWrapper
,
pMsg
,
pEpSet
);
}
int32_t
d
nd
InitMsgHandle
(
SDnode
*
pDnode
)
{
int32_t
d
m
InitMsgHandle
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
for
(
EDndNodeType
n
=
NODE_BEGIN
+
1
;
n
<
NODE_END
;
++
n
)
{
...
...
@@ -208,7 +208,7 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
return
0
;
}
static
inline
int32_t
d
nd
SendRpcReq
(
SDnode
*
pDnode
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
static
inline
int32_t
d
m
SendRpcReq
(
SDnode
*
pDnode
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
if
(
pDnode
->
trans
.
clientRpc
==
NULL
)
{
terrno
=
TSDB_CODE_NODE_OFFLINE
;
return
-
1
;
...
...
@@ -218,9 +218,9 @@ static inline int32_t dndSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMs
return
0
;
}
static
void
d
nd
SendRpcRedirectRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pReq
)
{
static
void
d
m
SendRpcRedirectRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
d
nd
GetMnodeEpSet
(
pDnode
,
&
epSet
);
d
m
GetMnodeEpSet
(
pDnode
,
&
epSet
);
dDebug
(
"RPC %p, req is redirected, num:%d use:%d"
,
pReq
->
handle
,
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
...
...
@@ -235,39 +235,33 @@ static void dndSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
rpcSendRedirectRsp
(
pReq
->
handle
,
&
epSet
);
}
static
inline
void
d
nd
SendRpcRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pRsp
)
{
static
inline
void
d
m
SendRpcRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_NODE_REDIRECT
)
{
d
nd
SendRpcRedirectRsp
(
pDnode
,
pRsp
);
d
m
SendRpcRedirectRsp
(
pDnode
,
pRsp
);
}
else
{
rpcSendResponse
(
pRsp
);
}
}
void
d
nd
SendRecv
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
void
d
m
SendRecv
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
rpcSendRecv
(
pDnode
->
trans
.
clientRpc
,
pEpSet
,
pReq
,
pRsp
);
}
int32_t
dndSendMsgToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
return
dndSendRpcReq
(
pDnode
,
&
epSet
,
pReq
);
}
void
dmSendToMnodeRecv
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
SEpSet
epSet
=
{
0
};
d
nd
GetMnodeEpSet
(
pDnode
,
&
epSet
);
d
m
GetMnodeEpSet
(
pDnode
,
&
epSet
);
rpcSendRecv
(
pDnode
->
trans
.
clientRpc
,
&
epSet
,
pReq
,
pRsp
);
}
static
inline
int32_t
d
nd
SendReq
(
SMgmtWrapper
*
pWrapper
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
if
(
dndGetStatus
(
pWrapper
->
pDnode
)
!=
DND_STAT_RUNNING
)
{
static
inline
int32_t
d
m
SendReq
(
SMgmtWrapper
*
pWrapper
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
if
(
pWrapper
->
pDnode
->
status
!=
DND_STAT_RUNNING
)
{
terrno
=
TSDB_CODE_NODE_OFFLINE
;
dError
(
"failed to send rpc msg since %s, handle:%p"
,
terrstr
(),
pReq
->
handle
);
return
-
1
;
}
if
(
pWrapper
->
procType
!=
DND_PROC_CHILD
)
{
return
d
nd
SendRpcReq
(
pWrapper
->
pDnode
,
pEpSet
,
pReq
);
return
d
m
SendRpcReq
(
pWrapper
->
pDnode
,
pEpSet
,
pReq
);
}
else
{
char
*
pHead
=
taosMemoryMalloc
(
sizeof
(
SRpcMsg
)
+
sizeof
(
SEpSet
));
if
(
pHead
==
NULL
)
{
...
...
@@ -284,15 +278,15 @@ static inline int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, S
}
}
static
inline
void
d
nd
SendRsp
(
SMgmtWrapper
*
pWrapper
,
const
SRpcMsg
*
pRsp
)
{
static
inline
void
d
m
SendRsp
(
SMgmtWrapper
*
pWrapper
,
const
SRpcMsg
*
pRsp
)
{
if
(
pWrapper
->
procType
!=
DND_PROC_CHILD
)
{
d
nd
SendRpcRsp
(
pWrapper
->
pDnode
,
pRsp
);
d
m
SendRpcRsp
(
pWrapper
->
pDnode
,
pRsp
);
}
else
{
taosProcPutToParentQ
(
pWrapper
->
procObj
,
pRsp
,
sizeof
(
SRpcMsg
),
pRsp
->
pCont
,
pRsp
->
contLen
,
PROC_FUNC_RSP
);
}
}
static
inline
void
d
nd
RegisterBrokenLinkArg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
)
{
static
inline
void
d
m
RegisterBrokenLinkArg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
)
{
if
(
pWrapper
->
procType
!=
DND_PROC_CHILD
)
{
rpcRegisterBrokenLinkArg
(
pMsg
);
}
else
{
...
...
@@ -300,7 +294,7 @@ static inline void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMs
}
}
static
inline
void
d
nd
ReleaseHandle
(
SMgmtWrapper
*
pWrapper
,
void
*
handle
,
int8_t
type
)
{
static
inline
void
d
m
ReleaseHandle
(
SMgmtWrapper
*
pWrapper
,
void
*
handle
,
int8_t
type
)
{
if
(
pWrapper
->
procType
!=
DND_PROC_CHILD
)
{
rpcReleaseHandle
(
handle
,
type
);
}
else
{
...
...
@@ -309,8 +303,8 @@ static inline void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t
}
}
static
void
d
nd
ConsumeChildQueue
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
,
int16_t
msgLen
,
void
*
pCont
,
int32_t
contLen
,
EProcFuncType
ftype
)
{
static
void
d
m
ConsumeChildQueue
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
,
int16_t
msgLen
,
void
*
pCont
,
int32_t
contLen
,
EProcFuncType
ftype
)
{
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
pRpc
->
pCont
=
pCont
;
dTrace
(
"msg:%p, get from child queue, handle:%p app:%p"
,
pMsg
,
pRpc
->
handle
,
pRpc
->
ahandle
);
...
...
@@ -322,7 +316,7 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
dError
(
"msg:%p, failed to process since code:0x%04x:%s"
,
pMsg
,
code
&
0XFFFF
,
tstrerror
(
code
));
if
(
pRpc
->
msgType
&
1U
)
{
SRpcMsg
rsp
=
{.
handle
=
pRpc
->
handle
,
.
ahandle
=
pRpc
->
ahandle
,
.
code
=
terrno
};
d
nd
SendRsp
(
pWrapper
,
&
rsp
);
d
m
SendRsp
(
pWrapper
,
&
rsp
);
}
dTrace
(
"msg:%p, is freed"
,
pMsg
);
...
...
@@ -331,8 +325,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
}
}
static
void
d
nd
ConsumeParentQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
,
int16_t
msgLen
,
void
*
pCont
,
int32_t
contLen
,
EProcFuncType
ftype
)
{
static
void
d
m
ConsumeParentQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
,
int16_t
msgLen
,
void
*
pCont
,
int32_t
contLen
,
EProcFuncType
ftype
)
{
pMsg
->
pCont
=
pCont
;
dTrace
(
"msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p"
,
pMsg
,
ftype
,
pMsg
->
handle
,
pMsg
->
code
&
0xFFFF
,
pMsg
->
msgType
,
pMsg
->
ahandle
);
...
...
@@ -347,11 +341,11 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
rpcFreeCont
(
pCont
);
break
;
case
PROC_FUNC_REQ
:
d
nd
SendRpcReq
(
pWrapper
->
pDnode
,
(
SEpSet
*
)((
char
*
)
pMsg
+
sizeof
(
SRpcMsg
)),
pMsg
);
d
m
SendRpcReq
(
pWrapper
->
pDnode
,
(
SEpSet
*
)((
char
*
)
pMsg
+
sizeof
(
SRpcMsg
)),
pMsg
);
break
;
case
PROC_FUNC_RSP
:
taosProcRemoveHandle
(
pWrapper
->
procObj
,
pMsg
->
handle
);
d
nd
SendRpcRsp
(
pWrapper
->
pDnode
,
pMsg
);
d
m
SendRpcRsp
(
pWrapper
->
pDnode
,
pMsg
);
break
;
default:
break
;
...
...
@@ -359,13 +353,13 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
taosMemoryFree
(
pMsg
);
}
SProcCfg
d
nd
GenProcCfg
(
SMgmtWrapper
*
pWrapper
)
{
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
d
nd
ConsumeChildQueue
,
SProcCfg
d
m
GenProcCfg
(
SMgmtWrapper
*
pWrapper
)
{
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
d
m
ConsumeChildQueue
,
.
childMallocHeadFp
=
(
ProcMallocFp
)
taosAllocateQitem
,
.
childFreeHeadFp
=
(
ProcFreeFp
)
taosFreeQitem
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
d
nd
ConsumeParentQueue
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
d
m
ConsumeParentQueue
,
.
parentMallocHeadFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
...
...
@@ -376,13 +370,13 @@ SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) {
return
cfg
;
}
static
int32_t
d
nd
InitClient
(
SDnode
*
pDnode
)
{
static
int32_t
d
m
InitClient
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SRpcInit
rpcInit
=
{
0
};
rpcInit
.
label
=
"DND"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
(
RpcCfp
)
d
nd
ProcessMsg
;
rpcInit
.
cfp
=
(
RpcCfp
)
d
m
ProcessMsg
;
rpcInit
.
sessions
=
1024
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
...
...
@@ -405,7 +399,7 @@ static int32_t dndInitClient(SDnode *pDnode) {
return
0
;
}
static
void
d
nd
CleanupClient
(
SDnode
*
pDnode
)
{
static
void
d
m
CleanupClient
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
if
(
pTrans
->
clientRpc
)
{
rpcClose
(
pTrans
->
clientRpc
);
...
...
@@ -414,8 +408,8 @@ static void dndCleanupClient(SDnode *pDnode) {
}
}
static
inline
int32_t
d
nd
GetHideUserAuth
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
static
inline
int32_t
d
m
GetHideUserAuth
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
int32_t
code
=
0
;
char
pass
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
...
...
@@ -437,9 +431,9 @@ static inline int32_t dndGetHideUserAuth(SDnode *pDnode, char *user, char *spi,
return
code
;
}
static
inline
int32_t
d
nd
RetrieveUserAuthInfo
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
if
(
d
nd
GetHideUserAuth
(
pDnode
,
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
static
inline
int32_t
d
m
RetrieveUserAuthInfo
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
if
(
d
m
GetHideUserAuth
(
pDnode
,
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
dTrace
(
"user:%s, get auth from mnode, spi:%d encrypt:%d"
,
user
,
*
spi
,
*
encrypt
);
return
0
;
}
...
...
@@ -473,18 +467,18 @@ static inline int32_t dndRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *
return
rpcRsp
.
code
;
}
static
int32_t
d
nd
InitServer
(
SDnode
*
pDnode
)
{
static
int32_t
d
m
InitServer
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SRpcInit
rpcInit
=
{
0
};
rpcInit
.
localPort
=
pDnode
->
data
.
serverPort
;
rpcInit
.
label
=
"DND"
;
rpcInit
.
numOfThreads
=
tsNumOfRpcThreads
;
rpcInit
.
cfp
=
(
RpcCfp
)
d
nd
ProcessMsg
;
rpcInit
.
cfp
=
(
RpcCfp
)
d
m
ProcessMsg
;
rpcInit
.
sessions
=
tsMaxShellConns
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
afp
=
(
RpcAfp
)
d
nd
RetrieveUserAuthInfo
;
rpcInit
.
afp
=
(
RpcAfp
)
d
m
RetrieveUserAuthInfo
;
rpcInit
.
parent
=
pDnode
;
pTrans
->
serverRpc
=
rpcOpen
(
&
rpcInit
);
...
...
@@ -497,7 +491,7 @@ static int32_t dndInitServer(SDnode *pDnode) {
return
0
;
}
static
void
d
nd
CleanupServer
(
SDnode
*
pDnode
)
{
static
void
d
m
CleanupServer
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
if
(
pTrans
->
serverRpc
)
{
rpcClose
(
pTrans
->
serverRpc
);
...
...
@@ -507,21 +501,21 @@ static void dndCleanupServer(SDnode *pDnode) {
}
int32_t
dmInitTrans
(
SDnode
*
pDnode
)
{
if
(
d
nd
InitServer
(
pDnode
)
!=
0
)
return
-
1
;
if
(
d
nd
InitClient
(
pDnode
)
!=
0
)
return
-
1
;
if
(
d
m
InitServer
(
pDnode
)
!=
0
)
return
-
1
;
if
(
d
m
InitClient
(
pDnode
)
!=
0
)
return
-
1
;
SMsgCb
msgCb
=
{
.
sendReqFp
=
d
nd
SendReq
,
.
sendRspFp
=
d
nd
SendRsp
,
.
registerBrokenLinkArgFp
=
d
nd
RegisterBrokenLinkArg
,
.
releaseHandleFp
=
d
nd
ReleaseHandle
,
.
sendReqFp
=
d
m
SendReq
,
.
sendRspFp
=
d
m
SendRsp
,
.
registerBrokenLinkArgFp
=
d
m
RegisterBrokenLinkArg
,
.
releaseHandleFp
=
d
m
ReleaseHandle
,
};
pDnode
->
data
.
msgCb
=
msgCb
;
return
0
;
}
void
d
nd
CleanupTrans
(
SDnode
*
pDnode
)
{
d
nd
CleanupServer
(
pDnode
);
d
nd
CleanupClient
(
pDnode
);
void
d
m
CleanupTrans
(
SDnode
*
pDnode
)
{
d
m
CleanupServer
(
pDnode
);
d
m
CleanupClient
(
pDnode
);
}
source/dnode/mgmt/implement/src/dmWorker.c
浏览文件 @
318d774b
...
...
@@ -33,7 +33,7 @@ static void *dmStatusThreadFp(void *param) {
int64_t
curTime
=
taosGetTimestampMs
();
float
interval
=
(
curTime
-
lastTime
)
/
1000
.
0
f
;
if
(
interval
>=
tsStatusInterval
)
{
dmSendStatusReq
(
p
Mgmt
);
dmSendStatusReq
(
p
Dnode
);
lastTime
=
curTime
;
}
}
...
...
@@ -67,8 +67,8 @@ static void *dmMonitorThreadFp(void *param) {
}
int32_t
dmStartStatusThread
(
SDnode
*
pDnode
)
{
pDnode
->
statusThreadId
=
taosCreateThread
(
dmStatusThreadFp
,
pDnode
);
if
(
pDnode
->
statusThreadId
==
NULL
)
{
pDnode
->
data
.
statusThreadId
=
taosCreateThread
(
dmStatusThreadFp
,
pDnode
);
if
(
pDnode
->
data
.
statusThreadId
==
NULL
)
{
dError
(
"failed to init dnode status thread"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -78,15 +78,15 @@ int32_t dmStartStatusThread(SDnode *pDnode) {
}
void
dmStopStatusThread
(
SDnode
*
pDnode
)
{
if
(
pDnode
->
statusThreadId
!=
NULL
)
{
taosDestoryThread
(
pDnode
->
statusThreadId
);
pDnode
->
statusThreadId
=
NULL
;
if
(
pDnode
->
data
.
statusThreadId
!=
NULL
)
{
taosDestoryThread
(
pDnode
->
data
.
statusThreadId
);
pDnode
->
data
.
statusThreadId
=
NULL
;
}
}
int32_t
dmStartMonitorThread
(
SDnode
*
pDnode
)
{
pDnode
->
monitorThreadId
=
taosCreateThread
(
dmMonitorThreadFp
,
pDnode
);
if
(
pDnode
->
monitorThreadId
==
NULL
)
{
pDnode
->
data
.
monitorThreadId
=
taosCreateThread
(
dmMonitorThreadFp
,
pDnode
);
if
(
pDnode
->
data
.
monitorThreadId
==
NULL
)
{
dError
(
"failed to init dnode monitor thread"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -96,9 +96,9 @@ int32_t dmStartMonitorThread(SDnode *pDnode) {
}
void
dmStopMonitorThread
(
SDnode
*
pDnode
)
{
if
(
p
Mgmt
->
monitorThreadId
!=
NULL
)
{
taosDestoryThread
(
p
Mgmt
->
monitorThreadId
);
p
Mgmt
->
monitorThreadId
=
NULL
;
if
(
p
Dnode
->
data
.
monitorThreadId
!=
NULL
)
{
taosDestoryThread
(
p
Dnode
->
data
.
monitorThreadId
);
p
Dnode
->
data
.
monitorThreadId
=
NULL
;
}
}
...
...
@@ -110,16 +110,39 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
switch
(
pRpc
->
msgType
)
{
case
TDMT_DND_CONFIG_DNODE
:
code
=
dmProcessConfigReq
(
p
Mgmt
,
pMsg
);
code
=
dmProcessConfigReq
(
p
Dnode
,
pMsg
);
break
;
case
TDMT_MND_AUTH_RSP
:
code
=
dmProcessAuthRsp
(
p
Mgmt
,
pMsg
);
code
=
dmProcessAuthRsp
(
p
Dnode
,
pMsg
);
break
;
case
TDMT_MND_GRANT_RSP
:
code
=
dmProcessGrantRsp
(
pMgmt
,
pMsg
);
code
=
dmProcessGrantRsp
(
pDnode
,
pMsg
);
break
;
case
TDMT_DND_CREATE_MNODE
:
code
=
dmProcessCreateNodeReq
(
pDnode
,
MNODE
,
pMsg
);
break
;
case
TDMT_DND_DROP_MNODE
:
code
=
dmProcessDropNodeReq
(
pDnode
,
MNODE
,
pMsg
);
break
;
case
TDMT_DND_CREATE_QNODE
:
code
=
dmProcessCreateNodeReq
(
pDnode
,
QNODE
,
pMsg
);
break
;
case
TDMT_DND_DROP_QNODE
:
code
=
dmProcessDropNodeReq
(
pDnode
,
QNODE
,
pMsg
);
break
;
case
TDMT_DND_CREATE_SNODE
:
code
=
dmProcessCreateNodeReq
(
pDnode
,
SNODE
,
pMsg
);
break
;
case
TDMT_DND_DROP_SNODE
:
code
=
dmProcessDropNodeReq
(
pDnode
,
SNODE
,
pMsg
);
break
;
case
TDMT_DND_CREATE_BNODE
:
code
=
dmProcessCreateNodeReq
(
pDnode
,
BNODE
,
pMsg
);
break
;
case
TDMT_DND_DROP_BNODE
:
code
=
dmProcessDropNodeReq
(
pDnode
,
BNODE
,
pMsg
);
break
;
default:
code
=
dmProcessCDnodeReq
(
pMgmt
->
pDnode
,
pMsg
);
break
;
}
...
...
@@ -134,9 +157,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
taosFreeQitem
(
pMsg
);
}
int32_t
dmStartWorker
(
SDnode
Data
*
pMgmt
)
{
SSingleWorkerCfg
cfg
=
{.
min
=
1
,
.
max
=
1
,
.
name
=
"dnode-mgmt"
,
.
fp
=
(
FItem
)
dmProcessMgmtQueue
,
.
param
=
p
Mgmt
};
if
(
tSingleWorkerInit
(
&
p
Mgmt
->
mgmtWorker
,
&
cfg
)
!=
0
)
{
int32_t
dmStartWorker
(
SDnode
*
pDnode
)
{
SSingleWorkerCfg
cfg
=
{.
min
=
1
,
.
max
=
1
,
.
name
=
"dnode-mgmt"
,
.
fp
=
(
FItem
)
dmProcessMgmtQueue
,
.
param
=
p
Dnode
};
if
(
tSingleWorkerInit
(
&
p
Dnode
->
data
.
mgmtWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start dnode-mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -145,24 +168,13 @@ int32_t dmStartWorker(SDnodeData *pMgmt) {
return
0
;
}
void
dmStopWorker
(
SDnode
Data
*
pMgmt
)
{
tSingleWorkerCleanup
(
&
p
Mgmt
->
mgmtWorker
);
void
dmStopWorker
(
SDnode
*
pDnode
)
{
tSingleWorkerCleanup
(
&
p
Dnode
->
data
.
mgmtWorker
);
dDebug
(
"dnode workers are closed"
);
}
int32_t
dmProcessMgmtMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnodeData
*
pMgmt
=
pWrapper
->
pMgmt
;
SSingleWorker
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
dTrace
(
"msg:%p, put into worker %s"
,
pMsg
,
pWorker
->
name
);
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
int32_t
dmProcessStatusMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnodeData
*
pMgmt
=
pWrapper
->
pMgmt
;
SSingleWorker
*
pWorker
=
&
pMgmt
->
monitorWorker
;
SSingleWorker
*
pWorker
=
&
pWrapper
->
pDnode
->
data
.
mgmtWorker
;
dTrace
(
"msg:%p, put into worker %s"
,
pMsg
,
pWorker
->
name
);
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
...
...
source/dnode/mgmt/interface/inc/dmDef.h
浏览文件 @
318d774b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_D
ND
_DEF_H_
#define _TD_D
ND
_DEF_H_
#ifndef _TD_D
M
_DEF_H_
#define _TD_D
M
_DEF_H_
#include "dmLog.h"
...
...
@@ -110,9 +110,9 @@ typedef struct {
int64_t
updateTime
;
int64_t
rebootTime
;
bool
dropped
;
SEpSet
mnodeEpSet
;
SHashObj
*
dnodeHash
;
SEpSet
mnodeEps
;
SArray
*
dnodeEps
;
SHashObj
*
dnodeHash
;
TdThread
*
statusThreadId
;
TdThread
*
monitorThreadId
;
SRWLatch
latch
;
...
...
@@ -140,6 +140,7 @@ typedef struct SDnode {
SStartupReq
startup
;
SDnodeTrans
trans
;
SDnodeData
data
;
SRWLatch
wrapperLock
;
SMgmtWrapper
wrappers
[
NODE_END
];
}
SDnode
;
...
...
@@ -147,4 +148,4 @@ typedef struct SDnode {
}
#endif
#endif
/*_TD_DND_DEF_H_*/
\ No newline at end of file
#endif
/*_TD_DM_DEF_H_*/
\ No newline at end of file
source/dnode/mgmt/interface/inc/dmInt.h
浏览文件 @
318d774b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_D
ND
_INT_H_
#define _TD_D
ND
_INT_H_
#ifndef _TD_D
M
_INT_H_
#define _TD_D
M
_INT_H_
#include "dmDef.h"
...
...
@@ -22,32 +22,32 @@
extern
"C"
{
#endif
// d
nd
Int.c
const
char
*
dndStatName
(
EDndRunStatus
stat
);
const
char
*
dndLogName
(
EDndNodeType
ntype
);
const
char
*
dndProcName
(
EDndNodeType
ntype
);
const
char
*
d
ndEventName
(
EDndEvent
ev
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
nT
ype
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
EDndRunStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dnd
SetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
stat
);
void
dnd
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
dnd
SetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
);
void
dnd
ReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
);
void
dnd
ProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
void
dnd
GetMonitorSysInfo
(
SMonSysInfo
*
pInfo
);
SMsgCb
dmGetMsgcb
(
SMgmtWrapper
*
pWrapper
);
// d
nd
File.c
int32_t
d
nd
ReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
d
nd
WriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
TdFilePtr
d
nd
CheckRunning
(
const
char
*
dataDir
);
int32_t
d
nd
ReadShmFile
(
SDnode
*
pDnode
);
int32_t
d
nd
WriteShmFile
(
SDnode
*
pDnode
);
// d
m
Int.c
SMgmtWrapper
*
dmAcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
nType
);
int32_t
dmMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dmReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
const
char
*
d
mStatName
(
EDndRunStatus
stat
);
const
char
*
dmLogName
(
EDndNodeType
nt
ype
);
const
char
*
dmProcName
(
EDndNodeType
ntype
);
const
char
*
dmEventName
(
EDndEvent
ev
);
void
dm
SetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
stat
);
void
dm
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
dm
SetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
);
void
dm
ReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
);
void
dm
ProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
void
dm
GetMonitorSysInfo
(
SMonSysInfo
*
pInfo
);
SMsgCb
dmGetMsgcb
(
SMgmtWrapper
*
pWrapper
);
// d
m
File.c
int32_t
d
m
ReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
d
m
WriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
TdFilePtr
d
m
CheckRunning
(
const
char
*
dataDir
);
int32_t
d
m
ReadShmFile
(
SDnode
*
pDnode
);
int32_t
d
m
WriteShmFile
(
SDnode
*
pDnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_DND_INT_H_*/
\ No newline at end of file
#endif
/*_TD_DM_INT_H_*/
\ No newline at end of file
source/dnode/mgmt/interface/inc/dmLog.h
浏览文件 @
318d774b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_D
ND
_LOG_H_
#define _TD_D
ND
_LOG_H_
#ifndef _TD_D
M
_LOG_H_
#define _TD_D
M
_LOG_H_
#include "tlog.h"
...
...
@@ -33,4 +33,4 @@ extern "C" {
}
#endif
#endif
/*_TD_DND_LOG_H_*/
\ No newline at end of file
#endif
/*_TD_DM_LOG_H_*/
\ No newline at end of file
source/dnode/mgmt/interface/src/dmEnv.c
浏览文件 @
318d774b
...
...
@@ -19,7 +19,7 @@
static
int8_t
once
=
DND_ENV_INIT
;
int32_t
d
nd
Init
()
{
int32_t
d
m
Init
()
{
dDebug
(
"start to init dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
terrno
=
TSDB_CODE_REPEAT_INIT
;
...
...
@@ -45,7 +45,7 @@ int32_t dndInit() {
return
0
;
}
void
d
nd
Cleanup
()
{
void
d
m
Cleanup
()
{
dDebug
(
"start to cleanup dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
dError
(
"dnode env is already cleaned up"
);
...
...
source/dnode/mgmt/interface/src/dmFile.c
浏览文件 @
318d774b
...
...
@@ -18,7 +18,7 @@
#define MAXLEN 1024
int32_t
d
nd
ReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
)
{
int32_t
d
m
ReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
)
{
int32_t
code
=
TSDB_CODE_INVALID_JSON_FORMAT
;
int64_t
len
=
0
;
char
content
[
MAXLEN
+
1
]
=
{
0
};
...
...
@@ -64,7 +64,7 @@ _OVER:
return
code
;
}
int32_t
d
nd
WriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
)
{
int32_t
d
m
WriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
)
{
int32_t
code
=
-
1
;
int32_t
len
=
0
;
char
content
[
MAXLEN
+
1
]
=
{
0
};
...
...
@@ -117,7 +117,7 @@ _OVER:
return
code
;
}
TdFilePtr
d
nd
CheckRunning
(
const
char
*
dataDir
)
{
TdFilePtr
d
m
CheckRunning
(
const
char
*
dataDir
)
{
char
filepath
[
PATH_MAX
]
=
{
0
};
snprintf
(
filepath
,
sizeof
(
filepath
),
"%s%s.running"
,
dataDir
,
TD_DIRSEP
);
...
...
@@ -140,7 +140,7 @@ TdFilePtr dndCheckRunning(const char *dataDir) {
return
pFile
;
}
int32_t
d
nd
ReadShmFile
(
SDnode
*
pDnode
)
{
int32_t
d
m
ReadShmFile
(
SDnode
*
pDnode
)
{
int32_t
code
=
-
1
;
char
itemName
[
24
]
=
{
0
};
char
content
[
MAXLEN
+
1
]
=
{
0
};
...
...
@@ -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"
,
d
nd
ProcName
(
ntype
));
snprintf
(
itemName
,
sizeof
(
itemName
),
"%s_shmid"
,
d
m
ProcName
(
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"
,
d
nd
ProcName
(
ntype
));
snprintf
(
itemName
,
sizeof
(
itemName
),
"%s_shmsize"
,
d
m
ProcName
(
ntype
));
cJSON
*
shmsize
=
cJSON_GetObjectItem
(
root
,
itemName
);
if
(
shmsize
&&
shmsize
->
type
==
cJSON_Number
)
{
pDnode
->
wrappers
[
ntype
].
procShm
.
size
=
shmsize
->
valueint
;
...
...
@@ -207,7 +207,7 @@ _OVER:
return
code
;
}
int32_t
d
nd
WriteShmFile
(
SDnode
*
pDnode
)
{
int32_t
d
m
WriteShmFile
(
SDnode
*
pDnode
)
{
int32_t
code
=
-
1
;
int32_t
len
=
0
;
char
content
[
MAXLEN
+
1
]
=
{
0
};
...
...
@@ -228,12 +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
"
,
d
nd
ProcName
(
ntype
),
pWrapper
->
procShm
.
id
);
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"
\"
%s_shmid
\"
:%d,
\n
"
,
d
m
ProcName
(
ntype
),
pWrapper
->
procShm
.
id
);
if
(
ntype
==
NODE_END
-
1
)
{
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"
\"
%s_shmsize
\"
:%d
\n
"
,
d
nd
ProcName
(
ntype
),
pWrapper
->
procShm
.
size
);
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"
\"
%s_shmsize
\"
:%d
\n
"
,
d
m
ProcName
(
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
"
,
dmProcName
(
ntype
),
pWrapper
->
procShm
.
size
);
}
}
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"}
\n
"
);
...
...
source/dnode/mgmt/interface/src/dmInt.c
浏览文件 @
318d774b
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmInt.h"
const
char
*
d
nd
StatName
(
EDndRunStatus
status
)
{
const
char
*
d
m
StatName
(
EDndRunStatus
status
)
{
switch
(
status
)
{
case
DND_STAT_INIT
:
return
"init"
;
...
...
@@ -29,7 +29,7 @@ const char *dndStatName(EDndRunStatus status) {
}
}
const
char
*
d
nd
LogName
(
EDndNodeType
ntype
)
{
const
char
*
d
m
LogName
(
EDndNodeType
ntype
)
{
switch
(
ntype
)
{
case
VNODE
:
return
"vnode"
;
...
...
@@ -46,7 +46,7 @@ const char *dndLogName(EDndNodeType ntype) {
}
}
const
char
*
d
nd
ProcName
(
EDndNodeType
ntype
)
{
const
char
*
d
m
ProcName
(
EDndNodeType
ntype
)
{
switch
(
ntype
)
{
case
VNODE
:
return
"taosv"
;
...
...
@@ -63,7 +63,7 @@ const char *dndProcName(EDndNodeType ntype) {
}
}
const
char
*
d
nd
EventName
(
EDndEvent
ev
)
{
const
char
*
d
m
EventName
(
EDndEvent
ev
)
{
switch
(
ev
)
{
case
DND_EVENT_START
:
return
"start"
;
...
...
@@ -76,27 +76,25 @@ const char *dndEventName(EDndEvent ev) {
}
}
EDndRunStatus
dndGetStatus
(
SDnode
*
pDnode
)
{
return
pDnode
->
status
;
}
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
status
)
{
void
dmSetStatus
(
SDnode
*
pDnode
,
EDndRunStatus
status
)
{
if
(
pDnode
->
status
!=
status
)
{
dDebug
(
"dnode status set from %s to %s"
,
d
ndStatName
(
pDnode
->
status
),
dnd
StatName
(
status
));
dDebug
(
"dnode status set from %s to %s"
,
d
mStatName
(
pDnode
->
status
),
dm
StatName
(
status
));
pDnode
->
status
=
status
;
}
}
void
d
nd
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
void
d
m
SetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
if
(
event
==
DND_EVENT_STOP
)
{
pDnode
->
event
=
event
;
}
}
void
d
nd
SetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
void
d
m
SetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
pWrapper
->
msgVgIds
[
TMSG_INDEX
(
msgType
)]
=
vgId
;
}
SMgmtWrapper
*
d
nd
AcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
ntype
)
{
SMgmtWrapper
*
d
m
AcquireWrapper
(
SDnode
*
pDnode
,
EDndNodeType
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
...
...
@@ -113,7 +111,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
return
pRetWrapper
;
}
int32_t
d
nd
MarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
d
m
MarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
...
...
@@ -129,7 +127,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
return
code
;
}
void
d
nd
ReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
void
d
m
ReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taosRLockLatch
(
&
pWrapper
->
latch
);
...
...
@@ -138,22 +136,22 @@ void dndReleaseWrapper(SMgmtWrapper *pWrapper) {
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
void
d
nd
ReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
void
d
m
ReportStartup
(
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
d
nd
GetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
static
void
d
m
GetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
pStartup
->
finished
=
(
pDnode
->
status
==
DND_STAT_RUNNING
);
}
void
d
nd
ProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
void
d
m
ProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
d
nd
GetStartup
(
pDnode
,
pStartup
);
d
m
GetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
...
...
@@ -161,7 +159,7 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse
(
&
rpcRsp
);
}
void
d
nd
GetMonitorSysInfo
(
SMonSysInfo
*
pInfo
)
{
void
d
m
GetMonitorSysInfo
(
SMonSysInfo
*
pInfo
)
{
taosGetCpuUsage
(
&
pInfo
->
cpu_engine
,
&
pInfo
->
cpu_system
);
taosGetCpuCores
(
&
pInfo
->
cpu_cores
);
taosGetProcMemory
(
&
pInfo
->
mem_engine
);
...
...
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
浏览文件 @
318d774b
...
...
@@ -21,7 +21,7 @@ void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo) {}
int32_t
bmProcessGetMonBmInfoReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
SMonBmInfo
bmInfo
=
{
0
};
bmGetMonitorInfo
(
pWrapper
,
&
bmInfo
);
d
nd
GetMonitorSysInfo
(
&
bmInfo
.
sys
);
d
m
GetMonitorSysInfo
(
&
bmInfo
.
sys
);
monGetLogs
(
&
bmInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonBmInfo
(
NULL
,
0
,
&
bmInfo
);
...
...
@@ -58,7 +58,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to create bnode since %s, input:%d cur:%d"
,
terrstr
(),
createReq
.
dnodeId
,
pDnode
->
data
.
dnodeId
);
return
-
1
;
}
else
{
// return d
nd
OpenNode(pWrapper);
// return d
m
OpenNode(pWrapper);
return
0
;
}
}
...
...
@@ -78,11 +78,11 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
// d
nd
CloseNode(pWrapper);
// d
m
CloseNode(pWrapper);
return
bmDrop
(
pWrapper
);
}
}
void
bmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_BM_INFO
,
bmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_BM_INFO
,
bmProcessMonitorMsg
,
DEFAULT_HANDLE
);
}
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
浏览文件 @
318d774b
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "bmInt.h"
static
int32_t
bmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
nd
ReadFile
(
pWrapper
,
required
);
}
static
int32_t
bmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
m
ReadFile
(
pWrapper
,
required
);
}
static
void
bmInitOption
(
SBnodeMgmt
*
pMgmt
,
SBnodeOpt
*
pOption
)
{
SMsgCb
msgCb
=
dmGetMsgcb
(
pMgmt
->
pWrapper
);
...
...
@@ -39,7 +39,7 @@ static int32_t bmOpenImp(SBnodeMgmt *pMgmt) {
}
bool
deployed
=
true
;
if
(
d
nd
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to write bnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -61,7 +61,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) {
dInfo
(
"bnode-mgmt start to drop"
);
bool
deployed
=
false
;
if
(
d
nd
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
318d774b
...
...
@@ -24,7 +24,7 @@ void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo) {
int32_t
mmProcessGetMonMmInfoReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
SMonMmInfo
mmInfo
=
{
0
};
mmGetMonitorInfo
(
pWrapper
,
&
mmInfo
);
d
nd
GetMonitorSysInfo
(
&
mmInfo
.
sys
);
d
m
GetMonitorSysInfo
(
&
mmInfo
.
sys
);
monGetLogs
(
&
mmInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonMmInfo
(
NULL
,
0
,
&
mmInfo
);
...
...
@@ -80,7 +80,7 @@ int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to drop mnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
// d
nd
CloseNode(pWrapper);
// d
m
CloseNode(pWrapper);
return
mmDrop
(
pWrapper
);
}
}
...
...
@@ -105,96 +105,96 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
}
void
mmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_MM_INFO
,
mmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_MM_INFO
,
mmProcessMonitorMsg
,
DEFAULT_HANDLE
);
// Requests handled by DNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
// Requests handled by MNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_DB_CFG
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_INDEX
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_DB_CFG
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MND_GET_INDEX
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
// Requests handled by VNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CANCEL_CONN_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CANCEL_CONN_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
mmProcessQueryMsg
,
MNODE_HANDLE
);
}
source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
浏览文件 @
318d774b
...
...
@@ -21,7 +21,7 @@ void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo) {}
int32_t
qmProcessGetMonQmInfoReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
SMonQmInfo
qmInfo
=
{
0
};
qmGetMonitorInfo
(
pWrapper
,
&
qmInfo
);
d
nd
GetMonitorSysInfo
(
&
qmInfo
.
sys
);
d
m
GetMonitorSysInfo
(
&
qmInfo
.
sys
);
monGetLogs
(
&
qmInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonQmInfo
(
NULL
,
0
,
&
qmInfo
);
...
...
@@ -58,7 +58,7 @@ int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
// return d
nd
OpenNode(pWrapper);
// return d
m
OpenNode(pWrapper);
return
0
;
}
}
...
...
@@ -78,23 +78,23 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to drop qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
// d
nd
CloseNode(pWrapper);
// d
m
CloseNode(pWrapper);
return
qmDrop
(
pWrapper
);
}
}
void
qmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_QM_INFO
,
qmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_QM_INFO
,
qmProcessMonitorMsg
,
DEFAULT_HANDLE
);
// Requests handled by VNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
qmProcessQueryMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
qmProcessQueryMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
qmProcessQueryMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
qmProcessQueryMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
qmProcessFetchMsg
,
QNODE_HANDLE
);
}
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
浏览文件 @
318d774b
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "qmInt.h"
static
int32_t
qmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
nd
ReadFile
(
pWrapper
,
required
);
}
static
int32_t
qmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
m
ReadFile
(
pWrapper
,
required
);
}
static
void
qmInitOption
(
SQnodeMgmt
*
pMgmt
,
SQnodeOpt
*
pOption
)
{
SMsgCb
msgCb
=
dmGetMsgcb
(
pMgmt
->
pWrapper
);
...
...
@@ -42,7 +42,7 @@ static int32_t qmOpenImp(SQnodeMgmt *pMgmt) {
}
bool
deployed
=
true
;
if
(
d
nd
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to write qnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -64,7 +64,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) {
dInfo
(
"qnode-mgmt start to drop"
);
bool
deployed
=
false
;
if
(
d
nd
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to drop qnode since %s"
,
terrstr
());
return
-
1
;
}
...
...
source/dnode/mgmt/mgmt_snode/src/smHandle.c
浏览文件 @
318d774b
...
...
@@ -21,7 +21,7 @@ void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo) {}
int32_t
smProcessGetMonSmInfoReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
SMonSmInfo
smInfo
=
{
0
};
smGetMonitorInfo
(
pWrapper
,
&
smInfo
);
d
nd
GetMonitorSysInfo
(
&
smInfo
.
sys
);
d
m
GetMonitorSysInfo
(
&
smInfo
.
sys
);
monGetLogs
(
&
smInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonSmInfo
(
NULL
,
0
,
&
smInfo
);
...
...
@@ -58,7 +58,7 @@ int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
// return d
nd
OpenNode(pWrapper);
// return d
m
OpenNode(pWrapper);
return
0
;
}
}
...
...
@@ -79,14 +79,14 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
-
1
;
}
else
{
return
smDrop
(
pWrapper
);
// return d
nd
CloseNode(pWrapper);
// return d
m
CloseNode(pWrapper);
}
}
void
smInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_SM_INFO
,
smProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_SM_INFO
,
smProcessMonitorMsg
,
DEFAULT_HANDLE
);
// Requests handled by SNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
smProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
smProcessExecMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
smProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
smProcessExecMsg
,
DEFAULT_HANDLE
);
}
source/dnode/mgmt/mgmt_snode/src/smInt.c
浏览文件 @
318d774b
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "smInt.h"
static
int32_t
smRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
nd
ReadFile
(
pWrapper
,
required
);
}
static
int32_t
smRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
d
m
ReadFile
(
pWrapper
,
required
);
}
static
void
smInitOption
(
SSnodeMgmt
*
pMgmt
,
SSnodeOpt
*
pOption
)
{
SMsgCb
msgCb
=
dmGetMsgcb
(
pMgmt
->
pWrapper
);
...
...
@@ -39,7 +39,7 @@ static int32_t smOpenImp(SSnodeMgmt *pMgmt) {
}
bool
deployed
=
true
;
if
(
d
nd
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to write snode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -61,7 +61,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) {
dInfo
(
"snode-mgmt start to drop"
);
bool
deployed
=
false
;
if
(
d
nd
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
if
(
d
m
WriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
318d774b
...
...
@@ -36,7 +36,7 @@ void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo) {
int32_t
vmProcessGetMonVmInfoReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
SMonVmInfo
vmInfo
=
{
0
};
vmGetMonitorInfo
(
pWrapper
,
&
vmInfo
);
d
nd
GetMonitorSysInfo
(
&
vmInfo
.
sys
);
d
m
GetMonitorSysInfo
(
&
vmInfo
.
sys
);
monGetLogs
(
&
vmInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonVmInfo
(
NULL
,
0
,
&
vmInfo
);
...
...
@@ -304,54 +304,54 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
}
void
vmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_VM_INFO
,
vmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_MON_VM_LOAD
,
vmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_VM_INFO
,
vmProcessMonitorMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_MON_VM_LOAD
,
vmProcessMonitorMsg
,
DEFAULT_HANDLE
);
// Requests handled by VNODE
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CANCEL_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_PIPE_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_MERGE_EXEC
,
(
NodeMsgFp
)
vmProcessMergeMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_WRITE_EXEC
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
nd
SetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CANCEL_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_PIPE_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_MERGE_EXEC
,
(
NodeMsgFp
)
vmProcessMergeMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_WRITE_EXEC
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
d
m
SetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
vmProcessMgmtMsg
,
DEFAULT_HANDLE
);
}
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
318d774b
...
...
@@ -126,7 +126,7 @@ static void *vmOpenVnodeFunc(void *param) {
char
stepDesc
[
TSDB_STEP_DESC_LEN
]
=
{
0
};
snprintf
(
stepDesc
,
TSDB_STEP_DESC_LEN
,
"vgId:%d, start to restore, %d of %d have been opened"
,
pCfg
->
vgId
,
pMgmt
->
state
.
openVnodes
,
pMgmt
->
state
.
totalVnodes
);
d
nd
ReportStartup
(
pDnode
,
"open-vnodes"
,
stepDesc
);
d
m
ReportStartup
(
pDnode
,
"open-vnodes"
,
stepDesc
);
SMsgCb
msgCb
=
dmGetMsgcb
(
pMgmt
->
pWrapper
);
msgCb
.
pWrapper
=
pMgmt
->
pWrapper
;
...
...
source/dnode/mgmt/test/sut/src/server.cpp
浏览文件 @
318d774b
...
...
@@ -17,7 +17,7 @@
void
*
serverLoop
(
void
*
param
)
{
SDnode
*
pDnode
=
(
SDnode
*
)
param
;
d
nd
Run
(
pDnode
);
d
m
Run
(
pDnode
);
return
NULL
;
}
...
...
@@ -36,7 +36,7 @@ bool TestServer::DoStart() {
SDnodeOpt
option
=
BuildOption
(
path
,
fqdn
,
port
,
firstEp
);
taosMkDir
(
path
);
pDnode
=
d
nd
Create
(
&
option
);
pDnode
=
d
m
Create
(
&
option
);
if
(
pDnode
==
NULL
)
{
return
false
;
}
...
...
@@ -68,11 +68,11 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const
}
void
TestServer
::
Stop
()
{
d
nd
SetEvent
(
pDnode
,
DND_EVENT_STOP
);
d
m
SetEvent
(
pDnode
,
DND_EVENT_STOP
);
taosThreadJoin
(
threadId
,
NULL
);
if
(
pDnode
!=
NULL
)
{
d
nd
Close
(
pDnode
);
d
m
Close
(
pDnode
);
pDnode
=
NULL
;
}
}
source/dnode/mgmt/test/sut/src/sut.cpp
浏览文件 @
318d774b
...
...
@@ -40,7 +40,7 @@ void Testbase::InitLog(const char* path) {
}
void
Testbase
::
Init
(
const
char
*
path
,
int16_t
port
)
{
d
nd
Init
();
d
m
Init
();
char
fqdn
[]
=
"localhost"
;
char
firstEp
[
TSDB_EP_LEN
]
=
{
0
};
...
...
@@ -62,7 +62,7 @@ void Testbase::Cleanup() {
client
.
Cleanup
();
taosMsleep
(
10
);
server
.
Stop
();
d
nd
Cleanup
();
d
m
Cleanup
();
}
void
Testbase
::
Restart
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录