Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
28f6dcad
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
28f6dcad
编写于
5月 25, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/sync-mnode-integration' into fix/mnode
上级
35d9d801
60b65b9f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
28 deletion
+38
-28
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+36
-27
未找到文件。
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
28f6dcad
...
...
@@ -31,7 +31,8 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
SMnode
*
pMnode
=
pFsm
->
data
;
SSdbRaw
*
pRaw
=
pMsg
->
pCont
;
mTrace
(
"raw:%p, apply to sdb, ver:%"
PRId64
" role:%s"
,
pRaw
,
cbMeta
.
index
,
syncStr
(
cbMeta
.
state
));
mTrace
(
"raw:%p, apply to sdb, ver:%"
PRId64
" term:%"
PRId64
" role:%s"
,
pRaw
,
cbMeta
.
index
,
cbMeta
.
term
,
syncStr
(
cbMeta
.
state
));
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
sdbSetApplyIndex
(
pMnode
->
pSdb
,
cbMeta
.
index
);
sdbSetApplyTerm
(
pMnode
->
pSdb
,
cbMeta
.
term
);
...
...
tests/test/c/sdbDump.c
浏览文件 @
28f6dcad
...
...
@@ -20,10 +20,13 @@
#include "tconfig.h"
#include "tjson.h"
#define TMP_SDB_DATA_DIR "/tmp/dumpsdb"
#define TMP_SDB_MNODE_DIR "/tmp/dumpsdb/mnode"
#define TMP_SDB_FILE "/tmp/dumpsdb/mnode/data/sdb.data"
#define TMP_SDB_PATH "/tmp/dumpsdb/mnode/data"
#define TMP_DNODE_DIR "/tmp/dumpsdb"
#define TMP_MNODE_DIR "/tmp/dumpsdb/mnode"
#define TMP_SDB_DATA_DIR "/tmp/dumpsdb/mnode/data"
#define TMP_SDB_SYNC_DIR "/tmp/dumpsdb/mnode/sync"
#define TMP_SDB_DATA_FILE "/tmp/dumpsdb/mnode/data/sdb.data"
#define TMP_SDB_RAFT_CFG_FILE "/tmp/dumpsdb/mnode/sync/raft_config.json"
#define TMP_SDB_RAFT_STORE_FILE "/tmp/dumpsdb/mnode/sync/raft_store.json"
void
reportStartup
(
const
char
*
name
,
const
char
*
desc
)
{}
...
...
@@ -318,6 +321,10 @@ void dumpHeader(SSdb *pSdb, SJson *json) {
}
int32_t
dumpSdb
()
{
wDebugFlag
=
0
;
mDebugFlag
=
0
;
sDebugFlag
=
0
;
SMsgCb
msgCb
=
{
0
};
msgCb
.
reportStartupFp
=
reportStartup
;
msgCb
.
sendReqFp
=
sendReq
;
...
...
@@ -325,9 +332,10 @@ int32_t dumpSdb() {
msgCb
.
mgmt
=
(
SMgmtWrapper
*
)(
&
msgCb
);
// hack
tmsgSetDefault
(
&
msgCb
);
walInit
();
syncInit
();
SMnodeOpt
opt
=
{.
msgCb
=
msgCb
};
SMnode
*
pMnode
=
mndOpen
(
TMP_
SDB_
MNODE_DIR
,
&
opt
);
SMnode
*
pMnode
=
mndOpen
(
TMP_MNODE_DIR
,
&
opt
);
if
(
pMnode
==
NULL
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -369,13 +377,11 @@ int32_t dumpSdb() {
taosCloseFile
(
&
pFile
);
tjsonDelete
(
json
);
taosMemoryFree
(
pCont
);
taosRemoveDir
(
TMP_
SDB_DATA
_DIR
);
taosRemoveDir
(
TMP_
DNODE
_DIR
);
return
0
;
}
int32_t
parseArgs
(
int32_t
argc
,
char
*
argv
[])
{
char
file
[
PATH_MAX
]
=
{
0
};
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
...
...
@@ -388,20 +394,8 @@ int32_t parseArgs(int32_t argc, char *argv[]) {
printf
(
"'-c' requires a parameter, default is %s
\n
"
,
configDir
);
return
-
1
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-f"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
strlen
(
argv
[
++
i
])
>=
PATH_MAX
)
{
printf
(
"file path overflow"
);
return
-
1
;
}
tstrncpy
(
file
,
argv
[
i
],
PATH_MAX
);
}
else
{
printf
(
"'-f' requires a parameter, default is %s
\n
"
,
configDir
);
return
-
1
;
}
}
else
{
printf
(
"-c Configuration directory.
\n
"
);
printf
(
"-f Input sdb.data file.
\n
"
);
return
-
1
;
}
}
...
...
@@ -416,13 +410,28 @@ int32_t parseArgs(int32_t argc, char *argv[]) {
return
-
1
;
}
if
(
file
[
0
]
==
0
)
{
snprintf
(
file
,
PATH_MAX
,
"%s/mnode/data/sdb.data"
,
tsDataDir
);
}
strcpy
(
tsDataDir
,
TMP_SDB_DATA_DIR
);
taosMulMkDir
(
TMP_SDB_PATH
);
taosCopyFile
(
file
,
TMP_SDB_FILE
);
char
dataFile
[
PATH_MAX
]
=
{
0
};
char
raftCfgFile
[
PATH_MAX
]
=
{
0
};
char
raftStoreFile
[
PATH_MAX
]
=
{
0
};
snprintf
(
dataFile
,
PATH_MAX
,
"%s/mnode/data/sdb.data"
,
tsDataDir
);
snprintf
(
raftCfgFile
,
PATH_MAX
,
"%s/mnode/sync/raft_config.json"
,
tsDataDir
);
snprintf
(
raftStoreFile
,
PATH_MAX
,
"%s/mnode/sync/raft_store.json"
,
tsDataDir
);
char
cmd
[
PATH_MAX
*
2
]
=
{
0
};
snprintf
(
cmd
,
sizeof
(
cmd
),
"rm -rf %s"
,
TMP_DNODE_DIR
);
system
(
cmd
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"mkdir -p %s"
,
TMP_SDB_DATA_DIR
);
system
(
cmd
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"mkdir -p %s"
,
TMP_SDB_SYNC_DIR
);
system
(
cmd
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"cp %s %s 2>/dev/null"
,
dataFile
,
TMP_SDB_DATA_FILE
);
system
(
cmd
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"cp %s %s 2>/dev/null"
,
raftCfgFile
,
TMP_SDB_RAFT_CFG_FILE
);
system
(
cmd
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"cp %s %s 2>/dev/null"
,
raftStoreFile
,
TMP_SDB_RAFT_STORE_FILE
);
system
(
cmd
);
strcpy
(
tsDataDir
,
TMP_DNODE_DIR
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录