Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d137ce1c
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看板
提交
d137ce1c
编写于
5月 25, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: create mnode handle
上级
28f6dcad
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
102 addition
and
99 deletion
+102
-99
include/common/tmsg.h
include/common/tmsg.h
+0
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+0
-2
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-1
source/dnode/mgmt/test/CMakeLists.txt
source/dnode/mgmt/test/CMakeLists.txt
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+100
-94
未找到文件。
include/common/tmsg.h
浏览文件 @
d137ce1c
...
...
@@ -1273,7 +1273,6 @@ int32_t tSerializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnod
int32_t
tDeserializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
typedef
struct
{
int32_t
dnodeId
;
int8_t
replica
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
}
SDCreateMnodeReq
,
SDAlterMnodeReq
;
...
...
source/common/src/tmsg.c
浏览文件 @
d137ce1c
...
...
@@ -3186,7 +3186,6 @@ int32_t tSerializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq *
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
dnodeId
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
replica
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
...
...
@@ -3204,7 +3203,6 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
dnodeId
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
replica
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
d137ce1c
...
...
@@ -79,7 +79,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
return
-
1
;
}
if
(
createReq
.
replica
<=
1
||
(
createReq
.
dnodeId
!=
pInput
->
pData
->
dnodeId
&&
pInput
->
pData
->
dnodeId
!=
0
)
)
{
if
(
createReq
.
replica
!=
1
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to create mnode since %s"
,
terrstr
());
return
-
1
;
...
...
source/dnode/mgmt/test/CMakeLists.txt
浏览文件 @
d137ce1c
...
...
@@ -3,7 +3,7 @@ if(${BUILD_TEST})
add_subdirectory
(
qnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
snode
)
add_subdirectory
(
mnode
)
#
add_subdirectory(mnode)
add_subdirectory
(
vnode
)
add_subdirectory
(
sut
)
endif
(
${
BUILD_TEST
}
)
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
d137ce1c
...
...
@@ -267,75 +267,83 @@ static int32_t mndSetCreateMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnod
}
static
int32_t
mndSetCreateMnodeRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SMnodeObj
*
pObj
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
SDAlterMnodeReq
alterReq
=
{
0
};
SDCreateMnodeReq
createReq
=
{
0
};
SEpSet
alterEpset
=
{
0
};
SEpSet
createEpset
=
{
0
};
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
if
(
pIter
==
NULL
)
break
;
SReplica
*
pReplica
=
&
createReq
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
pMObj
->
id
;
pReplica
->
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
numOfReplicas
++
;
alterReq
.
replicas
[
numOfReplicas
].
id
=
pMObj
->
id
;
alterReq
.
replicas
[
numOfReplicas
].
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
alterReq
.
replicas
[
numOfReplicas
].
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
alterEpset
.
eps
[
numOfReplicas
].
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
alterEpset
.
eps
[
numOfReplicas
].
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
if
(
pMObj
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
alterEpset
.
inUse
=
numOfReplicas
;
}
numOfReplicas
++
;
sdbRelease
(
pSdb
,
pMObj
);
}
SReplica
*
pReplica
=
&
createReq
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
pDnode
->
id
;
pReplica
->
port
=
pDnode
->
port
;
memcpy
(
pReplica
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
numOfReplicas
++
;
alterReq
.
replica
=
numOfReplicas
+
1
;
alterReq
.
replicas
[
numOfReplicas
].
id
=
pDnode
->
id
;
alterReq
.
replicas
[
numOfReplicas
].
port
=
pDnode
->
port
;
memcpy
(
alterReq
.
replicas
[
numOfReplicas
].
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
createReq
.
replica
=
numOfReplicas
;
alterEpset
.
numOfEps
=
numOfReplicas
+
1
;
alterEpset
.
eps
[
numOfReplicas
].
port
=
pDnode
->
port
;
memcpy
(
alterEpset
.
eps
[
numOfReplicas
].
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
)
;
if
(
pIter
==
NULL
)
break
;
createReq
.
replica
=
1
;
createReq
.
replicas
[
0
].
id
=
pDnode
->
id
;
createReq
.
replicas
[
0
].
port
=
pDnode
->
port
;
memcpy
(
createReq
.
replicas
[
0
].
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
)
;
STransAction
action
=
{
0
};
createEpset
.
numOfEps
=
1
;
createEpset
.
eps
[
0
].
port
=
pDnode
->
port
;
memcpy
(
createEpset
.
eps
[
0
].
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
createReq
.
dnodeId
=
pMObj
->
id
;
int32_t
contLen
=
tSerializeSDCreateMnodeReq
(
NULL
,
0
,
&
create
Req
);
{
int32_t
contLen
=
tSerializeSDCreateMnodeReq
(
NULL
,
0
,
&
alter
Req
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
create
Req
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alter
Req
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
STransAction
action
=
{
.
epSet
=
alterEpset
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_DND_ALTER_MNODE
,
.
acceptableCode
=
0
,
};
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
}
sdbRelease
(
pSdb
,
pMObj
);
}
{
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
createReq
.
dnodeId
=
pObj
->
id
;
int32_t
contLen
=
tSerializeSDCreateMnodeReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
createReq
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_DND_CREATE_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
STransAction
action
=
{
.
epSet
=
createEpset
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_DND_CREATE_MNODE
,
.
acceptableCode
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
,
};
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
...
...
@@ -441,73 +449,77 @@ static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeO
}
static
int32_t
mndSetDropMnodeRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SMnodeObj
*
pObj
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
int32_t
numOfReplicas
=
0
;
SDAlterMnodeReq
alterReq
=
{
0
};
SDDropMnodeReq
dropReq
=
{
0
};
SEpSet
alterEpset
=
{
0
};
SEpSet
dropEpSet
=
{
0
};
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pMObj
->
id
==
pObj
->
id
)
{
sdbRelease
(
pSdb
,
pMObj
);
continue
;
}
alterReq
.
replicas
[
numOfReplicas
].
id
=
pMObj
->
id
;
alterReq
.
replicas
[
numOfReplicas
].
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
alterReq
.
replicas
[
numOfReplicas
].
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
if
(
pMObj
->
id
!=
pObj
->
id
)
{
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
numOfReplicas
];
pReplica
->
id
=
pMObj
->
id
;
pReplica
->
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
pReplica
->
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
numOfReplicas
++
;
alterEpset
.
eps
[
numOfReplicas
].
port
=
pMObj
->
pDnode
->
port
;
memcpy
(
alterEpset
.
eps
[
numOfReplicas
].
fqdn
,
pMObj
->
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
if
(
pMObj
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
alterEpset
.
inUse
=
numOfReplicas
;
}
numOfReplicas
++
;
sdbRelease
(
pSdb
,
pMObj
);
}
alterReq
.
replica
=
numOfReplicas
;
alterEpset
.
numOfEps
=
numOfReplicas
;
while
(
1
)
{
SMnodeObj
*
pMObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pMObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pMObj
->
id
!=
pObj
->
id
)
{
STransAction
action
=
{
0
};
alterReq
.
dnodeId
=
pMObj
->
id
;
int32_t
contLen
=
tSerializeSDCreateMnodeReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
action
.
epSet
=
mndGetDnodeEpset
(
pMObj
->
pDnode
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pMObj
);
return
-
1
;
}
}
dropReq
.
dnodeId
=
pDnode
->
id
;
dropEpSet
.
numOfEps
=
1
;
dropEpSet
.
eps
[
0
].
port
=
pDnode
->
port
;
memcpy
(
dropEpSet
.
eps
[
0
].
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
sdbRelease
(
pSdb
,
pMObj
);
{
int32_t
contLen
=
tSerializeSDCreateMnodeReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
STransAction
action
=
{
.
epSet
=
alterEpset
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_DND_ALTER_MNODE
,
.
acceptableCode
=
0
,
};
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
}
{
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
SDDropMnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
pObj
->
id
;
int32_t
contLen
=
tSerializeSCreateDropMQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSCreateDropMQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_DND_DROP_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
STransAction
action
=
{
.
epSet
=
dropEpSet
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_DND_DROP_MNODE
,
.
acceptableCode
=
TSDB_CODE_NODE_NOT_DEPLOYED
,
};
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
...
...
@@ -662,7 +674,7 @@ static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {
}
static
int32_t
mndProcessAlterMnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SDAlterMnodeReq
alterReq
=
{
0
};
if
(
tDeserializeSDCreateMnodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
alterReq
)
!=
0
)
{
...
...
@@ -670,12 +682,6 @@ static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) {
return
-
1
;
}
if
(
alterReq
.
dnodeId
!=
pMnode
->
selfDnodeId
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
mError
(
"failed to alter mnode since %s, input:%d cur:%d"
,
terrstr
(),
alterReq
.
dnodeId
,
pMnode
->
selfDnodeId
);
return
-
1
;
}
SSyncCfg
cfg
=
{.
replicaNum
=
alterReq
.
replica
,
.
myIndex
=
-
1
};
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
cfg
.
nodeInfo
[
i
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录