Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1d54f14c
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1d54f14c
编写于
12月 14, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement commit threads and queue
上级
14ae798f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
130 addition
and
47 deletion
+130
-47
include/util/tmacro.h
include/util/tmacro.h
+3
-5
source/dnode/vnode/impl/inc/vnodeCommit.h
source/dnode/vnode/impl/inc/vnodeCommit.h
+0
-3
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+25
-0
source/dnode/vnode/impl/src/vnodeCommit.c
source/dnode/vnode/impl/src/vnodeCommit.c
+0
-9
source/dnode/vnode/impl/src/vnodeMain.c
source/dnode/vnode/impl/src/vnodeMain.c
+0
-30
source/dnode/vnode/impl/src/vnodeMgr.c
source/dnode/vnode/impl/src/vnodeMgr.c
+102
-0
未找到文件。
include/util/tmacro.h
浏览文件 @
1d54f14c
...
@@ -29,13 +29,11 @@ extern "C" {
...
@@ -29,13 +29,11 @@ extern "C" {
#define TD_MOD_UNCLEARD 0
#define TD_MOD_UNCLEARD 0
#define TD_MOD_CLEARD 1
#define TD_MOD_CLEARD 1
#define TD_DEF_MOD_INIT_FLAG(MOD) static int8_t MOD##InitFlag = TD_MOD_UNINITIALIZED
typedef
int8_t
td_mode_flag_t
;
#define TD_DEF_MOD_CLEAR_FLAG(MOD) static int8_t MOD##ClearFlag = TD_MOD_UNCLEARD
#define TD_CHECK_AND_SET_MODE_INIT(MOD) \
#define TD_CHECK_AND_SET_MODE_INIT(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNINITIALIZED, TD_MOD_INITIALIZED)
atomic_val_compare_exchange_8(&(MOD##InitFlag), TD_MOD_UNINITIALIZED, TD_MOD_INITIALIZED)
#define TD_CHECK_AND_SET_MOD_CLEAR(
MOD) atomic_val_compare_exchange_8(&(MOD##ClearFlag
), TD_MOD_UNCLEARD, TD_MOD_CLEARD)
#define TD_CHECK_AND_SET_MOD_CLEAR(
FLAG) atomic_val_compare_exchange_8((FLAG
), TD_MOD_UNCLEARD, TD_MOD_CLEARD)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/impl/inc/vnodeCommit.h
浏览文件 @
1d54f14c
...
@@ -22,9 +22,6 @@
...
@@ -22,9 +22,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int
vnodeInitCommit
(
uint16_t
nthreads
);
void
vnodeClearCommit
();
#define vnodeShouldCommit vnodeBufPoolIsFull
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/impl/inc/vnodeDef.h
浏览文件 @
1d54f14c
...
@@ -21,9 +21,11 @@
...
@@ -21,9 +21,11 @@
#include "tcoding.h"
#include "tcoding.h"
#include "tdlist.h"
#include "tdlist.h"
#include "tlockfree.h"
#include "tlockfree.h"
#include "tmacro.h"
#include "wal.h"
#include "wal.h"
#include "vnode.h"
#include "vnode.h"
#include "vnodeBufferPool.h"
#include "vnodeBufferPool.h"
#include "vnodeCfg.h"
#include "vnodeCfg.h"
#include "vnodeCommit.h"
#include "vnodeCommit.h"
...
@@ -37,6 +39,27 @@
...
@@ -37,6 +39,27 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SVnodeTask
{
TD_DLIST_NODE
(
SVnodeTask
);
void
*
arg
;
int
(
*
execute
)(
void
*
);
}
SVnodeTask
;
typedef
struct
SVnodeMgr
{
td_mode_flag_t
vnodeInitFlag
;
td_mode_flag_t
vnodeClearFlag
;
// For commit
bool
stop
;
uint16_t
nthreads
;
pthread_t
*
threads
;
pthread_mutex_t
mutex
;
pthread_cond_t
hasTask
;
TD_DLIST
(
SVnodeTask
)
queue
;
// For vnode Mgmt
}
SVnodeMgr
;
extern
SVnodeMgr
vnodeMgr
;
struct
SVnode
{
struct
SVnode
{
char
*
path
;
char
*
path
;
SVnodeCfg
config
;
SVnodeCfg
config
;
...
@@ -50,6 +73,8 @@ struct SVnode {
...
@@ -50,6 +73,8 @@ struct SVnode {
SVnodeFS
*
pFs
;
SVnodeFS
*
pFs
;
};
};
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/impl/src/vnodeCommit.c
浏览文件 @
1d54f14c
...
@@ -18,15 +18,6 @@
...
@@ -18,15 +18,6 @@
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
int
vnodeInitCommit
(
uint16_t
nthreads
)
{
// TODO
return
0
;
}
void
vnodeClearCommit
()
{
// TODO
}
int
vnodeAsyncCommit
(
SVnode
*
pVnode
)
{
int
vnodeAsyncCommit
(
SVnode
*
pVnode
)
{
#if 0
#if 0
if (vnodeStartCommit(pVnode) < 0) {
if (vnodeStartCommit(pVnode) < 0) {
...
...
source/dnode/vnode/impl/src/vnodeMain.c
浏览文件 @
1d54f14c
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tmacro.h"
#include "vnodeDef.h"
#include "vnodeDef.h"
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
...
@@ -21,35 +20,6 @@ static void vnodeFree(SVnode *pVnode);
...
@@ -21,35 +20,6 @@ static void vnodeFree(SVnode *pVnode);
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
);
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
);
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
);
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
);
TD_DEF_MOD_INIT_FLAG
(
vnode
);
TD_DEF_MOD_CLEAR_FLAG
(
vnode
);
int
vnodeInit
(
uint16_t
nthreads
)
{
if
(
TD_CHECK_AND_SET_MODE_INIT
(
vnode
)
==
TD_MOD_INITIALIZED
)
{
return
0
;
}
if
(
walInit
()
<
0
)
{
return
-
1
;
}
if
(
vnodeInitCommit
(
nthreads
)
<
0
)
{
return
-
1
;
}
return
0
;
}
void
vnodeClear
()
{
if
(
TD_CHECK_AND_SET_MOD_CLEAR
(
vnode
)
==
TD_MOD_CLEARD
)
{
return
;
}
walCleanUp
();
vnodeClearCommit
();
}
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
)
{
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
)
{
SVnode
*
pVnode
=
NULL
;
SVnode
*
pVnode
=
NULL
;
...
...
source/dnode/vnode/impl/src/vnodeMgr.c
0 → 100644
浏览文件 @
1d54f14c
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeDef.h"
SVnodeMgr
vnodeMgr
=
{.
vnodeInitFlag
=
TD_MOD_UNINITIALIZED
,
.
vnodeClearFlag
=
TD_MOD_UNCLEARD
,
.
stop
=
false
};
static
void
*
loop
(
void
*
arg
);
int
vnodeInit
(
uint16_t
nthreads
)
{
if
(
TD_CHECK_AND_SET_MODE_INIT
(
&
(
vnodeMgr
.
vnodeInitFlag
))
==
TD_MOD_INITIALIZED
)
{
return
0
;
}
// Start commit handers
if
(
nthreads
>
0
)
{
vnodeMgr
.
nthreads
=
nthreads
;
vnodeMgr
.
threads
=
(
pthread_t
*
)
calloc
(
nthreads
,
sizeof
(
pthread_t
));
if
(
vnodeMgr
.
threads
==
NULL
)
{
return
-
1
;
}
pthread_mutex_init
(
&
(
vnodeMgr
.
mutex
),
NULL
);
pthread_cond_init
(
&
(
vnodeMgr
.
hasTask
),
NULL
);
tDListInit
(
&
(
vnodeMgr
.
queue
));
for
(
uint16_t
i
=
0
;
i
<
nthreads
;
i
++
)
{
pthread_create
(
&
(
vnodeMgr
.
threads
[
i
]),
NULL
,
loop
,
NULL
);
}
}
else
{
// TODO: if no commit thread is set, then another mechanism should be
// given. Otherwise, it is a false.
ASSERT
(
0
);
}
if
(
walInit
()
<
0
)
{
return
-
1
;
}
return
0
;
}
void
vnodeClear
()
{
if
(
TD_CHECK_AND_SET_MOD_CLEAR
(
&
(
vnodeMgr
.
vnodeClearFlag
))
==
TD_MOD_CLEARD
)
{
return
;
}
walCleanUp
();
// Stop commit handler
pthread_mutex_lock
(
&
(
vnodeMgr
.
mutex
));
vnodeMgr
.
stop
=
true
;
pthread_cond_broadcast
(
&
(
vnodeMgr
.
hasTask
));
pthread_mutex_unlock
(
&
(
vnodeMgr
.
mutex
));
for
(
uint16_t
i
=
0
;
i
<
vnodeMgr
.
nthreads
;
i
++
)
{
pthread_join
(
vnodeMgr
.
threads
[
i
],
NULL
);
}
tfree
(
vnodeMgr
.
threads
);
pthread_cond_destroy
(
&
(
vnodeMgr
.
hasTask
));
pthread_mutex_destroy
(
&
(
vnodeMgr
.
mutex
));
}
static
void
*
loop
(
void
*
arg
)
{
SVnodeTask
*
pTask
;
for
(;;)
{
pthread_mutex_lock
(
&
(
vnodeMgr
.
mutex
));
for
(;;)
{
pTask
=
TD_DLIST_HEAD
(
&
(
vnodeMgr
.
queue
));
if
(
pTask
==
NULL
)
{
if
(
vnodeMgr
.
stop
)
{
pthread_mutex_unlock
(
&
(
vnodeMgr
.
mutex
));
return
NULL
;
}
else
{
pthread_cond_wait
(
&
(
vnodeMgr
.
hasTask
),
&
(
vnodeMgr
.
mutex
));
}
}
else
{
tDListPop
(
&
(
vnodeMgr
.
queue
),
pTask
);
break
;
}
}
pthread_mutex_unlock
(
&
(
vnodeMgr
.
mutex
));
(
*
(
pTask
->
execute
))(
pTask
->
arg
);
}
return
NULL
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录