Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b2bf8539
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b2bf8539
编写于
4月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename file
上级
6abfd9fe
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
101 addition
and
117 deletion
+101
-117
source/dnode/mgmt/dm/src/dmMsg.c
source/dnode/mgmt/dm/src/dmMsg.c
+101
-0
source/dnode/mgmt/main/src/dndMsg.c
source/dnode/mgmt/main/src/dndMsg.c
+0
-117
未找到文件。
source/dnode/mgmt/dm/src/dmMsg.c
浏览文件 @
b2bf8539
...
...
@@ -117,6 +117,107 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
static
int32_t
dndProcessCreateNodeMsg
(
SDnode
*
pDnode
,
ENodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
!=
NULL
)
{
dndReleaseWrapper
(
pWrapper
);
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
dError
(
"failed to create node since %s"
,
terrstr
());
return
-
1
;
}
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to create dir:%s since %s"
,
pWrapper
->
path
,
terrstr
());
return
-
1
;
}
int32_t
code
=
(
*
pWrapper
->
fp
.
createMsgFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
dError
(
"node:%s, failed to open since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
dDebug
(
"node:%s, has been opened"
,
pWrapper
->
name
);
pWrapper
->
deployed
=
true
;
}
return
code
;
}
static
int32_t
dndProcessDropNodeMsg
(
SDnode
*
pDnode
,
ENodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
==
NULL
)
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
dError
(
"failed to drop node since %s"
,
terrstr
());
return
-
1
;
}
taosWLockLatch
(
&
pWrapper
->
latch
);
pWrapper
->
deployed
=
false
;
int32_t
code
=
(
*
pWrapper
->
fp
.
dropMsgFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
pWrapper
->
deployed
=
true
;
dError
(
"node:%s, failed to drop since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
pWrapper
->
deployed
=
false
;
dDebug
(
"node:%s, has been dropped"
,
pWrapper
->
name
);
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
dndReleaseWrapper
(
pWrapper
);
return
code
;
}
int32_t
dndProcessNodeMsg
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
switch
(
pMsg
->
rpcMsg
.
msgType
)
{
case
TDMT_DND_CREATE_MNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_DROP_MNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_CREATE_QNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_DROP_QNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_CREATE_SNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_DROP_SNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_CREATE_BNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
case
TDMT_DND_DROP_BNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
return
-
1
;
}
}
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
}
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
};
rpcSendResponse
(
&
rpcRsp
);
}
void
dmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
dmProcessMgmtMsg
,
VND_VGID
);
...
...
source/dnode/mgmt/main/src/dndMsg.c
已删除
100644 → 0
浏览文件 @
6abfd9fe
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
static
int32_t
dndProcessCreateNodeMsg
(
SDnode
*
pDnode
,
ENodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
!=
NULL
)
{
dndReleaseWrapper
(
pWrapper
);
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
dError
(
"failed to create node since %s"
,
terrstr
());
return
-
1
;
}
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to create dir:%s since %s"
,
pWrapper
->
path
,
terrstr
());
return
-
1
;
}
int32_t
code
=
(
*
pWrapper
->
fp
.
createMsgFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
dError
(
"node:%s, failed to open since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
dDebug
(
"node:%s, has been opened"
,
pWrapper
->
name
);
pWrapper
->
deployed
=
true
;
}
return
code
;
}
static
int32_t
dndProcessDropNodeMsg
(
SDnode
*
pDnode
,
ENodeType
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
==
NULL
)
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
dError
(
"failed to drop node since %s"
,
terrstr
());
return
-
1
;
}
taosWLockLatch
(
&
pWrapper
->
latch
);
pWrapper
->
deployed
=
false
;
int32_t
code
=
(
*
pWrapper
->
fp
.
dropMsgFp
)(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
pWrapper
->
deployed
=
true
;
dError
(
"node:%s, failed to drop since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
pWrapper
->
deployed
=
false
;
dDebug
(
"node:%s, has been dropped"
,
pWrapper
->
name
);
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
dndReleaseWrapper
(
pWrapper
);
return
code
;
}
int32_t
dndProcessNodeMsg
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
)
{
switch
(
pMsg
->
rpcMsg
.
msgType
)
{
case
TDMT_DND_CREATE_MNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_DROP_MNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
MNODE
,
pMsg
);
case
TDMT_DND_CREATE_QNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_DROP_QNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
QNODE
,
pMsg
);
case
TDMT_DND_CREATE_SNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_DROP_SNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
SNODE
,
pMsg
);
case
TDMT_DND_CREATE_BNODE
:
return
dndProcessCreateNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
case
TDMT_DND_DROP_BNODE
:
return
dndProcessDropNodeMsg
(
pDnode
,
BNODE
,
pMsg
);
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
return
-
1
;
}
}
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
}
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
};
rpcSendResponse
(
&
rpcRsp
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录