Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c57b1574
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看板
提交
c57b1574
编写于
4月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact(cluster): node mgmt
上级
d812206e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
14 deletion
+39
-14
source/dnode/mgmt/implement/src/dmEps.c
source/dnode/mgmt/implement/src/dmEps.c
+6
-7
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
+13
-6
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+20
-1
未找到文件。
source/dnode/mgmt/implement/src/dmEps.c
浏览文件 @
c57b1574
...
...
@@ -45,7 +45,7 @@ int32_t dmReadEps(SDnode *pDnode) {
int32_t
maxLen
=
256
*
1024
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
char
file
[
PATH_MAX
];
char
file
[
PATH_MAX
]
=
{
0
}
;
TdFilePtr
pFile
=
NULL
;
pDnode
->
data
.
dnodeEps
=
taosArrayInit
(
1
,
sizeof
(
SDnodeEp
));
...
...
@@ -54,7 +54,7 @@ int32_t dmReadEps(SDnode *pDnode) {
goto
PRASE_DNODE_OVER
;
}
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json"
,
pDnode
->
data
.
dataDir
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json"
,
pDnode
->
wrappers
[
DNODE
].
path
,
TD_DIRSEP
);
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
if
(
pFile
==
NULL
)
{
// dDebug("file %s not exist", file);
...
...
@@ -175,8 +175,10 @@ PRASE_DNODE_OVER:
}
int32_t
dmWriteEps
(
SDnode
*
pDnode
)
{
char
file
[
PATH_MAX
];
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json.bak"
,
pDnode
->
data
.
dataDir
,
TD_DIRSEP
);
char
file
[
PATH_MAX
]
=
{
0
};
char
realfile
[
PATH_MAX
];
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode.json.bak"
,
pDnode
->
wrappers
[
DNODE
].
path
,
TD_DIRSEP
);
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode.json"
,
pDnode
->
wrappers
[
DNODE
].
path
,
TD_DIRSEP
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
...
...
@@ -215,9 +217,6 @@ int32_t dmWriteEps(SDnode *pDnode) {
taosCloseFile
(
&
pFile
);
taosMemoryFree
(
content
);
char
realfile
[
PATH_MAX
];
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode.json"
,
pDnode
->
data
.
dataDir
,
TD_DIRSEP
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
...
...
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
浏览文件 @
c57b1574
...
...
@@ -121,22 +121,29 @@ int32_t mmWriteFile(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq, bool deploye
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
if
(
pReq
!=
NULL
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
pReq
->
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
SMnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
if
(
pReq
!=
NULL
||
pMgmt
!=
NULL
)
{
int8_t
replica
=
(
pReq
!=
NULL
?
pReq
->
replica
:
pMgmt
->
replica
);
for
(
int32_t
i
=
0
;
i
<
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
if
(
pReq
!=
NULL
)
{
pReplica
=
&
pReq
->
replicas
[
i
];
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pReplica
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pReplica
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u
\n
"
,
pReplica
->
port
);
if
(
i
<
pReq
->
replica
-
1
)
{
if
(
i
<
replica
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }],
\n
"
);
}
}
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d
\n
"
,
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
c57b1574
...
...
@@ -103,7 +103,18 @@ int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq) {
if
(
mmBuildOptionFromReq
(
pMgmt
,
&
option
,
pReq
)
!=
0
)
{
return
-
1
;
}
return
mndAlter
(
pMgmt
->
pMnode
,
&
option
);
if
(
mndAlter
(
pMgmt
->
pMnode
,
&
option
)
!=
0
)
{
return
-
1
;
}
bool
deployed
=
true
;
if
(
mmWriteFile
(
pMgmt
->
pWrapper
,
pReq
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
void
mmClose
(
SMgmtWrapper
*
pWrapper
)
{
...
...
@@ -172,6 +183,14 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) {
return
-
1
;
}
if
(
!
deployed
)
{
deployed
=
true
;
if
(
mmWriteFile
(
pWrapper
,
NULL
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
}
}
dInfo
(
"mnode-mgmt is initialized"
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录