Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
648c85f0
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
648c85f0
编写于
7月 05, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vnode init/cleanup resource
上级
0c91ffae
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
21 deletion
+18
-21
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+6
-0
src/inc/vnode.h
src/inc/vnode.h
+2
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+10
-21
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
648c85f0
...
...
@@ -135,6 +135,12 @@ int32_t dnodeInitMgmt() {
return
-
1
;
}
code
=
vonodeInitResources
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
dnodeCleanupMgmt
();
return
-
1
;
}
code
=
dnodeOpenVnodes
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
dnodeCleanupMgmt
();
...
...
src/inc/vnode.h
浏览文件 @
648c85f0
...
...
@@ -60,6 +60,8 @@ int32_t vnodeProcessWrite(void *pVnode, int qtype, void *pHead, void *item);
int32_t
vnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
);
void
vnodeBuildStatusMsg
(
void
*
param
);
void
vnodeSetAccess
(
SDMVgroupAccess
*
pAccess
,
int32_t
numOfVnodes
);
int32_t
vonodeInitResources
();
void
vnodeCleanupResources
();
int32_t
vnodeProcessRead
(
void
*
pVnode
,
SReadMsg
*
pReadMsg
);
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
648c85f0
...
...
@@ -34,8 +34,7 @@
#define TSDB_VNODE_VERSION_CONTENT_LEN 31
static
int32_t
tsOpennedVnodes
;
static
void
*
tsDnodeVnodesHash
;
static
SHashObj
*
tsDnodeVnodesHash
;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
int32_t
vnodeSaveCfg
(
SMDCreateVnodeMsg
*
pVnodeCfg
);
static
int32_t
vnodeReadCfg
(
SVnodeObj
*
pVnode
);
...
...
@@ -48,8 +47,6 @@ static void vnodeNotifyRole(void *ahandle, int8_t role);
static
void
vnodeNotifyFileSynced
(
void
*
ahandle
,
uint64_t
fversion
);
static
void
vnodeFreeqHandle
(
void
*
phandle
);
static
pthread_once_t
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
#ifndef _SYNC
tsync_h
syncStart
(
const
SSyncInfo
*
info
)
{
return
NULL
;
}
int32_t
syncForwardToPeer
(
tsync_h
shandle
,
void
*
pHead
,
void
*
mhandle
,
int
qtype
)
{
return
0
;
}
...
...
@@ -59,25 +56,28 @@ int syncGetNodesRole(tsync_h shandle, SNodesRole * cfg) { return 0; }
void
syncConfirmForward
(
tsync_h
shandle
,
uint64_t
version
,
int32_t
code
)
{}
#endif
static
void
vnodeInit
()
{
int32_t
vonodeInitResources
()
{
vnodeInitWriteFp
();
vnodeInitReadFp
();
tsDnodeVnodesHash
=
taosHashInit
(
TSDB_MAX_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
);
if
(
tsDnodeVnodesHash
==
NULL
)
{
vError
(
"failed to init vnode list"
);
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
void
vnodeCleanupResources
()
{
if
(
tsDnodeVnodesHash
!=
NULL
)
{
taosHashCleanup
(
tsDnodeVnodesHash
);
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
tsDnodeVnodesHash
=
NULL
;
}
}
int32_t
vnodeCreate
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
int32_t
code
;
pthread_once
(
&
vnodeModuleInit
,
vnodeInit
);
SVnodeObj
*
pTemp
=
(
SVnodeObj
*
)
taosHashGet
(
tsDnodeVnodesHash
,
(
const
char
*
)
&
pVnodeCfg
->
cfg
.
vgId
,
sizeof
(
int32_t
));
if
(
pTemp
!=
NULL
)
{
...
...
@@ -145,11 +145,6 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
}
int32_t
vnodeDrop
(
int32_t
vgId
)
{
if
(
tsDnodeVnodesHash
==
NULL
)
{
vDebug
(
"vgId:%d, failed to drop, vgId not exist"
,
vgId
);
return
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
SVnodeObj
**
ppVnode
=
(
SVnodeObj
**
)
taosHashGet
(
tsDnodeVnodesHash
,
(
const
char
*
)
&
vgId
,
sizeof
(
int32_t
));
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
{
vDebug
(
"vgId:%d, failed to drop, vgId not find"
,
vgId
);
...
...
@@ -188,7 +183,6 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
int32_t
vnodeOpen
(
int32_t
vnode
,
char
*
rootDir
)
{
char
temp
[
TSDB_FILENAME_LEN
];
pthread_once
(
&
vnodeModuleInit
,
vnodeInit
);
SVnodeObj
*
pVnode
=
calloc
(
sizeof
(
SVnodeObj
),
1
);
if
(
pVnode
==
NULL
)
{
...
...
@@ -196,7 +190,6 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
return
TAOS_SYSTEM_ERROR
(
errno
);
}
atomic_add_fetch_32
(
&
tsOpennedVnodes
,
1
);
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
pVnode
->
vgId
=
vnode
;
...
...
@@ -366,13 +359,11 @@ void vnodeRelease(void *pVnodeRaw) {
free
(
pVnode
);
int32_t
count
=
atomic_sub_fetch_32
(
&
tsOpennedVnodes
,
1
);
int32_t
count
=
taosHashGetSize
(
tsDnodeVnodesHash
);
vDebug
(
"vgId:%d, vnode is released, vnodes:%d"
,
vgId
,
count
);
}
void
*
vnodeGetVnode
(
int32_t
vgId
)
{
if
(
tsDnodeVnodesHash
==
NULL
)
return
NULL
;
SVnodeObj
**
ppVnode
=
(
SVnodeObj
**
)
taosHashGet
(
tsDnodeVnodesHash
,
(
const
char
*
)
&
vgId
,
sizeof
(
int32_t
));
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
...
...
@@ -425,8 +416,6 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SDMStatusMsg *pStatus) {
}
int32_t
vnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
)
{
if
(
tsDnodeVnodesHash
==
NULL
)
return
TSDB_CODE_SUCCESS
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
tsDnodeVnodesHash
);
while
(
taosHashIterNext
(
pIter
))
{
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录