Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc3ead15
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看板
提交
cc3ead15
编写于
1月 17, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode2
上级
8b061f52
b5ba09fe
变更
101
展开全部
隐藏空白更改
内联
并排
Showing
101 changed file
with
2623 addition
and
1604 deletion
+2623
-1604
.devcontainer/devcontainer.json
.devcontainer/devcontainer.json
+2
-1
cmake/bdb_CMakeLists.txt.in
cmake/bdb_CMakeLists.txt.in
+1
-1
include/client/taos.h
include/client/taos.h
+1
-2
include/common/tmsg.h
include/common/tmsg.h
+48
-5
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-1
include/common/tname.h
include/common/tname.h
+0
-2
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-1
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
include/util/tcoding.h
include/util/tcoding.h
+1
-0
include/util/tdef.h
include/util/tdef.h
+1
-1
source/client/inc/clientHb.h
source/client/inc/clientHb.h
+0
-78
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+75
-15
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+4
-8
source/client/src/clientHb.c
source/client/src/clientHb.c
+69
-22
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+212
-62
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+4
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+156
-114
source/common/src/tmsg.c
source/common/src/tmsg.c
+66
-8
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-0
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
+11
-0
source/dnode/mgmt/impl/test/stb/dstb.cpp
source/dnode/mgmt/impl/test/stb/dstb.cpp
+139
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+5
-23
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+34
-0
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+28
-21
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+39
-0
source/dnode/mnode/impl/test/stb/CMakeLists.txt
source/dnode/mnode/impl/test/stb/CMakeLists.txt
+4
-4
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+12
-14
source/dnode/vnode/src/inc/metaCache.h
source/dnode/vnode/src/inc/metaCache.h
+0
-34
source/dnode/vnode/src/inc/metaCfg.h
source/dnode/vnode/src/inc/metaCfg.h
+0
-34
source/dnode/vnode/src/inc/metaDB.h
source/dnode/vnode/src/inc/metaDB.h
+0
-36
source/dnode/vnode/src/inc/metaDef.h
source/dnode/vnode/src/inc/metaDef.h
+38
-7
source/dnode/vnode/src/inc/metaQuery.h
source/dnode/vnode/src/inc/metaQuery.h
+0
-27
source/dnode/vnode/src/inc/metaTbCfg.h
source/dnode/vnode/src/inc/metaTbCfg.h
+0
-32
source/dnode/vnode/src/inc/metaTbTag.h
source/dnode/vnode/src/inc/metaTbTag.h
+0
-27
source/dnode/vnode/src/inc/metaTbUid.h
source/dnode/vnode/src/inc/metaTbUid.h
+0
-42
source/dnode/vnode/src/inc/tsdbHealth.h
source/dnode/vnode/src/inc/tsdbHealth.h
+0
-29
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+179
-0
source/dnode/vnode/src/inc/vnodeBufferPool.h
source/dnode/vnode/src/inc/vnodeBufferPool.h
+0
-41
source/dnode/vnode/src/inc/vnodeCfg.h
source/dnode/vnode/src/inc/vnodeCfg.h
+0
-34
source/dnode/vnode/src/inc/vnodeCommit.h
source/dnode/vnode/src/inc/vnodeCommit.h
+0
-33
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+0
-45
source/dnode/vnode/src/inc/vnodeMemAllocator.h
source/dnode/vnode/src/inc/vnodeMemAllocator.h
+0
-53
source/dnode/vnode/src/inc/vnodeWrite.h
source/dnode/vnode/src/inc/vnodeWrite.h
+0
-31
source/dnode/vnode/src/meta/metaMain.c
source/dnode/vnode/src/meta/metaMain.c
+5
-5
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+4
-4
source/dnode/vnode/src/tsdb/tsdbHealth.c
source/dnode/vnode/src/tsdb/tsdbHealth.c
+0
-98
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+1
-12
source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c
source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c
+0
-30
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+4
-2
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
+1
-1
source/dnode/vnode/src/vnd/vnodeBufferPool.c
source/dnode/vnode/src/vnd/vnodeBufferPool.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+1
-1
source/dnode/vnode/src/vnd/vnodeInt.c
source/dnode/vnode/src/vnd/vnodeInt.c
+2
-1
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+1
-1
source/dnode/vnode/src/vnd/vnodeMgr.c
source/dnode/vnode/src/vnd/vnodeMgr.c
+1
-1
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+2
-1
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+3
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+14
-14
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+31
-26
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+278
-104
source/libs/function/src/tscalarfunction.c
source/libs/function/src/tscalarfunction.c
+0
-1
source/libs/parser/inc/astGenerator.h
source/libs/parser/inc/astGenerator.h
+0
-2
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+1
-1
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+3
-2
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+24
-2
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+2
-0
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+8
-3
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+3
-3
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+28
-7
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+3
-2
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+30
-14
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+3
-1
source/libs/tdb/CMakeLists.txt
source/libs/tdb/CMakeLists.txt
+8
-7
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+10
-6
source/libs/tdb/src/db/tdbDB.c
source/libs/tdb/src/db/tdbDB.c
+67
-0
source/libs/tdb/src/dmgr/tdbDiskMgr.c
source/libs/tdb/src/dmgr/tdbDiskMgr.c
+0
-0
source/libs/tdb/src/inc/tdbBtree.h
source/libs/tdb/src/inc/tdbBtree.h
+3
-1
source/libs/tdb/src/inc/tdbDB.h
source/libs/tdb/src/inc/tdbDB.h
+8
-4
source/libs/tdb/src/inc/tdbDef.h
source/libs/tdb/src/inc/tdbDef.h
+5
-4
source/libs/tdb/src/inc/tdbHash.h
source/libs/tdb/src/inc/tdbHash.h
+5
-3
source/libs/tdb/src/inc/tdbHeap.h
source/libs/tdb/src/inc/tdbHeap.h
+9
-7
source/libs/tdb/src/mpool/tdbBufPool.c
source/libs/tdb/src/mpool/tdbBufPool.c
+0
-0
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+2
-2
source/libs/transport/CMakeLists.txt
source/libs/transport/CMakeLists.txt
+7
-0
source/libs/transport/inc/rpcHead.h
source/libs/transport/inc/rpcHead.h
+0
-5
source/libs/transport/inc/rpcTcp.h
source/libs/transport/inc/rpcTcp.h
+0
-4
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+52
-2
source/libs/transport/src/rpcCache.c
source/libs/transport/src/rpcCache.c
+0
-4
source/libs/transport/src/rpcMain.c
source/libs/transport/src/rpcMain.c
+31
-237
source/libs/transport/src/rpcTcp.c
source/libs/transport/src/rpcTcp.c
+5
-10
source/libs/transport/src/rpcUdp.c
source/libs/transport/src/rpcUdp.c
+0
-4
source/libs/transport/src/transport.c
source/libs/transport/src/transport.c
+732
-0
source/libs/transport/test/CMakeLists.txt
source/libs/transport/test/CMakeLists.txt
+21
-0
source/libs/transport/test/transportTests.cc
source/libs/transport/test/transportTests.cc
+17
-18
source/libs/transport/test/transportTests.cpp
source/libs/transport/test/transportTests.cpp
+0
-0
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+35
-44
source/util/src/terror.c
source/util/src/terror.c
+2
-1
tests/test/c/create_table.c
tests/test/c/create_table.c
+13
-7
未找到文件。
.devcontainer/devcontainer.json
浏览文件 @
cc3ead15
...
...
@@ -26,7 +26,8 @@
"eamodio.gitlens"
,
"matepek.vscode-catch2-test-adapter"
,
"spmeesseman.vscode-taskexplorer"
,
"cschlosser.doxdocgen"
"cschlosser.doxdocgen"
,
"urosvujosevic.explorer-manager"
],
//
Use
'forwardPorts'
to
make
a
list
of
ports
inside
the
container
available
locally.
//
"forwardPorts"
:
[],
...
...
cmake/bdb_CMakeLists.txt.in
浏览文件 @
cc3ead15
...
...
@@ -6,7 +6,7 @@ ExternalProject_Add(bdb
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/bdb"
BINARY_DIR "${CMAKE_CONTRIB_DIR}/bdb"
#BUILD_IN_SOURCE TRUE
CONFIGURE_COMMAND
"./dist/configure"
CONFIGURE_COMMAND
COMMAND ./dist/configure --enable-debug
BUILD_COMMAND "$(MAKE)"
INSTALL_COMMAND ""
TEST_COMMAND ""
...
...
include/client/taos.h
浏览文件 @
cc3ead15
...
...
@@ -193,8 +193,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
);
DLL_EXPORT
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
DLL_EXPORT
TAOS_RES
*
taos_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
#ifdef __cplusplus
}
...
...
include/common/tmsg.h
浏览文件 @
cc3ead15
...
...
@@ -68,6 +68,14 @@ typedef uint16_t tmsg_t;
#define TSDB_IE_TYPE_DNODE_EXT 6
#define TSDB_IE_TYPE_DNODE_STATE 7
typedef
enum
{
HEARTBEAT_TYPE_MQ
=
0
,
HEARTBEAT_TYPE_QUERY
=
1
,
// types can be added here
//
HEARTBEAT_TYPE_MAX
}
EHbType
;
typedef
enum
_mgmt_table
{
TSDB_MGMT_TABLE_START
,
TSDB_MGMT_TABLE_ACCT
,
...
...
@@ -147,7 +155,7 @@ typedef struct {
typedef
struct
{
SClientHbKey
connKey
;
SHashObj
*
info
;
// hash<S
lv.key, Skl
v>
SHashObj
*
info
;
// hash<S
kv.key, Sk
v>
}
SClientHbReq
;
typedef
struct
{
...
...
@@ -173,7 +181,10 @@ static FORCE_INLINE uint32_t hbKeyHashFunc(const char* key, uint32_t keyLen) {
}
int
tSerializeSClientHbReq
(
void
**
buf
,
const
SClientHbReq
*
pReq
);
void
*
tDeserializeClientHbReq
(
void
*
buf
,
SClientHbReq
*
pReq
);
void
*
tDeserializeSClientHbReq
(
void
*
buf
,
SClientHbReq
*
pReq
);
int
tSerializeSClientHbRsp
(
void
**
buf
,
const
SClientHbRsp
*
pRsp
);
void
*
tDeserializeSClientHbRsp
(
void
*
buf
,
SClientHbRsp
*
pRsp
);
static
FORCE_INLINE
void
tFreeClientHbReq
(
void
*
pReq
)
{
SClientHbReq
*
req
=
(
SClientHbReq
*
)
pReq
;
...
...
@@ -182,14 +193,17 @@ static FORCE_INLINE void tFreeClientHbReq(void *pReq) {
}
int
tSerializeSClientHbBatchReq
(
void
**
buf
,
const
SClientHbBatchReq
*
pReq
);
void
*
tDeserializeClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pReq
);
void
*
tDeserialize
S
ClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pReq
);
static
FORCE_INLINE
void
tFreeClientHbBatchReq
(
void
*
pReq
)
{
SClientHbBatchReq
*
req
=
(
SClientHbBatchReq
*
)
pReq
;
taosArrayDestroyEx
(
req
->
reqs
,
tFreeClientHbReq
);
//
taosArrayDestroyEx(req->reqs, tFreeClientHbReq);
free
(
pReq
);
}
int
tSerializeSClientHbBatchRsp
(
void
**
buf
,
const
SClientHbBatchRsp
*
pBatchRsp
);
void
*
tDeserializeSClientHbBatchRsp
(
void
*
buf
,
SClientHbBatchRsp
*
pBatchRsp
);
static
FORCE_INLINE
int
taosEncodeSKv
(
void
**
buf
,
const
SKv
*
pKv
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pKv
->
keyLen
);
...
...
@@ -220,6 +234,7 @@ static FORCE_INLINE void* taosDecodeSClientHbKey(void* buf, SClientHbKey* pKey)
return
buf
;
}
typedef
struct
{
int32_t
vgId
;
char
*
dbName
;
...
...
@@ -359,6 +374,31 @@ static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEp) {
return
buf
;
}
typedef
struct
SMqHbRsp
{
int8_t
status
;
//idle or not
int8_t
vnodeChanged
;
int8_t
epChanged
;
// should use new epset
int8_t
reserved
;
SEpSet
epSet
;
}
SMqHbRsp
;
static
FORCE_INLINE
int
taosEncodeSMqHbRsp
(
void
**
buf
,
const
SMqHbRsp
*
pRsp
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pRsp
->
status
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pRsp
->
vnodeChanged
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pRsp
->
epChanged
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pRsp
->
epSet
);
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSMqHbRsp
(
void
*
buf
,
SMqHbRsp
*
pRsp
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
status
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
vnodeChanged
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
epChanged
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pRsp
->
epSet
);
return
buf
;
}
typedef
struct
{
int32_t
acctId
;
int64_t
clusterId
;
...
...
@@ -1060,6 +1100,7 @@ typedef struct {
typedef
struct
{
int8_t
igExists
;
char
*
name
;
char
*
sql
;
char
*
physicalPlan
;
char
*
logicalPlan
;
}
SCMCreateTopicReq
;
...
...
@@ -1068,6 +1109,7 @@ static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateT
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
igExists
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
sql
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
logicalPlan
);
return
tlen
;
...
...
@@ -1076,6 +1118,7 @@ static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateT
static
FORCE_INLINE
void
*
tDeserializeSCMCreateTopicReq
(
void
*
buf
,
SCMCreateTopicReq
*
pReq
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
igExists
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
sql
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
physicalPlan
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
logicalPlan
));
return
buf
;
...
...
@@ -1198,7 +1241,7 @@ typedef struct {
}
SMVSubscribeRsp
;
typedef
struct
{
char
name
[
TSDB_TOPIC_
F
NAME_LEN
];
char
name
[
TSDB_TOPIC_NAME_LEN
];
int8_t
igExists
;
int32_t
execLen
;
void
*
executor
;
...
...
include/common/tmsgdef.h
浏览文件 @
cc3ead15
...
...
@@ -129,7 +129,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_VGROUP_LIST
,
"mnode-vgroup-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_QUERY
,
"mnode-kill-query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_CONN
,
"mnode-kill-conn"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_HEARTBEAT
,
"mnode-heartbeat"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_HEARTBEAT
,
"mnode-heartbeat"
,
SClientHbBatchReq
,
SClientHbBatchRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW
,
"mnode-show"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW_RETRIEVE
,
"mnode-retrieve"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_STATUS
,
"mnode-status"
,
NULL
,
NULL
)
...
...
include/common/tname.h
浏览文件 @
cc3ead15
...
...
@@ -25,14 +25,12 @@
#define T_NAME_ACCT 0x1u
#define T_NAME_DB 0x2u
#define T_NAME_TABLE 0x4u
#define T_NAME_TOPIC 0x8u
typedef
struct
SName
{
uint8_t
type
;
//db_name_t, table_name_t
int32_t
acctId
;
char
dbname
[
TSDB_DB_NAME_LEN
];
char
tname
[
TSDB_TABLE_NAME_LEN
];
char
topicName
[
TSDB_TOPIC_NAME_LEN
];
}
SName
;
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
);
...
...
include/libs/parser/parser.h
浏览文件 @
cc3ead15
...
...
@@ -44,7 +44,7 @@ typedef struct SParseContext {
* @param msg extended error message if exists.
* @return error code
*/
int32_t
qParseQuerySql
(
SParseContext
*
pContext
,
SQueryNode
**
pQuery
);
int32_t
qParseQuerySql
(
SParseContext
*
pContext
,
SQueryNode
**
pQuery
Node
);
/**
* Return true if it is a ddl/dcl sql statement
...
...
include/libs/planner/planner.h
浏览文件 @
cc3ead15
...
...
@@ -95,6 +95,7 @@ typedef struct SScanPhyNode {
int8_t
tableType
;
int32_t
order
;
// scan order: TSDB_ORDER_ASC|TSDB_ORDER_DESC
int32_t
count
;
// repeat count
int32_t
reverse
;
// reverse scan count
}
SScanPhyNode
;
typedef
SScanPhyNode
SSystemTableScanPhyNode
;
...
...
include/util/taoserror.h
浏览文件 @
cc3ead15
无法预览此类型文件
include/util/tcoding.h
浏览文件 @
cc3ead15
...
...
@@ -351,6 +351,7 @@ static FORCE_INLINE void *taosDecodeString(void *buf, char **value) {
buf
=
taosDecodeVariantU64
(
buf
,
&
size
);
*
value
=
(
char
*
)
malloc
((
size_t
)
size
+
1
);
if
(
*
value
==
NULL
)
return
NULL
;
memcpy
(
*
value
,
buf
,
(
size_t
)
size
);
...
...
include/util/tdef.h
浏览文件 @
cc3ead15
...
...
@@ -181,7 +181,7 @@ do { \
#define TSDB_COL_NAME_LEN 65
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
#define TSDB_MAX_SQL_SHOW_LEN
512
#define TSDB_MAX_SQL_SHOW_LEN
1024
#define TSDB_MAX_ALLOWED_SQL_LEN (1*1024*1024u) // sql length should be less than 1mb
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
...
...
source/client/inc/clientHb.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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 "os.h"
#include "tarray.h"
#include "thash.h"
#include "tmsg.h"
#define HEARTBEAT_INTERVAL 1500 // ms
typedef
enum
{
HEARTBEAT_TYPE_MQ
=
0
,
// types can be added here
//
HEARTBEAT_TYPE_MAX
}
EHbType
;
typedef
int32_t
(
*
FHbRspHandle
)(
SClientHbRsp
*
pReq
);
typedef
struct
SAppHbMgr
{
// statistics
int32_t
reportCnt
;
int32_t
connKeyCnt
;
int64_t
reportBytes
;
// not implemented
int64_t
startTime
;
// ctl
SRWLatch
lock
;
// lock is used in serialization
// connection
void
*
transporter
;
SEpSet
epSet
;
// info
SHashObj
*
activeInfo
;
// hash<SClientHbKey, SClientHbReq>
SHashObj
*
getInfoFuncs
;
// hash<SClientHbKey, FGetConnInfo>
}
SAppHbMgr
;
typedef
struct
SClientHbMgr
{
int8_t
inited
;
// ctl
int8_t
threadStop
;
pthread_t
thread
;
pthread_mutex_t
lock
;
// used when app init and cleanup
SArray
*
appHbMgrs
;
// SArray<SAppHbMgr*> one for each cluster
FHbRspHandle
handle
[
HEARTBEAT_TYPE_MAX
];
}
SClientHbMgr
;
// TODO: embed param into function
// return type: SArray<Skv>
typedef
SArray
*
(
*
FGetConnInfo
)(
SClientHbKey
connKey
,
void
*
param
);
// global, called by mgmt
int
hbMgrInit
();
void
hbMgrCleanUp
();
int
hbHandleRsp
(
SClientHbBatchRsp
*
hbRsp
);
// cluster level
SAppHbMgr
*
appHbMgrInit
(
void
*
transporter
,
SEpSet
epSet
);
void
appHbMgrCleanup
(
SAppHbMgr
*
pAppHbMgr
);
// conn level
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
FGetConnInfo
func
);
void
hbDeregisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
);
int
hbAddConnInfo
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
);
// mq
void
hbMgrInitMqHbRspHandle
();
source/client/inc/clientInt.h
浏览文件 @
cc3ead15
...
...
@@ -31,6 +31,41 @@ extern "C" {
#include "trpc.h"
#include "query.h"
#define HEARTBEAT_INTERVAL 1500 // ms
typedef
struct
SAppInstInfo
SAppInstInfo
;
typedef
int32_t
(
*
FHbRspHandle
)(
SClientHbRsp
*
pReq
);
typedef
struct
SAppHbMgr
{
// statistics
int32_t
reportCnt
;
int32_t
connKeyCnt
;
int64_t
reportBytes
;
// not implemented
int64_t
startTime
;
// ctl
SRWLatch
lock
;
// lock is used in serialization
// connection
SAppInstInfo
*
pAppInstInfo
;
// info
SHashObj
*
activeInfo
;
// hash<SClientHbKey, SClientHbReq>
SHashObj
*
getInfoFuncs
;
// hash<SClientHbKey, FGetConnInfo>
}
SAppHbMgr
;
typedef
struct
SClientHbMgr
{
int8_t
inited
;
// ctl
int8_t
threadStop
;
pthread_t
thread
;
pthread_mutex_t
lock
;
// used when app init and cleanup
SArray
*
appHbMgrs
;
// SArray<SAppHbMgr*> one for each cluster
FHbRspHandle
handle
[
HEARTBEAT_TYPE_MAX
];
}
SClientHbMgr
;
// TODO: embed param into function
// return type: SArray<Skv>
typedef
SArray
*
(
*
FGetConnInfo
)(
SClientHbKey
connKey
,
void
*
param
);
typedef
struct
SQueryExecMetric
{
int64_t
start
;
// start timestamp
int64_t
parsed
;
// start to parse
...
...
@@ -55,15 +90,15 @@ typedef struct SHeartBeatInfo {
void
*
pTimer
;
// timer, used to send request msg to mnode
}
SHeartBeatInfo
;
typedef
struct
SAppInstInfo
{
int64_t
numOfConns
;
SCorEpSet
mgmtEp
;
SInstanceSummary
summary
;
struct
SAppInstInfo
{
int64_t
numOfConns
;
SCorEpSet
mgmtEp
;
SInstanceSummary
summary
;
SList
*
pConnList
;
// STscObj linked list
int64_t
clusterId
;
int64_t
clusterId
;
void
*
pTransporter
;
SHeartBeatInfo
hb
;
}
SAppInstInfo
;
struct
SAppHbMgr
*
pAppHbMgr
;
};
typedef
struct
SAppInfo
{
int64_t
startTime
;
...
...
@@ -81,13 +116,17 @@ typedef struct STscObj {
char
db
[
TSDB_DB_FNAME_LEN
];
int32_t
acctId
;
uint32_t
connId
;
int32_t
connType
;
uint64_t
id
;
// ref ID returned by taosAddRef
void
*
pTransporter
;
pthread_mutex_t
mutex
;
// used to protect the operation on db
int32_t
numOfReqs
;
// number of sqlObj
from this tscObj
int32_t
numOfReqs
;
// number of sqlObj
bound to this connection
SAppInstInfo
*
pAppInfo
;
}
STscObj
;
typedef
struct
SMqConsumer
{
STscObj
*
pTscObj
;
}
SMqConsumer
;
typedef
struct
SReqResultInfo
{
const
char
*
pRspMsg
;
const
char
*
pData
;
...
...
@@ -109,12 +148,13 @@ typedef struct SShowReqInfo {
}
SShowReqInfo
;
typedef
struct
SRequestSendRecvBody
{
tsem_t
rspSem
;
// not used now
void
*
fp
;
SShowReqInfo
showInfo
;
// todo this attribute will be removed after the query framework being completed.
struct
SSchJob
*
pQueryJob
;
// query job, created according to sql query DAG.
SDataBuf
requestMsg
;
SReqResultInfo
resInfo
;
tsem_t
rspSem
;
// not used now
void
*
fp
;
SShowReqInfo
showInfo
;
// todo this attribute will be removed after the query framework being completed.
SDataBuf
requestMsg
;
struct
SSchJob
*
pQueryJob
;
// query job, created according to sql query DAG.
struct
SQueryDag
*
pDag
;
// the query dag, generated according to the sql statement.
SReqResultInfo
resInfo
;
}
SRequestSendRecvBody
;
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
...
...
@@ -169,6 +209,26 @@ void *doFetchRow(SRequestObj* pRequest);
void
setResultDataPtr
(
SReqResultInfo
*
pResultInfo
,
TAOS_FIELD
*
pFields
,
int32_t
numOfCols
,
int32_t
numOfRows
);
// --- heartbeat
// global, called by mgmt
int
hbMgrInit
();
void
hbMgrCleanUp
();
int
hbHandleRsp
(
SClientHbBatchRsp
*
hbRsp
);
// cluster level
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
);
void
appHbMgrCleanup
(
SAppHbMgr
*
pAppHbMgr
);
// conn level
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
FGetConnInfo
func
);
void
hbDeregisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
);
int
hbAddConnInfo
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
);
// --- mq
void
hbMgrInitMqHbRspHandle
();
#ifdef __cplusplus
}
#endif
...
...
source/client/src/clientEnv.c
浏览文件 @
cc3ead15
...
...
@@ -89,13 +89,12 @@ static void tscInitLogFile() {
// todo close the transporter properly
void
closeTransporter
(
STscObj
*
pTscObj
)
{
if
(
pTscObj
==
NULL
||
pTscObj
->
pTransporter
==
NULL
)
{
if
(
pTscObj
==
NULL
||
pTscObj
->
p
AppInfo
->
p
Transporter
==
NULL
)
{
return
;
}
tscDebug
(
"free transporter:%p in connObj: 0x%"
PRIx64
,
pTscObj
->
pTransporter
,
pTscObj
->
id
);
rpcClose
(
pTscObj
->
pTransporter
);
pTscObj
->
pTransporter
=
NULL
;
tscDebug
(
"free transporter:%p in connObj: 0x%"
PRIx64
,
pTscObj
->
pAppInfo
->
pTransporter
,
pTscObj
->
id
);
rpcClose
(
pTscObj
->
pAppInfo
->
pTransporter
);
}
// TODO refactor
...
...
@@ -140,10 +139,6 @@ void* createTscObj(const char* user, const char* auth, const char *db, SAppInstI
}
pObj
->
pAppInfo
=
pAppInfo
;
if
(
pAppInfo
!=
NULL
)
{
pObj
->
pTransporter
=
pAppInfo
->
pTransporter
;
}
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
memcpy
(
pObj
->
pass
,
auth
,
TSDB_PASSWORD_LEN
);
...
...
@@ -199,6 +194,7 @@ static void doDestroyRequest(void* p) {
tfree
(
pRequest
->
pInfo
);
doFreeReqResultInfo
(
&
pRequest
->
body
.
resInfo
);
qDestroyQueryDag
(
pRequest
->
body
.
pDag
);
deregisterRequest
(
pRequest
);
tfree
(
pRequest
);
...
...
source/client/src/clientHb.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client
Hb
.h"
#include "client
Int
.h"
#include "trpc.h"
static
SClientHbMgr
clientHbMgr
=
{
0
};
...
...
@@ -21,10 +21,18 @@ static SClientHbMgr clientHbMgr = {0};
static
int32_t
hbCreateThread
();
static
void
hbStopThread
();
static
int32_t
hbMqHbRspHandle
(
SClientHbRsp
*
pR
eq
)
{
static
int32_t
hbMqHbRspHandle
(
SClientHbRsp
*
pR
sp
)
{
return
0
;
}
static
int32_t
hbMqAsyncCallBack
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
0
)
{
return
-
1
;
}
SClientHbRsp
*
pRsp
=
(
SClientHbRsp
*
)
pMsg
->
pData
;
return
hbMqHbRspHandle
(
pRsp
);
}
void
hbMgrInitMqHbRspHandle
()
{
clientHbMgr
.
handle
[
HEARTBEAT_TYPE_MQ
]
=
hbMqHbRspHandle
;
}
...
...
@@ -35,18 +43,18 @@ static FORCE_INLINE void hbMgrInitHandle() {
}
SClientHbBatchReq
*
hbGatherAllInfo
(
SAppHbMgr
*
pAppHbMgr
)
{
SClientHbBatchReq
*
pReq
=
malloc
(
sizeof
(
SClientHbBatchReq
));
if
(
pReq
==
NULL
)
{
SClientHbBatchReq
*
p
Batch
Req
=
malloc
(
sizeof
(
SClientHbBatchReq
));
if
(
p
Batch
Req
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
int32_t
connKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
pReq
->
reqs
=
taosArrayInit
(
connKeyCnt
,
sizeof
(
SClientHbReq
));
p
Batch
Req
->
reqs
=
taosArrayInit
(
connKeyCnt
,
sizeof
(
SClientHbReq
));
void
*
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
NULL
);
while
(
pIter
!=
NULL
)
{
taosArrayPush
(
pReq
->
reqs
,
pIter
);
SClientHbReq
*
pOneReq
=
pIter
;
taosArrayPush
(
pBatchReq
->
reqs
,
pOneReq
);
taosHashClear
(
pOneReq
->
info
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
...
...
@@ -59,10 +67,10 @@ SClientHbBatchReq* hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
taosHashCopyKey
(
pIter
,
&
connKey
);
getConnInfoFp
(
connKey
,
NULL
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
getInfoFuncs
,
pIter
);
}
return
pReq
;
return
p
Batch
Req
;
}
static
void
*
hbThreadFunc
(
void
*
param
)
{
...
...
@@ -75,20 +83,48 @@ static void* hbThreadFunc(void* param) {
int
sz
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SAppHbMgr
*
pAppHbMgr
=
taosArrayGet
(
clientHbMgr
.
appHbMgrs
,
i
);
SClientHbBatchReq
*
pReq
=
hbGatherAllInfo
(
pAppHbMgr
);
void
*
reqStr
=
NULL
;
int
tlen
=
tSerializeSClientHbBatchReq
(
&
reqStr
,
pReq
);
SMsgSendInfo
info
;
/*info.fp = hbHandleRsp;*/
SAppHbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
int32_t
connCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
if
(
connCnt
==
0
)
{
continue
;
}
SClientHbBatchReq
*
pReq
=
hbGatherAllInfo
(
pAppHbMgr
);
if
(
pReq
==
NULL
)
{
continue
;
}
int
tlen
=
tSerializeSClientHbBatchReq
(
NULL
,
pReq
);
void
*
buf
=
malloc
(
tlen
);
if
(
buf
==
NULL
)
{
//TODO: error handling
break
;
}
void
*
bufCopy
=
buf
;
tSerializeSClientHbBatchReq
(
&
bufCopy
,
pReq
);
SMsgSendInfo
*
pInfo
=
malloc
(
sizeof
(
SMsgSendInfo
));
if
(
pInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tFreeClientHbBatchReq
(
pReq
);
free
(
buf
);
break
;
}
pInfo
->
fp
=
hbMqAsyncCallBack
;
pInfo
->
msgInfo
.
pData
=
buf
;
pInfo
->
msgInfo
.
len
=
tlen
;
pInfo
->
msgType
=
TDMT_MND_HEARTBEAT
;
pInfo
->
param
=
NULL
;
pInfo
->
requestId
=
generateRequestId
();
pInfo
->
requestObjRefId
=
0
;
SAppInstInfo
*
pAppInstInfo
=
pAppHbMgr
->
pAppInstInfo
;
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pAppHbMgr
->
transporter
,
&
pAppHbMgr
->
epSet
,
&
transporterId
,
&
info
);
SEpSet
epSet
=
getEpSet_s
(
&
pAppInstInfo
->
mgmtEp
);
asyncSendMsgToServer
(
pAppInstInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
pInfo
);
tFreeClientHbBatchReq
(
pReq
);
atomic_add_fetch_32
(
&
pAppHbMgr
->
reportCnt
,
1
);
taosMsleep
(
HEARTBEAT_INTERVAL
);
}
taosMsleep
(
HEARTBEAT_INTERVAL
);
}
return
NULL
;
}
...
...
@@ -110,7 +146,8 @@ static void hbStopThread() {
atomic_store_8
(
&
clientHbMgr
.
threadStop
,
1
);
}
SAppHbMgr
*
appHbMgrInit
(
void
*
transporter
,
SEpSet
epSet
)
{
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
)
{
hbMgrInit
();
SAppHbMgr
*
pAppHbMgr
=
malloc
(
sizeof
(
SAppHbMgr
));
if
(
pAppHbMgr
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -119,16 +156,27 @@ SAppHbMgr* appHbMgrInit(void* transporter, SEpSet epSet) {
// init stat
pAppHbMgr
->
startTime
=
taosGetTimestampMs
();
// init connection info
pAppHbMgr
->
transporter
=
transporter
;
pAppHbMgr
->
epSet
=
epSet
;
// init app info
pAppHbMgr
->
pAppInstInfo
=
pAppInstInfo
;
// init hash info
pAppHbMgr
->
activeInfo
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
if
(
pAppHbMgr
->
activeInfo
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
free
(
pAppHbMgr
);
return
NULL
;
}
pAppHbMgr
->
activeInfo
->
freeFp
=
tFreeClientHbReq
;
// init getInfoFunc
pAppHbMgr
->
getInfoFuncs
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
if
(
pAppHbMgr
->
getInfoFuncs
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
free
(
pAppHbMgr
);
return
NULL
;
}
taosArrayPush
(
clientHbMgr
.
appHbMgrs
,
&
pAppHbMgr
);
return
pAppHbMgr
;
}
...
...
@@ -138,7 +186,7 @@ void appHbMgrCleanup(SAppHbMgr* pAppHbMgr) {
int
sz
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SAppHbMgr
*
pTarget
=
taosArrayGet
(
clientHbMgr
.
appHbMgrs
,
i
);
SAppHbMgr
*
pTarget
=
taosArrayGet
P
(
clientHbMgr
.
appHbMgrs
,
i
);
if
(
pAppHbMgr
==
pTarget
)
{
taosHashCleanup
(
pTarget
->
activeInfo
);
taosHashCleanup
(
pTarget
->
getInfoFuncs
);
...
...
@@ -171,7 +219,6 @@ void hbMgrCleanUp() {
if
(
old
==
0
)
return
;
taosArrayDestroy
(
clientHbMgr
.
appHbMgrs
);
}
int
hbHandleRsp
(
SClientHbBatchRsp
*
hbRsp
)
{
...
...
source/client/src/clientImpl.c
浏览文件 @
cc3ead15
...
...
@@ -13,12 +13,12 @@
#include "tpagedfile.h"
#include "tref.h"
#define CHECK_CODE_GOTO(expr, lab
le
) \
#define CHECK_CODE_GOTO(expr, lab
el
) \
do { \
int32_t code = expr; \
if (TSDB_CODE_SUCCESS != code) { \
terrno = code; \
goto lab
le
; \
goto lab
el
; \
} \
} while (0)
...
...
@@ -58,7 +58,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i
return
strdup
(
key
);
}
static
STscObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
,
SAppInstInfo
*
pAppInfo
);
static
STscObj
*
taosConnectImpl
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
,
SAppInstInfo
*
pAppInfo
);
static
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SDataBlockSchema
*
pDataBlockSchema
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
...
...
@@ -71,18 +71,18 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
return
NULL
;
}
char
tmp
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
localDb
[
TSDB_DB_NAME_LEN
]
=
{
0
};
if
(
db
!=
NULL
)
{
if
(
!
validateDbName
(
db
))
{
terrno
=
TSDB_CODE_TSC_INVALID_DB_LENGTH
;
return
NULL
;
}
tstrncpy
(
tmp
,
db
,
sizeof
(
tmp
));
strdequote
(
tmp
);
tstrncpy
(
localDb
,
db
,
sizeof
(
localDb
));
strdequote
(
localDb
);
}
char
secretEncrypt
[
32
]
=
{
0
};
char
secretEncrypt
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
if
(
auth
==
NULL
)
{
if
(
!
validatePassword
(
pass
))
{
terrno
=
TSDB_CODE_TSC_INVALID_PASS_LENGTH
;
...
...
@@ -111,18 +111,20 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
char
*
key
=
getClusterKey
(
user
,
secretEncrypt
,
ip
,
port
);
// TODO: race condition here.
SAppInstInfo
**
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
));
if
(
pInst
==
NULL
)
{
SAppInstInfo
*
p
=
calloc
(
1
,
sizeof
(
struct
SAppInstInfo
));
p
->
mgmtEp
=
epSet
;
p
->
pTransporter
=
openTransporter
(
user
,
secretEncrypt
,
tsNumOfCores
);
p
->
pAppHbMgr
=
appHbMgrInit
(
p
);
taosHashPut
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
),
&
p
,
POINTER_BYTES
);
pInst
=
&
p
;
}
tfree
(
key
);
return
taosConnectImpl
(
ip
,
user
,
&
secretEncrypt
[
0
],
d
b
,
port
,
NULL
,
NULL
,
*
pInst
);
return
taosConnectImpl
(
user
,
&
secretEncrypt
[
0
],
localD
b
,
port
,
NULL
,
NULL
,
*
pInst
);
}
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
)
{
...
...
@@ -152,13 +154,13 @@ int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery) {
SParseContext
cxt
=
{
.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
getConnectionDB
(
pTscObj
),
.
p
Transporter
=
pTscObj
->
pTransporte
r
,
.
pSql
=
pRequest
->
sqlstr
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
.
acctId
=
pTscObj
->
acctId
,
.
db
=
getConnectionDB
(
pTscObj
),
.
p
Sql
=
pRequest
->
sqlst
r
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
};
cxt
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
...
...
@@ -191,10 +193,10 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
pShowReqInfo
->
pArray
=
pDcl
->
pExtension
;
}
}
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pDcl
->
epSet
,
&
transporterId
,
pSendMsg
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
p
Transporter
,
&
pDcl
->
epSet
,
&
transporterId
,
pSendMsg
);
}
else
{
SEpSet
*
pEpSet
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
pEpSet
,
&
transporterId
,
pSendMsg
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
p
Transporter
,
pEpSet
,
&
transporterId
,
pSendMsg
);
}
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
...
...
@@ -241,7 +243,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag) {
if
(
TSDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL_CREATE_TABLE
==
pRequest
->
type
)
{
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
scheduleExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
&
pRequest
->
body
.
pQueryJob
,
&
res
);
int32_t
code
=
scheduleExecJob
(
pRequest
->
pTscObj
->
p
AppInfo
->
p
Transporter
,
NULL
,
pDag
,
&
pRequest
->
body
.
pQueryJob
,
&
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// handle error and retry
}
else
{
...
...
@@ -255,39 +257,160 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag) {
return
pRequest
->
code
;
}
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
&
pRequest
->
body
.
pQueryJob
);
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
p
AppInfo
->
p
Transporter
,
NULL
,
pDag
,
&
pRequest
->
body
.
pQueryJob
);
}
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQuery
=
NULL
;
SQueryDag
*
pDag
=
NULL
;
char
*
dagStr
=
NULL
;
typedef
struct
tmq_t
tmq_t
;
typedef
struct
SMqClientTopic
{
// subscribe info
int32_t
sqlLen
;
char
*
sql
;
char
*
topicName
;
int64_t
topicId
;
// statistics
int64_t
consumeCnt
;
// offset
int64_t
committedOffset
;
int64_t
currentOffset
;
//connection info
int32_t
vgId
;
SEpSet
epSet
;
}
SMqClientTopic
;
typedef
struct
tmq_resp_err_t
{
int32_t
code
;
}
tmq_resp_err_t
;
typedef
struct
tmq_topic_vgroup_list_t
{
char
*
topicName
;
int32_t
vgId
;
int64_t
committedOffset
;
}
tmq_topic_vgroup_list_t
;
typedef
void
(
tmq_commit_cb
(
tmq_t
*
,
tmq_resp_err_t
,
tmq_topic_vgroup_list_t
*
,
void
*
param
));
typedef
struct
tmq_conf_t
{
char
*
clientId
;
char
*
groupId
;
char
*
ip
;
uint16_t
port
;
tmq_commit_cb
*
commit_cb
;
}
tmq_conf_t
;
struct
tmq_t
{
char
groupId
[
256
];
char
clientId
[
256
];
STscObj
*
pTscObj
;
tmq_commit_cb
*
commit_cb
;
SArray
*
clientTopics
;
// SArray<SMqClientTopic>
};
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
)
{
conf
->
commit_cb
=
cb
;
}
SArray
*
tmqGetConnInfo
(
SClientHbKey
connKey
,
void
*
param
)
{
tmq_t
*
pTmq
=
(
void
*
)
param
;
SArray
*
pArray
=
taosArrayInit
(
0
,
sizeof
(
SKv
));
if
(
pArray
==
NULL
)
{
return
NULL
;
}
SKv
kv
=
{
0
};
kv
.
key
=
malloc
(
256
);
if
(
kv
.
key
==
NULL
)
{
taosArrayDestroy
(
pArray
);
return
NULL
;
}
strcpy
(
kv
.
key
,
"groupId"
);
kv
.
keyLen
=
strlen
(
"groupId"
)
+
1
;
kv
.
value
=
malloc
(
256
);
if
(
kv
.
value
==
NULL
)
{
free
(
kv
.
key
);
taosArrayDestroy
(
pArray
);
return
NULL
;
}
strcpy
(
kv
.
value
,
pTmq
->
groupId
);
kv
.
valueLen
=
strlen
(
pTmq
->
groupId
)
+
1
;
taosArrayPush
(
pArray
,
&
kv
);
strcpy
(
kv
.
key
,
"clientUid"
);
kv
.
keyLen
=
strlen
(
"clientUid"
)
+
1
;
*
(
uint32_t
*
)
kv
.
value
=
pTmq
->
pTscObj
->
connId
;
kv
.
valueLen
=
sizeof
(
uint32_t
);
return
NULL
;
}
tmq_t
*
tmqCreateConsumerImpl
(
TAOS
*
conn
,
tmq_conf_t
*
conf
)
{
tmq_t
*
pTmq
=
malloc
(
sizeof
(
tmq_t
));
if
(
pTmq
==
NULL
)
{
return
NULL
;
}
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
strcpy
(
pTmq
->
clientId
,
conf
->
clientId
);
pTmq
->
pTscObj
=
(
STscObj
*
)
conn
;
pTmq
->
pTscObj
->
connType
=
HEARTBEAT_TYPE_MQ
;
return
pTmq
;
}
TAOS_RES
*
taos_create_topic
(
TAOS
*
taos
,
const
char
*
topicName
,
const
char
*
sql
,
int
sqlLen
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQueryNode
=
NULL
;
char
*
pStr
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
taos
==
NULL
||
topicName
==
NULL
||
sql
==
NULL
)
{
tscError
(
"invalid parameters for creating topic, connObj:%p, topic name:%s, sql:%s"
,
taos
,
topicName
,
sql
);
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
goto
_return
;
}
if
(
strlen
(
topicName
)
>=
TSDB_TOPIC_NAME_LEN
)
{
tscError
(
"topic name too long, max length:%d"
,
TSDB_TOPIC_NAME_LEN
-
1
);
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
goto
_return
;
}
if
(
sqlLen
>
tsMaxSQLStringLen
)
{
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
goto
_return
;
}
tscDebug
(
"start to create topic, %s"
,
topicName
);
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQueryNode
),
_return
);
//temporary disabled until planner ready
#if 0
CHECK_CODE_GOTO(parseSql(pRequest, &pQuery), _return);
//TODO: check sql valid
// todo check for invalid sql statement and return with error code
CHECK_CODE_GOTO(qCreateQueryDag(pQuery
, &pDag
), _return);
CHECK_CODE_GOTO
(
qCreateQueryDag
(
pQuery
Node
,
&
pRequest
->
body
.
pDag
,
pRequest
->
requestId
),
_return
);
dagStr = qDagToString(
pDag);
if(
dag
Str == NULL) {
//TODO
pStr
=
qDagToString
(
pRequest
->
body
.
pDag
);
if
(
p
Str
==
NULL
)
{
goto
_return
;
}
#endif
// The topic should be related to a database that the queried table is belonged to.
SName
name
=
{
0
};
char
dbName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
((
SQueryStmtInfo
*
)
pQueryNode
)
->
pTableMetaInfo
[
0
]
->
name
,
dbName
);
tNameFromString
(
&
name
,
dbName
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameFromString
(
&
name
,
topicName
,
T_NAME_TABLE
);
char
topicFname
[
TSDB_TOPIC_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
name
,
topicFname
);
SCMCreateTopicReq
req
=
{
.
name
=
(
char
*
)
name
,
.
igExists
=
0
,
/*.physicalPlan = dagStr,*/
.
physicalPlan
=
(
char
*
)
sql
,
.
logicalPlan
=
"
"
,
.
name
=
(
char
*
)
topicF
name
,
.
igExists
=
0
,
.
physicalPlan
=
(
char
*
)
pStr
,
.
sql
=
(
char
*
)
sql
,
.
logicalPlan
=
"no logic plan
"
,
};
int
tlen
=
tSerializeSCMCreateTopicReq
(
NULL
,
&
req
);
...
...
@@ -295,30 +418,54 @@ TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sq
if
(
buf
==
NULL
)
{
goto
_return
;
}
void
*
abuf
=
buf
;
tSerializeSCMCreateTopicReq
(
&
abuf
,
&
req
);
/*printf("formatted: %s\n", dagStr);*/
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){
.
pData
=
buf
,
.
len
=
tlen
};
pRequest
->
type
=
TDMT_MND_CREATE_TOPIC
;
SMsgSendInfo
*
body
=
buildMsgInfoImpl
(
pRequest
);
SEpSet
*
pEpSet
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
SEpSet
epSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
)
;
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pTscObj
->
p
Transporter
,
pE
pSet
,
&
transporterId
,
body
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
pTransporter
,
&
e
pSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
_return:
qDestroyQuery
(
pQuery
);
qDestroyQueryDag
(
pDag
);
destroySendMsgInfo
(
body
);
qDestroyQuery
(
pQueryNode
);
if
(
body
!=
NULL
)
{
destroySendMsgInfo
(
body
);
}
if
(
pRequest
!=
NULL
&&
terrno
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
terrno
;
}
return
pRequest
;
}
typedef
struct
tmq_message_t
{
int32_t
numOfRows
;
char
*
topicName
;
TAOS_ROW
row
[];
}
tmq_message_t
;
tmq_message_t
*
tmq_consume_poll
(
tmq_t
*
mq
,
int64_t
blocking_time
)
{
return
NULL
;
}
tmq_resp_err_t
*
tmq_commit
(
tmq_t
*
mq
,
void
*
callback
,
int32_t
async
)
{
return
NULL
;
}
void
tmq_message_destroy
(
tmq_message_t
*
mq_message
)
{
}
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
if
(
sqlLen
>
(
size_t
)
tsMaxSQLStringLen
)
{
...
...
@@ -330,24 +477,22 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
nPrintTsc
(
"%s"
,
sql
)
SRequestObj
*
pRequest
=
NULL
;
SQueryNode
*
pQuery
=
NULL
;
SQueryDag
*
pDag
=
NULL
;
SQueryNode
*
pQueryNode
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQuery
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQuery
Node
),
_return
);
if
(
qIsDdlQuery
(
pQuery
))
{
CHECK_CODE_GOTO
(
execDdlQuery
(
pRequest
,
pQuery
),
_return
);
if
(
qIsDdlQuery
(
pQuery
Node
))
{
CHECK_CODE_GOTO
(
execDdlQuery
(
pRequest
,
pQuery
Node
),
_return
);
}
else
{
CHECK_CODE_GOTO
(
getPlan
(
pRequest
,
pQuery
,
&
pDag
),
_return
);
CHECK_CODE_GOTO
(
scheduleQuery
(
pRequest
,
pDag
),
_return
);
CHECK_CODE_GOTO
(
getPlan
(
pRequest
,
pQuery
Node
,
&
pRequest
->
body
.
pDag
),
_return
);
CHECK_CODE_GOTO
(
scheduleQuery
(
pRequest
,
p
Request
->
body
.
p
Dag
),
_return
);
pRequest
->
code
=
terrno
;
}
_return:
qDestroyQuery
(
pQuery
);
qDestroyQueryDag
(
pDag
);
qDestroyQuery
(
pQueryNode
);
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
terrno
)
{
pRequest
->
code
=
terrno
;
}
...
...
@@ -391,7 +536,7 @@ int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSe
return
0
;
}
STscObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
,
SAppInstInfo
*
pAppInfo
)
{
STscObj
*
taosConnectImpl
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
__taos_async_fn_t
fp
,
void
*
param
,
SAppInstInfo
*
pAppInfo
)
{
STscObj
*
pTscObj
=
createTscObj
(
user
,
auth
,
db
,
pAppInfo
);
if
(
NULL
==
pTscObj
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -408,7 +553,7 @@ STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, con
SMsgSendInfo
*
body
=
buildConnectMsg
(
pRequest
);
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
p
Transporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -419,7 +564,7 @@ STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, con
taos_close
(
pTscObj
);
pTscObj
=
NULL
;
}
else
{
tscDebug
(
"0x%"
PRIx64
" connection is opening, connId:%d, dnodeConn:%p, reqId:0x%"
PRIx64
,
pTscObj
->
id
,
pTscObj
->
connId
,
pTscObj
->
pTransporter
,
pRequest
->
requestId
);
tscDebug
(
"0x%"
PRIx64
" connection is opening, connId:%d, dnodeConn:%p, reqId:0x%"
PRIx64
,
pTscObj
->
id
,
pTscObj
->
connId
,
pTscObj
->
p
AppInfo
->
p
Transporter
,
pRequest
->
requestId
);
destroyRequest
(
pRequest
);
}
...
...
@@ -450,7 +595,9 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
STscObj
*
pObj
=
pRequest
->
pTscObj
;
char
*
db
=
getConnectionDB
(
pObj
);
tstrncpy
(
pConnect
->
db
,
db
,
sizeof
(
pConnect
->
db
));
if
(
db
!=
NULL
)
{
tstrncpy
(
pConnect
->
db
,
db
,
sizeof
(
pConnect
->
db
));
}
tfree
(
db
);
pConnect
->
pid
=
htonl
(
appInfo
.
pid
);
...
...
@@ -587,7 +734,7 @@ void* doFetchRow(SRequestObj* pRequest) {
int64_t
transporterId
=
0
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
p
Transporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
...
...
@@ -597,7 +744,7 @@ void* doFetchRow(SRequestObj* pRequest) {
int64_t
transporterId
=
0
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncSendMsgToServer
(
pTscObj
->
p
AppInfo
->
p
Transporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
...
...
@@ -650,9 +797,12 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t
char
*
getConnectionDB
(
STscObj
*
pObj
)
{
char
*
p
=
NULL
;
pthread_mutex_lock
(
&
pObj
->
mutex
);
p
=
strndup
(
pObj
->
db
,
tListLen
(
pObj
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
size_t
len
=
strlen
(
pObj
->
db
);
if
(
len
>
0
)
{
p
=
strndup
(
pObj
->
db
,
tListLen
(
pObj
->
db
));
}
pthread_mutex_unlock
(
&
pObj
->
mutex
);
return
p
;
}
...
...
@@ -673,4 +823,4 @@ void setQueryResultByRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* p
pResultInfo
->
completed
=
(
pRsp
->
completed
==
1
);
setResultDataPtr
(
pResultInfo
,
pResultInfo
->
fields
,
pResultInfo
->
numOfCols
,
pResultInfo
->
numOfRows
);
}
\ No newline at end of file
}
source/client/src/clientMsgHandler.c
浏览文件 @
cc3ead15
...
...
@@ -71,6 +71,9 @@ int processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
pTscObj
->
pAppInfo
->
clusterId
=
pConnect
->
clusterId
;
atomic_add_fetch_64
(
&
pTscObj
->
pAppInfo
->
numOfConns
,
1
);
SClientHbKey
connKey
=
{.
connId
=
pConnect
->
connId
,
.
hbType
=
HEARTBEAT_TYPE_QUERY
};
hbRegisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
connKey
,
NULL
);
// pRequest->body.resInfo.pRspMsg = pMsg->pData;
tscDebug
(
"0x%"
PRIx64
" clusterId:%"
PRId64
", totalConn:%"
PRId64
,
pRequest
->
requestId
,
pConnect
->
clusterId
,
pTscObj
->
pAppInfo
->
numOfConns
);
...
...
@@ -379,4 +382,4 @@ void initMsgHandleFp() {
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_VND_SHOW_TABLES
)]
=
processShowRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_VND_SHOW_TABLES_FETCH
)]
=
processRetrieveVndRsp
;
}
\ No newline at end of file
}
source/client/test/clientTests.cpp
浏览文件 @
cc3ead15
...
...
@@ -53,6 +53,7 @@ TEST(testCase, connect_Test) {
if
(
pConn
==
NULL
)
{
printf
(
"failed to connect to server, reason:%s
\n
"
,
taos_errstr
(
NULL
));
}
sleep
(
3
);
taos_close
(
pConn
);
}
...
...
@@ -148,27 +149,27 @@ TEST(testCase, connect_Test) {
//}
//
//TEST(testCase, create_db_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != NULL);
//
//
TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
//
if (taos_errno(pRes) != 0) {
//
printf("error in create db, reason:%s\n", taos_errstr(pRes));
//
}
//
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
ASSERT_TRUE(pFields == NULL);
//
//
int32_t numOfFields = taos_num_fields(pRes);
//
ASSERT_EQ(numOfFields, 0);
//
//
taos_free_result(pRes);
//
//
pRes = taos_query(pConn, "create database abc1 vgroups 4");
//
if (taos_errno(pRes) != 0) {
//
printf("error in create db, reason:%s\n", taos_errstr(pRes));
//
}
//
taos_close(pConn);
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != NULL);
//
TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
//
if (taos_errno(pRes) != 0) {
//
printf("error in create db, reason:%s\n", taos_errstr(pRes));
//
}
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
ASSERT_TRUE(pFields == NULL);
//
int32_t numOfFields = taos_num_fields(pRes);
//
ASSERT_EQ(numOfFields, 0);
//
taos_free_result(pRes);
//
pRes = taos_query(pConn, "create database abc1 vgroups 4");
//
if (taos_errno(pRes) != 0) {
//
printf("error in create db, reason:%s\n", taos_errstr(pRes));
//
}
//
taos_close(pConn);
//}
//
//TEST(testCase, create_dnode_Test) {
...
...
@@ -194,7 +195,7 @@ TEST(testCase, connect_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "drop dnode
2
");
// TAOS_RES* pRes = taos_query(pConn, "drop dnode
3
");
// if (taos_errno(pRes) != 0) {
// printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));
// }
...
...
@@ -205,6 +206,11 @@ TEST(testCase, connect_Test) {
// int32_t numOfFields = taos_num_fields(pRes);
// ASSERT_EQ(numOfFields, 0);
//
// pRes = taos_query(pConn, "drop dnode 4");
// if (taos_errno(pRes) != 0) {
// printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));
// }
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
...
...
@@ -227,45 +233,39 @@ TEST(testCase, connect_Test) {
// taos_close(pConn);
//}
//
//// TEST(testCase, drop_db_test) {
//// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//// assert(pConn != NULL);
////
//// showDB(pConn);
////
//// TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
//// if (taos_errno(pRes) != 0) {
//// printf("failed to drop db, reason:%s\n", taos_errstr(pRes));
//// }
//// taos_free_result(pRes);
////
//// showDB(pConn);
////
//// pRes = taos_query(pConn, "create database abc1");
//// if (taos_errno(pRes) != 0) {
//// printf("create to drop db, reason:%s\n", taos_errstr(pRes));
//// }
//// taos_free_result(pRes);
//// taos_close(pConn);
////}
//
//TEST(testCase, create_stable_Test) {
// TEST(testCase, drop_db_test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
// showDB(pConn);
//
// TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
// if (taos_errno(pRes) != 0) {
// printf("
error in create
db, reason:%s\n", taos_errstr(pRes));
// printf("
failed to drop
db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "use abc1");
// showDB(pConn);
//
// pRes = taos_query(pConn, "create database abc1");
// if (taos_errno(pRes) != 0) {
// printf("
error in use
db, reason:%s\n", taos_errstr(pRes));
// printf("
create to drop
db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
// taos_close(pConn);
//}
//TEST(testCase, create_stable_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)");
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2");
// if (taos_errno(pRes) != 0) {
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "create table if not exists abc1.st1(ts timestamp, k int) tags(a int)");
// if (taos_errno(pRes) != 0) {
// printf("error in create stable, reason:%s\n", taos_errstr(pRes));
// }
...
...
@@ -277,42 +277,41 @@ TEST(testCase, connect_Test) {
// ASSERT_EQ(numOfFields, 0);
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
//TEST(testCase, create_table_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
// pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
//
// pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)");
// taos_free_result(pRes);
// pRes = taos_query(pConn, "drop stable `123_$^)`");
// if (taos_errno(pRes) != 0) {
// printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
//
// taos_close(pConn);
//}
TEST
(
testCase
,
create_
c
table_Test
)
{
TEST
(
testCase
,
create_table_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table tm0 using st1 tags(1)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tm0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
pRes
=
taos_query
(
pConn
,
"create table if not exists tm0(ts timestamp, k int)"
);
ASSERT_EQ
(
taos_errno
(
pRes
),
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists tm0(ts timestamp, k blob)"
);
ASSERT_NE
(
taos_errno
(
pRes
),
0
);
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
//TEST(testCase,
show_s
table_Test) {
//TEST(testCase,
create_c
table_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
...
...
@@ -322,26 +321,45 @@ TEST(testCase, create_ctable_Test) {
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "
show stables
");
// pRes = taos_query(pConn, "
create table tm0 using st1 tags(1)
");
// if (taos_errno(pRes) != 0) {
// printf("failed to show stables, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes));
// }
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
TEST
(
testCase
,
show_stable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
nullptr
);
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// if (taos_errno(pRes) != 0) {
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show abc1.stables"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to show stables, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
ASSERT_TRUE
(
false
);
}
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
//
//TEST(testCase, show_vgroup_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
@@ -499,44 +517,34 @@ TEST(testCase, create_ctable_Test) {
//
// taosHashCleanup(phash);
//}
//
TEST(testCase, create_topic_Test) {
//
//TEST(testCase, create_topic_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "create database abc1");
// if (taos_errno(pRes) != 0) {
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "use abc1");
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// if (taos_errno(pRes) != 0) {
// printf("error in use db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)");
// if (taos_errno(pRes) != 0) {
// printf("error in create stable, reason:%s\n", taos_errstr(pRes));
// }
//
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// ASSERT_TRUE(pFields ==
NULL
);
// ASSERT_TRUE(pFields ==
nullptr
);
//
// int32_t numOfFields = taos_num_fields(pRes);
// ASSERT_EQ(numOfFields, 0);
//
// taos_free_result(pRes);
//
// char* sql = "select * from st1";
// tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql));
// char* sql = "select * from tu";
// pRes = taos_create_topic(pConn, "test_topic_1", sql, strlen(sql));
// taos_free_result(pRes);
// taos_close(pConn);
//}
//
//TEST(testCase, insert_test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// ASSERT_
EQ
(pConn, nullptr);
// ASSERT_
NE
(pConn, nullptr);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
...
...
@@ -556,25 +564,31 @@ TEST(testCase, create_ctable_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// ASSERT_NE(pConn, nullptr);
//
//// TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2");
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
//
//// pRes = taos_query(pConn, "create stable st1 (ts timestamp, k int) tags(a int)");
//// if (taos_errno(pRes) != 0) {
//// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
//// taos_free_result(pRes);
//// return;
//// printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
//// }
//
//// taos_free_result(pRes);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
//
//// pRes = taos_query(pConn, "create table m1 (ts timestamp, k int) tags(a int)");
// taos_free_result(pRes);
////
//// pRes = taos_query(pConn, "create table tu using m1 tags(1)");
//// pRes = taos_query(pConn, "create table tu using st1 tags(1)");
//// if (taos_errno(pRes) != 0) {
//// printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
//// }
//// taos_free_result(pRes);
////
//// pRes = taos_query(pConn, "insert into tu values(now, 1)");
//// taos_free_result(pRes);
//// for(int32_t i = 0; i < 100; ++i) {
//// char sql[512] = {0};
//// sprintf(sql, "insert into tu values(now+%da, %d)", i, i);
//// TAOS_RES* p = taos_query(pConn, sql);
//// if (taos_errno(p) != 0) {
//// printf("failed to insert data, reason:%s\n", taos_errstr(p));
//// }
////
//// taos_free_result(p);
//// }
//
// pRes = taos_query(pConn, "select * from tu");
// if (taos_errno(pRes) != 0) {
...
...
@@ -596,3 +610,31 @@ TEST(testCase, create_ctable_Test) {
// taos_free_result(pRes);
// taos_close(pConn);
//}
//TEST(testCase, projection_query_stables) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// ASSERT_NE(pConn, nullptr);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "select ts,k from m1");
// if (taos_errno(pRes) != 0) {
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// }
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
source/common/src/tmsg.c
浏览文件 @
cc3ead15
...
...
@@ -89,7 +89,7 @@ int tSerializeSClientHbReq(void **buf, const SClientHbReq *pReq) {
int
tlen
=
0
;
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pReq
->
connKey
);
int
kvNum
=
taosHashGetSize
(
pReq
->
info
);
int
32_t
kvNum
=
taosHashGetSize
(
pReq
->
info
);
tlen
+=
taosEncodeFixedI32
(
buf
,
kvNum
);
SKv
kv
;
void
*
pIter
=
taosHashIterate
(
pReq
->
info
,
pIter
);
...
...
@@ -104,14 +104,15 @@ int tSerializeSClientHbReq(void **buf, const SClientHbReq *pReq) {
return
tlen
;
}
void
*
tDeserializeClientHbReq
(
void
*
buf
,
SClientHbReq
*
pReq
)
{
ASSERT
(
pReq
->
info
!=
NULL
);
void
*
tDeserializeSClientHbReq
(
void
*
buf
,
SClientHbReq
*
pReq
)
{
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pReq
->
connKey
);
// TODO: error handling
int
kvNum
;
taosDecodeFixedI32
(
buf
,
&
kvNum
);
pReq
->
info
=
taosHashInit
(
kvNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
int32_t
kvNum
;
buf
=
taosDecodeFixedI32
(
buf
,
&
kvNum
);
if
(
pReq
->
info
==
NULL
)
{
pReq
->
info
=
taosHashInit
(
kvNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
}
for
(
int
i
=
0
;
i
<
kvNum
;
i
++
)
{
SKv
kv
;
buf
=
taosDecodeSKv
(
buf
,
&
kv
);
...
...
@@ -121,12 +122,69 @@ void *tDeserializeClientHbReq(void *buf, SClientHbReq *pReq) {
return
buf
;
}
int
tSerializeSClientHbBatchReq
(
void
**
buf
,
const
SClientHbBatchReq
*
pReq
)
{
int
tSerializeSClientHbRsp
(
void
**
buf
,
const
SClientHbRsp
*
pRsp
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
bodyLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pRsp
->
body
,
pRsp
->
bodyLen
);
return
tlen
;
}
void
*
tDeserializeSClientHbRsp
(
void
*
buf
,
SClientHbRsp
*
pRsp
)
{
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
bodyLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pRsp
->
body
,
pRsp
->
bodyLen
);
return
buf
;
}
int
tSerializeSClientHbBatchReq
(
void
**
buf
,
const
SClientHbBatchReq
*
pBatchReq
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pBatchReq
->
reqId
);
int32_t
reqNum
=
taosArrayGetSize
(
pBatchReq
->
reqs
);
tlen
+=
taosEncodeFixedI32
(
buf
,
reqNum
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
SClientHbReq
*
pReq
=
taosArrayGet
(
pBatchReq
->
reqs
,
i
);
tlen
+=
tSerializeSClientHbReq
(
buf
,
pReq
);
}
return
tlen
;
}
void
*
tDeserializeClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pReq
)
{
void
*
tDeserializeSClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pBatchReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pBatchReq
->
reqId
);
if
(
pBatchReq
->
reqs
==
NULL
)
{
pBatchReq
->
reqs
=
taosArrayInit
(
0
,
sizeof
(
SClientHbReq
));
}
int32_t
reqNum
;
buf
=
taosDecodeFixedI32
(
buf
,
&
reqNum
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
SClientHbReq
req
=
{
0
};
buf
=
tDeserializeSClientHbReq
(
buf
,
&
req
);
taosArrayPush
(
pBatchReq
->
reqs
,
&
req
);
}
return
buf
;
}
int
tSerializeSClientHbBatchRsp
(
void
**
buf
,
const
SClientHbBatchRsp
*
pBatchRsp
)
{
int
tlen
=
0
;
int32_t
sz
=
taosArrayGetSize
(
pBatchRsp
->
rsps
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbRsp
*
pRsp
=
taosArrayGet
(
pBatchRsp
->
rsps
,
i
);
tlen
+=
tSerializeSClientHbRsp
(
buf
,
pRsp
);
}
return
tlen
;
}
void
*
tDeserializeSClientHbBatchRsp
(
void
*
buf
,
SClientHbBatchRsp
*
pBatchRsp
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBatchRsp
->
rsps
=
taosArrayInit
(
sz
,
sizeof
(
SClientHbRsp
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbRsp
rsp
=
{
0
};
buf
=
tDeserializeSClientHbRsp
(
buf
,
&
rsp
);
taosArrayPush
(
pBatchRsp
->
rsps
,
&
rsp
);
}
return
buf
;
}
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
cc3ead15
...
...
@@ -5,4 +5,5 @@ add_subdirectory(bnode)
add_subdirectory
(
snode
)
add_subdirectory
(
mnode
)
add_subdirectory
(
vnode
)
add_subdirectory
(
stb
)
add_subdirectory
(
sut
)
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
0 → 100644
浏览文件 @
cc3ead15
aux_source_directory
(
. DSTB_SRC
)
add_executable
(
dnode_test_stb
${
DSTB_SRC
}
)
target_link_libraries
(
dnode_test_stb
PUBLIC sut
)
add_test
(
NAME dnode_test_stb
COMMAND dnode_test_stb
)
source/dnode/mgmt/impl/test/stb/dstb.cpp
0 → 100644
浏览文件 @
cc3ead15
/**
* @file db.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module vnode tests
* @version 0.1
* @date 2021-12-20
*
* @copyright Copyright (c) 2021
*
*/
#include "sut.h"
class
DndTestVnode
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_stb"
,
9116
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestVnode
::
test
;
TEST_F
(
DndTestVnode
,
01
_Create_Restart_Drop_Vnode
)
{
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SCreateVnodeReq
);
SCreateVnodeReq
*
pReq
=
(
SCreateVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
pReq
->
vgVersion
=
htonl
(
1
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
minRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replica
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
selfIndex
=
0
;
for
(
int
r
=
0
;
r
<
pReq
->
replica
;
++
r
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
r
];
pReplica
->
id
=
htonl
(
1
);
pReplica
->
port
=
htons
(
9527
);
}
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
Restart
();
}
else
{
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED
);
}
}
}
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SAlterVnodeReq
);
SAlterVnodeReq
*
pReq
=
(
SAlterVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
pReq
->
vgVersion
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
minRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replica
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
selfIndex
=
0
;
for
(
int
r
=
0
;
r
<
pReq
->
replica
;
++
r
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
r
];
pReplica
->
id
=
htonl
(
1
);
pReplica
->
port
=
htons
(
9527
);
}
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SDropVnodeReq
);
SDropVnodeReq
*
pReq
=
(
SDropVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropVnodeReq
);
rpcMsg
.
msgType
=
TDMT_DND_DROP_VNODE
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
Restart
();
}
else
{
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_NOT_DEPLOYED
);
}
}
}
}
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
cc3ead15
...
...
@@ -350,7 +350,7 @@ typedef struct SMqTopicObj {
// TODO: add cache and change name to id
typedef
struct
SMqConsumerTopic
{
char
name
[
TSDB_TOPIC_
F
NAME_LEN
];
char
name
[
TSDB_TOPIC_NAME_LEN
];
SList
*
vgroups
;
// SList<int32_t>
}
SMqConsumerTopic
;
...
...
@@ -409,7 +409,7 @@ typedef struct SMqVGroupHbObj {
#if 0
typedef struct SCGroupObj {
char name[TSDB_TOPIC_
F
NAME_LEN];
char name[TSDB_TOPIC_NAME_LEN];
int64_t createTime;
int64_t updateTime;
uint64_t uid;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
cc3ead15
...
...
@@ -613,32 +613,14 @@ static int32_t mndSetUpdateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
static
int32_t
mndUpdateDb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDbObj
*
pOld
,
SDbObj
*
pNew
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"db:%s, failed to update since %s"
,
pOld
->
name
,
terrstr
());
return
terrno
;
}
if
(
pTrans
==
NULL
)
goto
UPDATE_DB_OVER
;
mDebug
(
"trans:%d, used to update db:%s"
,
pTrans
->
id
,
pOld
->
name
);
if
(
mndSetUpdateDbRedoLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbCommitLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbRedoActions
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbRedoLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
UPDATE_DB_OVER
;
if
(
mndSetUpdateDbCommitLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
UPDATE_DB_OVER
;
if
(
mndSetUpdateDbRedoActions
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
UPDATE_DB_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
UPDATE_DB_OVER
;
code
=
0
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
cc3ead15
...
...
@@ -258,6 +258,39 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
}
static
int32_t
mndProcessHeartBeatReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
char
*
batchReqStr
=
pReq
->
rpcMsg
.
pCont
;
SClientHbBatchReq
batchReq
=
{
0
};
tDeserializeSClientHbBatchReq
(
batchReqStr
,
&
batchReq
);
SArray
*
pArray
=
batchReq
.
reqs
;
int
sz
=
taosArrayGetSize
(
pArray
);
SClientHbBatchRsp
batchRsp
=
{
0
};
batchRsp
.
rsps
=
taosArrayInit
(
0
,
sizeof
(
SClientHbRsp
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbReq
*
pHbReq
=
taosArrayGet
(
pArray
,
i
);
if
(
pHbReq
->
connKey
.
hbType
==
HEARTBEAT_TYPE_QUERY
)
{
}
else
if
(
pHbReq
->
connKey
.
hbType
==
HEARTBEAT_TYPE_MQ
)
{
SClientHbRsp
rsp
=
{
.
status
=
0
,
.
connKey
=
pHbReq
->
connKey
,
.
bodyLen
=
0
,
.
body
=
NULL
};
taosArrayPush
(
batchRsp
.
rsps
,
&
rsp
);
}
}
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
&
batchRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
bufCopy
=
buf
;
tSerializeSClientHbBatchRsp
(
&
bufCopy
,
&
batchRsp
);
pReq
->
contLen
=
tlen
;
pReq
->
pCont
=
buf
;
return
0
;
#if 0
SMnode *pMnode = pReq->pMnode;
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
...
...
@@ -327,6 +360,7 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
pReq->contLen = sizeof(SConnectRsp);
pReq->pCont = pRsp;
return 0;
#endif
}
static
int32_t
mndProcessKillQueryReq
(
SMnodeMsg
*
pReq
)
{
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
cc3ead15
...
...
@@ -118,11 +118,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
calloc
(
pTopic
->
sqlLen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
logicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
len
,
TOPIC_DECODE_OVER
);
//
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
//
SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER);
//
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
//
SDB_GET_BINARY(pRaw, dataPos, pTopic->physicalPlan, len, TOPIC_DECODE_OVER);
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
)
...
...
@@ -178,7 +180,7 @@ void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic) {
static
SDbObj
*
mndAcquireDbByTopic
(
SMnode
*
pMnode
,
char
*
topicName
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
topicName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_T
OPIC
);
tNameFromString
(
&
name
,
topicName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_T
ABLE
);
char
db
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
db
);
...
...
@@ -203,20 +205,24 @@ static SDDropTopicReq *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, SMq
return
pDrop
;
}
static
int32_t
mndCheckCreateTopicMsg
(
SCMCreateTopicReq
*
pCreate
)
{
static
int32_t
mndCheckCreateTopicMsg
(
SCMCreateTopicReq
*
creattopReq
)
{
// deserialize and other stuff
return
0
;
}
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
SMqTopicObj
topicObj
=
{
0
};
tstrncpy
(
topicObj
.
name
,
pCreate
->
name
,
TSDB_T
ABLE
_FNAME_LEN
);
tstrncpy
(
topicObj
.
name
,
pCreate
->
name
,
TSDB_T
OPIC
_FNAME_LEN
);
tstrncpy
(
topicObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
topicObj
.
createTime
=
taosGetTimestampMs
();
topicObj
.
updateTime
=
topicObj
.
createTime
;
topicObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
topicObj
.
dbUid
=
pDb
->
uid
;
topicObj
.
version
=
1
;
topicObj
.
sql
=
strdup
(
pCreate
->
sql
);
topicObj
.
physicalPlan
=
strdup
(
pCreate
->
physicalPlan
);
topicObj
.
logicalPlan
=
strdup
(
pCreate
->
logicalPlan
);
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
);
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
&
topicObj
);
if
(
pTopicRaw
==
NULL
)
return
-
1
;
...
...
@@ -228,46 +234,47 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCMCreateTopicReq
static
int32_t
mndProcessCreateTopicMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
char
*
msgStr
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTopicReq
*
pCreate
;
tDeserializeSCMCreateTopicReq
(
msgStr
,
pCreate
);
mDebug
(
"topic:%s, start to create"
,
pCreate
->
name
);
SCMCreateTopicReq
createTopicReq
=
{
0
};
tDeserializeSCMCreateTopicReq
(
msgStr
,
&
createTopicReq
);
mDebug
(
"topic:%s, start to create, sql:%s"
,
createTopicReq
.
name
,
createTopicReq
.
sql
);
if
(
mndCheckCreateTopicMsg
(
pCreate
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
if
(
mndCheckCreateTopicMsg
(
&
createTopicReq
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
return
-
1
;
}
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
pCreate
->
name
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
createTopicReq
.
name
);
if
(
pTopic
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pTopic
);
if
(
pCreate
->
igExists
)
{
mDebug
(
"topic:%s, already exist, ignore exist is set"
,
pCreate
->
name
);
if
(
createTopicReq
.
igExists
)
{
mDebug
(
"topic:%s, already exist, ignore exist is set"
,
createTopicReq
.
name
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_TOPIC_ALREADY_EXIST
;
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"db:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
return
-
1
;
}
}
SDbObj
*
pDb
=
mndAcquireDbByTopic
(
pMnode
,
pCreate
->
name
);
SDbObj
*
pDb
=
mndAcquireDbByTopic
(
pMnode
,
createTopicReq
.
name
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndCreateTopic
(
pMnode
,
pMsg
,
pCreate
,
pDb
);
int32_t
code
=
mndCreateTopic
(
pMnode
,
pMsg
,
&
createTopicReq
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
if
(
code
!=
0
)
{
terrno
=
code
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_
MND_ACTION_IN_PROGR
ESS
;
return
TSDB_CODE_
SUCC
ESS
;
}
static
int32_t
mndDropTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SMqTopicObj
*
pTopic
)
{
return
0
;
}
...
...
source/dnode/mnode/impl/test/profile/profile.cpp
浏览文件 @
cc3ead15
...
...
@@ -96,6 +96,38 @@ TEST_F(MndTestProfile, 03_ConnectMsg_Show) {
}
TEST_F
(
MndTestProfile
,
04
_HeartBeatMsg
)
{
SClientHbBatchReq
batchReq
;
batchReq
.
reqs
=
taosArrayInit
(
0
,
sizeof
(
SClientHbReq
));
SClientHbReq
req
=
{
0
};
req
.
connKey
=
{.
connId
=
123
,
.
hbType
=
HEARTBEAT_TYPE_MQ
};
req
.
info
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
SKv
kv
;
kv
.
key
=
(
void
*
)
"abc"
;
kv
.
keyLen
=
4
;
kv
.
value
=
(
void
*
)
"bcd"
;
kv
.
valueLen
=
4
;
taosHashPut
(
req
.
info
,
kv
.
key
,
kv
.
keyLen
,
kv
.
value
,
kv
.
valueLen
);
taosArrayPush
(
batchReq
.
reqs
,
&
req
);
int32_t
tlen
=
tSerializeSClientHbBatchReq
(
NULL
,
&
batchReq
);
void
*
buf
=
(
SClientHbBatchReq
*
)
rpcMallocCont
(
tlen
);
void
*
bufCopy
=
buf
;
tSerializeSClientHbBatchReq
(
&
bufCopy
,
&
batchReq
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
buf
,
tlen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
char
*
pRspChar
=
(
char
*
)
pMsg
->
pCont
;
SClientHbBatchRsp
rsp
=
{
0
};
tDeserializeSClientHbBatchRsp
(
pRspChar
,
&
rsp
);
int
sz
=
taosArrayGetSize
(
rsp
.
rsps
);
ASSERT_EQ
(
sz
,
1
);
SClientHbRsp
*
pRsp
=
(
SClientHbRsp
*
)
taosArrayGet
(
rsp
.
rsps
,
0
);
EXPECT_EQ
(
pRsp
->
connKey
.
connId
,
123
);
EXPECT_EQ
(
pRsp
->
connKey
.
hbType
,
HEARTBEAT_TYPE_MQ
);
EXPECT_EQ
(
pRsp
->
status
,
0
);
#if 0
int32_t contLen = sizeof(SHeartBeatReq);
SHeartBeatReq* pReq = (SHeartBeatReq*)rpcMallocCont(contLen);
...
...
@@ -129,9 +161,12 @@ TEST_F(MndTestProfile, 04_HeartBeatMsg) {
EXPECT_EQ(pRsp->epSet.numOfEps, 1);
EXPECT_EQ(pRsp->epSet.port[0], 9031);
EXPECT_STREQ(pRsp->epSet.fqdn[0], "localhost");
#endif
}
TEST_F
(
MndTestProfile
,
05
_KillConnMsg
)
{
// temporary remove since kill will use new heartbeat msg
#if 0
{
int32_t contLen = sizeof(SKillConnReq);
...
...
@@ -190,6 +225,7 @@ TEST_F(MndTestProfile, 05_KillConnMsg) {
connId = pRsp->connId;
}
#endif
}
TEST_F
(
MndTestProfile
,
06
_KillConnMsg_InvalidConn
)
{
...
...
@@ -204,6 +240,8 @@ TEST_F(MndTestProfile, 06_KillConnMsg_InvalidConn) {
}
TEST_F
(
MndTestProfile
,
07
_KillQueryMsg
)
{
// temporary remove since kill will use new heartbeat msg
#if 0
{
int32_t contLen = sizeof(SKillQueryReq);
...
...
@@ -252,6 +290,7 @@ TEST_F(MndTestProfile, 07_KillQueryMsg) {
EXPECT_EQ(pRsp->epSet.port[0], 9031);
EXPECT_STREQ(pRsp->epSet.fqdn[0], "localhost");
}
#endif
}
TEST_F
(
MndTestProfile
,
08
_KillQueryMsg_InvalidConn
)
{
...
...
source/dnode/mnode/impl/test/stb/CMakeLists.txt
浏览文件 @
cc3ead15
aux_source_directory
(
. STB_SRC
)
add_executable
(
d
node_test_stb
${
STB_SRC
}
)
add_executable
(
m
node_test_stb
${
STB_SRC
}
)
target_link_libraries
(
d
node_test_stb
m
node_test_stb
PUBLIC sut
)
add_test
(
NAME
d
node_test_stb
COMMAND
d
node_test_stb
NAME
m
node_test_stb
COMMAND
m
node_test_stb
)
source/dnode/vnode/inc/vnode.h
浏览文件 @
cc3ead15
...
...
@@ -35,28 +35,26 @@ typedef struct SDnode SDnode;
typedef
int32_t
(
*
PutReqToVQueryQFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
pReq
);
typedef
struct
SVnodeCfg
{
int32_t
vgId
;
SDnode
*
pDnode
;
struct
{
uint64_t
wsize
;
uint64_t
ssize
;
uint64_t
lsize
;
bool
isHeapAllocator
;
};
int32_t
vgId
;
SDnode
*
pDnode
;
uint64_t
wsize
;
uint64_t
ssize
;
uint64_t
lsize
;
bool
isHeapAllocator
;
uint32_t
ttl
;
uint32_t
keep
;
bool
isWeak
;
bool
isWeak
;
STsdbCfg
tsdbCfg
;
SMetaCfg
metaCfg
;
STqCfg
tqCfg
;
SWalCfg
walCfg
;
STqCfg
tqCfg
;
SWalCfg
walCfg
;
}
SVnodeCfg
;
typedef
struct
{
int32_t
sver
;
char
*
timezone
;
char
*
locale
;
char
*
charset
;
char
*
timezone
;
char
*
locale
;
char
*
charset
;
uint16_t
nthreads
;
// number of commit threads. 0 for no threads and a schedule queue should be given (TODO)
PutReqToVQueryQFp
putReqToVQueryQFp
;
}
SVnodeOpt
;
...
...
source/dnode/vnode/src/inc/metaCache.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_CACHE_H_
#define _TD_META_CACHE_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SMetaCache
SMetaCache
;
int
metaOpenCache
(
SMeta
*
pMeta
);
void
metaCloseCache
(
SMeta
*
pMeta
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_CACHE_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaCfg.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_CFG_H_
#define _TD_META_CFG_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
const
SMetaCfg
defaultMetaOptions
;
int
metaValidateOptions
(
const
SMetaCfg
*
);
void
metaOptionsCopy
(
SMetaCfg
*
pDest
,
const
SMetaCfg
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaDB.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_DB_H_
#define _TD_META_DB_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SMetaDB
SMetaDB
;
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_DB_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaDef.h
浏览文件 @
cc3ead15
...
...
@@ -19,18 +19,49 @@
#include "mallocator.h"
#include "meta.h"
#include "metaCache.h"
#include "metaCfg.h"
#include "metaDB.h"
#include "metaIdx.h"
#include "metaTbCfg.h"
#include "metaTbTag.h"
#include "metaTbUid.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SMetaCache
SMetaCache
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaDB
SMetaDB
;
// SMetaDB
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// SMetaCache
int
metaOpenCache
(
SMeta
*
pMeta
);
void
metaCloseCache
(
SMeta
*
pMeta
);
// SMetaCfg
extern
const
SMetaCfg
defaultMetaOptions
;
// int metaValidateOptions(const SMetaCfg*);
void
metaOptionsCopy
(
SMetaCfg
*
pDest
,
const
SMetaCfg
*
pSrc
);
// SMetaIdx
int
metaOpenIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// STbUidGnrt
typedef
struct
STbUidGenerator
{
tb_uid_t
nextUid
;
}
STbUidGenerator
;
// STableUidGenerator
int
metaOpenUidGnrt
(
SMeta
*
pMeta
);
void
metaCloseUidGnrt
(
SMeta
*
pMeta
);
// tb_uid_t
#define IVLD_TB_UID 0
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
);
struct
SMeta
{
char
*
path
;
SMetaCfg
options
;
...
...
source/dnode/vnode/src/inc/metaQuery.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _VNODE_QUERY_H_
#define _VNODE_QUERY_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_VNODE_QUERY_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaTbCfg.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_TABLE_CFG_H_
#define _TD_META_TABLE_CFG_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int
metaValidateTbCfg
(
SMeta
*
pMeta
,
const
STbCfg
*
);
size_t
metaEncodeTbObjFromTbOptions
(
const
STbCfg
*
,
void
*
pBuf
,
size_t
bsize
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_TABLE_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaTbTag.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_TB_TAG_H_
#define _TD_META_TB_TAG_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_TB_TAG_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/metaTbUid.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_META_UID_H_
#define _TD_META_UID_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* ------------------------ APIS EXPOSED ------------------------ */
typedef
struct
STbUidGenerator
{
tb_uid_t
nextUid
;
}
STbUidGenerator
;
// STableUidGenerator
int
metaOpenUidGnrt
(
SMeta
*
pMeta
);
void
metaCloseUidGnrt
(
SMeta
*
pMeta
);
// tb_uid_t
#define IVLD_TB_UID 0
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_UID_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbHealth.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_TSDB_HEALTH_H_
#define _TD_TSDB_HEALTH_H_
#if 0
bool tsdbUrgeQueryFree(STsdbRepo* pRepo);
int32_t tsdbInsertNewBlock(STsdbRepo* pRepo);
bool tsdbIdleMemEnough();
bool tsdbAllowNewBlock(STsdbRepo* pRepo);
#endif
#endif
/* _TD_TSDB_BUFFER_H_ */
source/dnode/vnode/src/inc/vn
odeDef
.h
→
source/dnode/vnode/src/inc/vn
d
.h
浏览文件 @
cc3ead15
...
...
@@ -19,25 +19,23 @@
#include "mallocator.h"
// #include "sync.h"
#include "tcoding.h"
#include "tfs.h"
#include "tlist.h"
#include "tlockfree.h"
#include "tmacro.h"
#include "wal.h"
#include "tfs.h"
#include "vnode.h"
#include "vnodeBufferPool.h"
#include "vnodeCfg.h"
#include "vnodeCommit.h"
#include "vnodeMemAllocator.h"
#include "vnodeQuery.h"
#include "vnodeStateMgr.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SVState
SVState
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SVnodeTask
{
TD_DLIST_NODE
(
SVnodeTask
);
void
*
arg
;
...
...
@@ -60,34 +58,119 @@ typedef struct SVnodeMgr {
extern
SVnodeMgr
vnodeMgr
;
// SVState
struct
SVState
{
int64_t
processed
;
int64_t
committed
;
int64_t
applied
;
};
struct
SVnode
{
int32_t
vgId
;
char
*
path
;
SVnodeCfg
config
;
SVState
state
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
tsem_t
canCommit
;
SQHandle
*
pQuery
;
SDnode
*
pDnode
;
int32_t
vgId
;
char
*
path
;
SVnodeCfg
config
;
SVState
state
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
tsem_t
canCommit
;
SQHandle
*
pQuery
;
SDnode
*
pDnode
;
};
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int32_t
vnodePutReqToVQueryQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
int32_t
vnodePutReqToVQueryQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
// For Log
extern
int32_t
vDebugFlag
;
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }} while(0)
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }} while(0)
#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }} while(0)
#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", 255, __VA_ARGS__); }} while(0)
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define vFatal(...) \
do { \
if (vDebugFlag & DEBUG_FATAL) { \
taosPrintLog("VND FATAL ", 255, __VA_ARGS__); \
} \
} while (0)
#define vError(...) \
do { \
if (vDebugFlag & DEBUG_ERROR) { \
taosPrintLog("VND ERROR ", 255, __VA_ARGS__); \
} \
} while (0)
#define vWarn(...) \
do { \
if (vDebugFlag & DEBUG_WARN) { \
taosPrintLog("VND WARN ", 255, __VA_ARGS__); \
} \
} while (0)
#define vInfo(...) \
do { \
if (vDebugFlag & DEBUG_INFO) { \
taosPrintLog("VND ", 255, __VA_ARGS__); \
} \
} while (0)
#define vDebug(...) \
do { \
if (vDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \
} \
} while (0)
#define vTrace(...) \
do { \
if (vDebugFlag & DEBUG_TRACE) { \
taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \
} \
} while (0)
// vnodeCfg.h
extern
const
SVnodeCfg
defaultVnodeOptions
;
int
vnodeValidateOptions
(
const
SVnodeCfg
*
);
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
// For commit
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
// SVBufPool
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeBufPoolSwitch
(
SVnode
*
pVnode
);
int
vnodeBufPoolRecycle
(
SVnode
*
pVnode
);
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
);
bool
vnodeBufPoolIsFull
(
SVnode
*
pVnode
);
SMemAllocatorFactory
*
vBufPoolGetMAF
(
SVnode
*
pVnode
);
// SVMemAllocator
typedef
struct
SVArenaNode
{
TD_SLIST_NODE
(
SVArenaNode
);
uint64_t
size
;
// current node size
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
SVMemAllocator
{
T_REF_DECLARE
()
TD_DLIST_NODE
(
SVMemAllocator
);
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
SVArenaNode
*
pNode
;
TD_SLIST
(
SVArenaNode
)
nlist
;
}
SVMemAllocator
;
SVMemAllocator
*
vmaCreate
(
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
);
void
vmaDestroy
(
SVMemAllocator
*
pVMA
);
void
vmaReset
(
SVMemAllocator
*
pVMA
);
void
*
vmaMalloc
(
SVMemAllocator
*
pVMA
,
uint64_t
size
);
void
vmaFree
(
SVMemAllocator
*
pVMA
,
void
*
ptr
);
bool
vmaIsFull
(
SVMemAllocator
*
pVMA
);
#ifdef __cplusplus
}
...
...
source/dnode/vnode/src/inc/vnodeBufferPool.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_BUFFER_POOL_H_
#define _TD_VNODE_BUFFER_POOL_H_
#include "tlist.h"
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SVBufPool
SVBufPool
;
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeBufPoolSwitch
(
SVnode
*
pVnode
);
int
vnodeBufPoolRecycle
(
SVnode
*
pVnode
);
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
);
bool
vnodeBufPoolIsFull
(
SVnode
*
pVnode
);
SMemAllocatorFactory
*
vBufPoolGetMAF
(
SVnode
*
pVnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_BUFFER_POOL_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnodeCfg.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_CFG_H_
#define _TD_VNODE_CFG_H_
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
const
SVnodeCfg
defaultVnodeOptions
;
int
vnodeValidateOptions
(
const
SVnodeCfg
*
);
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnodeCommit.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_COMMIT_H_
#define _TD_VNODE_COMMIT_H_
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_COMMIT_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnodeInt.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_INT_H_
#define _TD_VNODE_INT_H_
#include "vnode.h"
#include "meta.h"
// #include "sync.h"
#include "tlog.h"
#include "tq.h"
#include "tsdb.h"
#include "wal.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
int32_t
vDebugFlag
;
#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }}
#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }}
#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", 255, __VA_ARGS__); }}
#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", 255, __VA_ARGS__); }}
#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }}
#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_INT_H_*/
source/dnode/vnode/src/inc/vnodeMemAllocator.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_MEM_ALLOCATOR_H_
#define _TD_VNODE_MEM_ALLOCATOR_H_
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SVArenaNode
{
TD_SLIST_NODE
(
SVArenaNode
);
uint64_t
size
;
// current node size
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
SVMemAllocator
{
T_REF_DECLARE
()
TD_DLIST_NODE
(
SVMemAllocator
);
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
SVArenaNode
*
pNode
;
TD_SLIST
(
SVArenaNode
)
nlist
;
}
SVMemAllocator
;
SVMemAllocator
*
vmaCreate
(
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
);
void
vmaDestroy
(
SVMemAllocator
*
pVMA
);
void
vmaReset
(
SVMemAllocator
*
pVMA
);
void
*
vmaMalloc
(
SVMemAllocator
*
pVMA
,
uint64_t
size
);
void
vmaFree
(
SVMemAllocator
*
pVMA
,
void
*
ptr
);
bool
vmaIsFull
(
SVMemAllocator
*
pVMA
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_MEM_ALLOCATOR_H_*/
source/dnode/vnode/src/inc/vnodeWrite.h
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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/>.
*/
#ifndef _TD_VNODE_WRITE_H_
#define _TD_VNODE_WRITE_H_
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
void
vnodeProcessWriteMsg
(
SVnode
*
pVnode
,
SVnodeMsg
*
pMsg
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_WRITE_H_*/
source/dnode/vnode/src/meta/metaMain.c
浏览文件 @
cc3ead15
...
...
@@ -30,11 +30,11 @@ SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory
pMetaCfg
=
&
defaultMetaOptions
;
}
// Validate the options
if
(
metaValidateOptions
(
pMetaCfg
)
<
0
)
{
// TODO: deal with error
return
NULL
;
}
//
//
Validate the options
//
if (metaValidateOptions(pMetaCfg) < 0) {
//
// TODO: deal with error
//
return NULL;
//
}
// Allocate handle
pMeta
=
metaNew
(
path
,
pMetaCfg
,
pMAF
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
cc3ead15
...
...
@@ -17,10 +17,10 @@
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
// Validate the tbOptions
if
(
metaValidateTbCfg
(
pMeta
,
pTbCfg
)
<
0
)
{
// TODO: handle error
return
-
1
;
}
//
if (metaValidateTbCfg(pMeta, pTbCfg) < 0) {
//
// TODO: handle error
//
return -1;
//
}
// TODO: add atomicity
...
...
source/dnode/vnode/src/tsdb/tsdbHealth.c
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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 "os.h"
// #include "tmsg.h"
// #include "tarray.h"
// #include "query.h"
// #include "tglobal.h"
// #include "tlist.h"
// #include "tsdbint.h"
// #include "tsdbBuffer.h"
// #include "tsdbLog.h"
// #include "tsdbHealth.h"
// #include "ttimer.h"
// #include "tthread.h"
// // return malloc new block count
// int32_t tsdbInsertNewBlock(STsdbRepo * pRepo) {
// STsdbBufPool *pPool = pRepo->pPool;
// int32_t cnt = 0;
// if(tsdbAllowNewBlock(pRepo)) {
// STsdbBufBlock *pBufBlock = tsdbNewBufBlock(pPool->bufBlockSize);
// if (pBufBlock) {
// if (tdListAppend(pPool->bufBlockList, (void *)(&pBufBlock)) < 0) {
// // append error
// tsdbFreeBufBlock(pBufBlock);
// } else {
// pPool->nElasticBlocks ++;
// cnt ++ ;
// }
// }
// }
// return cnt;
// }
// // switch anther thread to run
// void* cbKillQueryFree(void* param) {
// STsdbRepo* pRepo = (STsdbRepo*)param;
// // vnode
// if(pRepo->appH.notifyStatus) {
// pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_NOBLOCK, TSDB_CODE_SUCCESS);
// }
// // free
// if(pRepo->pthread){
// void* p = pRepo->pthread;
// pRepo->pthread = NULL;
// free(p);
// }
// return NULL;
// }
// // return true do free , false do nothing
// bool tsdbUrgeQueryFree(STsdbRepo * pRepo) {
// // check previous running
// if(pRepo->pthread && taosThreadRunning(pRepo->pthread)) {
// tsdbWarn("vgId:%d pre urge thread is runing. nBlocks=%d nElasticBlocks=%d", REPO_ID(pRepo), pRepo->pPool->nBufBlocks, pRepo->pPool->nElasticBlocks);
// return false;
// }
// // create new
// pRepo->pthread = taosCreateThread(cbKillQueryFree, pRepo);
// if(pRepo->pthread == NULL) {
// tsdbError("vgId:%d create urge thread error.", REPO_ID(pRepo));
// return false;
// }
// return true;
// }
// bool tsdbAllowNewBlock(STsdbRepo* pRepo) {
// int32_t nMaxElastic = pRepo->config.totalBlocks/3;
// STsdbBufPool* pPool = pRepo->pPool;
// if(pPool->nElasticBlocks >= nMaxElastic) {
// tsdbWarn("vgId:%d tsdbAllowNewBlock return fasle. nElasticBlock(%d) >= MaxElasticBlocks(%d)", REPO_ID(pRepo), pPool->nElasticBlocks, nMaxElastic);
// return false;
// }
// return true;
// }
// bool tsdbNoProblem(STsdbRepo* pRepo) {
// if(listNEles(pRepo->pPool->bufBlockList) == 0)
// return false;
// return true;
// }
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
cc3ead15
...
...
@@ -713,13 +713,6 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe
pCheckInfo
->
initBuf
=
true
;
int32_t
order
=
pHandle
->
order
;
// no data in buffer, abort
// if (pHandle->pMemTable->snapshot.mem == NULL && pHandle->pMemTable->snapshot.imem == NULL) {
// return false;
// }
//
// assert(pCheckInfo->iter == NULL && pCheckInfo->iiter == NULL);
//
STbData
**
pMem
=
NULL
;
STbData
**
pIMem
=
NULL
;
...
...
@@ -787,8 +780,7 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe
assert
(
pCheckInfo
->
lastKey
>=
key
);
}
}
else
{
tsdbDebug
(
"%p uid:%"
PRId64
", no data in imem, 0x%"
PRIx64
,
pHandle
,
pCheckInfo
->
tableId
,
pHandle
->
qId
);
tsdbDebug
(
"%p uid:%"
PRId64
", no data in imem, 0x%"
PRIx64
,
pHandle
,
pCheckInfo
->
tableId
,
pHandle
->
qId
);
}
return
true
;
...
...
@@ -2554,9 +2546,6 @@ static bool doHasDataInBuffer(STsdbReadHandle* pTsdbReadHandle) {
pTsdbReadHandle
->
activeIndex
+=
1
;
}
// no data in memtable or imemtable, decrease the memory reference.
// TODO !!
// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle);
return
false
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c
已删除
100644 → 0
浏览文件 @
8b061f52
/*
* 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 "tsdbRowMergeBuf.h"
// #include "tdataformat.h"
// // row1 has higher priority
// SMemRow tsdbMergeTwoRows(SMergeBuf *pBuf, SMemRow row1, SMemRow row2, STSchema *pSchema1, STSchema *pSchema2) {
// if(row2 == NULL) return row1;
// if(row1 == NULL) return row2;
// ASSERT(pSchema1->version == memRowVersion(row1));
// ASSERT(pSchema2->version == memRowVersion(row2));
// if(tsdbMergeBufMakeSureRoom(pBuf, pSchema1, pSchema2) < 0) {
// return NULL;
// }
// return mergeTwoMemRows(*pBuf, row1, row2, pSchema1, pSchema2);
// }
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
cc3ead15
...
...
@@ -17,9 +17,11 @@
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitMsg
*
pMsg
,
SSubmitRsp
*
pRsp
)
{
// Check if mem is there. If not, create one.
pTsdb
->
mem
=
tsdbNewMemTable
(
pTsdb
);
if
(
pTsdb
->
mem
==
NULL
)
{
return
-
1
;
pTsdb
->
mem
=
tsdbNewMemTable
(
pTsdb
);
if
(
pTsdb
->
mem
==
NULL
)
{
return
-
1
;
}
}
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
static
SVArenaNode
*
vArenaNodeNew
(
uint64_t
capacity
);
static
void
vArenaNodeFree
(
SVArenaNode
*
pNode
);
...
...
source/dnode/vnode/src/vnd/vnodeBufferPool.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
/* ------------------------ STRUCTURES ------------------------ */
#define VNODE_BUF_POOL_SHARDS 3
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
const
SVnodeCfg
defaultVnodeOptions
=
{
.
wsize
=
96
*
1024
*
1024
,
.
ssize
=
1
*
1024
*
1024
,
.
lsize
=
1024
,
.
walCfg
=
{.
level
=
TAOS_WAL_WRITE
}};
/* TODO */
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeInt.c
浏览文件 @
cc3ead15
...
...
@@ -14,7 +14,8 @@
*/
#define _DEFAULT_SOURCE
#include "vnodeInt.h"
#include "vnd.h"
// #include "vnodeInt.h"
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
static
void
vnodeFree
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeMgr.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
SVnodeMgr
vnodeMgr
=
{.
vnodeInitFlag
=
TD_MOD_UNINITIALIZED
};
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
cc3ead15
...
...
@@ -14,7 +14,7 @@
*/
#include "vnodeQuery.h"
#include "vn
odeDef
.h"
#include "vn
d
.h"
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
...
...
@@ -79,6 +79,7 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
pTbCfg
=
metaGetTbInfoByName
(
pVnode
->
pMeta
,
pReq
->
tableFname
,
&
uid
);
if
(
pTbCfg
==
NULL
)
{
code
=
TSDB_CODE_VND_TB_NOT_EXIST
;
goto
_exit
;
}
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
cc3ead15
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vn
odeDef
.h"
#include "vn
d
.h"
int
vnodeProcessNoWalWMsgs
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
switch
(
pMsg
->
msgType
)
{
...
...
@@ -84,6 +84,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// TODO: handle error
}
vTrace
(
"vgId:%d process create table %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
free
(
pCreateTbReq
->
name
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
free
(
pCreateTbReq
->
stbCfg
.
pSchema
);
free
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
...
...
@@ -116,7 +117,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// Check if it needs to commit
if
(
vnodeShouldCommit
(
pVnode
))
{
tsem_wait
(
&
(
pVnode
->
canCommit
));
//
tsem_wait(&(pVnode->canCommit));
if
(
vnodeAsyncCommit
(
pVnode
)
<
0
)
{
// TODO: handle error
}
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
cc3ead15
...
...
@@ -285,16 +285,16 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
char
dbFullName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFullName
);
ctgDebug
(
"try to get table meta from vnode, db:%s, tbName:%s"
,
dbFullName
,
pTableName
->
tname
);
ctgDebug
(
"try to get table meta from vnode, db:%s, tbName:%s"
,
dbFullName
,
tNameGetTableName
(
pTableName
)
);
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
dbName
=
dbFullName
,
.
tableFullName
=
(
char
*
)
pTableName
->
tname
};
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
dbName
=
dbFullName
,
.
tableFullName
=
(
char
*
)
tNameGetTableName
(
pTableName
)
};
char
*
msg
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
int32_t
msgLen
=
0
;
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
&
bInput
,
&
msg
,
0
,
&
msgLen
);
if
(
code
)
{
ctgError
(
"Build vnode tablemeta msg failed, code:%x, tbName:%s"
,
code
,
pTableName
->
tname
);
ctgError
(
"Build vnode tablemeta msg failed, code:%x, tbName:%s"
,
code
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_RET
(
code
);
}
...
...
@@ -313,21 +313,21 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
SET_META_TYPE_NONE
(
output
->
metaType
);
ctgDebug
(
"tablemeta not exist in vnode, tbName:%s"
,
pTableName
->
tname
);
ctgDebug
(
"tablemeta not exist in vnode, tbName:%s"
,
tNameGetTableName
(
pTableName
)
);
return
TSDB_CODE_SUCCESS
;
}
ctgError
(
"error rsp for table meta from vnode, code:%x, tbName:%s"
,
rpcRsp
.
code
,
pTableName
->
tname
);
ctgError
(
"error rsp for table meta from vnode, code:%x, tbName:%s"
,
rpcRsp
.
code
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_RET
(
rpcRsp
.
code
);
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
output
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
if
(
code
)
{
ctgError
(
"Process vnode tablemeta rsp failed, code:%x, tbName:%s"
,
code
,
pTableName
->
tname
);
ctgError
(
"Process vnode tablemeta rsp failed, code:%x, tbName:%s"
,
code
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_RET
(
code
);
}
ctgDebug
(
"Got table meta from vnode, db:%s, tbName:%s"
,
dbFullName
,
pTableName
->
tname
);
ctgDebug
(
"Got table meta from vnode, db:%s, tbName:%s"
,
dbFullName
,
tNameGetTableName
(
pTableName
)
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -776,7 +776,7 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
STableMetaOutput
*
output
=
&
voutput
;
if
(
CTG_IS_STABLE
(
isSTable
))
{
ctgDebug
(
"will renew table meta, supposed to be stable, tbName:%s"
,
pTableName
->
tname
);
ctgDebug
(
"will renew table meta, supposed to be stable, tbName:%s"
,
tNameGetTableName
(
pTableName
)
);
// if get from mnode failed, will not try vnode
CTG_ERR_JRET
(
ctgGetTableMetaFromMnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
moutput
));
...
...
@@ -787,13 +787,13 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
output
=
&
moutput
;
}
}
else
{
ctgDebug
(
"will renew table meta, not supposed to be stable, tbName:%s, isStable:%d"
,
pTableName
->
tname
,
isSTable
);
ctgDebug
(
"will renew table meta, not supposed to be stable, tbName:%s, isStable:%d"
,
tNameGetTableName
(
pTableName
)
,
isSTable
);
// if get from vnode failed or no table meta, will not try mnode
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
if
(
CTG_IS_META_TABLE
(
voutput
.
metaType
)
&&
TSDB_SUPER_TABLE
==
voutput
.
tbMeta
->
tableType
)
{
ctgDebug
(
"will continue to renew table meta since got stable, tbName:%s, metaType:%d"
,
pTableName
->
tname
,
voutput
.
metaType
);
ctgDebug
(
"will continue to renew table meta since got stable, tbName:%s, metaType:%d"
,
tNameGetTableName
(
pTableName
)
,
voutput
.
metaType
);
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFname
,
&
moutput
));
...
...
@@ -820,7 +820,7 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
}
if
(
CTG_IS_META_NONE
(
output
->
metaType
))
{
ctgError
(
"no tablemeta got, tbNmae:%s"
,
pTableName
->
tname
);
ctgError
(
"no tablemeta got, tbNmae:%s"
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_JRET
(
CTG_ERR_CODE_TABLE_NOT_EXIST
);
}
...
...
@@ -860,7 +860,7 @@ int32_t ctgGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMg
CTG_ERR_RET
(
ctgGetTableMetaFromCache
(
pCatalog
,
pTableName
,
pTableMeta
,
&
exist
));
if
(
0
==
exist
)
{
ctgError
(
"renew tablemeta succeed but get from cache failed, may be deleted, tbName:%s"
,
pTableName
->
tname
);
ctgError
(
"renew tablemeta succeed but get from cache failed, may be deleted, tbName:%s"
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
...
...
@@ -1241,7 +1241,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
}
else
{
int32_t
vgId
=
tbMeta
->
vgId
;
if
(
NULL
==
taosHashGetClone
(
dbVgroup
->
vgInfo
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
))
{
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
pTableName
->
tname
);
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
...
...
@@ -1252,7 +1252,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
}
if
(
NULL
==
taosArrayPush
(
vgList
,
&
vgroupInfo
))
{
ctgError
(
"taosArrayPush vgroupInfo to array failed, vgId:%d, tbName:%s"
,
vgId
,
pTableName
->
tname
);
ctgError
(
"taosArrayPush vgroupInfo to array failed, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
)
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
cc3ead15
...
...
@@ -374,6 +374,12 @@ typedef struct STaskParam {
struct
SUdfInfo
*
pUdfInfo
;
}
STaskParam
;
typedef
struct
SExchangeInfo
{
int32_t
numOfSources
;
SEpSet
*
pEpset
;
int32_t
bytes
;
// total load bytes from remote
}
SExchangeInfo
;
typedef
struct
STableScanInfo
{
void
*
pTsdbReadHandle
;
int32_t
numOfBlocks
;
...
...
@@ -393,12 +399,9 @@ typedef struct STableScanInfo {
SSDataBlock
block
;
int32_t
numOfOutput
;
int64_t
elapsedTime
;
int32_t
tableIndex
;
int32_t
prevGroupId
;
// previous table group id
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
STimeWindow
window
;
}
STableScanInfo
;
typedef
struct
STagScanInfo
{
...
...
@@ -542,34 +545,36 @@ typedef struct SOrderOperatorInfo {
void
appendUpstream
(
SOperatorInfo
*
p
,
SOperatorInfo
*
pUpstream
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
,
int32_t
repeatTime
,
int32_t
reverseTime
);
SOperatorInfo
*
createTableScanOperator
(
void
*
pTsdbQueryHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createProjectOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
);
SOperatorInfo
*
createTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSWindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
);
SOperatorInfo
*
createGroupbyOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SVgroupInfo
*
pVgroups
,
int32_t
numOfSources
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createProjectOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSWindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
);
SOperatorInfo
*
createGroupbyOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTagScanOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createDistinctOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTableBlockInfoScanOperator
(
void
*
pTsdb
Query
Handle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createDistinctOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTableBlockInfoScanOperator
(
void
*
pTsdb
Read
Handle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createMultiwaySortOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
numOfRows
,
void
*
merger
);
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
param
,
SArray
*
pUdfInfo
,
bool
groupResultMixedUp
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
merger
,
bool
multigroupResult
);
SOperatorInfo
*
createFilterOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
param
,
SArray
*
pUdfInfo
,
bool
groupResultMixedUp
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
merger
,
bool
multigroupResult
);
SOperatorInfo
*
createFilterOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SColumnInfo
*
pCols
,
int32_t
numOfFilter
);
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
p
Upstream
,
int32_t
numOfUp
stream
,
SSchema
*
pSchema
,
int32_t
numOfOutput
);
SOperatorInfo
*
createOrderOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
up
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrder
*
pOrderVal
);
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
p
downstream
,
int32_t
numOfDown
stream
,
SSchema
*
pSchema
,
int32_t
numOfOutput
);
SOperatorInfo
*
createOrderOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
down
stream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrder
*
pOrderVal
);
//SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
//SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/libs/function/src/tscalarfunction.c
浏览文件 @
cc3ead15
...
...
@@ -2,7 +2,6 @@
#include "tbinoperator.h"
#include "tunaryoperator.h"
static
void
assignBasicParaInfo
(
struct
SScalarFuncParam
*
dst
,
const
struct
SScalarFuncParam
*
src
)
{
dst
->
type
=
src
->
type
;
dst
->
bytes
=
src
->
bytes
;
...
...
source/libs/parser/inc/astGenerator.h
浏览文件 @
cc3ead15
...
...
@@ -170,8 +170,6 @@ typedef struct SCreateDbInfo {
int8_t
update
;
int8_t
cachelast
;
SArray
*
keep
;
// int8_t dbType;
// int16_t partitions;
}
SCreateDbInfo
;
typedef
struct
SCreateFuncInfo
{
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
cc3ead15
...
...
@@ -8,7 +8,7 @@
SCreateUserReq
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcctReq
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUserReq
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
...
...
source/libs/parser/src/astGenerator.c
浏览文件 @
cc3ead15
...
...
@@ -972,14 +972,15 @@ void tSetDbName(SToken *pCpxName, SToken *pDb) {
void
tSetColumnInfo
(
SField
*
pField
,
SToken
*
pName
,
SField
*
pType
)
{
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
//
column name is too long, set the
it to be invalid.
//
The column name is too long, set
it to be invalid.
if
((
int32_t
)
pName
->
n
>=
maxLen
)
{
p
Name
->
n
=
-
1
;
p
Field
->
name
[
0
]
=
0
;
}
else
{
strncpy
(
pField
->
name
,
pName
->
z
,
pName
->
n
);
pField
->
name
[
pName
->
n
]
=
0
;
}
// denote an invalid data type in the column definition.
pField
->
type
=
pType
->
type
;
if
(
!
isValidDataType
(
pField
->
type
)){
pField
->
bytes
=
0
;
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
cc3ead15
...
...
@@ -85,8 +85,12 @@ SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, cha
return
pMsg
;
}
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pCtx
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SShowReq
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
if
(
pShowMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
pShowMsg
;
}
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
...
...
@@ -105,7 +109,22 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext *pCtx, char* msgBuf,
if
(
pShowInfo
->
showType
==
TSDB_MGMT_TABLE_STB
||
pShowInfo
->
showType
==
TSDB_MGMT_TABLE_VGROUP
)
{
SName
n
=
{
0
};
tNameSetDbName
(
&
n
,
pCtx
->
acctId
,
pCtx
->
db
,
strlen
(
pCtx
->
db
));
if
(
pShowInfo
->
prefix
.
n
>
0
)
{
if
(
pShowInfo
->
prefix
.
n
>=
TSDB_DB_FNAME_LEN
)
{
terrno
=
buildInvalidOperationMsg
(
pMsgBuf
,
"prefix name is too long"
);
tfree
(
pShowMsg
);
return
NULL
;
}
tNameSetDbName
(
&
n
,
pCtx
->
acctId
,
pShowInfo
->
prefix
.
z
,
pShowInfo
->
prefix
.
n
);
}
else
if
(
pCtx
->
db
==
NULL
||
strlen
(
pCtx
->
db
)
==
0
)
{
terrno
=
buildInvalidOperationMsg
(
pMsgBuf
,
"database is not specified"
);
tfree
(
pShowMsg
);
return
NULL
;
}
else
{
tNameSetDbName
(
&
n
,
pCtx
->
acctId
,
pCtx
->
db
,
strlen
(
pCtx
->
db
));
}
tNameGetFullDbName
(
&
n
,
pShowMsg
->
db
);
}
...
...
@@ -240,6 +259,9 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len
}
SMCreateStbReq
*
pCreateStbMsg
=
(
SMCreateStbReq
*
)
calloc
(
1
,
sizeof
(
SMCreateStbReq
)
+
(
numOfCols
+
numOfTags
)
*
sizeof
(
SSchema
));
if
(
pCreateStbMsg
==
NULL
)
{
return
NULL
;
}
char
*
pMsg
=
NULL
;
#if 0
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
cc3ead15
...
...
@@ -917,6 +917,8 @@ int32_t validateLimitNode(SQueryStmtInfo *pQueryInfo, SSqlNode* pSqlNode, SMsgBu
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
validateOrderbyNode
(
SQueryStmtInfo
*
pQueryInfo
,
SSqlNode
*
pSqlNode
,
SMsgBuf
*
pMsgBuf
)
{
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
cc3ead15
...
...
@@ -109,7 +109,11 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
}
*
pEpSet
=
pCtx
->
mgmtEpSet
;
*
output
=
buildShowMsg
(
pShowInfo
,
pCtx
,
pMsgBuf
->
buf
,
pMsgBuf
->
len
);
*
output
=
buildShowMsg
(
pShowInfo
,
pCtx
,
pMsgBuf
);
if
(
*
output
==
NULL
)
{
return
terrno
;
}
*
outputLen
=
sizeof
(
SShowReq
)
/* + htons(pShowMsg->payloadLen)*/
;
}
...
...
@@ -312,9 +316,9 @@ int32_t doCheckForCreateTable(SCreateTableSql* pCreateTable, SMsgBuf* pMsgBuf) {
assert
(
pFieldList
!=
NULL
);
// if sql specifies db, use it, otherwise use default db
SToken
*
p
zTableName
=
&
(
pCreateTable
->
name
);
SToken
*
p
NameToken
=
&
(
pCreateTable
->
name
);
if
(
parserValidate
NameToken
(
pzTableName
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parserValidate
IdToken
(
pNameToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
...
...
@@ -973,6 +977,7 @@ SVnodeModifOpStmtInfo* qParserValidateCreateTbSqlNode(SSqlInfo* pInfo, SParseCon
int32_t
msgLen
=
0
;
int32_t
code
=
doCheckAndBuildCreateTableReq
(
pCreateTable
,
pCtx
,
pMsgBuf
,
(
char
**
)
&
pModifSqlStmt
,
&
msgLen
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
tfree
(
pModifSqlStmt
);
return
NULL
;
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
cc3ead15
...
...
@@ -80,11 +80,11 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
)
{
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
Node
)
{
if
(
isInsertSql
(
pCxt
->
pSql
,
pCxt
->
sqlLen
))
{
return
parseInsertSql
(
pCxt
,
(
SVnodeModifOpStmtInfo
**
)
pQuery
);
return
parseInsertSql
(
pCxt
,
(
SVnodeModifOpStmtInfo
**
)
pQuery
Node
);
}
else
{
return
parseQuerySql
(
pCxt
,
pQuery
);
return
parseQuerySql
(
pCxt
,
pQuery
Node
);
}
}
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
cc3ead15
...
...
@@ -124,12 +124,13 @@ int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf) {
}
int32_t
parserValidateNameToken
(
SToken
*
pToken
)
{
if
(
pToken
==
NULL
||
pToken
->
z
==
NULL
||
pToken
->
type
!=
TK_ID
)
{
if
(
pToken
==
NULL
||
pToken
->
z
==
NULL
||
pToken
->
type
!=
TK_ID
||
pToken
->
n
==
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
// it is a token quoted with escape char '`'
if
(
pToken
->
z
[
0
]
==
TS_ESCAPE_CHAR
&&
pToken
->
z
[
pToken
->
n
-
1
]
==
TS_ESCAPE_CHAR
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1945,17 +1946,30 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param) {
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"name too long"
;
const
char
*
msg2
=
"invalid database name"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
char
*
p
=
strnchr
(
pTableName
->
z
,
TS_PATH_DELIMITER
[
0
],
pTableName
->
n
,
fals
e
);
char
*
p
=
strnchr
(
pTableName
->
z
,
TS_PATH_DELIMITER
[
0
],
pTableName
->
n
,
tru
e
);
if
(
p
!=
NULL
)
{
// db has been specified in sql string so we ignore current db path
tNameSetAcctId
(
pName
,
pParseCtx
->
acctId
);
assert
(
*
p
==
TS_PATH_DELIMITER
[
0
]
);
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
strncpy
(
name
,
pTableName
->
z
,
pTableName
->
n
);
int32_t
dbLen
=
p
-
pTableName
->
z
;
char
name
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
strncpy
(
name
,
pTableName
->
z
,
dbLen
);
dbLen
=
strdequote
(
name
);
code
=
tNameFromString
(
pName
,
name
,
T_NAME_DB
|
T_NAME_TABLE
);
code
=
tNameSetDbName
(
pName
,
pParseCtx
->
acctId
,
name
,
dbLen
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
int32_t
tbLen
=
pTableName
->
n
-
dbLen
-
1
;
char
tbname
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
strncpy
(
tbname
,
p
+
1
,
tbLen
);
/*tbLen = */
strdequote
(
tbname
);
code
=
tNameFromString
(
pName
,
tbname
,
T_NAME_TABLE
);
if
(
code
!=
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
...
...
@@ -1964,10 +1978,17 @@ int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pParseCtx,
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
tNameSetDbName
(
pName
,
pParseCtx
->
acctId
,
pParseCtx
->
db
,
strlen
(
pParseCtx
->
db
)
);
assert
(
pTableName
->
n
<
TSDB_TABLE_FNAME_LEN
);
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
strncpy
(
name
,
pTableName
->
z
,
pTableName
->
n
);
strdequote
(
name
);
code
=
tNameSetDbName
(
pName
,
pParseCtx
->
acctId
,
pParseCtx
->
db
,
strlen
(
pParseCtx
->
db
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
code
=
buildInvalidOperationMsg
(
pMsgBuf
,
msg2
);
return
code
;
}
code
=
tNameFromString
(
pName
,
name
,
T_NAME_TABLE
);
if
(
code
!=
0
)
{
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
cc3ead15
...
...
@@ -189,6 +189,7 @@ static SPhyNode* createUserTableScanNode(SQueryPlanNode* pPlanNode, SQueryTableI
return
(
SPhyNode
*
)
node
;
}
static
bool
isSystemTable
(
SQueryTableInfo
*
pTable
)
{
// todo
return
false
;
...
...
@@ -261,8 +262,8 @@ static void vgroupMsgToEpSet(const SVgroupMsg* vg, SQueryNodeAddr* execNode) {
}
static
uint64_t
splitSubplanByTable
(
SPlanContext
*
pCxt
,
SQueryPlanNode
*
pPlanNode
,
SQueryTableInfo
*
pTable
)
{
SVgroupsInfo
*
v
groupList
=
pTable
->
pMeta
->
vgroupList
;
for
(
int32_t
i
=
0
;
i
<
p
Table
->
pMeta
->
v
groupList
->
numOfVgroups
;
++
i
)
{
SVgroupsInfo
*
pV
groupList
=
pTable
->
pMeta
->
vgroupList
;
for
(
int32_t
i
=
0
;
i
<
p
V
groupList
->
numOfVgroups
;
++
i
)
{
STORE_CURRENT_SUBPLAN
(
pCxt
);
SSubplan
*
subplan
=
initSubplan
(
pCxt
,
QUERY_TYPE_SCAN
);
subplan
->
msgType
=
TDMT_VND_QUERY
;
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
cc3ead15
...
...
@@ -559,28 +559,35 @@ static const char* jkScanNodeTableId = "TableId";
static
const
char
*
jkScanNodeTableType
=
"TableType"
;
static
const
char
*
jkScanNodeTableOrder
=
"Order"
;
static
const
char
*
jkScanNodeTableCount
=
"Count"
;
static
const
char
*
jkScanNodeTableRevCount
=
"Reverse"
;
static
bool
scanNodeToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SScanPhyNode
*
scan
=
(
const
SScanPhyNode
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableId
,
scan
->
uid
);
const
SScanPhyNode
*
pNode
=
(
const
SScanPhyNode
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableId
,
pNode
->
uid
);
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableType
,
pNode
->
tableType
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
Type
,
scan
->
tableType
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
Order
,
pNode
->
order
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
Order
,
scan
->
order
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
Count
,
pNode
->
count
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
Count
,
scan
->
count
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTable
RevCount
,
pNode
->
reverse
);
}
return
res
;
}
static
bool
scanNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SScanPhyNode
*
scan
=
(
SScanPhyNode
*
)
obj
;
scan
->
uid
=
getNumber
(
json
,
jkScanNodeTableId
);
scan
->
tableType
=
getNumber
(
json
,
jkScanNodeTableType
);
scan
->
count
=
getNumber
(
json
,
jkScanNodeTableCount
);
scan
->
order
=
getNumber
(
json
,
jkScanNodeTableOrder
);
SScanPhyNode
*
pNode
=
(
SScanPhyNode
*
)
obj
;
pNode
->
uid
=
getNumber
(
json
,
jkScanNodeTableId
);
pNode
->
tableType
=
getNumber
(
json
,
jkScanNodeTableType
);
pNode
->
count
=
getNumber
(
json
,
jkScanNodeTableCount
);
pNode
->
order
=
getNumber
(
json
,
jkScanNodeTableOrder
);
pNode
->
reverse
=
getNumber
(
json
,
jkScanNodeTableRevCount
);
return
true
;
}
...
...
@@ -996,10 +1003,13 @@ static SSubplan* subplanFromJson(const cJSON* json) {
if
(
NULL
==
subplan
)
{
return
NULL
;
}
bool
res
=
fromObject
(
json
,
jkSubplanId
,
subplanIdFromJson
,
&
subplan
->
id
,
true
);
if
(
res
)
{
res
=
fromPnode
(
json
,
jkSubplanNode
,
phyNodeFromJson
,
(
void
**
)
&
subplan
->
pNode
);
}
if
(
res
)
{
res
=
fromObjectWithAlloc
(
json
,
jkSubplanDataSink
,
dataSinkFromJson
,
(
void
**
)
&
subplan
->
pDataSink
,
sizeof
(
SDataSink
),
false
);
}
...
...
@@ -1027,7 +1037,7 @@ int32_t subPlanToString(const SSubplan* subplan, char** str, int32_t* len) {
}
*
str
=
cJSON_Print
(
json
);
// printf("====Physical plan:====\n")
// printf("====Physical plan:====\n")
;
// printf("%s\n", *str);
*
len
=
strlen
(
*
str
)
+
1
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1047,14 +1057,18 @@ cJSON* qDagToJson(const SQueryDag* pDag) {
if
(
pRoot
==
NULL
)
{
return
NULL
;
}
cJSON_AddNumberToObject
(
pRoot
,
"numOfSubplans"
,
pDag
->
numOfSubplans
);
cJSON_AddNumberToObject
(
pRoot
,
"queryId"
,
pDag
->
queryId
);
cJSON_AddNumberToObject
(
pRoot
,
"Number"
,
pDag
->
numOfSubplans
);
cJSON_AddNumberToObject
(
pRoot
,
"QueryId"
,
pDag
->
queryId
);
cJSON
*
pLevels
=
cJSON_CreateArray
();
if
(
pLevels
==
NULL
)
{
cJSON_Delete
(
pRoot
);
return
NULL
;
}
cJSON_AddItemToObject
(
pRoot
,
"pSubplans"
,
pLevels
);
cJSON_AddItemToObject
(
pRoot
,
"Subplans"
,
pLevels
);
size_t
level
=
taosArrayGetSize
(
pDag
->
pSubplans
);
for
(
size_t
i
=
0
;
i
<
level
;
i
++
)
{
const
SArray
*
pSubplans
=
(
const
SArray
*
)
taosArrayGetP
(
pDag
->
pSubplans
,
i
);
...
...
@@ -1064,6 +1078,7 @@ cJSON* qDagToJson(const SQueryDag* pDag) {
cJSON_Delete
(
pRoot
);
return
NULL
;
}
cJSON_AddItemToArray
(
pLevels
,
plansOneLevel
);
for
(
size_t
j
=
0
;
j
<
num
;
j
++
)
{
cJSON
*
pSubplan
=
subplanToJson
((
const
SSubplan
*
)
taosArrayGetP
(
pSubplans
,
j
));
...
...
@@ -1071,6 +1086,7 @@ cJSON* qDagToJson(const SQueryDag* pDag) {
cJSON_Delete
(
pRoot
);
return
NULL
;
}
cJSON_AddItemToArray
(
plansOneLevel
,
pSubplan
);
}
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
cc3ead15
...
...
@@ -1029,6 +1029,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
msg
=
pTask
->
msg
;
break
;
}
case
TDMT_VND_QUERY
:
{
msgSize
=
sizeof
(
SSubQueryMsg
)
+
pTask
->
msgLen
;
msg
=
calloc
(
1
,
msgSize
);
...
...
@@ -1047,7 +1048,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
pMsg
->
contentLen
=
htonl
(
pTask
->
msgLen
);
memcpy
(
pMsg
->
msg
,
pTask
->
msg
,
pTask
->
msgLen
);
break
;
}
}
case
TDMT_VND_RES_READY
:
{
msgSize
=
sizeof
(
SResReadyReq
);
msg
=
calloc
(
1
,
msgSize
);
...
...
source/libs/tdb/CMakeLists.txt
浏览文件 @
cc3ead15
aux_source_directory
(
src TDB_SRC
)
set
(
TDB_SUBDIRS
"btree"
"db"
"hash"
"mpool"
"dmgr"
)
foreach
(
TDB_SUBDIR
${
TDB_SUBDIRS
}
)
aux_source_directory
(
"src/
${
TDB_SUBDIR
}
"
TDB_SRC
)
endforeach
()
add_library
(
tdb STATIC
${
TDB_SRC
}
)
# target_include_directories(
# tkv
# PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv"
# PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
# )
target_include_directories
(
tdb
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
...
...
@@ -17,5 +18,5 @@ target_link_libraries(
)
if
(
${
BUILD_TEST
}
)
#
add_subdirectory(test)
add_subdirectory
(
test
)
endif
(
${
BUILD_TEST
}
)
source/libs/tdb/inc/tdb.h
浏览文件 @
cc3ead15
...
...
@@ -22,10 +22,14 @@
extern
"C"
{
#endif
#define TDB_EXTERN
#define TDB_PUBLIC
#define TDB_STATIC static
typedef
enum
{
TDB_BTREE
=
0
,
TDB_HASH
,
TDB_HEAP
,
TDB_BTREE
_T
=
0
,
TDB_HASH
_T
,
TDB_HEAP
_T
,
}
tdb_db_t
;
// Forward declaration
...
...
@@ -39,9 +43,9 @@ typedef struct {
}
TDB_KEY
,
TDB_VALUE
;
// TDB Operations
int
tdbCreateDB
(
TDB
**
dbpp
);
int
tdbOpenDB
(
TDB
*
dbp
,
tdb_db_t
type
,
uint32_t
flags
);
int
tdbCloseDB
(
TDB
*
dbp
,
uint32_t
flags
);
TDB_EXTERN
int
tdbCreateDB
(
TDB
**
dbpp
,
tdb_db_t
type
);
TDB_EXTERN
int
tdbOpenDB
(
TDB
*
dbp
,
uint32_t
flags
);
TDB_EXTERN
int
tdbCloseDB
(
TDB
*
dbp
,
uint32_t
flags
);
#ifdef __cplusplus
}
...
...
source/
dnode/vnode/src/inc/tsdbRowMergeBuf.h
→
source/
libs/tdb/src/db/tdbDB.c
浏览文件 @
cc3ead15
...
...
@@ -13,37 +13,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#i
fndef TSDB_ROW_MERGE_BUF_H
#
define TSDB_ROW_MERGE_BUF_H
#i
nclude "tdbDB.h"
#
include "tdb.h"
#if 0
TDB_EXTERN
int
tdbCreateDB
(
TDB
**
dbpp
,
tdb_db_t
type
)
{
TDB
*
dbp
;
int
ret
;
#ifdef __cplusplus
extern "C" {
#endif
dbp
=
calloc
(
1
,
sizeof
(
*
dbp
));
if
(
dbp
==
NULL
)
{
return
-
1
;
}
#include "tsdb.h"
#include "tchecksum.h"
#include "tsdbReadImpl.h"
dbp
->
pageSize
=
TDB_DEFAULT_PGSIZE
;
dbp
->
type
=
type
;
typedef void* SMergeBuf;
switch
(
type
)
{
case
TDB_BTREE_T
:
// ret = tdbInitBtreeDB(dbp);
// if (ret < 0) goto _err;
break
;
case
TDB_HASH_T
:
// ret = tdbInitHashDB(dbp);
// if (ret < 0) goto _err;
break
;
case
TDB_HEAP_T
:
// ret = tdbInitHeapDB(dbp);
// if (ret < 0) goto _err;
break
;
default:
break
;
}
SDataRow tsdbMergeTwoRows(SMergeBuf *pBuf, SMemRow row1, SMemRow row2, STSchema *pSchema1, STSchema *pSchema2);
*
dbpp
=
dbp
;
return
0
;
static FORCE_INLINE int tsdbMergeBufMakeSureRoom(SMergeBuf *pBuf, STSchema* pSchema1, STSchema* pSchema2) {
size_t len1 = dataRowMaxBytesFromSchema(pSchema1);
size_t len2 = dataRowMaxBytesFromSchema(pSchema2);
return tsdbMakeRoom(pBuf, MAX(len1, len2));
_err:
if
(
dbp
)
{
free
(
dbp
);
}
*
dbpp
=
NULL
;
return
0
;
}
static FORCE_INLINE void tsdbFreeMergeBuf(SMergeBuf buf) {
taosTZfree(buf);
TDB_EXTERN
int
tdbOpenDB
(
TDB
*
dbp
,
uint32_t
flags
)
{
// TODO
return
0
;
}
#ifdef __cplusplus
}
#endif
#endif
#endif
/* ifndef TSDB_ROW_MERGE_BUF_H */
TDB_EXTERN
int
tdbCloseDB
(
TDB
*
dbp
,
uint32_t
flags
)
{
// TODO
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/tdbDiskMgr.c
→
source/libs/tdb/src/
dmgr/
tdbDiskMgr.c
浏览文件 @
cc3ead15
文件已移动
source/libs/tdb/src/inc/tdbBtree.h
浏览文件 @
cc3ead15
...
...
@@ -16,7 +16,7 @@
#ifndef _TD_TDB_BTREE_H_
#define _TD_TDB_BTREE_H_
#include "t
kv
Def.h"
#include "t
db
Def.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -26,6 +26,8 @@ typedef struct {
pgid_t
root
;
// root page number
}
TDB_BTREE
;
TDB_PUBLIC
int
tdbInitBtreeDB
(
TDB
*
dbp
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/tdb/src/inc/tdbDB.h
浏览文件 @
cc3ead15
...
...
@@ -16,21 +16,25 @@
#ifndef _TD_TDB_DB_H_
#define _TD_TDB_DB_H_
#include "tdb.h"
#include "tdbBtree.h"
#include "tdbHash.h"
#include "tdbHeap.h"
#ifdef __cplusplus
extern
"C"
{
#endif
struct
TDB
{
pgsize_t
pageSize
;
tdb_db_t
type
;
char
*
fname
;
char
*
dbname
;
union
{
TDB_BTREE
btree
;
TDB_HASH
hash
;
}
dbam
;
// Different access methods
TDB_BTREE
*
btree
;
TDB_HASH
*
hash
;
TDB_HEAP
*
heap
;
}
dbam
;
// db access method
};
#ifdef __cplusplus
...
...
source/libs/tdb/src/inc/tdbDef.h
浏览文件 @
cc3ead15
...
...
@@ -24,16 +24,17 @@ extern "C" {
// pgid_t
typedef
int32_t
pgid_t
;
#define T
KV
_IVLD_PGID ((pgid_t)-1)
#define T
DB
_IVLD_PGID ((pgid_t)-1)
// framd_id_t
typedef
int32_t
frame_id_t
;
// pgsize_t
typedef
int32_t
pgsize_t
;
#define TKV_MIN_PGSIZE 512
#define TKV_MAX_PGSIZE 16384
#define TKV_IS_PGSIZE_VLD(s) (((s) >= TKV_MIN_PGSIZE) && (TKV_MAX_PGSIZE <= TKV_MAX_PGSIZE))
#define TDB_MIN_PGSIZE 512
#define TDB_MAX_PGSIZE 16384
#define TDB_DEFAULT_PGSIZE 4096
#define TDB_IS_PGSIZE_VLD(s) (((s) >= TKV_MIN_PGSIZE) && (TKV_MAX_PGSIZE <= TKV_MAX_PGSIZE))
#ifdef __cplusplus
}
...
...
source/libs/tdb/src/inc/tdbHash.h
浏览文件 @
cc3ead15
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_T
KV_HAHS
_H_
#define _TD_T
KV_HAHS
_H_
#ifndef _TD_T
DB_HASH
_H_
#define _TD_T
DB_HASH
_H_
#include "tdbDef.h"
...
...
@@ -26,8 +26,10 @@ typedef struct {
// TODO
}
TDB_HASH
;
TDB_PUBLIC
int
tdbInitHashDB
(
TDB
*
dbp
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TKV_HAHS_H_*/
\ No newline at end of file
#endif
/*_TD_TDB_HASH_H_*/
\ No newline at end of file
source/
dnode/vnode/src/inc/vnodeStateMgr
.h
→
source/
libs/tdb/src/inc/tdbHeap
.h
浏览文件 @
cc3ead15
...
...
@@ -13,21 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_STATE_MGR_H_
#define _TD_VNODE_STATE_MGR_H_
#ifndef _TD_TDB_HEAP_H_
#define _TD_TDB_HEAP_H_
#include "tdbDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int64_t
processed
;
int64_t
committed
;
int64_t
applied
;
}
SVState
;
// TODO
}
TDB_HEAP
;
TDB_PUBLIC
int
tdbInitHeapDB
(
TDB
*
dbp
)
;
#ifdef __cplusplus
}
#endif
#endif
/*_TD_
VNODE_STATE_MGR
_H_*/
#endif
/*_TD_
TDB_HEAP
_H_*/
\ No newline at end of file
source/libs/tdb/src/tdbBufPool.c
→
source/libs/tdb/src/
mpool/
tdbBufPool.c
浏览文件 @
cc3ead15
文件已移动
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
cc3ead15
...
...
@@ -6,9 +6,9 @@ TEST(tdb_api_test, tdb_create_open_close_db_test) {
int
ret
;
TDB
*
dbp
;
tdbCreateDB
(
&
dbp
);
tdbCreateDB
(
&
dbp
,
TDB_BTREE_T
);
tdbOpenDB
(
dbp
,
TDB_BTREE
,
0
);
tdbOpenDB
(
dbp
,
0
);
tdbCloseDB
(
dbp
,
0
);
}
\ No newline at end of file
source/libs/transport/CMakeLists.txt
浏览文件 @
cc3ead15
...
...
@@ -27,4 +27,11 @@ if (${BUILD_WITH_UV})
add_definitions
(
-DUSE_UV
)
endif
(
${
BUILD_WITH_UV
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
endif
(
${
BUILD_TEST
}
)
source/libs/transport/inc/rpcHead.h
浏览文件 @
cc3ead15
...
...
@@ -21,10 +21,6 @@
extern
"C"
{
#endif
#ifdef USE_UV
#else
#define RPC_CONN_TCP 2
extern
int
tsRpcOverhead
;
...
...
@@ -75,7 +71,6 @@ typedef struct {
}
SRpcDigest
;
#pragma pack(pop)
#endif
#ifdef __cplusplus
}
...
...
source/libs/transport/inc/rpcTcp.h
浏览文件 @
cc3ead15
...
...
@@ -21,8 +21,6 @@
extern
"C"
{
#endif
#ifdef USE_UV
#else
void
*
taosInitTcpServer
(
uint32_t
ip
,
uint16_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
void
taosStopTcpServer
(
void
*
param
);
void
taosCleanUpTcpServer
(
void
*
param
);
...
...
@@ -35,8 +33,6 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uin
void
taosCloseTcpConnection
(
void
*
chandle
);
int
taosSendTcpData
(
uint32_t
ip
,
uint16_t
port
,
void
*
data
,
int
len
,
void
*
chandle
);
#endif
#ifdef __cplusplus
}
#endif
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
cc3ead15
...
...
@@ -16,15 +16,65 @@
#ifndef _TD_TRANSPORT_INT_H_
#define _TD_TRANSPORT_INT_H_
#include "rpcHead.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef USE_UV
#else
#include <stddef.h>
typedef
void
*
queue
[
2
];
/* Private macros. */
#define QUEUE_NEXT(q) (*(queue **)&((*(q))[0]))
#define QUEUE_PREV(q) (*(queue **)&((*(q))[1]))
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q)))
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q)))
/* Initialize an empty queue. */
#define QUEUE_INIT(q) \
{ \
QUEUE_NEXT(q) = (q); \
QUEUE_PREV(q) = (q); \
}
/* Return true if the queue has no element. */
#define QUEUE_IS_EMPTY(q) ((const queue *)(q) == (const queue *)QUEUE_NEXT(q))
/* Insert an element at the back of a queue. */
#define QUEUE_PUSH(q, e) \
{ \
QUEUE_NEXT(e) = (q); \
QUEUE_PREV(e) = QUEUE_PREV(q); \
QUEUE_PREV_NEXT(e) = (e); \
QUEUE_PREV(q) = (e); \
}
/* Remove the given element from the queue. Any element can be removed at any *
* time. */
#define QUEUE_REMOVE(e) \
{ \
QUEUE_PREV_NEXT(e) = QUEUE_NEXT(e); \
QUEUE_NEXT_PREV(e) = QUEUE_PREV(e); \
}
/* Return the element at the front of the queue. */
#define QUEUE_HEAD(q) (QUEUE_NEXT(q))
/* Return the element at the back of the queue. */
#define QUEUE_TAIL(q) (QUEUE_PREV(q))
/* Iterate over the element of a queue. * Mutating the queue while iterating
* results in undefined behavior. */
#define QUEUE_FOREACH(q, e) for ((q) = QUEUE_NEXT(e); (q) != (e); (q) = QUEUE_NEXT(q))
/* Return the structure holding the given element. */
#define QUEUE_DATA(e, type, field) ((type *)((void *)((char *)(e)-offsetof(type, field))))
#endif // USE_LIBUV
#endif
#ifdef __cplusplus
}
#endif
...
...
source/libs/transport/src/rpcCache.c
浏览文件 @
cc3ead15
...
...
@@ -22,9 +22,6 @@
#include "ttimer.h"
#include "tutil.h"
#ifdef USE_UV
#else
typedef
struct
SConnHash
{
char
fqdn
[
TSDB_FQDN_LEN
];
uint16_t
port
;
...
...
@@ -295,4 +292,3 @@ static void rpcUnlockCache(int64_t *lockedBy) {
assert
(
false
);
}
}
#endif
source/libs/transport/src/rpcMain.c
浏览文件 @
cc3ead15
...
...
@@ -13,9 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_UV
#include <uv.h>
#endif
#include "lz4.h"
#include "os.h"
#include "rpcCache.h"
...
...
@@ -30,11 +27,23 @@
#include "tmd5.h"
#include "tmempool.h"
#include "tmsg.h"
#include "transportInt.h"
#include "tref.h"
#include "trpc.h"
#include "ttimer.h"
#include "tutil.h"
static
pthread_once_t
tsRpcInitOnce
=
PTHREAD_ONCE_INIT
;
int
tsRpcMaxUdpSize
=
15000
;
// bytes
int
tsProgressTimer
=
100
;
// not configurable
int
tsRpcMaxRetry
;
int
tsRpcHeadSize
;
int
tsRpcOverhead
;
#ifndef USE_UV
typedef
struct
{
int
sessions
;
// number of sessions allowed
int
numOfThreads
;
// number of threads to process incoming messages
...
...
@@ -50,235 +59,21 @@ typedef struct {
char
secret
[
TSDB_PASSWORD_LEN
];
// secret for the link
char
ckey
[
TSDB_PASSWORD_LEN
];
// ciphering key
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int
(
*
afp
)(
void
*
parent
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int
(
*
afp
)(
void
*
parent
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
int32_t
refCount
;
void
*
parent
;
void
*
idPool
;
// handle to ID pool
void
*
tmrCtrl
;
// handle to timer
SHashObj
*
hash
;
// handle returned by hash utility
void
*
tcphandle
;
// returned handle from TCP initialization
void
*
udphandle
;
// returned handle from UDP initialization
void
*
pCache
;
// connection cache
void
*
parent
;
void
*
idPool
;
// handle to ID pool
void
*
tmrCtrl
;
// handle to timer
SHashObj
*
hash
;
// handle returned by hash utility
void
*
tcphandle
;
// returned handle from TCP initialization
void
*
udphandle
;
// returned handle from UDP initialization
void
*
pCache
;
// connection cache
pthread_mutex_t
mutex
;
struct
SRpcConn
*
connList
;
// connection list
struct
SRpcConn
*
connList
;
// connection list
}
SRpcInfo
;
#ifdef USE_UV
#define container_of(ptr, type, member) ((type*)((char*)(ptr)-offsetof(type, member)))
typedef
struct
SThreadObj
{
pthread_t
thread
;
uv_pipe_t
*
pipe
;
uv_loop_t
*
loop
;
uv_async_t
*
workerAsync
;
//
int
fd
;
}
SThreadObj
;
typedef
struct
SServerObj
{
uv_tcp_t
server
;
uv_loop_t
*
loop
;
int
workerIdx
;
int
numOfThread
;
SThreadObj
**
pThreadObj
;
uv_pipe_t
**
pipe
;
}
SServerObj
;
typedef
struct
SConnCtx
{
uv_tcp_t
*
pClient
;
uv_timer_t
*
pTimer
;
uv_async_t
*
pWorkerAsync
;
int
ref
;
}
SConnCtx
;
static
void
allocBuffer
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
);
static
void
onTimeout
(
uv_timer_t
*
handle
);
static
void
onRead
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
);
static
void
onWrite
(
uv_write_t
*
req
,
int
status
);
static
void
onAccept
(
uv_stream_t
*
stream
,
int
status
);
void
onConnection
(
uv_stream_t
*
q
,
ssize_t
nread
,
const
uv_buf_t
*
buf
);
static
void
workerAsyncCB
(
uv_async_t
*
handle
);
static
void
*
workerThread
(
void
*
arg
);
int32_t
rpcInit
()
{
return
-
1
;
}
void
rpcCleanup
()
{
return
;
};
void
*
rpcOpen
(
const
SRpcInit
*
pInit
)
{
SRpcInfo
*
pRpc
=
calloc
(
1
,
sizeof
(
SRpcInfo
));
if
(
pRpc
==
NULL
)
{
return
NULL
;
}
if
(
pInit
->
label
)
{
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
sizeof
(
pRpc
->
label
));
}
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
SServerObj
*
srv
=
calloc
(
1
,
sizeof
(
SServerObj
));
srv
->
loop
=
(
uv_loop_t
*
)
malloc
(
sizeof
(
uv_loop_t
));
srv
->
numOfThread
=
pRpc
->
numOfThreads
;
srv
->
workerIdx
=
0
;
srv
->
pThreadObj
=
(
SThreadObj
**
)
calloc
(
srv
->
numOfThread
,
sizeof
(
SThreadObj
*
));
srv
->
pipe
=
(
uv_pipe_t
**
)
calloc
(
srv
->
numOfThread
,
sizeof
(
uv_pipe_t
*
));
uv_loop_init
(
srv
->
loop
);
for
(
int
i
=
0
;
i
<
srv
->
numOfThread
;
i
++
)
{
srv
->
pThreadObj
[
i
]
=
(
SThreadObj
*
)
calloc
(
1
,
sizeof
(
SThreadObj
));
srv
->
pipe
[
i
]
=
(
uv_pipe_t
*
)
calloc
(
2
,
sizeof
(
uv_pipe_t
));
int
fds
[
2
];
if
(
uv_socketpair
(
AF_UNIX
,
SOCK_STREAM
,
fds
,
UV_NONBLOCK_PIPE
,
UV_NONBLOCK_PIPE
)
!=
0
)
{
return
NULL
;
}
uv_pipe_init
(
srv
->
loop
,
&
(
srv
->
pipe
[
i
][
0
]),
1
);
uv_pipe_open
(
&
(
srv
->
pipe
[
i
][
0
]),
fds
[
1
]);
// init write
srv
->
pThreadObj
[
i
]
->
fd
=
fds
[
0
];
srv
->
pThreadObj
[
i
]
->
pipe
=
&
(
srv
->
pipe
[
i
][
1
]);
// init read
int
err
=
pthread_create
(
&
(
srv
->
pThreadObj
[
i
]
->
thread
),
NULL
,
workerThread
,
(
void
*
)(
srv
->
pThreadObj
[
i
]));
if
(
err
==
0
)
{
tError
(
"sucess to create worker thread %d"
,
i
);
// printf("thread %d create\n", i);
}
else
{
tError
(
"failed to create worker thread %d"
,
i
);
return
NULL
;
}
}
uv_tcp_init
(
srv
->
loop
,
&
srv
->
server
);
struct
sockaddr_in
bind_addr
;
uv_ip4_addr
(
"0.0.0.0"
,
pInit
->
localPort
,
&
bind_addr
);
uv_tcp_bind
(
&
srv
->
server
,
(
const
struct
sockaddr
*
)
&
bind_addr
,
0
);
int
err
=
0
;
if
((
err
=
uv_listen
((
uv_stream_t
*
)
&
srv
->
server
,
128
,
onAccept
))
!=
0
)
{
tError
(
"Listen error %s
\n
"
,
uv_err_name
(
err
));
return
NULL
;
}
uv_run
(
srv
->
loop
,
UV_RUN_DEFAULT
);
return
pRpc
;
}
void
rpcClose
(
void
*
arg
)
{
return
;
}
void
*
rpcMallocCont
(
int
contLen
)
{
return
NULL
;
}
void
rpcFreeCont
(
void
*
cont
)
{
return
;
}
void
*
rpcReallocCont
(
void
*
ptr
,
int
contLen
)
{
return
NULL
;
}
void
rpcSendRequest
(
void
*
thandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
int64_t
*
rid
)
{
return
;
}
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{}
void
rpcSendRedirectRsp
(
void
*
pConn
,
const
SEpSet
*
pEpSet
)
{}
int
rpcGetConnInfo
(
void
*
thandle
,
SRpcConnInfo
*
pInfo
)
{
return
-
1
;
}
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
return
;
}
int
rpcReportProgress
(
void
*
pConn
,
char
*
pCont
,
int
contLen
)
{
return
-
1
;
}
void
rpcCancelRequest
(
int64_t
rid
)
{
return
;
}
void
allocBuffer
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
buf
->
base
=
malloc
(
suggested_size
);
buf
->
len
=
suggested_size
;
}
void
onTimeout
(
uv_timer_t
*
handle
)
{
// opt
tDebug
(
"time out"
);
}
void
onRead
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
// opt
tDebug
(
"data already was read on a stream"
);
}
void
onWrite
(
uv_write_t
*
req
,
int
status
)
{
// opt
if
(
req
)
tDebug
(
"data already was written on stream"
);
}
void
workerAsyncCB
(
uv_async_t
*
handle
)
{
// opt
SThreadObj
*
pObj
=
container_of
(
handle
,
SThreadObj
,
workerAsync
);
}
void
onAccept
(
uv_stream_t
*
stream
,
int
status
)
{
if
(
status
==
-
1
)
{
return
;
}
SServerObj
*
pObj
=
container_of
(
stream
,
SServerObj
,
server
);
tDebug
(
"new conntion accepted by main server, dispatch to one worker thread"
);
uv_tcp_t
*
cli
=
(
uv_tcp_t
*
)
malloc
(
sizeof
(
uv_tcp_t
));
uv_tcp_init
(
pObj
->
loop
,
cli
);
if
(
uv_accept
(
stream
,
(
uv_stream_t
*
)
cli
)
==
0
)
{
uv_write_t
*
wr
=
(
uv_write_t
*
)
malloc
(
sizeof
(
uv_write_t
));
uv_buf_t
buf
=
uv_buf_init
(
"a"
,
1
);
// despatch to worker thread
pObj
->
workerIdx
=
(
pObj
->
workerIdx
+
1
)
%
pObj
->
numOfThread
;
uv_write2
(
wr
,
(
uv_stream_t
*
)
&
(
pObj
->
pipe
[
pObj
->
workerIdx
][
0
]),
&
buf
,
1
,
(
uv_stream_t
*
)
cli
,
onWrite
);
}
else
{
uv_close
((
uv_handle_t
*
)
cli
,
NULL
);
}
}
void
onConnection
(
uv_stream_t
*
q
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
if
(
nread
<
0
)
{
if
(
nread
!=
UV_EOF
)
{
tError
(
"read error %s"
,
uv_err_name
(
nread
));
}
// TODO(log other failure reason)
uv_close
((
uv_handle_t
*
)
q
,
NULL
);
return
;
}
SThreadObj
*
pObj
=
(
SThreadObj
*
)
container_of
(
q
,
struct
SThreadObj
,
pipe
);
uv_pipe_t
*
pipe
=
(
uv_pipe_t
*
)
q
;
if
(
!
uv_pipe_pending_count
(
pipe
))
{
tError
(
"No pending count"
);
return
;
}
uv_handle_type
pending
=
uv_pipe_pending_type
(
pipe
);
assert
(
pending
==
UV_TCP
);
SConnCtx
*
pConn
=
malloc
(
sizeof
(
SConnCtx
));
/* init conn timer*/
pConn
->
pTimer
=
malloc
(
sizeof
(
uv_timer_t
));
uv_timer_init
(
pObj
->
loop
,
pConn
->
pTimer
);
pConn
->
pClient
=
(
uv_tcp_t
*
)
malloc
(
sizeof
(
uv_tcp_t
));
pConn
->
pWorkerAsync
=
pObj
->
workerAsync
;
// thread safty
uv_tcp_init
(
pObj
->
loop
,
pConn
->
pClient
);
if
(
uv_accept
(
q
,
(
uv_stream_t
*
)(
pConn
->
pClient
))
==
0
)
{
uv_os_fd_t
fd
;
uv_fileno
((
const
uv_handle_t
*
)
pConn
->
pClient
,
&
fd
);
tDebug
(
"new connection created: %d"
,
fd
);
uv_timer_start
(
pConn
->
pTimer
,
onTimeout
,
10
,
0
);
uv_read_start
((
uv_stream_t
*
)(
pConn
->
pClient
),
allocBuffer
,
onRead
);
}
else
{
uv_timer_stop
(
pConn
->
pTimer
);
free
(
pConn
->
pTimer
);
uv_close
((
uv_handle_t
*
)
pConn
->
pClient
,
NULL
);
free
(
pConn
->
pClient
);
free
(
pConn
);
}
}
void
*
workerThread
(
void
*
arg
)
{
SThreadObj
*
pObj
=
(
SThreadObj
*
)
arg
;
int
fd
=
pObj
->
fd
;
pObj
->
loop
=
(
uv_loop_t
*
)
malloc
(
sizeof
(
uv_loop_t
));
uv_loop_init
(
pObj
->
loop
);
uv_pipe_init
(
pObj
->
loop
,
pObj
->
pipe
,
1
);
uv_pipe_open
(
pObj
->
pipe
,
fd
);
pObj
->
workerAsync
=
malloc
(
sizeof
(
uv_async_t
));
uv_async_init
(
pObj
->
loop
,
pObj
->
workerAsync
,
workerAsyncCB
);
uv_read_start
((
uv_stream_t
*
)
pObj
->
pipe
,
allocBuffer
,
onConnection
);
}
#else
#define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest))
#define rpcHeadFromCont(cont) ((SRpcHead*)((char*)cont - sizeof(SRpcHead)))
#define rpcContFromHead(msg) (msg + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead))
#define rpcIsReq(type) (type & 1U)
typedef
struct
{
SRpcInfo
*
pRpc
;
// associated SRpcInfo
SEpSet
epSet
;
// ip list provided by app
...
...
@@ -299,6 +94,13 @@ typedef struct {
char
msg
[
0
];
// RpcHead starts from here
}
SRpcReqContext
;
#define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest))
#define rpcHeadFromCont(cont) ((SRpcHead *)((char *)cont - sizeof(SRpcHead)))
#define rpcContFromHead(msg) (msg + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead))
#define rpcIsReq(type) (type & 1U)
typedef
struct
SRpcConn
{
char
info
[
48
];
// debug info: label + pConn + ahandle
int
sid
;
// session ID
...
...
@@ -336,15 +138,6 @@ typedef struct SRpcConn {
SRpcReqContext
*
pContext
;
// request context
}
SRpcConn
;
static
pthread_once_t
tsRpcInitOnce
=
PTHREAD_ONCE_INIT
;
int
tsRpcMaxUdpSize
=
15000
;
// bytes
int
tsProgressTimer
=
100
;
// not configurable
int
tsRpcMaxRetry
;
int
tsRpcHeadSize
;
int
tsRpcOverhead
;
static
int
tsRpcRefId
=
-
1
;
static
int32_t
tsRpcNum
=
0
;
// static pthread_once_t tsRpcInit = PTHREAD_ONCE_INIT;
...
...
@@ -442,7 +235,8 @@ void *rpcOpen(const SRpcInit *pInit) {
pRpc
=
(
SRpcInfo
*
)
calloc
(
1
,
sizeof
(
SRpcInfo
));
if
(
pRpc
==
NULL
)
return
NULL
;
if
(
pInit
->
label
)
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
sizeof
(
pRpc
->
label
));
if
(
pInit
->
label
)
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
strlen
(
pInit
->
label
));
pRpc
->
connType
=
pInit
->
connType
;
if
(
pRpc
->
connType
==
TAOS_CONN_CLIENT
)
{
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
;
...
...
source/libs/transport/src/rpcTcp.c
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/libs/transport/src/rpcUdp.c
浏览文件 @
cc3ead15
...
...
@@ -22,9 +22,6 @@
#include "ttimer.h"
#include "tutil.h"
#ifdef USE_UV
// no support upd currently
#else
#define RPC_MAX_UDP_CONNS 256
#define RPC_MAX_UDP_PKTS 1000
#define RPC_UDP_BUF_TIME 5 // mseconds
...
...
@@ -260,4 +257,3 @@ int taosSendUdpData(uint32_t ip, uint16_t port, void *data, int dataLen, void *c
return
ret
;
}
#endif
source/libs/transport/src/transport.c
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/libs/transport/test/CMakeLists.txt
0 → 100644
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/
dnode/vnode/src/inc/metaIdx.h
→
source/
libs/transport/test/transportTests.cc
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/libs/transport/test/transportTests.cpp
已删除
100644 → 0
浏览文件 @
8b061f52
source/libs/wal/src/walMeta.c
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
cc3ead15
...
...
@@ -301,12 +301,13 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_CFG_FILE, "Invalid config file")
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_INVALID_TERM_FILE
,
"Invalid term file"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_FLOWCTRL
,
"Database memory is full"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_DROPPING
,
"Database is dropping"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_UPDATING
,
"Database is updating"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_UPDATING
,
"Database is updating"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_CLOSING
,
"Database is closing"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_NOT_SYNCED
,
"Database suspended"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_NO_WRITE_AUTH
,
"Database write operation denied"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_IS_SYNCING
,
"Database is syncing"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_INVALID_TSDB_STATE
,
"Invalid tsdb state"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_TB_NOT_EXIST
,
"Table not exists"
)
// tsdb
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_INVALID_TABLE_ID
,
"Invalid table ID"
)
...
...
tests/test/c/create_table.c
浏览文件 @
cc3ead15
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录