Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f99b20aa
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f99b20aa
编写于
5月 24, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: add standby option for mnode
上级
6cf9f50c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
22 deletion
+28
-22
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+1
-0
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+22
-20
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+4
-2
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+1
-0
未找到文件。
include/dnode/mnode/mnode.h
浏览文件 @
f99b20aa
...
...
@@ -29,6 +29,7 @@ extern "C" {
typedef
struct
SMnode
SMnode
;
typedef
struct
{
bool
isStandBy
;
bool
deploy
;
int8_t
replica
;
int8_t
selfIndex
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
f99b20aa
...
...
@@ -55,29 +55,31 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu
static
void
mmBuildOptionForOpen
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
)
{
pOption
->
msgCb
=
pMgmt
->
msgCb
;
#if 1
pOption
->
replica
=
1
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
if
(
pMgmt
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pReplica
->
id
=
pMgmt
->
replicas
[
i
].
id
;
pReplica
->
port
=
pMgmt
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
pMgmt
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
if
(
pMgmt
->
replica
>
1
)
{
pOption
->
replica
=
1
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
if
(
pMgmt
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pReplica
->
id
=
pMgmt
->
replicas
[
i
].
id
;
pReplica
->
port
=
pMgmt
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
pMgmt
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
}
}
}
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
#else
pOption
->
replica
=
pMgmt
->
replica
;
pOption
->
selfIndex
=
-
1
;
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
pOption
->
replica
;
++
i
)
{
if
(
pOption
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pOption
->
selfIndex
=
i
;
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
pOption
->
isStandBy
=
1
;
}
else
{
pOption
->
replica
=
pMgmt
->
replica
;
pOption
->
selfIndex
=
-
1
;
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
pOption
->
replica
;
++
i
)
{
if
(
pOption
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pOption
->
selfIndex
=
i
;
}
}
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
}
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
#endif
pOption
->
deploy
=
false
;
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
f99b20aa
...
...
@@ -121,7 +121,8 @@ int32_t mndInitSync(SMnode *pMnode) {
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
replicaNum
=
pMnode
->
replica
;
pCfg
->
myIndex
=
pMnode
->
selfIndex
;
mInfo
(
"start to open mnode sync, replica:%d myIndex:%d"
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
mInfo
(
"start to open mnode sync, replica:%d myIndex:%d standBy:%d"
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
,
pMgmt
->
isStandBy
);
for
(
int32_t
i
=
0
;
i
<
pMnode
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
tstrncpy
(
pNode
->
nodeFqdn
,
pMnode
->
replicas
[
i
].
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
...
...
@@ -201,7 +202,7 @@ bool mndIsMaster(SMnode *pMnode) {
int32_t
mndAlter
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
SSyncCfg
cfg
=
{.
replicaNum
=
pOption
->
replica
,
.
myIndex
=
pOption
->
selfIndex
};
mInfo
(
"start to alter mnode sync, replica:%d myIndex:%d
"
,
cfg
.
replicaNum
,
cfg
.
myIndex
);
mInfo
(
"start to alter mnode sync, replica:%d myIndex:%d
standBy:%d"
,
cfg
.
replicaNum
,
cfg
.
myIndex
,
pOption
->
isStandBy
);
for
(
int32_t
i
=
0
;
i
<
pOption
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
cfg
.
nodeInfo
[
i
];
tstrncpy
(
pNode
->
nodeFqdn
,
pOption
->
replicas
[
i
].
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
...
...
@@ -210,5 +211,6 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
}
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
pMgmt
->
isStandBy
=
pOption
->
isStandBy
;
return
syncReconfig
(
pMgmt
->
sync
,
&
cfg
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
f99b20aa
...
...
@@ -263,6 +263,7 @@ static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
msgCb
=
pOption
->
msgCb
;
pMnode
->
selfId
=
pOption
->
replicas
[
pOption
->
selfIndex
].
id
;
pMnode
->
syncMgmt
.
isStandBy
=
pOption
->
isStandBy
;
}
SMnode
*
mndOpen
(
const
char
*
path
,
const
SMnodeOpt
*
pOption
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录