Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c67e0b62
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c67e0b62
编写于
5月 13, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
5月 13, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1897 from taosdata/feature/notifyTSDBstatus
tsdb notify the vnode about it status changes
上级
5119c4d8
4ee2cb13
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
15 deletion
+28
-15
src/inc/tsdb.h
src/inc/tsdb.h
+4
-2
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+6
-3
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+1
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+17
-10
未找到文件。
src/inc/tsdb.h
浏览文件 @
c67e0b62
...
...
@@ -34,12 +34,14 @@ extern "C" {
#define TSDB_INVALID_SUPER_TABLE_ID -1
#define TSDB_STATUS_COMMIT_START 1
#define TSDB_STATUS_COMMIT_OVER 2
// --------- TSDB APPLICATION HANDLE DEFINITION
typedef
struct
{
// WAL handle
void
*
appH
;
void
*
cqH
;
int
(
*
walCallBack
)(
void
*
);
int
(
*
notifyStatus
)(
void
*
,
int
status
);
int
(
*
eventCallBack
)(
void
*
);
}
STsdbAppH
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
c67e0b62
...
...
@@ -284,6 +284,7 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) {
pRepo
->
tsdbCache
->
curBlock
=
NULL
;
tsdbUnLockRepo
(
repo
);
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_START
);
tsdbCommitData
((
void
*
)
repo
);
tsdbCloseFileH
(
pRepo
->
tsdbFileH
);
...
...
@@ -330,7 +331,7 @@ int32_t tsdbConfigRepo(TsdbRepoT *repo, STsdbCfg *pCfg) {
int32_t
tsdbTriggerCommit
(
TsdbRepoT
*
repo
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
if
(
pRepo
->
appH
.
walCallBack
)
pRepo
->
appH
.
walCallBack
(
pRepo
->
appH
.
appH
);
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_START
);
tsdbLockRepo
(
repo
);
if
(
pRepo
->
commit
)
{
...
...
@@ -942,7 +943,6 @@ static void tsdbFreeMemTable(SMemTable *pMemTable) {
// Commit to file
static
void
*
tsdbCommitData
(
void
*
arg
)
{
printf
(
"Starting to commit....
\n
"
);
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
arg
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbCache
*
pCache
=
pRepo
->
tsdbCache
;
...
...
@@ -951,6 +951,8 @@ static void *tsdbCommitData(void *arg) {
SRWHelper
whelper
=
{
0
};
if
(
pCache
->
imem
==
NULL
)
return
NULL
;
tsdbPrint
(
"vgId: %d, starting to commit...."
,
pRepo
->
config
.
tsdbId
);
// Create the iterator to read from cache
SSkipListIterator
**
iters
=
tsdbCreateTableIters
(
pMeta
,
pCfg
->
maxTables
);
if
(
iters
==
NULL
)
{
...
...
@@ -974,6 +976,7 @@ static void *tsdbCommitData(void *arg) {
// Do retention actions
tsdbFitRetention
(
pRepo
);
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_OVER
);
_exit:
tdFreeDataCols
(
pDataCols
);
...
...
@@ -1176,4 +1179,4 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *
magic
=
*
size
;
return
magic
;
}
\ No newline at end of file
}
src/vnode/inc/vnodeInt.h
浏览文件 @
c67e0b62
...
...
@@ -38,6 +38,7 @@ typedef struct {
int
status
;
int8_t
role
;
int64_t
version
;
int64_t
savedVersion
;
void
*
wqueue
;
void
*
rqueue
;
void
*
wal
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
c67e0b62
...
...
@@ -33,12 +33,11 @@ static int32_t tsOpennedVnodes;
static
void
*
tsDnodeVnodesHash
;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
void
vnodeBuildVloadMsg
(
char
*
pNode
,
void
*
param
);
static
int
vnodeWalCallback
(
void
*
arg
);
static
int32_t
vnodeSaveCfg
(
SMDCreateVnodeMsg
*
pVnodeCfg
);
static
int32_t
vnodeReadCfg
(
SVnodeObj
*
pVnode
);
static
int32_t
vnodeSaveVersion
(
SVnodeObj
*
pVnode
);
static
bool
vnodeReadVersion
(
SVnodeObj
*
pVnode
);
static
int
vnode
WalCallback
(
void
*
arg
);
static
int
vnode
ProcessTsdbStatus
(
void
*
arg
,
int
status
);
static
uint32_t
vnodeGetFileInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
,
int32_t
*
size
);
static
int
vnodeGetWalInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
);
static
void
vnodeNotifyRole
(
void
*
ahandle
,
int8_t
role
);
...
...
@@ -206,7 +205,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
STsdbAppH
appH
=
{
0
};
appH
.
appH
=
(
void
*
)
pVnode
;
appH
.
walCallBack
=
vnodeWalCallback
;
appH
.
notifyStatus
=
vnodeProcessTsdbStatus
;
appH
.
cqH
=
pVnode
->
cq
;
sprintf
(
temp
,
"%s/tsdb"
,
rootDir
);
...
...
@@ -374,14 +373,22 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
walClose
(
pVnode
->
wal
);
pVnode
->
wal
=
NULL
;
vnodeSaveVersion
(
pVnode
);
vnodeRelease
(
pVnode
);
}
// TODO: this is a simple implement
static
int
vnode
WalCallback
(
void
*
arg
)
{
static
int
vnode
ProcessTsdbStatus
(
void
*
arg
,
int
status
)
{
SVnodeObj
*
pVnode
=
arg
;
return
walRenew
(
pVnode
->
wal
);
if
(
status
==
TSDB_STATUS_COMMIT_START
)
{
pVnode
->
savedVersion
=
pVnode
->
version
;
return
walRenew
(
pVnode
->
wal
);
}
if
(
status
==
TSDB_STATUS_COMMIT_OVER
)
return
vnodeSaveVersion
(
pVnode
);
return
0
;
}
static
uint32_t
vnodeGetFileInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
,
int32_t
*
size
)
{
...
...
@@ -414,7 +421,7 @@ static void vnodeNotifyFileSynced(void *ahandle) {
tsdbCloseRepo
(
pVnode
->
tsdb
);
STsdbAppH
appH
=
{
0
};
appH
.
appH
=
(
void
*
)
pVnode
;
appH
.
walCallBack
=
vnodeWalCallback
;
appH
.
notifyStatus
=
vnodeProcessTsdbStatus
;
appH
.
cqH
=
pVnode
->
cq
;
pVnode
->
tsdb
=
tsdbOpenRepo
(
rootDir
,
&
appH
);
}
...
...
@@ -685,14 +692,14 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
version
\"
: %"
PRId64
"
\n
"
,
pVnode
->
v
ersion
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
version
\"
: %"
PRId64
"
\n
"
,
pVnode
->
savedV
ersion
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
fwrite
(
content
,
1
,
len
,
fp
);
fclose
(
fp
);
free
(
content
);
vPrint
(
"vgId:%d, save vnode version:%"
PRId64
" succe
ssed"
,
pVnode
->
vgId
,
pVnode
->
v
ersion
);
vPrint
(
"vgId:%d, save vnode version:%"
PRId64
" succe
ed"
,
pVnode
->
vgId
,
pVnode
->
savedV
ersion
);
return
0
;
}
...
...
@@ -734,7 +741,7 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) {
ret
=
true
;
vPrint
(
"vgId:%d, read vnode version succe
ssed, version:%
%"
PRId64
,
pVnode
->
vgId
,
pVnode
->
version
);
vPrint
(
"vgId:%d, read vnode version succe
ed, version:
%"
PRId64
,
pVnode
->
vgId
,
pVnode
->
version
);
PARSE_OVER:
free
(
content
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录