Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e3478a52
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
e3478a52
编写于
11月 29, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
0d02f7fc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
101 addition
and
52 deletion
+101
-52
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+1
-1
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+5
-0
source/dnode/vnode/impl/inc/vnodeBufferPool.h
source/dnode/vnode/impl/inc/vnodeBufferPool.h
+3
-2
source/dnode/vnode/impl/inc/vnodeRequest.h
source/dnode/vnode/impl/inc/vnodeRequest.h
+4
-13
source/dnode/vnode/impl/src/vnodeBufferPool.c
source/dnode/vnode/impl/src/vnodeBufferPool.c
+23
-6
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+64
-28
source/dnode/vnode/meta/src/metaTable.c
source/dnode/vnode/meta/src/metaTable.c
+1
-2
未找到文件。
include/dnode/vnode/meta/meta.h
浏览文件 @
e3478a52
...
...
@@ -74,7 +74,7 @@ typedef struct STbCfg {
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pOptions
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
const
void
*
pReq
,
const
int
len
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaDropTable
(
SMeta
*
pMeta
,
const
void
*
pReq
,
const
int
len
);
int
metaCommit
(
SMeta
*
pMeta
);
...
...
include/dnode/vnode/vnode.h
浏览文件 @
e3478a52
...
...
@@ -131,6 +131,11 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
void
vnodeOptionsClear
(
SVnodeCfg
*
pOptions
);
/* ------------------------ REQUESTS ------------------------ */
typedef
struct
{
uint64_t
ver
;
char
req
[];
}
SVnodeReq
;
typedef
struct
{
int
err
;
char
info
[];
...
...
source/dnode/vnode/impl/inc/vnodeBufferPool.h
浏览文件 @
e3478a52
...
...
@@ -25,8 +25,9 @@ extern "C" {
typedef
struct
SVBufPool
SVBufPool
;
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
);
#ifdef __cplusplus
}
...
...
source/dnode/vnode/impl/inc/vnodeRequest.h
浏览文件 @
e3478a52
...
...
@@ -16,23 +16,14 @@
#ifndef _TD_VNODE_REQUEST_H_
#define _TD_VNODE_REQUEST_H_
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SVnodeReq
SVnodeReq
;
typedef
struct
SVnodeRsp
SVnodeRsp
;
typedef
enum
{}
EVReqT
;
typedef
enum
{}
EVRspT
;
struct
SVnodeReq
{
EVReqT
type
;
};
struct
SVnodeRsp
{
EVRspT
type
;
};
int
vnodeBuildCreateTableReq
(
const
SVCreateTableReq
*
pReq
,
char
*
msg
,
int
len
);
int
vnodeParseCreateTableReq
(
const
char
*
msg
,
int
len
,
SVCreateTableReq
*
pReq
);
#ifdef __cplusplus
}
...
...
source/dnode/vnode/impl/src/vnodeBufferPool.c
浏览文件 @
e3478a52
...
...
@@ -71,6 +71,7 @@ static SListNode * vBufPoolNewNode(uint64_t capacity, EVMemAllocatorT type);
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
);
static
SMemAllocator
*
vBufPoolCreateMA
(
SMemAllocatorFactory
*
pmaf
);
static
void
vBufPoolDestroyMA
(
SMemAllocatorFactory
*
pmaf
,
SMemAllocator
*
pma
);
static
void
*
vBufPoolMalloc
(
SVMemAllocator
*
pvma
,
uint64_t
size
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
)
{
uint64_t
capacity
;
...
...
@@ -129,6 +130,24 @@ void vnodeCloseBufPool(SVnode *pVnode) {
}
}
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
)
{
void
*
ptr
;
if
(
pVnode
->
pBufPool
->
inuse
==
NULL
)
{
SListNode
*
pNode
;
while
((
pNode
=
tdListPopHead
(
&
(
pVnode
->
pBufPool
->
free
)))
==
NULL
)
{
// todo
// tsem_wait();
ASSERT
(
0
);
}
pVnode
->
pBufPool
->
inuse
=
pNode
;
}
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pVnode
->
pBufPool
->
inuse
->
data
);
return
vBufPoolMalloc
(
pvma
,
size
);
}
/* ------------------------ STATIC METHODS ------------------------ */
static
void
vArenaAllocatorInit
(
SVArenaAllocator
*
pvaa
,
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
)
{
/* TODO */
pvaa
->
ssize
=
ssize
;
...
...
@@ -201,10 +220,8 @@ static void vBufPoolFreeNode(SListNode *pNode) {
free
(
pNode
);
}
static
void
*
vBufPoolMalloc
(
SMemAllocator
*
pma
,
uint64_t
size
)
{
SVMAWrapper
*
pvmaw
=
(
SVMAWrapper
*
)(
pma
->
impl
);
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pvmaw
->
pNode
->
data
);
void
*
ptr
=
NULL
;
static
void
*
vBufPoolMalloc
(
SVMemAllocator
*
pvma
,
uint64_t
size
)
{
void
*
ptr
=
NULL
;
if
(
pvma
->
type
==
E_V_ARENA_ALLOCATOR
)
{
SVArenaAllocator
*
pvaa
=
&
(
pvma
->
vaa
);
...
...
@@ -229,7 +246,7 @@ static void *vBufPoolMalloc(SMemAllocator *pma, uint64_t size) {
/* TODO */
}
return
NULL
;
return
ptr
;
}
static
SMemAllocator
*
vBufPoolCreateMA
(
SMemAllocatorFactory
*
pmaf
)
{
...
...
@@ -267,7 +284,7 @@ static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pmaf) {
pvmaw
->
pNode
=
pVnode
->
pBufPool
->
inuse
;
pma
->
impl
=
pvmaw
;
pma
->
malloc
=
vBufPoolMalloc
;
pma
->
malloc
=
NULL
;
pma
->
calloc
=
NULL
;
/* TODO */
pma
->
realloc
=
NULL
;
/* TODO */
pma
->
free
=
NULL
;
/* TODO */
...
...
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
e3478a52
...
...
@@ -16,46 +16,82 @@
#include "vnodeDef.h"
int
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
SRpcMsg
*
pReq
;
S
RpcMsg
*
pRsp
;
SRpcMsg
*
pMsg
;
S
VnodeReq
*
pVnodeReq
;
for
(
size_
t
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
p
Req
=
taosArrayGet
(
pMsgs
,
i
);
for
(
in
t
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
p
Msg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
vnodeApplyWMsg
(
pVnode
,
pReq
,
&
pRsp
);
// ser request version
pVnodeReq
=
(
SVnodeReq
*
)(
pMsg
->
pCont
);
pVnodeReq
->
ver
=
pVnode
->
state
.
processed
++
;
if
(
walWrite
(
pVnode
->
pWal
,
pVnodeReq
->
ver
,
pVnodeReq
->
req
,
pMsg
->
contLen
-
sizeof
(
pVnodeReq
->
ver
))
<
0
)
{
// TODO: handle error
}
}
return
0
;
}
walFsync
(
pVnode
->
pWal
,
false
);
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
// TODO
int
code
=
0
;
// Apply each request now
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pVnodeReq
=
(
SVnodeReq
*
)(
pMsg
->
pCont
);
SVCreateTableReq
ctReq
;
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
/* TODO */
return
-
1
;
// Apply the request
{
void
*
ptr
=
vnodeMalloc
(
pVnode
,
pMsg
->
contLen
);
if
(
ptr
==
NULL
)
{
// TODO: handle error
}
break
;
case
TSDB_MSG_TYPE_DROP_TABLE
:
if
(
metaDropTable
(
pVnode
->
pMeta
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
/* TODO */
return
-
1
;
memcpy
(
ptr
,
pVnodeReq
,
pMsg
->
contLen
);
// todo: change the interface here
if
(
tqPushMsg
(
pVnode
->
pTq
,
pVnodeReq
->
req
,
pVnodeReq
->
ver
)
<
0
)
{
// TODO: handle error
}
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
if
(
vnodeParseCreateTableReq
(
pVnodeReq
->
req
,
pMsg
->
contLen
-
sizeof
(
pVnodeReq
->
ver
),
&
(
ctReq
))
<
0
)
{
// TODO: handle error
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
ctReq
)
<
0
)
{
// TODO: handle error
}
// TODO: maybe need to clear the requst struct
break
;
case
TSDB_MSG_TYPE_DROP_TABLE
:
/* code */
break
;
case
TSDB_MSG_TYPE_SUBMIT
:
/* code */
break
;
default:
break
;
}
break
;
case
TSDB_MSG_TYPE_SUBMIT
:
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
/* TODO */
return
-
1
;
}
pVnode
->
state
.
applied
=
pVnodeReq
->
ver
;
// Check if it needs to commit
if
(
vnodeShouldCommit
(
pVnode
))
{
if
(
vnodeAsyncCommit
(
pVnode
)
<
0
)
{
// TODO: handle error
}
break
;
default:
break
;
}
}
return
0
;
}
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
// TODO
return
0
;
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/dnode/vnode/meta/src/metaTable.c
浏览文件 @
e3478a52
...
...
@@ -15,8 +15,7 @@
#include "metaDef.h"
int
metaCreateTable
(
SMeta
*
pMeta
,
const
void
*
pCont
,
const
int
len
)
{
STbCfg
*
pTbCfg
=
NULL
;
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
// Validate the tbOptions
if
(
metaValidateTbOptions
(
pMeta
,
pTbCfg
)
<
0
)
{
// TODO: handle error
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录