Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7906e782
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
7906e782
编写于
11月 26, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-11265 refact dndVnodes
上级
0d57a4be
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
43 addition
and
50 deletion
+43
-50
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+1
-1
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+0
-18
source/dnode/mgmt/daemon/src/daemon.c
source/dnode/mgmt/daemon/src/daemon.c
+1
-1
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+6
-7
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+3
-3
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+29
-15
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+1
-0
source/dnode/vnode/impl/src/vnodeInt.c
source/dnode/vnode/impl/src/vnodeInt.c
+2
-5
未找到文件。
include/dnode/mgmt/dnode.h
浏览文件 @
7906e782
...
...
@@ -78,7 +78,7 @@ typedef struct {
* @brief data file's directory.
*
*/
char
dataDir
[
PATH_MAX
];
char
dataDir
[
TSDB_FILENAME_LEN
];
/**
* @brief local endpoint.
...
...
include/dnode/vnode/vnode.h
浏览文件 @
7906e782
...
...
@@ -184,27 +184,9 @@ typedef struct {
SRpcMsg
rpcMsg
[];
}
SVnodeMsg
;
typedef
struct
SDnode
SDnode
;
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
PutMsgToVnodeQFp
)(
SDnode
*
pDnode
,
int32_t
vgId
,
SVnodeMsg
*
pMsg
);
typedef
struct
{
PutMsgToVnodeQFp
putMsgToApplyQueueFp
;
SendMsgToDnodeFp
sendMsgToDnodeFp
;
SendMsgToMnodeFp
sendMsgToMnodeFp
;
}
SVnodePara
;
int32_t
vnodeInit
(
SVnodePara
);
void
vnodeCleanup
();
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
);
SVnode
*
vnodeCreate
(
int32_t
vgId
,
const
char
*
path
,
const
SVnodeCfg
*
pCfg
);
void
vnodeDrop
(
SVnode
*
pVnode
);
int32_t
vnodeCompact
(
SVnode
*
pVnode
);
int32_t
vnodeSync
(
SVnode
*
pVnode
);
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
);
SVnodeMsg
*
vnodeInitMsg
(
int32_t
msgNum
);
...
...
source/dnode/mgmt/daemon/src/daemon.c
浏览文件 @
7906e782
...
...
@@ -141,7 +141,7 @@ void dmnInitOption(SDnodeOpt *pOption) {
pOption
->
shellActivityTimer
=
tsShellActivityTimer
;
pOption
->
statusInterval
=
tsStatusInterval
;
pOption
->
serverPort
=
tsServerPort
;
tstrncpy
(
pOption
->
dataDir
,
tsDataDir
,
PATH_MAX
);
tstrncpy
(
pOption
->
dataDir
,
tsDataDir
,
TSDB_FILENAME_LEN
);
tstrncpy
(
pOption
->
localEp
,
tsLocalEp
,
TSDB_EP_LEN
);
tstrncpy
(
pOption
->
localFqdn
,
tsLocalFqdn
,
TSDB_FQDN_LEN
);
tstrncpy
(
pOption
->
firstEp
,
tsFirst
,
TSDB_EP_LEN
);
...
...
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
7906e782
...
...
@@ -455,12 +455,11 @@ static void *dnodeThreadRoutine(void *param) {
while
(
true
)
{
taosMsleep
(
ms
);
if
(
dndGetStat
(
pDnode
)
!=
DND_STAT_RUNNING
)
{
continue
;
}
pthread_testcancel
();
dndSendStatusMsg
(
pDnode
);
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
)
{
dndSendStatusMsg
(
pDnode
);
}
}
}
...
...
@@ -501,7 +500,7 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
}
dInfo
(
"dn
d
-dnode is initialized"
);
dInfo
(
"dn
ode
-dnode is initialized"
);
return
0
;
}
...
...
@@ -531,7 +530,7 @@ void dndCleanupDnode(SDnode *pDnode) {
}
dndWUnLockDnode
(
pDnode
);
dInfo
(
"dn
d
-dnode is cleaned up"
);
dInfo
(
"dn
ode
-dnode is cleaned up"
);
}
void
dndProcessDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
7906e782
...
...
@@ -616,7 +616,7 @@ static int32_t dndInitMnodeMgmtWorker(SDnode *pDnode) {
pPool
->
min
=
1
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -652,7 +652,7 @@ static int32_t dndInitMnodeReadWorker(SDnode *pDnode) {
pPool
->
min
=
0
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -703,7 +703,7 @@ static int32_t dndInitMnodeWriteWorker(SDnode *pDnode) {
pPool
->
min
=
0
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
7906e782
...
...
@@ -22,6 +22,7 @@ typedef struct {
int32_t
refCount
;
int8_t
dropped
;
int8_t
accessState
;
char
*
path
;
SVnode
*
pImpl
;
taos_queue
pWriteQ
;
taos_queue
pSyncQ
;
...
...
@@ -74,7 +75,7 @@ static int32_t dndPutMsgIntoVnodeApplyQueue(SDnode *pDnode, int32_t vgId, SVnode
static
SVnodeObj
*
dndAcquireVnode
(
SDnode
*
pDnode
,
int32_t
vgId
);
static
void
dndReleaseVnode
(
SDnode
*
pDnode
,
SVnodeObj
*
pVnode
);
static
int32_t
dndCreateVnodeWrapper
(
SDnode
*
pDnode
,
int32_t
vgId
,
SVnode
*
pImpl
);
static
int32_t
dndCreateVnodeWrapper
(
SDnode
*
pDnode
,
int32_t
vgId
,
char
*
path
,
SVnode
*
pImpl
);
static
void
dndDropVnodeWrapper
(
SDnode
*
pDnode
,
SVnodeObj
*
pVnode
);
static
SVnodeObj
**
dndGetVnodesFromHash
(
SDnode
*
pDnode
,
int32_t
*
numOfVnodes
);
static
int32_t
dndGetVnodesFromFile
(
SDnode
*
pDnode
,
SVnodeObj
**
ppVnodes
,
int32_t
*
numOfVnodes
);
...
...
@@ -125,7 +126,7 @@ static void dndReleaseVnode(SDnode *pDnode, SVnodeObj *pVnode) {
}
}
static
int32_t
dndCreateVnodeWrapper
(
SDnode
*
pDnode
,
int32_t
vgId
,
SVnode
*
pImpl
)
{
static
int32_t
dndCreateVnodeWrapper
(
SDnode
*
pDnode
,
int32_t
vgId
,
char
*
path
,
SVnode
*
pImpl
)
{
SVnodesMgmt
*
pMgmt
=
&
pDnode
->
vmgmt
;
SVnodeObj
*
pVnode
=
calloc
(
1
,
sizeof
(
SVnodeObj
));
if
(
pVnode
==
NULL
)
{
...
...
@@ -139,6 +140,12 @@ static int32_t dndCreateVnodeWrapper(SDnode *pDnode, int32_t vgId, SVnode *pImpl
pVnode
->
accessState
=
TSDB_VN_ALL_ACCCESS
;
pVnode
->
pImpl
=
pImpl
;
pVnode
->
path
=
tstrdup
(
path
);
if
(
pVnode
->
path
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
dndAllocVnodeQueryQueue
(
pDnode
,
pVnode
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -354,22 +361,25 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
static
int32_t
dndCreateVnode
(
SDnode
*
pDnode
,
int32_t
vgId
,
SVnodeCfg
*
pCfg
)
{
char
path
[
PATH_MAX
+
20
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s/vnode%d"
,
pDnode
->
dir
.
vnodes
,
vgId
);
SVnode
*
pImpl
=
vnodeCreate
(
vgId
,
path
,
pCfg
);
//
SVnode *pImpl = vnodeCreate(vgId, path, pCfg);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
NULL
);
if
(
pImpl
==
NULL
)
{
return
-
1
;
}
int32_t
code
=
dndCreateVnodeWrapper
(
pDnode
,
vgId
,
pImpl
);
int32_t
code
=
dndCreateVnodeWrapper
(
pDnode
,
vgId
,
p
ath
,
p
Impl
);
if
(
code
!=
0
)
{
vnodeDrop
(
pImpl
);
vnodeClose
(
pImpl
);
vnodeDestroy
(
path
);
terrno
=
code
;
return
code
;
}
code
=
dndWriteVnodesToFile
(
pDnode
);
if
(
code
!=
0
)
{
vnodeDrop
(
pImpl
);
vnodeClose
(
pImpl
);
vnodeDestroy
(
path
);
terrno
=
code
;
return
code
;
}
...
...
@@ -385,7 +395,8 @@ static int32_t dndDropVnode(SDnode *pDnode, SVnodeObj *pVnode) {
}
dndDropVnodeWrapper
(
pDnode
,
pVnode
);
vnodeDrop
(
pVnode
->
pImpl
);
vnodeClose
(
pVnode
->
pImpl
);
vnodeDestroy
(
pVnode
->
path
);
dndWriteVnodesToFile
(
pDnode
);
return
0
;
}
...
...
@@ -413,7 +424,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
dError
(
"vgId:%d, failed to open vnode by thread:%d"
,
pVnode
->
vgId
,
pThread
->
threadIndex
);
pThread
->
failed
++
;
}
else
{
dndCreateVnodeWrapper
(
pDnode
,
pVnode
->
vgId
,
pImpl
);
dndCreateVnodeWrapper
(
pDnode
,
pVnode
->
vgId
,
p
ath
,
p
Impl
);
dDebug
(
"vgId:%d, is opened by thread:%d"
,
pVnode
->
vgId
,
pThread
->
threadIndex
);
pThread
->
opened
++
;
}
...
...
@@ -433,7 +444,7 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
pMgmt
->
hash
=
taosHashInit
(
TSDB_MIN_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
if
(
pMgmt
->
hash
==
NULL
)
{
dError
(
"failed to init vnode hash"
);
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -874,13 +885,13 @@ static int32_t dndInitVnodeMgmtWorker(SDnode *pDnode) {
pPool
->
min
=
1
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pMgmt
->
pMgmtQ
=
tWorkerAllocQueue
(
pPool
,
pDnode
,
(
FProcessItem
)
dndProcessVnodeMgmtQueue
);
if
(
pMgmt
->
pMgmtQ
==
NULL
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -918,6 +929,7 @@ static int32_t dndAllocVnodeFetchQueue(SDnode *pDnode, SVnodeObj *pVnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
...
...
@@ -938,7 +950,8 @@ static int32_t dndInitVnodeReadWorker(SDnode *pDnode) {
pPool
->
min
=
(
int32_t
)
threadsForQuery
;
pPool
->
max
=
pPool
->
min
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pPool
=
&
pMgmt
->
fetchPool
;
...
...
@@ -946,7 +959,8 @@ static int32_t dndInitVnodeReadWorker(SDnode *pDnode) {
pPool
->
min
=
MIN
(
maxFetchThreads
,
pDnode
->
opt
.
numOfCores
);
pPool
->
max
=
pPool
->
min
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
TSDB_CODE_VND_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
...
...
@@ -998,7 +1012,7 @@ static int32_t dndInitVnodeWriteWorker(SDnode *pDnode) {
pPool
->
name
=
"vnode-write"
;
pPool
->
max
=
tsNumOfCores
;
if
(
tMWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -1036,7 +1050,7 @@ static int32_t dndInitVnodeSyncWorker(SDnode *pDnode) {
pPool
->
name
=
"vnode-sync"
;
pPool
->
max
=
maxThreads
;
if
(
tMWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
7906e782
...
...
@@ -116,6 +116,7 @@ static int32_t dndInitEnv(SDnode *pDnode, SDnodeOpt *pOptions) {
return
-
1
;
}
memcpy
(
&
pDnode
->
opt
,
pOptions
,
sizeof
(
SDnodeOpt
));
return
0
;
}
...
...
source/dnode/vnode/impl/src/vnodeInt.c
浏览文件 @
7906e782
...
...
@@ -17,9 +17,6 @@
#include "vnodeInt.h"
#include "tqueue.h"
int32_t
vnodeInit
(
SVnodePara
para
)
{
return
0
;
}
void
vnodeCleanup
()
{}
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
SVnode
*
vnodeCreate
(
int32_t
vgId
,
const
char
*
path
,
const
SVnodeCfg
*
pCfg
)
{
return
NULL
;
}
void
vnodeDrop
(
SVnode
*
pVnode
)
{}
...
...
@@ -31,7 +28,7 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { return 0; }
SVnodeMsg
*
vnodeInitMsg
(
int32_t
msgNum
)
{
SVnodeMsg
*
pMsg
=
taosAllocateQitem
(
msgNum
*
sizeof
(
SRpcMsg
*
)
+
sizeof
(
SVnodeMsg
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
else
{
pMsg
->
allocNum
=
msgNum
;
...
...
@@ -41,7 +38,7 @@ SVnodeMsg *vnodeInitMsg(int32_t msgNum) {
int32_t
vnodeAppendMsg
(
SVnodeMsg
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
if
(
pMsg
->
curNum
>=
pMsg
->
allocNum
)
{
return
TSDB_CODE_
VND_
OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMsg
->
rpcMsg
[
pMsg
->
curNum
++
]
=
*
pRpcMsg
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录