Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e861bdeb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e861bdeb
编写于
11月 29, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
018661e1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
81 addition
and
46 deletion
+81
-46
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+21
-16
source/dnode/vnode/impl/src/vnodeRequest.c
source/dnode/vnode/impl/src/vnodeRequest.c
+37
-4
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+14
-17
source/dnode/vnode/impl/test/vnodeApiTests.cpp
source/dnode/vnode/impl/test/vnodeApiTests.cpp
+9
-9
未找到文件。
include/dnode/vnode/vnode.h
浏览文件 @
e861bdeb
...
...
@@ -144,9 +144,17 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
void
vnodeOptionsClear
(
SVnodeCfg
*
pOptions
);
/* ------------------------ REQUESTS ------------------------ */
typedef
STbCfg
SVCreateTableReq
;
typedef
struct
{
tb_uid_t
uid
;
}
SVDropTableReq
;
typedef
struct
{
uint64_t
ver
;
char
req
[];
union
{
SVCreateTableReq
ctReq
;
SVDropTableReq
dtReq
;
};
}
SVnodeReq
;
typedef
struct
{
...
...
@@ -154,24 +162,21 @@ typedef struct {
char
info
[];
}
SVnodeRsp
;
/// Create table request
typedef
STbCfg
SVCreateTableReq
;
#define VNODE_INIT_CREATE_STB_REQ(VER, NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \
{ .ver = (VER), .ctReq = META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) }
int
vnodeBuildCreateTableReq
(
void
**
buf
,
const
SVCreateTableReq
*
pReq
);
void
*
vnodeParseCreateTableReq
(
void
*
buf
,
SVCreateTableReq
*
pReq
);
#define VNODE_INIT_CREATE_CTB_REQ(VER, NAME, TTL, KEEP, SUID, PTAG) \
{ .ver = (VER), .ctReq = META_INIT_CTB_CFG(NAME, TTL, KEEP, SUID, PTAG) }
/// Drop table request
typedef
struct
{
tb_uid_t
uid
;
}
SVDropTableReq
;
/// Alter table request
typedef
struct
{
// TODO
}
SVAlterTableReq
;
#define VNODE_INIT_CREATE_NTB_REQ(VER, NAME, TTL, KEEP, SUID, PSCHEMA) \
{ .ver = (VER), .ctReq = META_INIT_NTB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA) }
int
vnodeBuildReq
(
void
**
buf
,
const
SVnodeReq
*
pReq
,
uint8_t
type
);
void
*
vnodeParseReq
(
void
*
buf
,
SVnodeReq
*
pReq
,
uint8_t
type
);
int
vnodeCreateTable
(
SVnode
*
pVnode
,
SVCreateTableReq
*
pReq
,
SVnodeRsp
*
pRsp
);
int
vnodeDropTable
(
SVnode
*
pVnode
,
SVDropTableReq
*
pReq
,
SVnodeRsp
*
pRsp
);
int
vnodeAlterTable
(
SVnode
*
pVnode
,
SVAlterTableReq
*
pReq
,
SVnodeRsp
*
pRsp
);
// TODO
int
vnodeBuildCreateTableReq
(
void
**
buf
,
const
SVCreateTableReq
*
pReq
);
void
*
vnodeParseCreateTableReq
(
void
*
buf
,
SVCreateTableReq
*
pReq
);
/* ------------------------ FOR COMPILE ------------------------ */
...
...
source/dnode/vnode/impl/src/vnodeRequest.c
浏览文件 @
e861bdeb
...
...
@@ -15,6 +15,39 @@
#include "vnodeDef.h"
int
vnodeBuildReq
(
void
**
buf
,
const
SVnodeReq
*
pReq
,
uint8_t
type
)
{
int
tsize
=
0
;
tsize
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
switch
(
type
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
tsize
+=
vnodeBuildCreateTableReq
(
buf
,
&
(
pReq
->
ctReq
));
/* code */
break
;
default:
break
;
}
/* TODO */
return
tsize
;
}
void
*
vnodeParseReq
(
void
*
buf
,
SVnodeReq
*
pReq
,
uint8_t
type
)
{
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pReq
->
ver
));
switch
(
type
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
buf
=
vnodeParseCreateTableReq
(
buf
,
&
(
pReq
->
ctReq
));
break
;
default:
break
;
}
// TODO
return
buf
;
}
int
vnodeBuildCreateTableReq
(
void
**
buf
,
const
SVCreateTableReq
*
pReq
)
{
int
tsize
=
0
;
...
...
@@ -69,11 +102,11 @@ void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq) {
return
buf
;
}
int
vnodeBuildDropTableReq
(
void
**
buf
,
const
SVDropTableReq
*
pReq
)
{
// TODO
return
0
;
int
vnodeBuildDropTableReq
(
void
**
buf
,
const
SVDropTableReq
*
pReq
)
{
// TODO
return
0
;
}
void
*
vnodeParseDropTableReq
(
void
*
buf
,
SVDropTableReq
*
pReq
)
{
// TODO
// TODO
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
e861bdeb
...
...
@@ -23,10 +23,10 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
// ser request version
pVnodeReq
=
(
SVnodeReq
*
)
(
pMsg
->
pCont
);
pVnodeReq
->
ver
=
pVnode
->
state
.
processed
++
;
void
**
pBuf
=
&
(
pMsg
->
pCont
);
taosEncodeFixedU64
(
pBuf
,
pVnode
->
state
.
processed
++
)
;
if
(
walWrite
(
pVnode
->
pWal
,
pVnodeReq
->
ver
,
p
VnodeReq
->
req
,
pMsg
->
contLen
-
sizeof
(
pVnodeReq
->
ver
)
)
<
0
)
{
if
(
walWrite
(
pVnode
->
pWal
,
pVnodeReq
->
ver
,
p
Msg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
// TODO: handle error
}
}
...
...
@@ -36,9 +36,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
// Apply each request now
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pVnodeReq
=
(
SVnodeReq
*
)(
pMsg
->
pCont
);
SVCreateTableReq
ctReq
;
SVDropTableReq
dtReq
;
SVnodeReq
vReq
;
// Apply the request
{
...
...
@@ -47,29 +45,28 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
// TODO: handle error
}
memcpy
(
ptr
,
pVnodeReq
,
pMsg
->
contLen
);
// TODO: copy here need to be extended
memcpy
(
ptr
,
pMsg
->
pCont
,
pMsg
->
contLen
);
// todo: change the interface here
if
(
tqPushMsg
(
pVnode
->
pTq
,
ptr
,
pVnodeReq
->
ver
)
<
0
)
{
// // todo: change the interface here
uint64_t
ver
;
taosDecodeFixedU64
(
pMsg
->
pCont
,
&
ver
);
if
(
tqPushMsg
(
pVnode
->
pTq
,
ptr
,
ver
)
<
0
)
{
// TODO: handle error
}
vnodeParseReq
(
pMsg
->
pCont
,
&
vReq
,
pMsg
->
msgType
);
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
vnodeParseCreateTableReq
(
pVnodeReq
->
req
,
&
(
ctReq
));
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
ctReq
)
<
0
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vReq
.
ctReq
))
<
0
)
{
// TODO: handle error
}
// TODO: maybe need to clear the requst struct
break
;
case
TSDB_MSG_TYPE_DROP_TABLE
:
if
(
vnodeParseDropTableReq
(
pVnodeReq
->
req
,
&
(
dtReq
))
<
0
)
{
// TODO: handle error
}
if
(
metaDropTable
(
pVnode
->
pMeta
,
dtReq
.
uid
)
<
0
)
{
if
(
metaDropTable
(
pVnode
->
pMeta
,
vReq
.
dtReq
.
uid
)
<
0
)
{
// TODO: handle error
}
break
;
...
...
source/dnode/vnode/impl/test/vnodeApiTests.cpp
浏览文件 @
e861bdeb
...
...
@@ -17,18 +17,18 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
STSchema
*
pTagSchema
=
NULL
;
char
tbname
[
128
]
=
"st"
;
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
SRpcMsg
*
));
S
TbCfg
stbCfg
=
META_INIT_STB_CFG
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pSchema
,
pTagSchema
);
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
SRpcMsg
*
));
S
VnodeReq
vCreateSTbReq
=
VNODE_INIT_CREATE_STB_REQ
(
0
,
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pSchema
,
pTagSchema
);
int
zs
=
vnodeBuild
CreateTableReq
(
NULL
,
&
stbCfg
);
int
zs
=
vnodeBuild
Req
(
NULL
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
zs
);
pMsg
->
contLen
=
zs
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
SRpcMsg
));
void
**
pBuf
=
&
(
pMsg
->
pCont
);
vnodeBuild
CreateTableReq
(
pBuf
,
&
stbCfg
);
META_CLEAR_TB_CFG
(
&
stbCfg
);
vnodeBuild
Req
(
pBuf
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateSTbReq
);
taosArrayPush
(
pMsgs
,
&
(
pMsg
));
...
...
@@ -48,16 +48,16 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
SRow
*
pTag
=
NULL
;
char
tbname
[
128
];
sprintf
(
tbname
,
"tb%d"
,
i
*
batch
+
j
);
S
TbCfg
ctbCfg
=
META_INIT_CTB_CFG
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pTag
);
S
VnodeReq
vCreateCTbReq
=
VNODE_INIT_CREATE_CTB_REQ
(
0
,
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pTag
);
int
tz
=
vnodeBuild
CreateTableReq
(
NULL
,
&
ctbCfg
);
int
tz
=
vnodeBuild
Req
(
NULL
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
tz
);
pMsg
->
contLen
=
tz
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
*
pMsg
));
void
**
pBuf
=
&
(
pMsg
->
pCont
);
vnodeBuild
CreateTableReq
(
pBuf
,
&
ctbCfg
);
META_CLEAR_TB_CFG
(
&
ctbCfg
);
vnodeBuild
Req
(
pBuf
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateCTbReq
);
}
vnodeProcessWMsgs
(
pVnode
,
pMsgs
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录