Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f3067eb2
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
f3067eb2
编写于
12月 29, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
差异文件
merge from 3.0
上级
335de535
1ba2f77c
变更
96
展开全部
隐藏空白更改
内联
并排
Showing
96 changed file
with
5521 addition
and
4286 deletion
+5521
-4286
.devcontainer/devcontainer.json
.devcontainer/devcontainer.json
+1
-1
contrib/test/tdev/src/main.c
contrib/test/tdev/src/main.c
+51
-5
include/common/taosdef.h
include/common/taosdef.h
+6
-6
include/common/tmsg.h
include/common/tmsg.h
+35
-12
include/common/tmsgdef.h
include/common/tmsgdef.h
+4
-0
include/common/ttokendef.h
include/common/ttokendef.h
+191
-197
include/dnode/bnode/bnode.h
include/dnode/bnode/bnode.h
+9
-1
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+2
-18
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+7
-7
include/dnode/snode/snode.h
include/dnode/snode/snode.h
+10
-2
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+4
-26
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+0
-72
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+12
-17
include/libs/parser/parsenodes.h
include/libs/parser/parsenodes.h
+1
-0
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-1
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-1
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+0
-1
include/os/osEndian.h
include/os/osEndian.h
+3
-0
include/util/encode.h
include/util/encode.h
+476
-0
include/util/tbuffer.h
include/util/tbuffer.h
+71
-76
include/util/tcoding.h
include/util/tcoding.h
+4
-0
include/util/tdef.h
include/util/tdef.h
+3
-3
include/util/tmacro.h
include/util/tmacro.h
+2
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+4
-34
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+20
-13
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+44
-45
source/common/src/tvariant.c
source/common/src/tvariant.c
+0
-1
source/dnode/bnode/src/bnode.c
source/dnode/bnode/src/bnode.c
+3
-1
source/dnode/mgmt/daemon/src/daemon.c
source/dnode/mgmt/daemon/src/daemon.c
+1
-1
source/dnode/mgmt/impl/inc/dndBnode.h
source/dnode/mgmt/impl/inc/dndBnode.h
+1
-1
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+25
-30
source/dnode/mgmt/impl/inc/dndWorker.h
source/dnode/mgmt/impl/inc/dndWorker.h
+2
-2
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+379
-0
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+13
-10
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+68
-294
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+11
-8
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+354
-0
source/dnode/mgmt/impl/src/dndWorker.c
source/dnode/mgmt/impl/src/dndWorker.c
+39
-14
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+1
-1
source/dnode/mgmt/impl/test/stb/stb.cpp
source/dnode/mgmt/impl/test/stb/stb.cpp
+33
-6
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+0
-4
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-0
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+1
-0
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+3
-5
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+5
-5
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+27
-35
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+5
-6
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+9
-9
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+82
-26
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+6
-12
source/dnode/mnode/sdb/inc/sdbInt.h
source/dnode/mnode/sdb/inc/sdbInt.h
+1
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+2
-6
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+3
-3
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+59
-20
source/dnode/mnode/sdb/src/sdbRaw.c
source/dnode/mnode/sdb/src/sdbRaw.c
+2
-2
source/dnode/mnode/sdb/src/sdbRow.c
source/dnode/mnode/sdb/src/sdbRow.c
+10
-1
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+3
-1
source/dnode/vnode/impl/inc/vnodeRequest.h
source/dnode/vnode/impl/inc/vnodeRequest.h
+2
-2
source/dnode/vnode/impl/src/vnodeInt.c
source/dnode/vnode/impl/src/vnodeInt.c
+0
-5
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+22
-4
source/dnode/vnode/impl/src/vnodeRequest.c
source/dnode/vnode/impl/src/vnodeRequest.c
+4
-1
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+4
-5
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+81
-3
source/dnode/vnode/meta/src/metaTbCfg.c
source/dnode/vnode/meta/src/metaTbCfg.c
+0
-54
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+0
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+115
-110
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+41
-27
source/libs/index/inc/index_cache.h
source/libs/index/inc/index_cache.h
+10
-7
source/libs/index/src/index.c
source/libs/index/src/index.c
+37
-31
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+164
-90
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+100
-42
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+180
-26
source/libs/parser/inc/astGenerator.h
source/libs/parser/inc/astGenerator.h
+1
-1
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+0
-1
source/libs/parser/inc/parserUtil.h
source/libs/parser/inc/parserUtil.h
+14
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+5
-2
source/libs/parser/inc/ttokendef.h
source/libs/parser/inc/ttokendef.h
+0
-230
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+14
-17
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+16
-55
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+107
-104
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+231
-250
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+290
-245
source/libs/parser/src/queryInfoUtil.c
source/libs/parser/src/queryInfoUtil.c
+1
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1686
-1684
source/libs/parser/src/ttokenizer.c
source/libs/parser/src/ttokenizer.c
+6
-6
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+4
-4
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+12
-7
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+2
-2
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+9
-8
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+30
-6
source/util/src/tbuffer.c
source/util/src/tbuffer.c
+174
-192
tests/script/general/db/basic1.sim
tests/script/general/db/basic1.sim
+21
-1
tests/script/general/table/basic1.sim
tests/script/general/table/basic1.sim
+3
-4
tests/script/sh/exec.sh
tests/script/sh/exec.sh
+2
-2
tests/script/tmp/dnodes.sim
tests/script/tmp/dnodes.sim
+11
-12
tests/script/unique/dnode/basic1.sim
tests/script/unique/dnode/basic1.sim
+11
-0
未找到文件。
.devcontainer/devcontainer.json
浏览文件 @
f3067eb2
...
@@ -28,5 +28,5 @@
...
@@ -28,5 +28,5 @@
//
"postCreateCommand"
:
"gcc -v"
,
//
"postCreateCommand"
:
"gcc -v"
,
//
Comment
out
connect
as
root
instead.
More
info:
https://aka.ms/vscode-remote/containers/non-root.
//
Comment
out
connect
as
root
instead.
More
info:
https://aka.ms/vscode-remote/containers/non-root.
"remoteUser"
:
"
vscode
"
"remoteUser"
:
"
root
"
}
}
contrib/test/tdev/src/main.c
浏览文件 @
f3067eb2
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
#define tPutB(buf, val) \
#define tPutB(buf, val) \
({ \
({ \
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
...
@@ -21,13 +25,33 @@
...
@@ -21,13 +25,33 @@
POINTER_SHIFT(buf, sizeof(val)); \
POINTER_SHIFT(buf, sizeof(val)); \
})
})
#define tPutC(buf, val) \
#define tPutC(buf, val) \
({ \
({ \
((uint64_t *)buf)[0] = (val); \
if (buf) { \
POINTER_SHIFT(buf, sizeof(val)); \
((uint64_t *)buf)[0] = (val); \
POINTER_SHIFT(buf, sizeof(val)); \
} \
NULL; \
})
})
typedef
enum
{
A
,
B
,
C
}
T
;
#define tPutD(buf, val) \
({ \
uint64_t tmp = val; \
for (size_t i = 0; i < sizeof(val); i++) { \
((uint8_t *)buf)[i] = tmp & 0xff; \
tmp >>= 8; \
} \
POINTER_SHIFT(buf, sizeof(val)); \
})
static
inline
void
tPutE
(
void
**
buf
,
uint64_t
val
)
{
if
(
buf
)
{
((
uint64_t
*
)(
*
buf
))[
0
]
=
val
;
*
buf
=
POINTER_SHIFT
(
*
buf
,
sizeof
(
val
));
}
}
typedef
enum
{
A
,
B
,
C
,
D
,
E
}
T
;
static
void
func
(
T
t
)
{
static
void
func
(
T
t
)
{
uint64_t
val
=
198
;
uint64_t
val
=
198
;
...
@@ -59,6 +83,22 @@ static void func(T t) {
...
@@ -59,6 +83,22 @@ static void func(T t) {
}
}
}
}
break
;
break
;
case
D
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
pBuf
=
tPutD
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
}
}
break
;
case
E
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
tPutE
(
&
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
}
}
break
;
default:
default:
break
;
break
;
...
@@ -83,5 +123,11 @@ int main(int argc, char const *argv[]) {
...
@@ -83,5 +123,11 @@ int main(int argc, char const *argv[]) {
func
(
C
);
func
(
C
);
uint64_t
t4
=
now
();
uint64_t
t4
=
now
();
printf
(
"C: %ld
\n
"
,
t4
-
t3
);
printf
(
"C: %ld
\n
"
,
t4
-
t3
);
func
(
D
);
uint64_t
t5
=
now
();
printf
(
"D: %ld
\n
"
,
t5
-
t4
);
func
(
E
);
uint64_t
t6
=
now
();
printf
(
"E: %ld
\n
"
,
t6
-
t5
);
return
0
;
return
0
;
}
}
include/common/taosdef.h
浏览文件 @
f3067eb2
...
@@ -38,12 +38,12 @@ typedef enum {
...
@@ -38,12 +38,12 @@ typedef enum {
}
EQType
;
}
EQType
;
typedef
enum
{
typedef
enum
{
TSDB_SUPER_TABLE
=
1
,
// super table
TSDB_SUPER_TABLE
=
1
,
// super table
TSDB_CHILD_TABLE
=
2
,
// table created from super table
TSDB_CHILD_TABLE
=
2
,
// table created from super table
TSDB_NORMAL_TABLE
=
3
,
// ordinary table
TSDB_NORMAL_TABLE
=
3
,
// ordinary table
TSDB_STREAM_TABLE
=
4
,
// table created from stream computing
TSDB_STREAM_TABLE
=
4
,
// table created from stream computing
TSDB_TEMP_TABLE
=
5
,
// temp table created by nest query
TSDB_TEMP_TABLE
=
5
,
// temp table created by nest query
TSDB_TABLE_MAX
=
6
TSDB_TABLE_MAX
=
6
}
ETableType
;
}
ETableType
;
typedef
enum
{
typedef
enum
{
...
...
include/common/tmsg.h
浏览文件 @
f3067eb2
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "encode.h"
#include "taosdef.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tcoding.h"
#include "tcoding.h"
...
@@ -331,12 +332,12 @@ static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEpSet) {
...
@@ -331,12 +332,12 @@ static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEpSet) {
}
}
typedef
struct
{
typedef
struct
{
int32_t
acctId
;
int32_t
acctId
;
int64_t
clusterId
;
int64_t
clusterId
;
int32_t
connId
;
int32_t
connId
;
int8_t
superUser
;
int8_t
superUser
;
int8_t
reserved
[
5
];
int8_t
reserved
[
5
];
SEpSet
epSet
;
SEpSet
epSet
;
}
SConnectRsp
;
}
SConnectRsp
;
typedef
struct
{
typedef
struct
{
...
@@ -673,8 +674,6 @@ typedef struct {
...
@@ -673,8 +674,6 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
clusterId
;
int8_t
dropped
;
char
reserved
[
7
];
}
SDnodeCfg
;
}
SDnodeCfg
;
typedef
struct
{
typedef
struct
{
...
@@ -1105,10 +1104,9 @@ static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateT
...
@@ -1105,10 +1104,9 @@ static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateT
}
}
static
FORCE_INLINE
void
*
tDeserializeSCMCreateTopicReq
(
void
*
buf
,
SCMCreateTopicReq
*
pReq
)
{
static
FORCE_INLINE
void
*
tDeserializeSCMCreateTopicReq
(
void
*
buf
,
SCMCreateTopicReq
*
pReq
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
igExists
);
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
igExists
));
buf
=
taosDecodeString
(
buf
,
&
pReq
->
name
);
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeString
(
buf
,
&
pReq
->
physicalPlan
);
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
phyPlan
));
buf
=
taosDecodeString
(
buf
,
&
pReq
->
logicalPlan
);
return
buf
;
return
buf
;
}
}
...
@@ -1339,6 +1337,31 @@ static FORCE_INLINE void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pR
...
@@ -1339,6 +1337,31 @@ static FORCE_INLINE void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pR
typedef
struct
SVCreateTbRsp
{
typedef
struct
SVCreateTbRsp
{
}
SVCreateTbRsp
;
}
SVCreateTbRsp
;
typedef
struct
SVShowTablesReq
{
SMsgHead
head
;
}
SVShowTablesReq
;
typedef
struct
SVShowTablesRsp
{
int64_t
id
;
STableMetaMsg
metaInfo
;
}
SVShowTablesRsp
;
typedef
struct
SVShowTablesFetchReq
{
SMsgHead
head
;
int64_t
id
;
}
SVShowTablesFetchReq
;
typedef
struct
SVShowTablesFetchRsp
{
int64_t
useconds
;
int8_t
completed
;
// all results are returned to client
int8_t
precision
;
int8_t
compressed
;
int32_t
compLen
;
int32_t
numOfRows
;
char
data
[];
}
SVShowTablesFetchRsp
;
#pragma pack(pop)
#pragma pack(pop)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsgdef.h
浏览文件 @
f3067eb2
...
@@ -147,8 +147,12 @@ enum {
...
@@ -147,8 +147,12 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_TOPIC
,
"vnode-create-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_TOPIC
,
"vnode-create-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_TOPIC
,
"vnode-alter-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_TOPIC
,
"vnode-alter-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TOPIC
,
"vnode-drop-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TOPIC
,
"vnode-drop-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SHOW_TABLES
,
"vnode-show-tables"
,
SVShowTablesReq
,
SVShowTablesRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SHOW_TABLES_FETCH
,
"vnode-show-tables-fetch"
,
SVShowTablesFetchReq
,
SVShowTablesFetchRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBSCRIBE
,
"vnode-subscribe"
,
SMVSubscribeReq
,
SMVSubscribeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBSCRIBE
,
"vnode-subscribe"
,
SMVSubscribeReq
,
SMVSubscribeRsp
)
// Requests handled by QNODE
// Requests handled by QNODE
TD_NEW_MSG_SEG
(
TDMT_QND_MSG
)
TD_NEW_MSG_SEG
(
TDMT_QND_MSG
)
...
...
include/common/ttokendef.h
浏览文件 @
f3067eb2
...
@@ -13,205 +13,199 @@
...
@@ -13,205 +13,199 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef
_TD_COMMON_TOKEN_DEF_H_
#ifndef
TDENGINE_TTOKENDEF_H
#define
_TD_COMMON_TOKEN_DEF_H_
#define
TDENGINE_TTOKENDEF_H
#define TK_ID 1
#define TK_ID 1
#define TK_BOOL 2
#define TK_BOOL 2
#define TK_TINYINT 3
#define TK_INTEGER 3
#define TK_SMALLINT 4
#define TK_FLOAT 4
#define TK_INTEGER 5
#define TK_STRING 5
#define TK_BIGINT 6
#define TK_TIMESTAMP 6
#define TK_FLOAT 7
#define TK_OR 7
#define TK_DOUBLE 8
#define TK_AND 8
#define TK_STRING 9
#define TK_NOT 9
#define TK_TIMESTAMP 10
#define TK_EQ 10
#define TK_BINARY 11
#define TK_NE 11
#define TK_NCHAR 12
#define TK_ISNULL 12
#define TK_OR 13
#define TK_NOTNULL 13
#define TK_AND 14
#define TK_IS 14
#define TK_NOT 15
#define TK_LIKE 15
#define TK_EQ 16
#define TK_MATCH 16
#define TK_NE 17
#define TK_NMATCH 17
#define TK_ISNULL 18
#define TK_GLOB 18
#define TK_NOTNULL 19
#define TK_BETWEEN 19
#define TK_IS 20
#define TK_IN 20
#define TK_LIKE 21
#define TK_GT 21
#define TK_MATCH 22
#define TK_GE 22
#define TK_NMATCH 23
#define TK_LT 23
#define TK_GLOB 24
#define TK_LE 24
#define TK_BETWEEN 25
#define TK_BITAND 25
#define TK_IN 26
#define TK_BITOR 26
#define TK_GT 27
#define TK_LSHIFT 27
#define TK_GE 28
#define TK_RSHIFT 28
#define TK_LT 29
#define TK_PLUS 29
#define TK_LE 30
#define TK_MINUS 30
#define TK_BITAND 31
#define TK_DIVIDE 31
#define TK_BITOR 32
#define TK_TIMES 32
#define TK_LSHIFT 33
#define TK_STAR 33
#define TK_RSHIFT 34
#define TK_SLASH 34
#define TK_PLUS 35
#define TK_REM 35
#define TK_MINUS 36
#define TK_CONCAT 36
#define TK_DIVIDE 37
#define TK_UMINUS 37
#define TK_TIMES 38
#define TK_UPLUS 38
#define TK_STAR 39
#define TK_BITNOT 39
#define TK_SLASH 40
#define TK_SHOW 40
#define TK_REM 41
#define TK_DATABASES 41
#define TK_CONCAT 42
#define TK_TOPICS 42
#define TK_UMINUS 43
#define TK_FUNCTIONS 43
#define TK_UPLUS 44
#define TK_MNODES 44
#define TK_BITNOT 45
#define TK_DNODES 45
#define TK_SHOW 46
#define TK_ACCOUNTS 46
#define TK_DATABASES 47
#define TK_USERS 47
#define TK_TOPICS 48
#define TK_MODULES 48
#define TK_FUNCTIONS 49
#define TK_QUERIES 49
#define TK_MNODES 50
#define TK_CONNECTIONS 50
#define TK_DNODES 51
#define TK_STREAMS 51
#define TK_ACCOUNTS 52
#define TK_VARIABLES 52
#define TK_USERS 53
#define TK_SCORES 53
#define TK_MODULES 54
#define TK_GRANTS 54
#define TK_QUERIES 55
#define TK_VNODES 55
#define TK_CONNECTIONS 56
#define TK_DOT 56
#define TK_STREAMS 57
#define TK_CREATE 57
#define TK_VARIABLES 58
#define TK_TABLE 58
#define TK_SCORES 59
#define TK_STABLE 59
#define TK_GRANTS 60
#define TK_DATABASE 60
#define TK_VNODES 61
#define TK_TABLES 61
#define TK_DOT 62
#define TK_STABLES 62
#define TK_CREATE 63
#define TK_VGROUPS 63
#define TK_TABLE 64
#define TK_DROP 64
#define TK_STABLE 65
#define TK_TOPIC 65
#define TK_DATABASE 66
#define TK_FUNCTION 66
#define TK_TABLES 67
#define TK_DNODE 67
#define TK_STABLES 68
#define TK_USER 68
#define TK_VGROUPS 69
#define TK_ACCOUNT 69
#define TK_DROP 70
#define TK_USE 70
#define TK_TOPIC 71
#define TK_DESCRIBE 71
#define TK_FUNCTION 72
#define TK_DESC 72
#define TK_DNODE 73
#define TK_ALTER 73
#define TK_USER 74
#define TK_PASS 74
#define TK_ACCOUNT 75
#define TK_PRIVILEGE 75
#define TK_USE 76
#define TK_LOCAL 76
#define TK_DESCRIBE 77
#define TK_COMPACT 77
#define TK_DESC 78
#define TK_LP 78
#define TK_ALTER 79
#define TK_RP 79
#define TK_PASS 80
#define TK_IF 80
#define TK_PRIVILEGE 81
#define TK_EXISTS 81
#define TK_LOCAL 82
#define TK_PORT 82
#define TK_COMPACT 83
#define TK_IPTOKEN 83
#define TK_LP 84
#define TK_AS 84
#define TK_RP 85
#define TK_OUTPUTTYPE 85
#define TK_IF 86
#define TK_AGGREGATE 86
#define TK_EXISTS 87
#define TK_BUFSIZE 87
#define TK_AS 88
#define TK_PPS 88
#define TK_OUTPUTTYPE 89
#define TK_TSERIES 89
#define TK_AGGREGATE 90
#define TK_DBS 90
#define TK_BUFSIZE 91
#define TK_STORAGE 91
#define TK_PPS 92
#define TK_QTIME 92
#define TK_TSERIES 93
#define TK_CONNS 93
#define TK_DBS 94
#define TK_STATE 94
#define TK_STORAGE 95
#define TK_COMMA 95
#define TK_QTIME 96
#define TK_KEEP 96
#define TK_CONNS 97
#define TK_CACHE 97
#define TK_STATE 98
#define TK_REPLICA 98
#define TK_COMMA 99
#define TK_QUORUM 99
#define TK_KEEP 100
#define TK_DAYS 100
#define TK_CACHE 101
#define TK_MINROWS 101
#define TK_REPLICA 102
#define TK_MAXROWS 102
#define TK_QUORUM 103
#define TK_BLOCKS 103
#define TK_DAYS 104
#define TK_CTIME 104
#define TK_MINROWS 105
#define TK_WAL 105
#define TK_MAXROWS 106
#define TK_FSYNC 106
#define TK_BLOCKS 107
#define TK_COMP 107
#define TK_CTIME 108
#define TK_PRECISION 108
#define TK_WAL 109
#define TK_UPDATE 109
#define TK_FSYNC 110
#define TK_CACHELAST 110
#define TK_COMP 111
#define TK_UNSIGNED 111
#define TK_PRECISION 112
#define TK_TAGS 112
#define TK_UPDATE 113
#define TK_USING 113
#define TK_CACHELAST 114
#define TK_NULL 114
#define TK_PARTITIONS 115
#define TK_NOW 115
#define TK_UNSIGNED 116
#define TK_SELECT 116
#define TK_TAGS 117
#define TK_UNION 117
#define TK_USING 118
#define TK_ALL 118
#define TK_NULL 119
#define TK_DISTINCT 119
#define TK_NOW 120
#define TK_FROM 120
#define TK_SELECT 121
#define TK_VARIABLE 121
#define TK_UNION 122
#define TK_INTERVAL 122
#define TK_ALL 123
#define TK_EVERY 123
#define TK_DISTINCT 124
#define TK_SESSION 124
#define TK_FROM 125
#define TK_STATE_WINDOW 125
#define TK_VARIABLE 126
#define TK_FILL 126
#define TK_INTERVAL 127
#define TK_SLIDING 127
#define TK_EVERY 128
#define TK_ORDER 128
#define TK_SESSION 129
#define TK_BY 129
#define TK_STATE_WINDOW 130
#define TK_ASC 130
#define TK_FILL 131
#define TK_GROUP 131
#define TK_SLIDING 132
#define TK_HAVING 132
#define TK_ORDER 133
#define TK_LIMIT 133
#define TK_BY 134
#define TK_OFFSET 134
#define TK_ASC 135
#define TK_SLIMIT 135
#define TK_GROUP 136
#define TK_SOFFSET 136
#define TK_HAVING 137
#define TK_WHERE 137
#define TK_LIMIT 138
#define TK_RESET 138
#define TK_OFFSET 139
#define TK_QUERY 139
#define TK_SLIMIT 140
#define TK_SYNCDB 140
#define TK_SOFFSET 141
#define TK_ADD 141
#define TK_WHERE 142
#define TK_COLUMN 142
#define TK_RESET 143
#define TK_MODIFY 143
#define TK_QUERY 144
#define TK_TAG 144
#define TK_SYNCDB 145
#define TK_CHANGE 145
#define TK_ADD 146
#define TK_SET 146
#define TK_COLUMN 147
#define TK_KILL 147
#define TK_MODIFY 148
#define TK_CONNECTION 148
#define TK_TAG 149
#define TK_STREAM 149
#define TK_CHANGE 150
#define TK_COLON 150
#define TK_SET 151
#define TK_ABORT 151
#define TK_KILL 152
#define TK_AFTER 152
#define TK_CONNECTION 153
#define TK_ATTACH 153
#define TK_STREAM 154
#define TK_BEFORE 154
#define TK_COLON 155
#define TK_BEGIN 155
#define TK_ABORT 156
#define TK_CASCADE 156
#define TK_AFTER 157
#define TK_CLUSTER 157
#define TK_ATTACH 158
#define TK_CONFLICT 158
#define TK_BEFORE 159
#define TK_COPY 159
#define TK_BEGIN 160
#define TK_DEFERRED 160
#define TK_CASCADE 161
#define TK_DELIMITERS 161
#define TK_CLUSTER 162
#define TK_DETACH 162
#define TK_CONFLICT 163
#define TK_EACH 163
#define TK_COPY 164
#define TK_END 164
#define TK_DEFERRED 165
#define TK_EXPLAIN 165
#define TK_DELIMITERS 166
#define TK_FAIL 166
#define TK_DETACH 167
#define TK_FOR 167
#define TK_EACH 168
#define TK_IGNORE 168
#define TK_END 169
#define TK_IMMEDIATE 169
#define TK_EXPLAIN 170
#define TK_INITIALLY 170
#define TK_FAIL 171
#define TK_INSTEAD 171
#define TK_FOR 172
#define TK_KEY 172
#define TK_IGNORE 173
#define TK_OF 173
#define TK_IMMEDIATE 174
#define TK_RAISE 174
#define TK_INITIALLY 175
#define TK_REPLACE 175
#define TK_INSTEAD 176
#define TK_RESTRICT 176
#define TK_KEY 177
#define TK_ROW 177
#define TK_OF 178
#define TK_STATEMENT 178
#define TK_RAISE 179
#define TK_TRIGGER 179
#define TK_REPLACE 180
#define TK_VIEW 180
#define TK_RESTRICT 181
#define TK_SEMI 181
#define TK_ROW 182
#define TK_NONE 182
#define TK_STATEMENT 183
#define TK_PREV 183
#define TK_TRIGGER 184
#define TK_LINEAR 184
#define TK_VIEW 185
#define TK_IMPORT 185
#define TK_IPTOKEN 186
#define TK_TBNAME 186
#define TK_SEMI 187
#define TK_JOIN 187
#define TK_NONE 188
#define TK_INSERT 188
#define TK_PREV 189
#define TK_INTO 189
#define TK_LINEAR 190
#define TK_VALUES 190
#define TK_IMPORT 191
#define TK_TBNAME 192
#define TK_JOIN 193
#define TK_INSERT 194
#define TK_INTO 195
#define TK_VALUES 196
#define TK_SPACE 300
#define TK_SPACE 300
...
@@ -223,6 +217,6 @@
...
@@ -223,6 +217,6 @@
#define TK_FILE 306
#define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#endif
/*_TD_COMMON_TOKEN_DEF_H_*/
#endif
include/dnode/bnode/bnode.h
浏览文件 @
f3067eb2
...
@@ -49,10 +49,11 @@ typedef struct {
...
@@ -49,10 +49,11 @@ typedef struct {
/**
/**
* @brief Start one Bnode in Dnode.
* @brief Start one Bnode in Dnode.
*
*
* @param path Path of the bnode.
* @param pOption Option of the bnode.
* @param pOption Option of the bnode.
* @return SBnode* The bnode object.
* @return SBnode* The bnode object.
*/
*/
SBnode
*
bndOpen
(
const
SBnodeOpt
*
pOption
);
SBnode
*
bndOpen
(
const
char
*
path
,
const
SBnodeOpt
*
pOption
);
/**
/**
* @brief Stop Bnode in Dnode.
* @brief Stop Bnode in Dnode.
...
@@ -79,6 +80,13 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad);
...
@@ -79,6 +80,13 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad);
*/
*/
int32_t
bndProcessWMsgs
(
SBnode
*
pBnode
,
SArray
*
pMsgs
);
int32_t
bndProcessWMsgs
(
SBnode
*
pBnode
,
SArray
*
pMsgs
);
/**
* @brief Drop a bnode.
*
* @param path Path of the bnode.
*/
void
bndDestroy
(
const
char
*
path
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/dnode/mnode/mnode.h
浏览文件 @
f3067eb2
...
@@ -147,28 +147,12 @@ void mndCleanupMsg(SMnodeMsg *pMsg);
...
@@ -147,28 +147,12 @@ void mndCleanupMsg(SMnodeMsg *pMsg);
void
mndSendRsp
(
SMnodeMsg
*
pMsg
,
int32_t
code
);
void
mndSendRsp
(
SMnodeMsg
*
pMsg
,
int32_t
code
);
/**
/**
* @brief Process the read request.
* @brief Process the read
, write, sync
request.
*
*
* @param pMsg The request msg.
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
* @return int32_t 0 for success, -1 for failure.
*/
*/
void
mndProcessReadMsg
(
SMnodeMsg
*
pMsg
);
void
mndProcessMsg
(
SMnodeMsg
*
pMsg
);
/**
* @brief Process the write request.
*
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
*/
void
mndProcessWriteMsg
(
SMnodeMsg
*
pMsg
);
/**
* @brief Process the sync request.
*
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
*/
void
mndProcessSyncMsg
(
SMnodeMsg
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/dnode/mnode/sdb/sdb.h
浏览文件 @
f3067eb2
...
@@ -25,7 +25,7 @@ extern "C" {
...
@@ -25,7 +25,7 @@ extern "C" {
#define SDB_GET_INT64(pData, pRow, dataPos, val) \
#define SDB_GET_INT64(pData, pRow, dataPos, val) \
{ \
{ \
if (sdbGetRawInt64(pRaw, dataPos, val) != 0) { \
if (sdbGetRawInt64(pRaw, dataPos, val) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += sizeof(int64_t); \
dataPos += sizeof(int64_t); \
...
@@ -34,7 +34,7 @@ extern "C" {
...
@@ -34,7 +34,7 @@ extern "C" {
#define SDB_GET_INT32(pData, pRow, dataPos, val) \
#define SDB_GET_INT32(pData, pRow, dataPos, val) \
{ \
{ \
if (sdbGetRawInt32(pRaw, dataPos, val) != 0) { \
if (sdbGetRawInt32(pRaw, dataPos, val) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += sizeof(int32_t); \
dataPos += sizeof(int32_t); \
...
@@ -43,7 +43,7 @@ extern "C" {
...
@@ -43,7 +43,7 @@ extern "C" {
#define SDB_GET_INT16(pData, pRow, dataPos, val) \
#define SDB_GET_INT16(pData, pRow, dataPos, val) \
{ \
{ \
if (sdbGetRawInt16(pRaw, dataPos, val) != 0) { \
if (sdbGetRawInt16(pRaw, dataPos, val) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += sizeof(int16_t); \
dataPos += sizeof(int16_t); \
...
@@ -52,7 +52,7 @@ extern "C" {
...
@@ -52,7 +52,7 @@ extern "C" {
#define SDB_GET_INT8(pData, pRow, dataPos, val) \
#define SDB_GET_INT8(pData, pRow, dataPos, val) \
{ \
{ \
if (sdbGetRawInt8(pRaw, dataPos, val) != 0) { \
if (sdbGetRawInt8(pRaw, dataPos, val) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += sizeof(int8_t); \
dataPos += sizeof(int8_t); \
...
@@ -61,7 +61,7 @@ extern "C" {
...
@@ -61,7 +61,7 @@ extern "C" {
#define SDB_GET_BINARY(pRaw, pRow, dataPos, val, valLen) \
#define SDB_GET_BINARY(pRaw, pRow, dataPos, val, valLen) \
{ \
{ \
if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += valLen; \
dataPos += valLen; \
...
@@ -71,7 +71,7 @@ extern "C" {
...
@@ -71,7 +71,7 @@ extern "C" {
{ \
{ \
char val[valLen] = {0}; \
char val[valLen] = {0}; \
if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \
sdbFreeRow(pRow);
\
tfree(pRow);
\
return NULL; \
return NULL; \
} \
} \
dataPos += valLen; \
dataPos += valLen; \
...
@@ -327,7 +327,7 @@ int32_t sdbGetRawSoftVer(SSdbRaw *pRaw, int8_t *sver);
...
@@ -327,7 +327,7 @@ int32_t sdbGetRawSoftVer(SSdbRaw *pRaw, int8_t *sver);
int32_t
sdbGetRawTotalSize
(
SSdbRaw
*
pRaw
);
int32_t
sdbGetRawTotalSize
(
SSdbRaw
*
pRaw
);
SSdbRow
*
sdbAllocRow
(
int32_t
objSize
);
SSdbRow
*
sdbAllocRow
(
int32_t
objSize
);
void
sdbFreeRow
(
SSdbRow
*
pRow
);
void
sdbFreeRow
(
SSdb
*
pSdb
,
SSdb
Row
*
pRow
);
void
*
sdbGetRowObj
(
SSdbRow
*
pRow
);
void
*
sdbGetRowObj
(
SSdbRow
*
pRow
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/dnode/snode/snode.h
浏览文件 @
f3067eb2
...
@@ -49,10 +49,11 @@ typedef struct {
...
@@ -49,10 +49,11 @@ typedef struct {
/**
/**
* @brief Start one Snode in Dnode.
* @brief Start one Snode in Dnode.
*
*
* @param path Path of the snode.
* @param pOption Option of the snode.
* @param pOption Option of the snode.
* @return SSnode* The snode object.
* @return SSnode* The snode object.
*/
*/
SSnode
*
sndOpen
(
const
SSnodeOpt
*
pOption
);
SSnode
*
sndOpen
(
const
char
*
path
,
const
SSnodeOpt
*
pOption
);
/**
/**
* @brief Stop Snode in Dnode.
* @brief Stop Snode in Dnode.
...
@@ -78,7 +79,14 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
...
@@ -78,7 +79,14 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
* @param pRsp The response message
* @param pRsp The response message
* @return int32_t 0 for success, -1 for failure
* @return int32_t 0 for success, -1 for failure
*/
*/
int32_t
sndProcessWriteMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int32_t
sndProcessMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
/**
* @brief Drop a snode.
*
* @param path Path of the snode.
*/
void
sndDestroy
(
const
char
*
path
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/dnode/vnode/meta/meta.h
浏览文件 @
f3067eb2
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
#include "mallocator.h"
#include "mallocator.h"
#include "os.h"
#include "os.h"
#include "trow.h"
#include "tmsg.h"
#include "tmsg.h"
#include "trow.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -47,35 +47,13 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);
...
@@ -47,35 +47,13 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
// For Query
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
);
// Options
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
// STbCfg
#define META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \
{ \
.name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_SUPER_TABLE, .stbCfg = { \
.suid = (SUID), \
.pSchema = (PSCHEMA), \
.pTagSchema = (PTAGSCHEMA) \
} \
}
#define META_INIT_CTB_CFG(NAME, TTL, KEEP, SUID, PTAG) \
{ \
.name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_CHILD_TABLE, .ctbCfg = {.suid = (SUID), .pTag = PTAG } \
}
#define META_INIT_NTB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA) \
{ \
.name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_NORMAL_TABLE, .ntbCfg = {.pSchema = (PSCHEMA) } \
}
#define META_CLEAR_TB_CFG(pTbCfg)
int
metaEncodeTbCfg
(
void
**
pBuf
,
STbCfg
*
pTbCfg
);
void
*
metaDecodeTbCfg
(
void
*
pBuf
,
STbCfg
*
pTbCfg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/dnode/vnode/vnode.h
浏览文件 @
f3067eb2
...
@@ -162,16 +162,6 @@ int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
...
@@ -162,16 +162,6 @@ int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
*/
*/
int
vnodeProcessFetchReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessFetchReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
/**
* @brief Process a consume message.
*
* @param pVnode The vnode object.
* @param pMsg The request message
* @param pRsp The response message
* @return int 0 for success, -1 for failure
*/
int
vnodeProcessConsumeReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
/* ------------------------ SVnodeCfg ------------------------ */
/* ------------------------ SVnodeCfg ------------------------ */
/**
/**
* @brief Initialize VNODE options.
* @brief Initialize VNODE options.
...
@@ -187,68 +177,6 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
...
@@ -187,68 +177,6 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
*/
*/
void
vnodeOptionsClear
(
SVnodeCfg
*
pOptions
);
void
vnodeOptionsClear
(
SVnodeCfg
*
pOptions
);
/* ------------------------ REQUESTS ------------------------ */
typedef
STbCfg
SVCreateTableReq
;
typedef
struct
{
tb_uid_t
uid
;
}
SVDropTableReq
;
typedef
struct
{
// TODO
}
SVSubmitReq
;
typedef
struct
{
uint64_t
ver
;
union
{
SVCreateTableReq
ctReq
;
SVDropTableReq
dtReq
;
};
}
SVnodeReq
;
typedef
struct
{
int
err
;
char
info
[];
}
SVnodeRsp
;
static
FORCE_INLINE
void
vnodeSetCreateStbReq
(
SVnodeReq
*
pReq
,
char
*
name
,
uint32_t
ttl
,
uint32_t
keep
,
tb_uid_t
suid
,
STSchema
*
pSchema
,
STSchema
*
pTagSchema
)
{
pReq
->
ver
=
0
;
pReq
->
ctReq
.
name
=
name
;
pReq
->
ctReq
.
ttl
=
ttl
;
pReq
->
ctReq
.
keep
=
keep
;
pReq
->
ctReq
.
type
=
META_SUPER_TABLE
;
pReq
->
ctReq
.
stbCfg
.
suid
=
suid
;
pReq
->
ctReq
.
stbCfg
.
pSchema
=
pSchema
;
pReq
->
ctReq
.
stbCfg
.
pTagSchema
=
pTagSchema
;
}
static
FORCE_INLINE
void
vnodeSetCreateCtbReq
(
SVnodeReq
*
pReq
,
char
*
name
,
uint32_t
ttl
,
uint32_t
keep
,
tb_uid_t
suid
,
SKVRow
pTag
)
{
pReq
->
ver
=
0
;
pReq
->
ctReq
.
name
=
name
;
pReq
->
ctReq
.
ttl
=
ttl
;
pReq
->
ctReq
.
keep
=
keep
;
pReq
->
ctReq
.
type
=
META_CHILD_TABLE
;
pReq
->
ctReq
.
ctbCfg
.
suid
=
suid
;
pReq
->
ctReq
.
ctbCfg
.
pTag
=
pTag
;
}
static
FORCE_INLINE
void
vnodeSetCreateNtbReq
(
SVnodeReq
*
pReq
,
char
*
name
,
uint32_t
ttl
,
uint32_t
keep
,
STSchema
*
pSchema
)
{
pReq
->
ver
=
0
;
pReq
->
ctReq
.
name
=
name
;
pReq
->
ctReq
.
ttl
=
ttl
;
pReq
->
ctReq
.
keep
=
keep
;
pReq
->
ctReq
.
type
=
META_NORMAL_TABLE
;
pReq
->
ctReq
.
ntbCfg
.
pSchema
=
pSchema
;
}
int
vnodeBuildReq
(
void
**
buf
,
const
SVnodeReq
*
pReq
,
tmsg_t
type
);
void
*
vnodeParseReq
(
void
*
buf
,
SVnodeReq
*
pReq
,
tmsg_t
type
);
/* ------------------------ FOR COMPILE ------------------------ */
/* ------------------------ FOR COMPILE ------------------------ */
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
);
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
);
...
...
include/libs/catalog/catalog.h
浏览文件 @
f3067eb2
...
@@ -21,13 +21,14 @@ extern "C" {
...
@@ -21,13 +21,14 @@ extern "C" {
#endif
#endif
#include "os.h"
#include "os.h"
#include "thash.h"
#include "tarray.h"
#include "taosdef.h"
#include "taosdef.h"
#include "transport.h"
#include "query.h"
#include "tname.h"
#include "common.h"
#include "common.h"
#include "tarray.h"
#include "thash.h"
#include "tmsg.h"
#include "tmsg.h"
#include "
query
.h"
#include "
transport
.h"
struct
SCatalog
;
struct
SCatalog
;
...
@@ -45,7 +46,6 @@ typedef struct SMetaData {
...
@@ -45,7 +46,6 @@ typedef struct SMetaData {
}
SMetaData
;
}
SMetaData
;
typedef
struct
SCatalogCfg
{
typedef
struct
SCatalogCfg
{
bool
enableVgroupCache
;
uint32_t
maxTblCacheNum
;
uint32_t
maxTblCacheNum
;
uint32_t
maxDBCacheNum
;
uint32_t
maxDBCacheNum
;
}
SCatalogCfg
;
}
SCatalogCfg
;
...
@@ -61,43 +61,40 @@ int32_t catalogInit(SCatalogCfg *cfg);
...
@@ -61,43 +61,40 @@ int32_t catalogInit(SCatalogCfg *cfg);
int32_t
catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
);
int32_t
catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
);
int32_t
catalogGetDBVgroupVersion
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
int32_t
*
version
);
int32_t
catalogGetDBVgroupVersion
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
int32_t
*
version
);
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
int32_t
forceUpdate
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgroup
Cache
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
/**
/**
* Get a table's meta data.
* Get a table's meta data.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param pTransporter (input, rpc object)
* @param pTransporter (input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableMeta(output, table meta data, NEED to free it by calller)
* @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
);
int32_t
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
/**
/**
* Force renew a table's local cached meta data.
* Force renew a table's local cached meta data.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param pRpc (input, rpc object)
* @param pRpc (input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @return error code
* @return error code
*/
*/
int32_t
catalogRenewTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
);
int32_t
catalogRenewTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
);
/**
/**
* Force renew a table's local cached meta data and get the new one.
* Force renew a table's local cached meta data and get the new one.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param pRpc (input, rpc object)
* @param pRpc (input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableMeta(output, table meta data, NEED to free it by calller)
* @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code
* @return error code
*/
*/
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
);
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
/**
/**
...
@@ -105,24 +102,22 @@ int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const
...
@@ -105,24 +102,22 @@ int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param pRpc (input, rpc object)
* @param pRpc (input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetTableDistVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
SArray
**
pVgroupList
);
int32_t
catalogGetTableDistVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgroupList
);
/**
/**
* Get a table's vgroup from its name's hash value.
* Get a table's vgroup from its name's hash value.
* @param pCatalog (input, got with catalogGetHandle)
* @param pCatalog (input, got with catalogGetHandle)
* @param pTransporter (input, rpc object)
* @param pTransporter (input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pMgmtEps (input, mnode EPs)
* @param pDBName (input, full db name)
* @param pTableName (input, table name, NOT including db name)
* @param pTableName (input, table name, NOT including db name)
* @param vgInfo (output, vgroup info)
* @param vgInfo (output, vgroup info)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTable
Name
,
SVgroupInfo
*
vgInfo
);
int32_t
catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
p
Name
,
SVgroupInfo
*
vgInfo
);
/**
/**
...
...
include/libs/parser/parsenodes.h
浏览文件 @
f3067eb2
...
@@ -166,6 +166,7 @@ typedef struct SInsertStmtInfo {
...
@@ -166,6 +166,7 @@ typedef struct SInsertStmtInfo {
typedef
struct
SDclStmtInfo
{
typedef
struct
SDclStmtInfo
{
int16_t
nodeType
;
int16_t
nodeType
;
int16_t
msgType
;
int16_t
msgType
;
SEpSet
epSet
;
char
*
pMsg
;
char
*
pMsg
;
int32_t
msgLen
;
int32_t
msgLen
;
}
SDclStmtInfo
;
}
SDclStmtInfo
;
...
...
include/libs/parser/parser.h
浏览文件 @
f3067eb2
...
@@ -27,7 +27,7 @@ typedef struct SParseContext {
...
@@ -27,7 +27,7 @@ typedef struct SParseContext {
int8_t
schemaAttached
;
// denote if submit block is built with table schema or not
int8_t
schemaAttached
;
// denote if submit block is built with table schema or not
const
char
*
pSql
;
// sql string
const
char
*
pSql
;
// sql string
size_t
sqlLen
;
// length of the sql string
size_t
sqlLen
;
// length of the sql string
char
*
pMsg
;
// extended error message if exists to help
avoid
the problem in sql statement.
char
*
pMsg
;
// extended error message if exists to help
identifying
the problem in sql statement.
int32_t
msgLen
;
// max length of the msg
int32_t
msgLen
;
// max length of the msg
}
SParseContext
;
}
SParseContext
;
...
...
include/libs/qcom/query.h
浏览文件 @
f3067eb2
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
#include "tarray.h"
#include "tarray.h"
#include "thash.h"
#include "thash.h"
#include "tlog.h"
#include "tlog.h"
#include "tmsg.h"
enum
{
enum
{
JOB_TASK_STATUS_NULL
=
0
,
JOB_TASK_STATUS_NULL
=
0
,
...
@@ -73,7 +74,6 @@ typedef struct STableMeta {
...
@@ -73,7 +74,6 @@ typedef struct STableMeta {
SSchema
schema
[];
SSchema
schema
[];
}
STableMeta
;
}
STableMeta
;
typedef
struct
SDBVgroupInfo
{
typedef
struct
SDBVgroupInfo
{
int32_t
vgVersion
;
int32_t
vgVersion
;
int8_t
hashMethod
;
int8_t
hashMethod
;
...
...
include/libs/scheduler/scheduler.h
浏览文件 @
f3067eb2
...
@@ -24,7 +24,6 @@ extern "C" {
...
@@ -24,7 +24,6 @@ extern "C" {
#include "catalog.h"
#include "catalog.h"
typedef
struct
SSchedulerCfg
{
typedef
struct
SSchedulerCfg
{
int32_t
clusterType
;
int32_t
maxJobNum
;
int32_t
maxJobNum
;
}
SSchedulerCfg
;
}
SSchedulerCfg
;
...
...
include/os/osEndian.h
浏览文件 @
f3067eb2
...
@@ -20,8 +20,11 @@
...
@@ -20,8 +20,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
enum
{
TD_LITTLE_ENDIAN
=
0
,
TD_BIG_ENDIAN
}
td_endian_t
;
static
const
int32_t
endian_test_var
=
1
;
static
const
int32_t
endian_test_var
=
1
;
#define IS_LITTLE_ENDIAN() (*(uint8_t *)(&endian_test_var) != 0)
#define IS_LITTLE_ENDIAN() (*(uint8_t *)(&endian_test_var) != 0)
#define TD_RT_ENDIAN() (IS_LITTLE_ENDIAN() ? TD_LITTLE_ENDIAN : TD_BIG_ENDIAN)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/encode.h
0 → 100644
浏览文件 @
f3067eb2
/*
* 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_UTIL_ENCODE_H_
#define _TD_UTIL_ENCODE_H_
#include "tcoding.h"
#include "tmacro.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
td_endian_t
endian
;
uint8_t
*
data
;
int64_t
size
;
int64_t
pos
;
}
SEncoder
,
SDecoder
;
#define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL)
#define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0]
#define tRPut16(PDEST, PSRC) \
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[1]; \
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[0];
#define tRPut32(PDEST, PSRC) \
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[3]; \
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[2]; \
((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[1]; \
((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[0];
#define tRPut64(PDEST, PSRC) \
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[7]; \
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[6]; \
((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[5]; \
((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[4]; \
((uint8_t*)(PDEST))[4] = ((uint8_t*)(PSRC))[3]; \
((uint8_t*)(PDEST))[5] = ((uint8_t*)(PSRC))[2]; \
((uint8_t*)(PDEST))[6] = ((uint8_t*)(PSRC))[1]; \
((uint8_t*)(PDEST))[7] = ((uint8_t*)(PSRC))[0];
#define tRGet16 tRPut16
#define tRGet32 tRPut32
#define tRGet64 tRPut64
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
#define TD_CHECK_CODER_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
/* ------------------------ FOR ENCODER ------------------------ */
static
FORCE_INLINE
void
tInitEncoder
(
SEncoder
*
pEncoder
,
td_endian_t
endian
,
uint8_t
*
data
,
int64_t
size
)
{
pEncoder
->
endian
=
endian
;
pEncoder
->
data
=
data
;
pEncoder
->
size
=
(
data
)
?
size
:
0
;
pEncoder
->
pos
=
0
;
}
// 8
static
FORCE_INLINE
int
tEncodeU8
(
SEncoder
*
pEncoder
,
uint8_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
tPut
(
uint8_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
static
FORCE_INLINE
int
tEncodeI8
(
SEncoder
*
pEncoder
,
int8_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
tPut
(
int8_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
// 16
static
FORCE_INLINE
int
tEncodeU16
(
SEncoder
*
pEncoder
,
uint16_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
uint16_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut16
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
static
FORCE_INLINE
int
tEncodeI16
(
SEncoder
*
pEncoder
,
int16_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
int16_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut16
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
// 32
static
FORCE_INLINE
int
tEncodeU32
(
SEncoder
*
pEncoder
,
uint32_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
uint32_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut32
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
static
FORCE_INLINE
int
tEncodeI32
(
SEncoder
*
pEncoder
,
int32_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
int32_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut32
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
// 64
static
FORCE_INLINE
int
tEncodeU64
(
SEncoder
*
pEncoder
,
uint64_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
uint64_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut64
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
static
FORCE_INLINE
int
tEncodeI64
(
SEncoder
*
pEncoder
,
int64_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
int64_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut64
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
}
TD_CODER_MOVE_POS
(
pEncoder
,
sizeof
(
val
));
return
0
;
}
// 16v
static
FORCE_INLINE
int
tEncodeU16v
(
SEncoder
*
pEncoder
,
uint16_t
val
)
{
int64_t
i
=
0
;
while
(
val
>=
ENCODE_LIMIT
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
val
|
ENCODE_LIMIT
)
&
0xff
;
}
val
>>=
7
;
i
++
;
}
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
uint8_t
)
val
;
}
TD_CODER_MOVE_POS
(
pEncoder
,
i
+
1
);
return
0
;
}
static
FORCE_INLINE
int
tEncodeI16v
(
SEncoder
*
pEncoder
,
int16_t
val
)
{
return
tEncodeU16v
(
pEncoder
,
ZIGZAGE
(
int16_t
,
val
));
}
// 32v
static
FORCE_INLINE
int
tEncodeU32v
(
SEncoder
*
pEncoder
,
uint32_t
val
)
{
int64_t
i
=
0
;
while
(
val
>=
ENCODE_LIMIT
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
val
|
ENCODE_LIMIT
)
&
0xff
;
}
val
>>=
7
;
i
++
;
}
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
uint8_t
)
val
;
}
TD_CODER_MOVE_POS
(
pEncoder
,
i
+
1
);
return
0
;
}
static
FORCE_INLINE
int
tEncodeI32v
(
SEncoder
*
pEncoder
,
int32_t
val
)
{
return
tEncodeU32v
(
pEncoder
,
ZIGZAGE
(
int32_t
,
val
));
}
// 64v
static
FORCE_INLINE
int
tEncodeU64v
(
SEncoder
*
pEncoder
,
uint64_t
val
)
{
int64_t
i
=
0
;
while
(
val
>=
ENCODE_LIMIT
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
val
|
ENCODE_LIMIT
)
&
0xff
;
}
val
>>=
7
;
i
++
;
}
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
uint8_t
)
val
;
}
TD_CODER_MOVE_POS
(
pEncoder
,
i
+
1
);
return
0
;
}
static
FORCE_INLINE
int
tEncodeI64v
(
SEncoder
*
pEncoder
,
int64_t
val
)
{
return
tEncodeU64v
(
pEncoder
,
ZIGZAGE
(
int64_t
,
val
));
}
static
FORCE_INLINE
int
tEncodeFloat
(
SEncoder
*
pEncoder
,
float
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tEncodeDouble
(
SEncoder
*
pEncoder
,
double
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tEncodeCStr
(
SEncoder
*
pEncoder
,
const
char
*
val
)
{
// TODO
return
0
;
}
/* ------------------------ FOR DECODER ------------------------ */
static
FORCE_INLINE
void
tInitDecoder
(
SDecoder
*
pDecoder
,
td_endian_t
endian
,
uint8_t
*
data
,
int64_t
size
)
{
ASSERT
(
!
TD_IS_NULL
(
data
));
pDecoder
->
endian
=
endian
;
pDecoder
->
data
=
data
;
pDecoder
->
size
=
size
;
pDecoder
->
pos
=
0
;
}
// 8
static
FORCE_INLINE
int
tDecodeU8
(
SDecoder
*
pDecoder
,
uint8_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
tGet
(
uint8_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
static
FORCE_INLINE
int
tDecodeI8
(
SDecoder
*
pDecoder
,
int8_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
tGet
(
int8_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
// 16
static
FORCE_INLINE
int
tDecodeU16
(
SDecoder
*
pDecoder
,
uint16_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
uint16_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet16
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
static
FORCE_INLINE
int
tDecodeI16
(
SDecoder
*
pDecoder
,
int16_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
int16_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet16
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
// 32
static
FORCE_INLINE
int
tDecodeU32
(
SDecoder
*
pDecoder
,
uint32_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
uint32_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet32
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
static
FORCE_INLINE
int
tDecodeI32
(
SDecoder
*
pDecoder
,
int32_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
int32_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet32
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
// 64
static
FORCE_INLINE
int
tDecodeU64
(
SDecoder
*
pDecoder
,
uint64_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
uint64_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet64
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
static
FORCE_INLINE
int
tDecodeI64
(
SDecoder
*
pDecoder
,
int64_t
*
val
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
sizeof
(
*
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pDecoder
->
endian
)
{
tGet
(
int64_t
,
TD_CODER_CURRENT
(
pDecoder
),
*
val
);
}
else
{
tRGet64
(
val
,
TD_CODER_CURRENT
(
pDecoder
));
}
TD_CODER_MOVE_POS
(
pDecoder
,
sizeof
(
*
val
));
return
0
;
}
// 16v
static
FORCE_INLINE
int
tDecodeU16v
(
SDecoder
*
pDecoder
,
uint16_t
*
val
)
{
int64_t
i
=
0
;
*
val
=
0
;
for
(;;)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
1
))
return
-
1
;
uint16_t
tval
=
TD_CODER_CURRENT
(
pDecoder
)[
i
];
if
(
tval
<
ENCODE_LIMIT
)
{
(
*
val
)
|=
(
tval
<<
(
7
*
i
));
break
;
}
else
{
(
*
val
)
|=
(((
tval
)
&
(
ENCODE_LIMIT
-
1
))
<<
(
7
*
i
));
i
++
;
}
}
TD_CODER_MOVE_POS
(
pDecoder
,
i
);
return
0
;
}
static
FORCE_INLINE
int
tDecodeI16v
(
SDecoder
*
pDecoder
,
int16_t
*
val
)
{
uint16_t
tval
;
if
(
tDecodeU16v
(
pDecoder
,
&
tval
)
<
0
)
{
return
-
1
;
}
*
val
=
ZIGZAGD
(
int16_t
,
tval
);
return
0
;
}
// 32v
static
FORCE_INLINE
int
tDecodeU32v
(
SDecoder
*
pDecoder
,
uint32_t
*
val
)
{
int64_t
i
=
0
;
*
val
=
0
;
for
(;;)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
1
))
return
-
1
;
uint32_t
tval
=
TD_CODER_CURRENT
(
pDecoder
)[
i
];
if
(
tval
<
ENCODE_LIMIT
)
{
(
*
val
)
|=
(
tval
<<
(
7
*
i
));
break
;
}
else
{
(
*
val
)
|=
(((
tval
)
&
(
ENCODE_LIMIT
-
1
))
<<
(
7
*
i
));
i
++
;
}
}
TD_CODER_MOVE_POS
(
pDecoder
,
i
);
return
0
;
}
static
FORCE_INLINE
int
tDecodeI32v
(
SDecoder
*
pDecoder
,
int32_t
*
val
)
{
uint32_t
tval
;
if
(
tDecodeU32v
(
pDecoder
,
&
tval
)
<
0
)
{
return
-
1
;
}
*
val
=
ZIGZAGD
(
int32_t
,
tval
);
return
0
;
}
// 64v
static
FORCE_INLINE
int
tDecodeU64v
(
SDecoder
*
pDecoder
,
uint64_t
*
val
)
{
int64_t
i
=
0
;
*
val
=
0
;
for
(;;)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pDecoder
,
1
))
return
-
1
;
uint64_t
tval
=
TD_CODER_CURRENT
(
pDecoder
)[
i
];
if
(
tval
<
ENCODE_LIMIT
)
{
(
*
val
)
|=
(
tval
<<
(
7
*
i
));
break
;
}
else
{
(
*
val
)
|=
(((
tval
)
&
(
ENCODE_LIMIT
-
1
))
<<
(
7
*
i
));
i
++
;
}
}
TD_CODER_MOVE_POS
(
pDecoder
,
i
);
return
0
;
}
static
FORCE_INLINE
int
tDecodeI64v
(
SDecoder
*
pDecoder
,
int64_t
*
val
)
{
uint64_t
tval
;
if
(
tDecodeU64v
(
pDecoder
,
&
tval
)
<
0
)
{
return
-
1
;
}
*
val
=
ZIGZAGD
(
int64_t
,
tval
);
return
0
;
}
static
FORCE_INLINE
int
tDecodeFloat
(
SDecoder
*
pDecoder
,
float
*
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tDecodeDouble
(
SDecoder
*
pDecoder
,
double
*
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tDecodeCStr
(
SDecoder
*
pEncoder
,
const
char
**
val
)
{
// TODO
return
0
;
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_ENCODE_H_*/
\ No newline at end of file
include/util/tbuffer.h
浏览文件 @
f3067eb2
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_UTIL_BUFFER_H
#ifndef _TD_UTIL_BUFFER_H
#define _TD_UTIL_BUFFER_H
#define _TD_UTIL_BUFFER_H
#include "os.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -71,102 +73,95 @@ int main( int argc, char** argv ) {
...
@@ -71,102 +73,95 @@ int main( int argc, char** argv ) {
*/
*/
typedef
struct
SBufferReader
{
typedef
struct
SBufferReader
{
bool
endian
;
bool
endian
;
const
char
*
data
;
const
char
*
data
;
size_t
pos
;
size_t
pos
;
size_t
size
;
size_t
size
;
}
SBufferReader
;
}
SBufferReader
;
typedef
struct
SBufferWriter
{
typedef
struct
SBufferWriter
{
bool
endian
;
bool
endian
;
char
*
data
;
char
*
data
;
size_t
pos
;
size_t
pos
;
size_t
size
;
size_t
size
;
void
*
(
*
allocator
)(
void
*
,
size_t
);
void
*
(
*
allocator
)(
void
*
,
size_t
);
}
SBufferWriter
;
}
SBufferWriter
;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// common functions & macros for both reader & writer
// common functions & macros for both reader & writer
#define tbufTell( buf ) ((buf)->pos)
#define tbufTell(buf) ((buf)->pos)
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// reader functions & macros
/* ------------------------ BUFFER WRITER FUNCTIONS AND MACROS ------------------------ */
// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically
#define tbufInitReader( Data, Size, Endian ) {.endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 :(Size))}
size_t
tbufSkip
(
SBufferReader
*
buf
,
size_t
size
);
const
char
*
tbufRead
(
SBufferReader
*
buf
,
size_t
size
);
void
tbufReadToBuffer
(
SBufferReader
*
buf
,
void
*
dst
,
size_t
size
);
const
char
*
tbufReadString
(
SBufferReader
*
buf
,
size_t
*
len
);
size_t
tbufReadToString
(
SBufferReader
*
buf
,
char
*
dst
,
size_t
size
);
const
char
*
tbufReadBinary
(
SBufferReader
*
buf
,
size_t
*
len
);
size_t
tbufReadToBinary
(
SBufferReader
*
buf
,
void
*
dst
,
size_t
size
);
bool
tbufReadBool
(
SBufferReader
*
buf
);
char
tbufReadChar
(
SBufferReader
*
buf
);
int8_t
tbufReadInt8
(
SBufferReader
*
buf
);
uint8_t
tbufReadUint8
(
SBufferReader
*
buf
);
int16_t
tbufReadInt16
(
SBufferReader
*
buf
);
uint16_t
tbufReadUint16
(
SBufferReader
*
buf
);
int32_t
tbufReadInt32
(
SBufferReader
*
buf
);
uint32_t
tbufReadUint32
(
SBufferReader
*
buf
);
int64_t
tbufReadInt64
(
SBufferReader
*
buf
);
uint64_t
tbufReadUint64
(
SBufferReader
*
buf
);
float
tbufReadFloat
(
SBufferReader
*
buf
);
double
tbufReadDouble
(
SBufferReader
*
buf
);
////////////////////////////////////////////////////////////////////////////////
// writer functions & macros
// *Allocator*, function to allocate memory, will use 'realloc' if NULL
// *Allocator*, function to allocate memory, will use 'realloc' if NULL
// *Endian*, if true, writer functions of primitive types will do 'hton' automatically
// *Endian*, if true, writer functions of primitive types will do 'hton' automatically
#define tbufInitWriter(
Allocator, Endian ) {.endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator))}
#define tbufInitWriter(
Allocator, Endian) \
void
tbufCloseWriter
(
SBufferWriter
*
buf
);
{ .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) }
void
tbuf
EnsureCapacity
(
SBufferWriter
*
buf
,
size_t
size
);
void
tbuf
CloseWriter
(
SBufferWriter
*
buf
);
size_t
tbufReserve
(
SBufferWriter
*
buf
,
size_t
size
);
void
tbufEnsureCapacity
(
SBufferWriter
*
buf
,
size_t
size
);
char
*
tbufGetData
(
SBufferWriter
*
buf
,
bool
takeOver
);
size_t
tbufReserve
(
SBufferWriter
*
buf
,
size_t
size
);
char
*
tbufGetData
(
SBufferWriter
*
buf
,
bool
takeOver
);
void
tbufWrite
(
SBufferWriter
*
buf
,
const
void
*
data
,
size_t
size
);
void
tbufWrite
(
SBufferWriter
*
buf
,
const
void
*
data
,
size_t
size
);
void
tbufWriteAt
(
SBufferWriter
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
);
void
tbufWriteAt
(
SBufferWriter
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
);
void
tbufWriteStringLen
(
SBufferWriter
*
buf
,
const
char
*
str
,
size_t
len
);
void
tbufWriteStringLen
(
SBufferWriter
*
buf
,
const
char
*
str
,
size_t
len
);
void
tbufWriteString
(
SBufferWriter
*
buf
,
const
char
*
str
);
void
tbufWriteString
(
SBufferWriter
*
buf
,
const
char
*
str
);
// the prototype of tbufWriteBinary and tbufWrite are identical
// the prototype of tbufWriteBinary and tbufWrite are identical
// the difference is: tbufWriteBinary writes the length of the data to the buffer
// the difference is: tbufWriteBinary writes the length of the data to the buffer
// first, then the actual data, which means the reader don't need to know data
// first, then the actual data, which means the reader don't need to know data
// size before read. Write only write the data itself, which means the reader
// size before read. Write only write the data itself, which means the reader
// need to know data size before read.
// need to know data size before read.
void
tbufWriteBinary
(
SBufferWriter
*
buf
,
const
void
*
data
,
size_t
len
);
void
tbufWriteBinary
(
SBufferWriter
*
buf
,
const
void
*
data
,
size_t
len
);
void
tbufWriteBool
(
SBufferWriter
*
buf
,
bool
data
);
void
tbufWriteBool
(
SBufferWriter
*
buf
,
bool
data
);
void
tbufWriteBoolAt
(
SBufferWriter
*
buf
,
size_t
pos
,
bool
data
);
void
tbufWriteBoolAt
(
SBufferWriter
*
buf
,
size_t
pos
,
bool
data
);
void
tbufWriteChar
(
SBufferWriter
*
buf
,
char
data
);
void
tbufWriteChar
(
SBufferWriter
*
buf
,
char
data
);
void
tbufWriteCharAt
(
SBufferWriter
*
buf
,
size_t
pos
,
char
data
);
void
tbufWriteCharAt
(
SBufferWriter
*
buf
,
size_t
pos
,
char
data
);
void
tbufWriteInt8
(
SBufferWriter
*
buf
,
int8_t
data
);
void
tbufWriteInt8
(
SBufferWriter
*
buf
,
int8_t
data
);
void
tbufWriteInt8At
(
SBufferWriter
*
buf
,
size_t
pos
,
int8_t
data
);
void
tbufWriteInt8At
(
SBufferWriter
*
buf
,
size_t
pos
,
int8_t
data
);
void
tbufWriteUint8
(
SBufferWriter
*
buf
,
uint8_t
data
);
void
tbufWriteUint8
(
SBufferWriter
*
buf
,
uint8_t
data
);
void
tbufWriteUint8At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint8_t
data
);
void
tbufWriteUint8At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint8_t
data
);
void
tbufWriteInt16
(
SBufferWriter
*
buf
,
int16_t
data
);
void
tbufWriteInt16
(
SBufferWriter
*
buf
,
int16_t
data
);
void
tbufWriteInt16At
(
SBufferWriter
*
buf
,
size_t
pos
,
int16_t
data
);
void
tbufWriteInt16At
(
SBufferWriter
*
buf
,
size_t
pos
,
int16_t
data
);
void
tbufWriteUint16
(
SBufferWriter
*
buf
,
uint16_t
data
);
void
tbufWriteUint16
(
SBufferWriter
*
buf
,
uint16_t
data
);
void
tbufWriteUint16At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint16_t
data
);
void
tbufWriteUint16At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint16_t
data
);
void
tbufWriteInt32
(
SBufferWriter
*
buf
,
int32_t
data
);
void
tbufWriteInt32
(
SBufferWriter
*
buf
,
int32_t
data
);
void
tbufWriteInt32At
(
SBufferWriter
*
buf
,
size_t
pos
,
int32_t
data
);
void
tbufWriteInt32At
(
SBufferWriter
*
buf
,
size_t
pos
,
int32_t
data
);
void
tbufWriteUint32
(
SBufferWriter
*
buf
,
uint32_t
data
);
void
tbufWriteUint32
(
SBufferWriter
*
buf
,
uint32_t
data
);
void
tbufWriteUint32At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint32_t
data
);
void
tbufWriteUint32At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint32_t
data
);
void
tbufWriteInt64
(
SBufferWriter
*
buf
,
int64_t
data
);
void
tbufWriteInt64
(
SBufferWriter
*
buf
,
int64_t
data
);
void
tbufWriteInt64At
(
SBufferWriter
*
buf
,
size_t
pos
,
int64_t
data
);
void
tbufWriteInt64At
(
SBufferWriter
*
buf
,
size_t
pos
,
int64_t
data
);
void
tbufWriteUint64
(
SBufferWriter
*
buf
,
uint64_t
data
);
void
tbufWriteUint64
(
SBufferWriter
*
buf
,
uint64_t
data
);
void
tbufWriteUint64At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint64_t
data
);
void
tbufWriteUint64At
(
SBufferWriter
*
buf
,
size_t
pos
,
uint64_t
data
);
void
tbufWriteFloat
(
SBufferWriter
*
buf
,
float
data
);
void
tbufWriteFloat
(
SBufferWriter
*
buf
,
float
data
);
void
tbufWriteFloatAt
(
SBufferWriter
*
buf
,
size_t
pos
,
float
data
);
void
tbufWriteFloatAt
(
SBufferWriter
*
buf
,
size_t
pos
,
float
data
);
void
tbufWriteDouble
(
SBufferWriter
*
buf
,
double
data
);
void
tbufWriteDouble
(
SBufferWriter
*
buf
,
double
data
);
void
tbufWriteDoubleAt
(
SBufferWriter
*
buf
,
size_t
pos
,
double
data
);
void
tbufWriteDoubleAt
(
SBufferWriter
*
buf
,
size_t
pos
,
double
data
);
/* ------------------------ BUFFER READER FUNCTIONS AND MACROS ------------------------ */
// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically
#define tbufInitReader(Data, Size, Endian) \
{ .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) }
size_t
tbufSkip
(
SBufferReader
*
buf
,
size_t
size
);
const
char
*
tbufRead
(
SBufferReader
*
buf
,
size_t
size
);
void
tbufReadToBuffer
(
SBufferReader
*
buf
,
void
*
dst
,
size_t
size
);
const
char
*
tbufReadString
(
SBufferReader
*
buf
,
size_t
*
len
);
size_t
tbufReadToString
(
SBufferReader
*
buf
,
char
*
dst
,
size_t
size
);
const
char
*
tbufReadBinary
(
SBufferReader
*
buf
,
size_t
*
len
);
size_t
tbufReadToBinary
(
SBufferReader
*
buf
,
void
*
dst
,
size_t
size
);
bool
tbufReadBool
(
SBufferReader
*
buf
);
char
tbufReadChar
(
SBufferReader
*
buf
);
int8_t
tbufReadInt8
(
SBufferReader
*
buf
);
uint8_t
tbufReadUint8
(
SBufferReader
*
buf
);
int16_t
tbufReadInt16
(
SBufferReader
*
buf
);
uint16_t
tbufReadUint16
(
SBufferReader
*
buf
);
int32_t
tbufReadInt32
(
SBufferReader
*
buf
);
uint32_t
tbufReadUint32
(
SBufferReader
*
buf
);
int64_t
tbufReadInt64
(
SBufferReader
*
buf
);
uint64_t
tbufReadUint64
(
SBufferReader
*
buf
);
float
tbufReadFloat
(
SBufferReader
*
buf
);
double
tbufReadDouble
(
SBufferReader
*
buf
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/tcoding.h
浏览文件 @
f3067eb2
...
@@ -25,6 +25,8 @@ extern "C" {
...
@@ -25,6 +25,8 @@ extern "C" {
#define ZIGZAGE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode
#define ZIGZAGE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode
#define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode
#define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode
/* ------------------------ LEGACY CODES ------------------------ */
#if 1
// ---- Fixed U8
// ---- Fixed U8
static
FORCE_INLINE
int
taosEncodeFixedU8
(
void
**
buf
,
uint8_t
value
)
{
static
FORCE_INLINE
int
taosEncodeFixedU8
(
void
**
buf
,
uint8_t
value
)
{
if
(
buf
!=
NULL
)
{
if
(
buf
!=
NULL
)
{
...
@@ -368,6 +370,8 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
...
@@ -368,6 +370,8 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
return
POINTER_SHIFT
(
buf
,
size
);
return
POINTER_SHIFT
(
buf
,
size
);
}
}
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/tdef.h
浏览文件 @
f3067eb2
...
@@ -317,12 +317,12 @@ do { \
...
@@ -317,12 +317,12 @@ do { \
#define TSDB_MAX_FIELD_LEN 16384
#define TSDB_MAX_FIELD_LEN 16384
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define PRIMARYKEY_TIMESTAMP_COL_ID
0
#define PRIMARYKEY_TIMESTAMP_COL_ID
1
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_QUERY_TYPE_NON_TYPE
0x00u // none type
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE
0x01u // free qhandle at vnode
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
...
...
include/util/tmacro.h
浏览文件 @
f3067eb2
...
@@ -35,6 +35,8 @@ typedef int8_t td_mode_flag_t;
...
@@ -35,6 +35,8 @@ typedef int8_t td_mode_flag_t;
#define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNCLEARD, TD_MOD_CLEARD)
#define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNCLEARD, TD_MOD_CLEARD)
#define TD_IS_NULL(PTR) ((PTR) == NULL)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/src/clientImpl.c
浏览文件 @
f3067eb2
...
@@ -181,43 +181,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
...
@@ -181,43 +181,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) {
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){.
pData
=
pDcl
->
pMsg
,
.
len
=
pDcl
->
msgLen
};
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){.
pData
=
pDcl
->
pMsg
,
.
len
=
pDcl
->
msgLen
};
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SMsgSendInfo
*
pSendMsg
=
buildSendMsgInfoImpl
(
pRequest
);
SMsgSendInfo
*
pSendMsg
=
buildSendMsgInfoImpl
(
pRequest
);
SEpSet
*
pEpSet
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
int64_t
transporterId
=
0
;
if
(
pDcl
->
msgType
==
TDMT_VND_CREATE_TABLE
)
{
if
(
pDcl
->
msgType
==
TDMT_VND_CREATE_TABLE
)
{
struct
SCatalog
*
pCatalog
=
NULL
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pDcl
->
epSet
,
&
transporterId
,
pSendMsg
);
char
buf
[
18
]
=
{
0
};
sprintf
(
buf
,
"%"
PRId64
,
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
);
int32_t
code
=
catalogGetHandle
(
buf
,
&
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
SCreateTableMsg
*
pMsg
=
pSendMsg
->
msgInfo
.
pData
;
SName
t
=
{
0
};
tNameFromString
(
&
t
,
pMsg
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
db
[
TSDB_DB_NAME_LEN
+
TSDB_NAME_DELIMITER_LEN
+
TSDB_ACCT_ID_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
t
,
db
);
SVgroupInfo
info
=
{
0
};
catalogGetTableHashVgroup
(
pCatalog
,
pRequest
->
pTscObj
->
pTransporter
,
pEpSet
,
db
,
tNameGetTableName
(
&
t
),
&
info
);
int64_t
transporterId
=
0
;
SEpSet
ep
=
{
0
};
ep
.
inUse
=
info
.
inUse
;
ep
.
numOfEps
=
info
.
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
ep
.
numOfEps
;
++
i
)
{
ep
.
port
[
i
]
=
info
.
epAddr
[
i
].
port
;
tstrncpy
(
ep
.
fqdn
[
i
],
info
.
epAddr
[
i
].
fqdn
,
tListLen
(
ep
.
fqdn
[
i
]));
}
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
ep
,
&
transporterId
,
pSendMsg
);
}
else
{
}
else
{
int64_t
transporterId
=
0
;
SEpSet
*
pEpSet
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
pEpSet
,
&
transporterId
,
pSendMsg
);
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
pEpSet
,
&
transporterId
,
pSendMsg
);
}
}
...
@@ -410,7 +380,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
...
@@ -410,7 +380,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnectMsg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnectMsg
);
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
pMsgSendInfo
->
msgType
];
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)
];
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
param
=
pRequest
;
SConnectMsg
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectMsg
));
SConnectMsg
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectMsg
));
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
f3067eb2
...
@@ -79,7 +79,7 @@ static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SMsgSendInfo* pMsgSe
...
@@ -79,7 +79,7 @@ static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SMsgSendInfo* pMsgSe
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTableMsg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTableMsg
);
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
pMsgSendInfo
->
msgType
];
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)
];
SRetrieveTableMsg
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableMsg
));
SRetrieveTableMsg
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableMsg
));
if
(
pRetrieveMsg
==
NULL
)
{
if
(
pRetrieveMsg
==
NULL
)
{
...
@@ -104,7 +104,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) {
...
@@ -104,7 +104,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) {
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
fp
=
(
handleRequestRspFp
[
pRequest
->
type
]
==
NULL
)
?
genericRspCallback
:
handleRequestRspFp
[
pRequest
->
type
];
pMsgSendInfo
->
fp
=
(
handleRequestRspFp
[
TMSG_INDEX
(
pRequest
->
type
)]
==
NULL
)
?
genericRspCallback
:
handleRequestRspFp
[
TMSG_INDEX
(
pRequest
->
type
)
];
}
}
return
pMsgSendInfo
;
return
pMsgSendInfo
;
...
@@ -188,14 +188,21 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -188,14 +188,21 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
}
}
int32_t
processUseDbRsp
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
int32_t
processUseDbRsp
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
SUseDbRsp
*
pUseDbRsp
=
(
SUseDbRsp
*
)
pMsg
->
pData
;
SRequestObj
*
pRequest
=
param
;
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pUseDbRsp
->
db
,
T_NAME_ACCT
|
T_NAME_DB
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
}
SUseDbRsp
*
pUseDbRsp
=
(
SUseDbRsp
*
)
pMsg
->
pData
;
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pUseDbRsp
->
db
,
T_NAME_ACCT
|
T_NAME_DB
);
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
tNameGetDbName
(
&
name
,
db
);
tNameGetDbName
(
&
name
,
db
);
SRequestObj
*
pRequest
=
param
;
setConnectionDB
(
pRequest
->
pTscObj
,
db
);
setConnectionDB
(
pRequest
->
pTscObj
,
db
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
...
@@ -290,11 +297,11 @@ void initMsgHandleFp() {
...
@@ -290,11 +297,11 @@ void initMsgHandleFp() {
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp;
#endif
#endif
handleRequestRspFp
[
T
DMT_MND_CONNECT
]
=
processConnectRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_CONNECT
)
]
=
processConnectRsp
;
handleRequestRspFp
[
T
DMT_MND_SHOW
]
=
processShowRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_SHOW
)
]
=
processShowRsp
;
handleRequestRspFp
[
T
DMT_MND_SHOW_RETRIEVE
]
=
processRetrieveMnodeRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_SHOW_RETRIEVE
)
]
=
processRetrieveMnodeRsp
;
handleRequestRspFp
[
T
DMT_MND_CREATE_DB
]
=
processCreateDbRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_CREATE_DB
)
]
=
processCreateDbRsp
;
handleRequestRspFp
[
T
DMT_MND_USE_DB
]
=
processUseDbRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_USE_DB
)
]
=
processUseDbRsp
;
handleRequestRspFp
[
T
DMT_MND_CREATE_STB
]
=
processCreateTableRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_CREATE_STB
)
]
=
processCreateTableRsp
;
handleRequestRspFp
[
T
DMT_MND_DROP_DB
]
=
processDropDbRsp
;
handleRequestRspFp
[
T
MSG_INDEX
(
TDMT_MND_DROP_DB
)
]
=
processDropDbRsp
;
}
}
\ No newline at end of file
source/client/test/clientTests.cpp
浏览文件 @
f3067eb2
...
@@ -163,7 +163,7 @@ TEST(testCase, create_db_Test) {
...
@@ -163,7 +163,7 @@ TEST(testCase, create_db_Test) {
taos_free_result(pRes);
taos_free_result(pRes);
pRes = taos_query(pConn, "create database abc1");
pRes = taos_query(pConn, "create database abc1
vgroups 4
");
if (taos_errno(pRes) != 0) {
if (taos_errno(pRes) != 0) {
printf("error in create db, reason:%s\n", taos_errstr(pRes));
printf("error in create db, reason:%s\n", taos_errstr(pRes));
}
}
...
@@ -178,14 +178,14 @@ TEST(testCase, create_dnode_Test) {
...
@@ -178,14 +178,14 @@ TEST(testCase, create_dnode_Test) {
if (taos_errno(pRes) != 0) {
if (taos_errno(pRes) != 0) {
printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
printf("error in create dnode, reason:%s\n", taos_errstr(pRes));
}
}
taos_free_result(pRes);
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000");
ASSERT_TRUE(pFields == NULL);
if (taos_errno(pRes) != 0) {
printf("failed to create dnode, reason:%s\n", taos_errstr(pRes));
int32_t numOfFields = taos_num_fields(pRes);
}
ASSERT_EQ(numOfFields, 0);
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
...
@@ -401,50 +401,49 @@ TEST(testCase, drop_stable_Test) {
...
@@ -401,50 +401,49 @@ TEST(testCase, drop_stable_Test) {
}
}
#endif
#endif
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"
);
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
);
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
));
taos_close
(
pConn
);
}
//TEST(testCase, show_table_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
// assert(pConn != NULL);
//
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// 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");
// if (taos_errno(pRes) != 0) {
// printf("error in use db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
// taos_free_result(pRes);
//
//
// pRes = taos_query(pConn, "show tables");
// 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);
//
// int32_t numOfFields = taos_num_fields(pRes);
// ASSERT_EQ(numOfFields, 0);
//
// taos_free_result(pRes);
// taos_free_result(pRes);
//
//
// char* sql = "select * from st1";
// tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql));
// taos_close(pConn);
// taos_close(pConn);
//}
//}
TEST
(
testCase
,
show_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
,
"show tables"
);
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
source/common/src/tvariant.c
浏览文件 @
f3067eb2
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#include "taos.h"
#include "taos.h"
#include "taosdef.h"
#include "taosdef.h"
#include "thash.h"
#include "ttime.h"
#include "ttime.h"
#include "ttokendef.h"
#include "ttokendef.h"
#include "ttypes.h"
#include "ttypes.h"
...
...
source/dnode/bnode/src/bnode.c
浏览文件 @
f3067eb2
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "bndInt.h"
#include "bndInt.h"
SBnode
*
bndOpen
(
const
SBnodeOpt
*
pOption
)
{
SBnode
*
bndOpen
(
const
char
*
path
,
const
SBnodeOpt
*
pOption
)
{
SBnode
*
pBnode
=
calloc
(
1
,
sizeof
(
SBnode
));
SBnode
*
pBnode
=
calloc
(
1
,
sizeof
(
SBnode
));
return
pBnode
;
return
pBnode
;
}
}
...
@@ -25,3 +25,5 @@ void bndClose(SBnode *pBnode) { free(pBnode); }
...
@@ -25,3 +25,5 @@ void bndClose(SBnode *pBnode) { free(pBnode); }
int32_t
bndGetLoad
(
SBnode
*
pBnode
,
SBnodeLoad
*
pLoad
)
{
return
0
;
}
int32_t
bndGetLoad
(
SBnode
*
pBnode
,
SBnodeLoad
*
pLoad
)
{
return
0
;
}
int32_t
bndProcessWMsgs
(
SBnode
*
pBnode
,
SArray
*
pMsgs
)
{
return
0
;
}
int32_t
bndProcessWMsgs
(
SBnode
*
pBnode
,
SArray
*
pMsgs
)
{
return
0
;
}
void
bndDestroy
(
const
char
*
path
)
{}
source/dnode/mgmt/daemon/src/daemon.c
浏览文件 @
f3067eb2
...
@@ -139,7 +139,7 @@ void dmnWaitSignal() {
...
@@ -139,7 +139,7 @@ void dmnWaitSignal() {
void
dmnInitOption
(
SDnodeOpt
*
pOption
)
{
void
dmnInitOption
(
SDnodeOpt
*
pOption
)
{
pOption
->
sver
=
30000000
;
//3.0.0.0
pOption
->
sver
=
30000000
;
//3.0.0.0
pOption
->
numOfCores
=
tsNumOfCores
;
pOption
->
numOfCores
=
tsNumOfCores
;
pOption
->
numOfSupportVnodes
=
1
;
pOption
->
numOfSupportVnodes
=
1
6
;
pOption
->
numOfCommitThreads
=
1
;
pOption
->
numOfCommitThreads
=
1
;
pOption
->
statusInterval
=
tsStatusInterval
;
pOption
->
statusInterval
=
tsStatusInterval
;
pOption
->
numOfThreadsPerCore
=
tsNumOfThreadsPerCore
;
pOption
->
numOfThreadsPerCore
=
tsNumOfThreadsPerCore
;
...
...
source/dnode/mgmt/impl/inc/dndBnode.h
浏览文件 @
f3067eb2
...
@@ -24,7 +24,7 @@ extern "C" {
...
@@ -24,7 +24,7 @@ extern "C" {
int32_t
dndInitBnode
(
SDnode
*
pDnode
);
int32_t
dndInitBnode
(
SDnode
*
pDnode
);
void
dndCleanupBnode
(
SDnode
*
pDnode
);
void
dndCleanupBnode
(
SDnode
*
pDnode
);
i
oid
dndProcessBnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
v
oid
dndProcessBnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
int32_t
dndProcessCreateBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
int32_t
dndProcessCreateBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
int32_t
dndProcessDropBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
int32_t
dndProcessDropBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
f3067eb2
...
@@ -54,18 +54,21 @@ extern int32_t dDebugFlag;
...
@@ -54,18 +54,21 @@ extern int32_t dDebugFlag;
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EStat
;
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EStat
;
typedef
enum
{
DND_WORKER_SINGLE
,
DND_WORKER_MULTI
}
E
Dnd
WorkerType
;
typedef
enum
{
DND_WORKER_SINGLE
,
DND_WORKER_MULTI
}
EWorkerType
;
typedef
void
(
*
DndMsgFp
)(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEps
);
typedef
void
(
*
DndMsgFp
)(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEps
);
typedef
struct
{
typedef
struct
{
E
DndWorkerType
type
;
E
WorkerType
type
;
const
char
*
name
;
const
char
*
name
;
int32_t
minNum
;
int32_t
minNum
;
int32_t
maxNum
;
int32_t
maxNum
;
FProcessItem
f
p
;
void
*
queueF
p
;
SDnode
*
pDnode
;
SDnode
*
pDnode
;
taos_queue
queue
;
taos_queue
queue
;
SWorkerPool
pool
;
union
{
SWorkerPool
pool
;
SMWorkerPool
mpool
;
};
}
SDnodeWorker
;
}
SDnodeWorker
;
typedef
struct
{
typedef
struct
{
...
@@ -94,21 +97,17 @@ typedef struct {
...
@@ -94,21 +97,17 @@ typedef struct {
}
SDnodeMgmt
;
}
SDnodeMgmt
;
typedef
struct
{
typedef
struct
{
int32_t
refCount
;
int32_t
refCount
;
int8_t
deployed
;
int8_t
deployed
;
int8_t
dropped
;
int8_t
dropped
;
int8_t
replica
;
SMnode
*
pMnode
;
int8_t
selfIndex
;
SRWLatch
latch
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SDnodeWorker
readWorker
;
char
*
file
;
SDnodeWorker
writeWorker
;
SMnode
*
pMnode
;
SDnodeWorker
syncWorker
;
SRWLatch
latch
;
int8_t
replica
;
taos_queue
pReadQ
;
int8_t
selfIndex
;
taos_queue
pWriteQ
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
taos_queue
pSyncQ
;
SWorkerPool
readPool
;
SWorkerPool
writePool
;
SWorkerPool
syncPool
;
}
SMnodeMgmt
;
}
SMnodeMgmt
;
typedef
struct
{
typedef
struct
{
...
@@ -122,25 +121,21 @@ typedef struct {
...
@@ -122,25 +121,21 @@ typedef struct {
}
SQnodeMgmt
;
}
SQnodeMgmt
;
typedef
struct
{
typedef
struct
{
int32_t
refCount
;
int32_t
refCount
;
int8_t
deployed
;
int8_t
deployed
;
int8_t
dropped
;
int8_t
dropped
;
char
*
file
;
SSnode
*
pSnode
;
SSnode
*
pSnode
;
SRWLatch
latch
;
SRWLatch
latch
;
SDnodeWorker
writeWorker
;
taos_queue
pWriteQ
;
SWorkerPool
writePool
;
}
SSnodeMgmt
;
}
SSnodeMgmt
;
typedef
struct
{
typedef
struct
{
int32_t
refCount
;
int32_t
refCount
;
int8_t
deployed
;
int8_t
deployed
;
int8_t
dropped
;
int8_t
dropped
;
char
*
file
;
SBnode
*
pBnode
;
SBnode
*
pBnode
;
SRWLatch
latch
;
SRWLatch
latch
;
taos_queue
pWriteQ
;
SDnodeWorker
writeWorker
;
SMWorkerPool
writePool
;
}
SBnodeMgmt
;
}
SBnodeMgmt
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mgmt/impl/inc/dndWorker.h
浏览文件 @
f3067eb2
...
@@ -21,8 +21,8 @@ extern "C" {
...
@@ -21,8 +21,8 @@ extern "C" {
#endif
#endif
#include "dndInt.h"
#include "dndInt.h"
int32_t
dndInitWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
E
Dnd
WorkerType
type
,
const
char
*
name
,
int32_t
minNum
,
int32_t
dndInitWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
EWorkerType
type
,
const
char
*
name
,
int32_t
minNum
,
int32_t
maxNum
,
FProcessItem
f
p
);
int32_t
maxNum
,
void
*
queueF
p
);
void
dndCleanupWorker
(
SDnodeWorker
*
pWorker
);
void
dndCleanupWorker
(
SDnodeWorker
*
pWorker
);
int32_t
dndWriteMsgToWorker
(
SDnodeWorker
*
pWorker
,
void
*
pCont
,
int32_t
contLen
);
int32_t
dndWriteMsgToWorker
(
SDnodeWorker
*
pWorker
,
void
*
pCont
,
int32_t
contLen
);
...
...
source/dnode/mgmt/impl/src/dndBnode.c
0 → 100644
浏览文件 @
f3067eb2
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndDnode.h"
#include "dndTransport.h"
#include "dndWorker.h"
static
void
dndProcessBnodeQueue
(
SDnode
*
pDnode
,
taos_qall
qall
,
int32_t
numOfMsgs
);
static
SBnode
*
dndAcquireBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
SBnode
*
pBnode
=
NULL
;
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pBnode
=
pMgmt
->
pBnode
;
}
else
{
terrno
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
pBnode
!=
NULL
)
{
dTrace
(
"acquire bnode, refCount:%d"
,
refCount
);
}
return
pBnode
;
}
static
void
dndReleaseBnode
(
SDnode
*
pDnode
,
SBnode
*
pBnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pBnode
!=
NULL
)
{
refCount
=
atomic_sub_fetch_32
(
&
pMgmt
->
refCount
,
1
);
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
pBnode
!=
NULL
)
{
dTrace
(
"release bnode, refCount:%d"
,
refCount
);
}
}
static
int32_t
dndReadBnodeFile
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
int32_t
code
=
TSDB_CODE_DND_BNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/bnode.json"
,
pDnode
->
dir
.
dnode
);
FILE
*
fp
=
fopen
(
file
,
"r"
);
if
(
fp
==
NULL
)
{
dDebug
(
"file %s not exist"
,
file
);
code
=
0
;
goto
PRASE_BNODE_OVER
;
}
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
dError
(
"failed to read %s since content is null"
,
file
);
goto
PRASE_BNODE_OVER
;
}
content
[
len
]
=
0
;
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
dError
(
"failed to read %s since invalid json format"
,
file
);
goto
PRASE_BNODE_OVER
;
}
cJSON
*
deployed
=
cJSON_GetObjectItem
(
root
,
"deployed"
);
if
(
!
deployed
||
deployed
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since deployed not found"
,
file
);
goto
PRASE_BNODE_OVER
;
}
pMgmt
->
deployed
=
deployed
->
valueint
;
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
if
(
!
dropped
||
dropped
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since dropped not found"
,
file
);
goto
PRASE_BNODE_OVER
;
}
pMgmt
->
dropped
=
dropped
->
valueint
;
code
=
0
;
dDebug
(
"succcessed to read file %s, deployed:%d dropped:%d"
,
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
PRASE_BNODE_OVER:
if
(
content
!=
NULL
)
free
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
fp
!=
NULL
)
fclose
(
fp
);
terrno
=
code
;
return
code
;
}
static
int32_t
dndWriteBnodeFile
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/bnode.json"
,
pDnode
->
dir
.
dnode
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
if
(
fp
==
NULL
)
{
terrno
=
TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR
;
dError
(
"failed to write %s since %s"
,
file
,
terrstr
());
return
-
1
;
}
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d,
\n
"
,
pMgmt
->
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dropped
\"
: %d
\n
"
,
pMgmt
->
dropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
fwrite
(
content
,
1
,
len
,
fp
);
taosFsyncFile
(
fileno
(
fp
));
fclose
(
fp
);
free
(
content
);
char
realfile
[
PATH_MAX
+
20
];
snprintf
(
realfile
,
PATH_MAX
+
20
,
"%s/bnode.json"
,
pDnode
->
dir
.
dnode
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR
;
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
return
-
1
;
}
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
realfile
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
return
0
;
}
static
int32_t
dndStartBnodeWorker
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
writeWorker
,
DND_WORKER_MULTI
,
"bnode-write"
,
0
,
1
,
dndProcessBnodeQueue
)
!=
0
)
{
dError
(
"failed to start bnode write worker since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
void
dndStopBnodeWorker
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
taosMsleep
(
10
);
}
dndCleanupWorker
(
&
pMgmt
->
writeWorker
);
}
static
void
dndBuildBnodeOption
(
SDnode
*
pDnode
,
SBnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
sendMsgToDnodeFp
=
dndSendMsgToDnode
;
pOption
->
sendMsgToMnodeFp
=
dndSendMsgToMnode
;
pOption
->
sendRedirectMsgFp
=
dndSendRedirectMsg
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
}
static
int32_t
dndOpenBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
SBnodeOpt
option
=
{
0
};
dndBuildBnodeOption
(
pDnode
,
&
option
);
SBnode
*
pBnode
=
bndOpen
(
pDnode
->
dir
.
bnode
,
&
option
);
if
(
pBnode
==
NULL
)
{
dError
(
"failed to open bnode since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndStartBnodeWorker
(
pDnode
)
!=
0
)
{
dError
(
"failed to start bnode worker since %s"
,
terrstr
());
bndClose
(
pBnode
);
return
-
1
;
}
pMgmt
->
deployed
=
1
;
if
(
dndWriteBnodeFile
(
pDnode
)
!=
0
)
{
pMgmt
->
deployed
=
0
;
dError
(
"failed to write bnode file since %s"
,
terrstr
());
dndStopBnodeWorker
(
pDnode
);
bndClose
(
pBnode
);
return
-
1
;
}
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
pBnode
=
pBnode
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"bnode open successfully"
);
return
0
;
}
static
int32_t
dndDropBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
SBnode
*
pBnode
=
dndAcquireBnode
(
pDnode
);
if
(
pBnode
==
NULL
)
{
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
taosRLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dropped
=
1
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
dndWriteBnodeFile
(
pDnode
)
!=
0
)
{
taosRLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dropped
=
0
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
dndReleaseBnode
(
pDnode
,
pBnode
);
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
dndReleaseBnode
(
pDnode
,
pBnode
);
dndStopBnodeWorker
(
pDnode
);
pMgmt
->
deployed
=
0
;
dndWriteBnodeFile
(
pDnode
);
bndClose
(
pBnode
);
pMgmt
->
pBnode
=
NULL
;
bndDestroy
(
pDnode
->
dir
.
bnode
);
return
0
;
}
int32_t
dndProcessCreateBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SCreateBnodeInMsg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
return
-
1
;
}
else
{
return
dndOpenBnode
(
pDnode
);
}
}
int32_t
dndProcessDropBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDropBnodeInMsg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
return
-
1
;
}
else
{
return
dndDropBnode
(
pDnode
);
}
}
static
void
dndSendBnodeErrorRsp
(
SRpcMsg
*
pMsg
,
int32_t
code
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
handle
,
.
ahandle
=
pMsg
->
ahandle
,
.
code
=
code
};
rpcSendResponse
(
&
rpcRsp
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
dndSendBnodeErrorRsps
(
taos_qall
qall
,
int32_t
numOfMsgs
,
int32_t
code
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
SRpcMsg
*
pMsg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
dndSendBnodeErrorRsp
(
pMsg
,
code
);
}
}
static
void
dndProcessBnodeQueue
(
SDnode
*
pDnode
,
taos_qall
qall
,
int32_t
numOfMsgs
)
{
SBnode
*
pBnode
=
dndAcquireBnode
(
pDnode
);
if
(
pBnode
==
NULL
)
{
dndSendBnodeErrorRsps
(
qall
,
numOfMsgs
,
TSDB_CODE_OUT_OF_MEMORY
);
return
;
}
SArray
*
pArray
=
taosArrayInit
(
numOfMsgs
,
sizeof
(
SRpcMsg
*
));
if
(
pArray
==
NULL
)
{
dndReleaseBnode
(
pDnode
,
pBnode
);
dndSendBnodeErrorRsps
(
qall
,
numOfMsgs
,
TSDB_CODE_OUT_OF_MEMORY
);
return
;
}
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
SRpcMsg
*
pMsg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
void
*
ptr
=
taosArrayPush
(
pArray
,
&
pMsg
);
if
(
ptr
==
NULL
)
{
dndSendBnodeErrorRsp
(
pMsg
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
bndProcessWMsgs
(
pBnode
,
pArray
);
for
(
size_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
SRpcMsg
*
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pArray
,
i
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
taosArrayDestroy
(
pArray
);
dndReleaseBnode
(
pDnode
,
pBnode
);
}
static
void
dndWriteBnodeMsgToWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
SBnode
*
pBnode
=
dndAcquireBnode
(
pDnode
);
if
(
pBnode
!=
NULL
)
{
code
=
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
sizeof
(
SRpcMsg
));
}
dndReleaseBnode
(
pDnode
,
pBnode
);
if
(
code
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
ahandle
=
pMsg
->
ahandle
,
.
code
=
code
};
rpcSendResponse
(
&
rsp
);
}
rpcFreeCont
(
pMsg
->
pCont
);
}
}
void
dndProcessBnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
dndWriteBnodeMsgToWorker
(
pDnode
,
&
pDnode
->
bmgmt
.
writeWorker
,
pMsg
);
}
int32_t
dndInitBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
taosInitRWLatch
(
&
pMgmt
->
latch
);
if
(
dndReadBnodeFile
(
pDnode
)
!=
0
)
{
return
-
1
;
}
if
(
pMgmt
->
dropped
)
{
dInfo
(
"bnode has been deployed and needs to be deleted"
);
bndDestroy
(
pDnode
->
dir
.
bnode
);
return
0
;
}
if
(
!
pMgmt
->
deployed
)
return
0
;
return
dndOpenBnode
(
pDnode
);
}
void
dndCleanupBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
if
(
pMgmt
->
pBnode
)
{
dndStopBnodeWorker
(
pDnode
);
bndClose
(
pMgmt
->
pBnode
);
pMgmt
->
pBnode
=
NULL
;
}
}
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
f3067eb2
...
@@ -393,13 +393,11 @@ void dndSendStatusMsg(SDnode *pDnode) {
...
@@ -393,13 +393,11 @@ void dndSendStatusMsg(SDnode *pDnode) {
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pMgmt
->
dnodeId
==
0
||
pMgmt
->
dropped
!=
pCfg
->
dropped
)
{
if
(
pMgmt
->
dnodeId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:% "
PRId64
" dropped:%d"
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
,
pCfg
->
dropped
);
dInfo
(
"set dnodeId:%d clusterId:% "
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosWLockLatch
(
&
pMgmt
->
latch
);
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
dropped
=
pCfg
->
dropped
;
dndWriteDnodes
(
pDnode
);
dndWriteDnodes
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
}
...
@@ -430,6 +428,11 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -430,6 +428,11 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
pMgmt
->
statusSent
=
0
;
pMgmt
->
statusSent
=
0
;
if
(
pMsg
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pMgmt
->
dnodeId
);
pMgmt
->
dropped
=
1
;
dndWriteDnodes
(
pDnode
);
}
return
;
return
;
}
}
...
@@ -439,11 +442,6 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -439,11 +442,6 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
if
(
pCfg
->
dropped
)
{
pMgmt
->
statusSent
=
0
;
return
;
}
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
...
@@ -487,7 +485,7 @@ static void *dnodeThreadRoutine(void *param) {
...
@@ -487,7 +485,7 @@ static void *dnodeThreadRoutine(void *param) {
pthread_testcancel
();
pthread_testcancel
();
taosMsleep
(
ms
);
taosMsleep
(
ms
);
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
&&
!
pMgmt
->
statusSent
)
{
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
&&
!
pMgmt
->
statusSent
&&
!
pMgmt
->
dropped
)
{
dndSendStatusMsg
(
pDnode
);
dndSendStatusMsg
(
pDnode
);
}
}
}
}
...
@@ -522,6 +520,11 @@ int32_t dndInitDnode(SDnode *pDnode) {
...
@@ -522,6 +520,11 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
return
-
1
;
}
}
if
(
pMgmt
->
dropped
)
{
dError
(
"dnode will not start for its already dropped"
);
return
-
1
;
}
if
(
dndInitMgmtWorker
(
pDnode
)
!=
0
)
{
if
(
dndInitMgmtWorker
(
pDnode
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
f3067eb2
...
@@ -17,42 +17,9 @@
...
@@ -17,42 +17,9 @@
#include "dndMnode.h"
#include "dndMnode.h"
#include "dndDnode.h"
#include "dndDnode.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndWorker.h"
static
int32_t
dndInitMnodeReadWorker
(
SDnode
*
pDnode
);
static
void
dndProcessMnodeQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
);
static
int32_t
dndInitMnodeWriteWorker
(
SDnode
*
pDnode
);
static
int32_t
dndInitMnodeSyncWorker
(
SDnode
*
pDnode
);
static
void
dndCleanupMnodeReadWorker
(
SDnode
*
pDnode
);
static
void
dndCleanupMnodeWriteWorker
(
SDnode
*
pDnode
);
static
void
dndCleanupMnodeSyncWorker
(
SDnode
*
pDnode
);
static
void
dndCleanupMnodeMgmtWorker
(
SDnode
*
pDnode
);
static
int32_t
dndAllocMnodeReadQueue
(
SDnode
*
pDnode
);
static
int32_t
dndAllocMnodeWriteQueue
(
SDnode
*
pDnode
);
static
int32_t
dndAllocMnodeSyncQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMnodeReadQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMnodeWriteQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMnodeSyncQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMnodeMgmtQueue
(
SDnode
*
pDnode
);
static
void
dndProcessMnodeReadQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
);
static
void
dndProcessMnodeWriteQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
);
static
void
dndProcessMnodeSyncQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
);
static
int32_t
dndWriteMnodeMsgToQueue
(
SMnode
*
pMnode
,
taos_queue
pQueue
,
SRpcMsg
*
pRpcMsg
);
void
dndProcessMnodeReadMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
dndProcessMnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
dndProcessMnodeSyncMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
int32_t
dndStartMnodeWorker
(
SDnode
*
pDnode
);
static
void
dndStopMnodeWorker
(
SDnode
*
pDnode
);
static
SMnode
*
dndAcquireMnode
(
SDnode
*
pDnode
);
static
void
dndReleaseMnode
(
SDnode
*
pDnode
,
SMnode
*
pMnode
);
static
int32_t
dndReadMnodeFile
(
SDnode
*
pDnode
);
static
int32_t
dndWriteMnodeFile
(
SDnode
*
pDnode
);
static
int32_t
dndOpenMnode
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
);
static
int32_t
dndAlterMnode
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
);
static
int32_t
dndDropMnode
(
SDnode
*
pDnode
);
static
SMnode
*
dndAcquireMnode
(
SDnode
*
pDnode
)
{
static
SMnode
*
dndAcquireMnode
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
...
@@ -97,49 +64,52 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
...
@@ -97,49 +64,52 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
FILE
*
fp
=
fopen
(
pMgmt
->
file
,
"r"
);
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/mnode.json"
,
pDnode
->
dir
.
dnode
);
FILE
*
fp
=
fopen
(
file
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
dDebug
(
"file %s not exist"
,
pMgmt
->
file
);
dDebug
(
"file %s not exist"
,
file
);
code
=
0
;
code
=
0
;
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
dError
(
"failed to read %s since content is null"
,
pMgmt
->
file
);
dError
(
"failed to read %s since content is null"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
content
[
len
]
=
0
;
content
[
len
]
=
0
;
root
=
cJSON_Parse
(
content
);
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
if
(
root
==
NULL
)
{
dError
(
"failed to read %s since invalid json format"
,
pMgmt
->
file
);
dError
(
"failed to read %s since invalid json format"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
cJSON
*
deployed
=
cJSON_GetObjectItem
(
root
,
"deployed"
);
cJSON
*
deployed
=
cJSON_GetObjectItem
(
root
,
"deployed"
);
if
(
!
deployed
||
deployed
->
type
!=
cJSON_Number
)
{
if
(
!
deployed
||
deployed
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since deployed not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since deployed not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
pMgmt
->
deployed
=
deployed
->
valueint
;
pMgmt
->
deployed
=
deployed
->
valueint
;
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
if
(
!
dropped
||
dropped
->
type
!=
cJSON_Number
)
{
if
(
!
dropped
||
dropped
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since dropped not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since dropped not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
pMgmt
->
dropped
=
dropped
->
valueint
;
pMgmt
->
dropped
=
dropped
->
valueint
;
cJSON
*
mnodes
=
cJSON_GetObjectItem
(
root
,
"mnodes"
);
cJSON
*
mnodes
=
cJSON_GetObjectItem
(
root
,
"mnodes"
);
if
(
!
mnodes
||
mnodes
->
type
!=
cJSON_Array
)
{
if
(
!
mnodes
||
mnodes
->
type
!=
cJSON_Array
)
{
dError
(
"failed to read %s since nodes not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since nodes not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
pMgmt
->
replica
=
cJSON_GetArraySize
(
mnodes
);
pMgmt
->
replica
=
cJSON_GetArraySize
(
mnodes
);
if
(
pMgmt
->
replica
<=
0
||
pMgmt
->
replica
>
TSDB_MAX_REPLICA
)
{
if
(
pMgmt
->
replica
<=
0
||
pMgmt
->
replica
>
TSDB_MAX_REPLICA
)
{
dError
(
"failed to read %s since mnodes size %d invalid"
,
pMgmt
->
file
,
pMgmt
->
replica
);
dError
(
"failed to read %s since mnodes size %d invalid"
,
file
,
pMgmt
->
replica
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
...
@@ -151,28 +121,28 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
...
@@ -151,28 +121,28 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
cJSON
*
id
=
cJSON_GetObjectItem
(
node
,
"id"
);
cJSON
*
id
=
cJSON_GetObjectItem
(
node
,
"id"
);
if
(
!
id
||
id
->
type
!=
cJSON_Number
)
{
if
(
!
id
||
id
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since id not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since id not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
pReplica
->
id
=
id
->
valueint
;
pReplica
->
id
=
id
->
valueint
;
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
node
,
"fqdn"
);
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
node
,
"fqdn"
);
if
(
!
fqdn
||
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
if
(
!
fqdn
||
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s since fqdn not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since fqdn not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
cJSON
*
port
=
cJSON_GetObjectItem
(
node
,
"port"
);
cJSON
*
port
=
cJSON_GetObjectItem
(
node
,
"port"
);
if
(
!
port
||
port
->
type
!=
cJSON_Number
)
{
if
(
!
port
||
port
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since port not found"
,
pMgmt
->
file
);
dError
(
"failed to read %s since port not found"
,
file
);
goto
PRASE_MNODE_OVER
;
goto
PRASE_MNODE_OVER
;
}
}
pReplica
->
port
=
port
->
valueint
;
pReplica
->
port
=
port
->
valueint
;
}
}
code
=
0
;
code
=
0
;
dDebug
(
"succcessed to read file %s, deployed:%d dropped:%d"
,
pMgmt
->
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
dDebug
(
"succcessed to read file %s, deployed:%d dropped:%d"
,
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
PRASE_MNODE_OVER:
PRASE_MNODE_OVER:
if
(
content
!=
NULL
)
free
(
content
);
if
(
content
!=
NULL
)
free
(
content
);
...
@@ -186,8 +156,8 @@ PRASE_MNODE_OVER:
...
@@ -186,8 +156,8 @@ PRASE_MNODE_OVER:
static
int32_t
dndWriteMnodeFile
(
SDnode
*
pDnode
)
{
static
int32_t
dndWriteMnodeFile
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
char
file
[
PATH_MAX
+
20
]
=
{
0
}
;
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
sizeof
(
file
),
"%s.bak"
,
pMgmt
->
fil
e
);
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/mnode.json.bak"
,
pDnode
->
dir
.
dnod
e
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
...
@@ -223,47 +193,36 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
...
@@ -223,47 +193,36 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
fclose
(
fp
);
fclose
(
fp
);
free
(
content
);
free
(
content
);
if
(
taosRenameFile
(
file
,
pMgmt
->
file
)
!=
0
)
{
char
realfile
[
PATH_MAX
+
20
];
snprintf
(
realfile
,
PATH_MAX
+
20
,
"%s/mnode.json"
,
pDnode
->
dir
.
dnode
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
;
terrno
=
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
;
dError
(
"failed to rename %s since %s"
,
pMgmt
->
file
,
terrstr
());
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
pMgmt
->
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
real
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
return
0
;
return
0
;
}
}
static
int32_t
dndStartMnodeWorker
(
SDnode
*
pDnode
)
{
static
int32_t
dndStartMnodeWorker
(
SDnode
*
pDnode
)
{
if
(
dndInitMnodeReadWorker
(
pDnode
)
!=
0
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
readWorker
,
DND_WORKER_SINGLE
,
"mnode-read"
,
0
,
1
,
dndProcessMnodeQueue
)
!=
0
)
{
dError
(
"failed to start mnode read worker since %s"
,
terrstr
());
dError
(
"failed to start mnode read worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
dndInit
MnodeWriteWorker
(
pDnod
e
)
!=
0
)
{
if
(
dndInit
Worker
(
pDnode
,
&
pMgmt
->
writeWorker
,
DND_WORKER_SINGLE
,
"mnode-write"
,
0
,
1
,
dndProcessMnodeQueu
e
)
!=
0
)
{
dError
(
"failed to start mnode write worker since %s"
,
terrstr
());
dError
(
"failed to start mnode write worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
dndInit
MnodeSyncWorker
(
pDnod
e
)
!=
0
)
{
if
(
dndInit
Worker
(
pDnode
,
&
pMgmt
->
syncWorker
,
DND_WORKER_SINGLE
,
"mnode-sync"
,
0
,
1
,
dndProcessMnodeQueu
e
)
!=
0
)
{
dError
(
"failed to start mnode sync worker since %s"
,
terrstr
());
dError
(
"failed to start mnode sync worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
dndAllocMnodeReadQueue
(
pDnode
)
!=
0
)
{
dError
(
"failed to alloc mnode read queue since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndAllocMnodeWriteQueue
(
pDnode
)
!=
0
)
{
dError
(
"failed to alloc mnode write queue since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndAllocMnodeSyncQueue
(
pDnode
)
!=
0
)
{
dError
(
"failed to alloc mnode sync queue since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
return
0
;
}
}
...
@@ -274,18 +233,13 @@ static void dndStopMnodeWorker(SDnode *pDnode) {
...
@@ -274,18 +233,13 @@ static void dndStopMnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
taosMsleep
(
10
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
!
taosQueueEmpty
(
pMgmt
->
pReadQ
))
taosMsleep
(
10
);
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pMgmt
->
pWriteQ
))
taosMsleep
(
10
);
}
while
(
!
taosQueueEmpty
(
pMgmt
->
pSyncQ
))
taosMsleep
(
10
);
dndCleanupMnodeReadWorker
(
pDnode
);
dndCleanupMnodeWriteWorker
(
pDnode
);
dndCleanupMnodeSyncWorker
(
pDnode
);
dnd
FreeMnodeReadQueue
(
pDnode
);
dnd
CleanupWorker
(
&
pMgmt
->
readWorker
);
dnd
FreeMnodeWriteQueue
(
pDnode
);
dnd
CleanupWorker
(
&
pMgmt
->
writeWorker
);
dnd
FreeMnodeSyncQueue
(
pDnode
);
dnd
CleanupWorker
(
&
pMgmt
->
syncWorker
);
}
}
static
bool
dndNeedDeployMnode
(
SDnode
*
pDnode
)
{
static
bool
dndNeedDeployMnode
(
SDnode
*
pDnode
)
{
...
@@ -383,28 +337,21 @@ static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption) {
...
@@ -383,28 +337,21 @@ static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption) {
dError
(
"failed to open mnode since %s"
,
terrstr
());
dError
(
"failed to open mnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
pMgmt
->
deployed
=
1
;
int32_t
code
=
dndWriteMnodeFile
(
pDnode
);
if
(
dndStartMnodeWorker
(
pDnode
)
!=
0
)
{
if
(
code
!=
0
)
{
dError
(
"failed to start mnode worker since %s"
,
terrstr
());
dError
(
"failed to write mnode file since %s"
,
terrstr
());
code
=
terrno
;
pMgmt
->
deployed
=
0
;
mndClose
(
pMnode
);
mndClose
(
pMnode
);
mndDestroy
(
pDnode
->
dir
.
mnode
);
mndDestroy
(
pDnode
->
dir
.
mnode
);
terrno
=
code
;
return
-
1
;
return
-
1
;
}
}
code
=
dndStartMnodeWorker
(
pDnode
);
pMgmt
->
deployed
=
1
;
if
(
code
!=
0
)
{
if
(
dndWriteMnodeFile
(
pDnode
)
!=
0
)
{
dError
(
"failed to start mnode worker since %s"
,
terrstr
());
dError
(
"failed to write mnode file since %s"
,
terrstr
());
code
=
terrno
;
pMgmt
->
deployed
=
0
;
pMgmt
->
deployed
=
0
;
dndStopMnodeWorker
(
pDnode
);
dndStopMnodeWorker
(
pDnode
);
mndClose
(
pMnode
);
mndClose
(
pMnode
);
mndDestroy
(
pDnode
->
dir
.
mnode
);
mndDestroy
(
pDnode
->
dir
.
mnode
);
terrno
=
code
;
return
-
1
;
return
-
1
;
}
}
...
@@ -461,6 +408,7 @@ static int32_t dndDropMnode(SDnode *pDnode) {
...
@@ -461,6 +408,7 @@ static int32_t dndDropMnode(SDnode *pDnode) {
dndReleaseMnode
(
pDnode
,
pMnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
dndStopMnodeWorker
(
pDnode
);
dndStopMnodeWorker
(
pDnode
);
pMgmt
->
deployed
=
0
;
dndWriteMnodeFile
(
pDnode
);
dndWriteMnodeFile
(
pDnode
);
mndClose
(
pMnode
);
mndClose
(
pMnode
);
pMgmt
->
pMnode
=
NULL
;
pMgmt
->
pMnode
=
NULL
;
...
@@ -528,13 +476,12 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
...
@@ -528,13 +476,12 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
}
}
}
static
void
dndProcessMnodeQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
)
{
static
void
dndProcessMnodeReadQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
!=
NULL
)
{
mndProcess
Read
Msg
(
pMsg
);
mndProcessMsg
(
pMsg
);
dndReleaseMnode
(
pDnode
,
pMnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
}
else
{
}
else
{
mndSendRsp
(
pMsg
,
terrno
);
mndSendRsp
(
pMsg
,
terrno
);
...
@@ -543,208 +490,43 @@ static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
...
@@ -543,208 +490,43 @@ static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) {
mndCleanupMsg
(
pMsg
);
mndCleanupMsg
(
pMsg
);
}
}
static
void
dnd
ProcessMnodeWriteQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
p
Msg
)
{
static
void
dnd
WriteMnodeMsgToWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
SRpcMsg
*
pRpc
Msg
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
int32_t
code
=
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
;
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
!=
NULL
)
{
mndProcessWriteMsg
(
pMsg
);
SMnodeMsg
*
pMsg
=
mndInitMsg
(
pMnode
,
pRpcMsg
);
dndReleaseMnode
(
pDnode
,
pMnode
);
if
(
pMsg
==
NULL
)
{
}
else
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
mndSendRsp
(
pMsg
,
terrno
);
}
else
{
}
code
=
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
0
);
mndCleanupMsg
(
pMsg
);
}
static
void
dndProcessMnodeSyncQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
!=
NULL
)
{
mndProcessSyncMsg
(
pMsg
);
dndReleaseMnode
(
pDnode
,
pMnode
);
}
else
{
mndSendRsp
(
pMsg
,
terrno
);
}
mndCleanupMsg
(
pMsg
);
}
static
int32_t
dndWriteMnodeMsgToQueue
(
SMnode
*
pMnode
,
taos_queue
pQueue
,
SRpcMsg
*
pRpcMsg
)
{
SMnodeMsg
*
pMsg
=
mndInitMsg
(
pMnode
,
pRpcMsg
);
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
taosWriteQitem
(
pQueue
,
pMsg
)
!=
0
)
{
mndCleanupMsg
(
pMsg
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
void
dndProcessMnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
||
dndWriteMnodeMsgToQueue
(
pMnode
,
pMgmt
->
pWriteQ
,
pMsg
)
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
terrno
};
rpcSendResponse
(
&
rsp
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
dndReleaseMnode
(
pDnode
,
pMnode
);
if
(
code
!=
0
)
{
}
mndCleanupMsg
(
pMsg
);
void
dndProcessMnodeSyncMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
||
dndWriteMnodeMsgToQueue
(
pMnode
,
pMgmt
->
pSyncQ
,
pMsg
)
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
terrno
};
rpcSendResponse
(
&
rsp
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
}
dndReleaseMnode
(
pDnode
,
pMnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
}
void
dndProcessMnodeReadMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
if
(
code
!=
0
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
if
(
pRpcMsg
->
msgType
&
1u
)
{
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
SRpcMsg
rsp
=
{.
handle
=
pRpcMsg
->
handle
,
.
ahandle
=
pRpcMsg
->
ahandle
,
.
code
=
code
};
if
(
pMnode
==
NULL
||
dndWriteMnodeMsgToQueue
(
pMnode
,
pMgmt
->
pReadQ
,
pMsg
)
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
terrno
};
rpcSendResponse
(
&
rsp
);
rpcSendResponse
(
&
rsp
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
dndReleaseMnode
(
pDnode
,
pMnode
);
}
static
int32_t
dndAllocMnodeReadQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
pMgmt
->
pReadQ
=
tWorkerAllocQueue
(
&
pMgmt
->
readPool
,
pDnode
,
(
FProcessItem
)
dndProcessMnodeReadQueue
);
if
(
pMgmt
->
pReadQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
return
0
;
}
static
void
dndFreeMnodeReadQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tWorkerFreeQueue
(
&
pMgmt
->
readPool
,
pMgmt
->
pReadQ
);
pMgmt
->
pReadQ
=
NULL
;
}
static
int32_t
dndInitMnodeReadWorker
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SWorkerPool
*
pPool
=
&
pMgmt
->
readPool
;
pPool
->
name
=
"mnode-read"
;
pPool
->
min
=
0
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
dDebug
(
"mnode read worker is initialized"
);
return
0
;
}
static
void
dndCleanupMnodeReadWorker
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tWorkerCleanup
(
&
pMgmt
->
readPool
);
dDebug
(
"mnode read worker is closed"
);
}
static
int32_t
dndAllocMnodeWriteQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
pMgmt
->
pWriteQ
=
tWorkerAllocQueue
(
&
pMgmt
->
writePool
,
pDnode
,
(
FProcessItem
)
dndProcessMnodeWriteQueue
);
if
(
pMgmt
->
pWriteQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
static
void
dndFreeMnodeWriteQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tWorkerFreeQueue
(
&
pMgmt
->
writePool
,
pMgmt
->
pWriteQ
);
pMgmt
->
pWriteQ
=
NULL
;
}
}
static
int32_t
dndInitMnodeWriteWorker
(
SDnode
*
pDnode
)
{
void
dndProcessMnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
dndWriteMnodeMsgToWorker
(
pDnode
,
&
pDnode
->
mmgmt
.
writeWorker
,
pMsg
);
SWorkerPool
*
pPool
=
&
pMgmt
->
writePool
;
pPool
->
name
=
"mnode-write"
;
pPool
->
min
=
0
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
dDebug
(
"mnode write worker is initialized"
);
return
0
;
}
static
void
dndCleanupMnodeWriteWorker
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tWorkerCleanup
(
&
pMgmt
->
writePool
);
dDebug
(
"mnode write worker is closed"
);
}
static
int32_t
dndAllocMnodeSyncQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
pMgmt
->
pSyncQ
=
tWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pDnode
,
(
FProcessItem
)
dndProcessMnodeSyncQueue
);
if
(
pMgmt
->
pSyncQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
static
void
dndFreeMnodeSyncQueue
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pMgmt
->
pSyncQ
);
pMgmt
->
pSyncQ
=
NULL
;
}
}
static
int32_t
dndInitMnodeSyncWorker
(
SDnode
*
pDnode
)
{
void
dndProcessMnodeSyncMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
dndWriteMnodeMsgToWorker
(
pDnode
,
&
pDnode
->
mmgmt
.
syncWorker
,
pMsg
);
SWorkerPool
*
pPool
=
&
pMgmt
->
syncPool
;
pPool
->
name
=
"mnode-sync"
;
pPool
->
min
=
0
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
dDebug
(
"mnode sync worker is initialized"
);
return
0
;
}
}
static
void
dndCleanupMnodeSyncWorker
(
SDnode
*
pDnode
)
{
void
dndProcessMnodeReadMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
dndWriteMnodeMsgToWorker
(
pDnode
,
&
pDnode
->
mmgmt
.
readWorker
,
pMsg
);
tWorkerCleanup
(
&
pMgmt
->
syncPool
);
dDebug
(
"mnode sync worker is closed"
);
}
}
int32_t
dndInitMnode
(
SDnode
*
pDnode
)
{
int32_t
dndInitMnode
(
SDnode
*
pDnode
)
{
...
@@ -752,14 +534,6 @@ int32_t dndInitMnode(SDnode *pDnode) {
...
@@ -752,14 +534,6 @@ int32_t dndInitMnode(SDnode *pDnode) {
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
taosInitRWLatch
(
&
pMgmt
->
latch
);
taosInitRWLatch
(
&
pMgmt
->
latch
);
char
path
[
PATH_MAX
];
snprintf
(
path
,
PATH_MAX
,
"%s/mnode.json"
,
pDnode
->
dir
.
dnode
);
pMgmt
->
file
=
strdup
(
path
);
if
(
pMgmt
->
file
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
dndReadMnodeFile
(
pDnode
)
!=
0
)
{
if
(
dndReadMnodeFile
(
pDnode
)
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -790,13 +564,13 @@ int32_t dndInitMnode(SDnode *pDnode) {
...
@@ -790,13 +564,13 @@ int32_t dndInitMnode(SDnode *pDnode) {
}
}
void
dndCleanupMnode
(
SDnode
*
pDnode
)
{
void
dndCleanupMnode
(
SDnode
*
pDnode
)
{
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
dInfo
(
"dnode-mnode start to clean up"
);
dInfo
(
"dnode-mnode start to clean up"
);
if
(
pMgmt
->
pMnode
)
dndStopMnodeWorker
(
pDnode
);
SMnodeMgmt
*
pMgmt
=
&
pDnode
->
mmgmt
;
tfree
(
pMgmt
->
file
);
if
(
pMgmt
->
pMnode
)
{
mndClose
(
pMgmt
->
pMnode
);
dndStopMnodeWorker
(
pDnode
);
pMgmt
->
pMnode
=
NULL
;
mndClose
(
pMgmt
->
pMnode
);
pMgmt
->
pMnode
=
NULL
;
}
dInfo
(
"dnode-mnode is cleaned up"
);
dInfo
(
"dnode-mnode is cleaned up"
);
}
}
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
f3067eb2
...
@@ -140,26 +140,27 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
...
@@ -140,26 +140,27 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
fclose
(
fp
);
fclose
(
fp
);
free
(
content
);
free
(
content
);
if
(
taosRenameFile
(
file
,
file
)
!=
0
)
{
char
realfile
[
PATH_MAX
+
20
];
snprintf
(
realfile
,
PATH_MAX
+
20
,
"%s/qnode.json"
,
pDnode
->
dir
.
dnode
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR
;
terrno
=
TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR
;
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
real
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
return
0
;
return
0
;
}
}
static
int32_t
dndStartQnodeWorker
(
SDnode
*
pDnode
)
{
static
int32_t
dndStartQnodeWorker
(
SDnode
*
pDnode
)
{
SQnodeMgmt
*
pMgmt
=
&
pDnode
->
qmgmt
;
SQnodeMgmt
*
pMgmt
=
&
pDnode
->
qmgmt
;
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
queryWorker
,
DND_WORKER_SINGLE
,
"qnode-query"
,
0
,
1
,
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
queryWorker
,
DND_WORKER_SINGLE
,
"qnode-query"
,
0
,
1
,
dndProcessQnodeQueue
)
!=
0
)
{
(
FProcessItem
)
dndProcessQnodeQueue
)
!=
0
)
{
dError
(
"failed to start qnode query worker since %s"
,
terrstr
());
dError
(
"failed to start qnode query worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
fetchWorker
,
DND_WORKER_SINGLE
,
"qnode-fetch"
,
0
,
1
,
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
fetchWorker
,
DND_WORKER_SINGLE
,
"qnode-fetch"
,
0
,
1
,
dndProcessQnodeQueue
)
!=
0
)
{
(
FProcessItem
)
dndProcessQnodeQueue
)
!=
0
)
{
dError
(
"failed to start qnode fetch worker since %s"
,
terrstr
());
dError
(
"failed to start qnode fetch worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -209,7 +210,9 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
...
@@ -209,7 +210,9 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
return
-
1
;
return
-
1
;
}
}
pMgmt
->
deployed
=
1
;
if
(
dndWriteQnodeFile
(
pDnode
)
!=
0
)
{
if
(
dndWriteQnodeFile
(
pDnode
)
!=
0
)
{
pMgmt
->
deployed
=
0
;
dError
(
"failed to write qnode file since %s"
,
terrstr
());
dError
(
"failed to write qnode file since %s"
,
terrstr
());
dndStopQnodeWorker
(
pDnode
);
dndStopQnodeWorker
(
pDnode
);
qndClose
(
pQnode
);
qndClose
(
pQnode
);
...
@@ -218,7 +221,6 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
...
@@ -218,7 +221,6 @@ static int32_t dndOpenQnode(SDnode *pDnode) {
taosWLockLatch
(
&
pMgmt
->
latch
);
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
pQnode
=
pQnode
;
pMgmt
->
pQnode
=
pQnode
;
pMgmt
->
deployed
=
1
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"qnode open successfully"
);
dInfo
(
"qnode open successfully"
);
...
@@ -250,9 +252,10 @@ static int32_t dndDropQnode(SDnode *pDnode) {
...
@@ -250,9 +252,10 @@ static int32_t dndDropQnode(SDnode *pDnode) {
dndReleaseQnode
(
pDnode
,
pQnode
);
dndReleaseQnode
(
pDnode
,
pQnode
);
dndStopQnodeWorker
(
pDnode
);
dndStopQnodeWorker
(
pDnode
);
pMgmt
->
deployed
=
0
;
dndWriteQnodeFile
(
pDnode
);
qndClose
(
pQnode
);
qndClose
(
pQnode
);
pMgmt
->
pQnode
=
NULL
;
pMgmt
->
pQnode
=
NULL
;
// qndDestroy(pDnode->dir.qnode);
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/impl/src/dndSnode.c
0 → 100644
浏览文件 @
f3067eb2
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "dndSnode.h"
#include "dndDnode.h"
#include "dndTransport.h"
#include "dndWorker.h"
static
void
dndProcessSnodeQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
SSnode
*
dndAcquireSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SSnode
*
pSnode
=
NULL
;
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pSnode
=
pMgmt
->
pSnode
;
}
else
{
terrno
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
pSnode
!=
NULL
)
{
dTrace
(
"acquire snode, refCount:%d"
,
refCount
);
}
return
pSnode
;
}
static
void
dndReleaseSnode
(
SDnode
*
pDnode
,
SSnode
*
pSnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pSnode
!=
NULL
)
{
refCount
=
atomic_sub_fetch_32
(
&
pMgmt
->
refCount
,
1
);
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
pSnode
!=
NULL
)
{
dTrace
(
"release snode, refCount:%d"
,
refCount
);
}
}
static
int32_t
dndReadSnodeFile
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
int32_t
code
=
TSDB_CODE_DND_SNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/snode.json"
,
pDnode
->
dir
.
dnode
);
FILE
*
fp
=
fopen
(
file
,
"r"
);
if
(
fp
==
NULL
)
{
dDebug
(
"file %s not exist"
,
file
);
code
=
0
;
goto
PRASE_SNODE_OVER
;
}
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
dError
(
"failed to read %s since content is null"
,
file
);
goto
PRASE_SNODE_OVER
;
}
content
[
len
]
=
0
;
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
dError
(
"failed to read %s since invalid json format"
,
file
);
goto
PRASE_SNODE_OVER
;
}
cJSON
*
deployed
=
cJSON_GetObjectItem
(
root
,
"deployed"
);
if
(
!
deployed
||
deployed
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since deployed not found"
,
file
);
goto
PRASE_SNODE_OVER
;
}
pMgmt
->
deployed
=
deployed
->
valueint
;
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
if
(
!
dropped
||
dropped
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since dropped not found"
,
file
);
goto
PRASE_SNODE_OVER
;
}
pMgmt
->
dropped
=
dropped
->
valueint
;
code
=
0
;
dDebug
(
"succcessed to read file %s, deployed:%d dropped:%d"
,
file
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
PRASE_SNODE_OVER:
if
(
content
!=
NULL
)
free
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
fp
!=
NULL
)
fclose
(
fp
);
terrno
=
code
;
return
code
;
}
static
int32_t
dndWriteSnodeFile
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
char
file
[
PATH_MAX
+
20
];
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/snode.json"
,
pDnode
->
dir
.
dnode
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
if
(
fp
==
NULL
)
{
terrno
=
TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR
;
dError
(
"failed to write %s since %s"
,
file
,
terrstr
());
return
-
1
;
}
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d,
\n
"
,
pMgmt
->
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dropped
\"
: %d
\n
"
,
pMgmt
->
dropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
fwrite
(
content
,
1
,
len
,
fp
);
taosFsyncFile
(
fileno
(
fp
));
fclose
(
fp
);
free
(
content
);
char
realfile
[
PATH_MAX
+
20
];
snprintf
(
realfile
,
PATH_MAX
+
20
,
"%s/snode.json"
,
pDnode
->
dir
.
dnode
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
terrno
=
TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR
;
dError
(
"failed to rename %s since %s"
,
file
,
terrstr
());
return
-
1
;
}
dInfo
(
"successed to write %s, deployed:%d dropped:%d"
,
realfile
,
pMgmt
->
deployed
,
pMgmt
->
dropped
);
return
0
;
}
static
int32_t
dndStartSnodeWorker
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
writeWorker
,
DND_WORKER_SINGLE
,
"snode-write"
,
0
,
1
,
dndProcessSnodeQueue
)
!=
0
)
{
dError
(
"failed to start snode write worker since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
void
dndStopSnodeWorker
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
taosMsleep
(
10
);
}
dndCleanupWorker
(
&
pMgmt
->
writeWorker
);
}
static
void
dndBuildSnodeOption
(
SDnode
*
pDnode
,
SSnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
sendMsgToDnodeFp
=
dndSendMsgToDnode
;
pOption
->
sendMsgToMnodeFp
=
dndSendMsgToMnode
;
pOption
->
sendRedirectMsgFp
=
dndSendRedirectMsg
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
}
static
int32_t
dndOpenSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SSnodeOpt
option
=
{
0
};
dndBuildSnodeOption
(
pDnode
,
&
option
);
SSnode
*
pSnode
=
sndOpen
(
pDnode
->
dir
.
snode
,
&
option
);
if
(
pSnode
==
NULL
)
{
dError
(
"failed to open snode since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndStartSnodeWorker
(
pDnode
)
!=
0
)
{
dError
(
"failed to start snode worker since %s"
,
terrstr
());
sndClose
(
pSnode
);
return
-
1
;
}
pMgmt
->
deployed
=
1
;
if
(
dndWriteSnodeFile
(
pDnode
)
!=
0
)
{
pMgmt
->
deployed
=
0
;
dError
(
"failed to write snode file since %s"
,
terrstr
());
dndStopSnodeWorker
(
pDnode
);
sndClose
(
pSnode
);
return
-
1
;
}
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
pSnode
=
pSnode
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"snode open successfully"
);
return
0
;
}
static
int32_t
dndDropSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SSnode
*
pSnode
=
dndAcquireSnode
(
pDnode
);
if
(
pSnode
==
NULL
)
{
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
taosRLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dropped
=
1
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
if
(
dndWriteSnodeFile
(
pDnode
)
!=
0
)
{
taosRLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dropped
=
0
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
dndReleaseSnode
(
pDnode
,
pSnode
);
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
dndReleaseSnode
(
pDnode
,
pSnode
);
dndStopSnodeWorker
(
pDnode
);
pMgmt
->
deployed
=
0
;
dndWriteSnodeFile
(
pDnode
);
sndClose
(
pSnode
);
pMgmt
->
pSnode
=
NULL
;
sndDestroy
(
pDnode
->
dir
.
snode
);
return
0
;
}
int32_t
dndProcessCreateSnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SCreateSnodeInMsg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
return
-
1
;
}
else
{
return
dndOpenSnode
(
pDnode
);
}
}
int32_t
dndProcessDropSnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDropSnodeInMsg
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
return
-
1
;
}
else
{
return
dndDropSnode
(
pDnode
);
}
}
static
void
dndProcessSnodeQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SRpcMsg
*
pRsp
=
NULL
;
int32_t
code
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
SSnode
*
pSnode
=
dndAcquireSnode
(
pDnode
);
if
(
pSnode
!=
NULL
)
{
code
=
sndProcessMsg
(
pSnode
,
pMsg
,
&
pRsp
);
}
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
rpcSendResponse
(
pRsp
);
free
(
pRsp
);
}
else
{
if
(
code
!=
0
)
code
=
terrno
;
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
handle
,
.
ahandle
=
pMsg
->
ahandle
,
.
code
=
code
};
rpcSendResponse
(
&
rpcRsp
);
}
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
dndWriteSnodeMsgToWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
SSnode
*
pSnode
=
dndAcquireSnode
(
pDnode
);
if
(
pSnode
!=
NULL
)
{
code
=
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
sizeof
(
SRpcMsg
));
}
dndReleaseSnode
(
pDnode
,
pSnode
);
if
(
code
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
ahandle
=
pMsg
->
ahandle
,
.
code
=
code
};
rpcSendResponse
(
&
rsp
);
}
rpcFreeCont
(
pMsg
->
pCont
);
}
}
void
dndProcessSnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
dndWriteSnodeMsgToWorker
(
pDnode
,
&
pDnode
->
smgmt
.
writeWorker
,
pMsg
);
}
int32_t
dndInitSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
taosInitRWLatch
(
&
pMgmt
->
latch
);
if
(
dndReadSnodeFile
(
pDnode
)
!=
0
)
{
return
-
1
;
}
if
(
pMgmt
->
dropped
)
{
dInfo
(
"snode has been deployed and needs to be deleted"
);
sndDestroy
(
pDnode
->
dir
.
snode
);
return
0
;
}
if
(
!
pMgmt
->
deployed
)
return
0
;
return
dndOpenSnode
(
pDnode
);
}
void
dndCleanupSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
if
(
pMgmt
->
pSnode
)
{
dndStopSnodeWorker
(
pDnode
);
sndClose
(
pMgmt
->
pSnode
);
pMgmt
->
pSnode
=
NULL
;
}
}
source/dnode/mgmt/impl/src/dndWorker.c
浏览文件 @
f3067eb2
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndWorker.h"
#include "dndWorker.h"
int32_t
dndInitWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
E
Dnd
WorkerType
type
,
const
char
*
name
,
int32_t
minNum
,
int32_t
dndInitWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
EWorkerType
type
,
const
char
*
name
,
int32_t
minNum
,
int32_t
maxNum
,
FProcessItem
f
p
)
{
int32_t
maxNum
,
void
*
queueF
p
)
{
if
(
pDnode
==
NULL
||
pWorker
==
NULL
||
name
==
NULL
||
minNum
<
0
||
maxNum
<=
0
||
f
p
==
NULL
)
{
if
(
pDnode
==
NULL
||
pWorker
==
NULL
||
name
==
NULL
||
minNum
<
0
||
maxNum
<=
0
||
queueF
p
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
return
-
1
;
}
}
...
@@ -27,19 +27,32 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type
...
@@ -27,19 +27,32 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type
pWorker
->
name
=
name
;
pWorker
->
name
=
name
;
pWorker
->
minNum
=
minNum
;
pWorker
->
minNum
=
minNum
;
pWorker
->
maxNum
=
maxNum
;
pWorker
->
maxNum
=
maxNum
;
pWorker
->
fp
=
f
p
;
pWorker
->
queueFp
=
queueF
p
;
pWorker
->
pDnode
=
pDnode
;
pWorker
->
pDnode
=
pDnode
;
if
(
pWorker
->
type
==
DND_WORKER_SINGLE
)
{
if
(
pWorker
->
type
==
DND_WORKER_SINGLE
)
{
SWorkerPool
*
pPool
=
&
pWorker
->
pool
;
SWorkerPool
*
pPool
=
&
pWorker
->
pool
;
pPool
->
name
=
name
;
pPool
->
min
=
minNum
;
pPool
->
min
=
minNum
;
pPool
->
max
=
maxNum
;
pPool
->
max
=
maxNum
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
pWorker
->
queue
=
tWorkerAllocQueue
(
pPool
,
pDnode
,
(
FProcessItem
)
queueFp
);
pWorker
->
queue
=
tWorkerAllocQueue
(
&
pPool
,
pDnode
,
fp
);
if
(
pWorker
->
queue
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
else
if
(
pWorker
->
type
==
DND_WORKER_MULTI
)
{
SMWorkerPool
*
pPool
=
&
pWorker
->
mpool
;
pPool
->
name
=
name
;
pPool
->
max
=
maxNum
;
if
(
tMWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pWorker
->
queue
=
tMWorkerAllocQueue
(
pPool
,
pDnode
,
(
FProcessItems
)
queueFp
);
if
(
pWorker
->
queue
==
NULL
)
{
if
(
pWorker
->
queue
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -52,12 +65,17 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type
...
@@ -52,12 +65,17 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type
}
}
void
dndCleanupWorker
(
SDnodeWorker
*
pWorker
)
{
void
dndCleanupWorker
(
SDnodeWorker
*
pWorker
)
{
while
(
!
taosQueueEmpty
(
pWorker
->
queue
))
{
taosMsleep
(
10
);
}
if
(
pWorker
->
type
==
DND_WORKER_SINGLE
)
{
if
(
pWorker
->
type
==
DND_WORKER_SINGLE
)
{
while
(
!
taosQueueEmpty
(
pWorker
->
queue
))
{
taosMsleep
(
10
);
}
tWorkerCleanup
(
&
pWorker
->
pool
);
tWorkerCleanup
(
&
pWorker
->
pool
);
tWorkerFreeQueue
(
&
pWorker
->
pool
,
pWorker
->
queue
);
tWorkerFreeQueue
(
&
pWorker
->
pool
,
pWorker
->
queue
);
}
else
if
(
pWorker
->
type
==
DND_WORKER_MULTI
)
{
tMWorkerCleanup
(
&
pWorker
->
mpool
);
tMWorkerFreeQueue
(
&
pWorker
->
mpool
,
pWorker
->
queue
);
}
else
{
}
}
}
}
...
@@ -67,16 +85,23 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
...
@@ -67,16 +85,23 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
return
-
1
;
return
-
1
;
}
}
void
*
pMsg
=
taosAllocateQitem
(
contLen
);
void
*
pMsg
=
NULL
;
if
(
contLen
!=
0
)
{
pMsg
=
taosAllocateQitem
(
contLen
);
if
(
pMsg
!=
NULL
)
{
memcpy
(
pMsg
,
pCont
,
contLen
);
}
}
else
{
pMsg
=
pCont
;
}
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
pMsg
,
pCont
,
contLen
);
if
(
taosWriteQitem
(
pWorker
->
queue
,
pMsg
)
!=
0
)
{
taosFreeQitem
(
pMsg
);
if
(
taosWriteQitem
(
pWorker
,
pMsg
)
!=
0
)
{
taosFreeItem
(
pMsg
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
f3067eb2
...
@@ -162,7 +162,7 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -162,7 +162,7 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
904
);
pReq
->
port
=
htonl
(
904
4
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
...
source/dnode/mgmt/impl/test/stb/stb.cpp
浏览文件 @
f3067eb2
...
@@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
0
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
0
];
pSchema
->
colId
=
htonl
(
0
);
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pSchema
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
->
name
,
"ts"
);
strcpy
(
pSchema
->
name
,
"ts"
);
...
@@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
1
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
1
];
pSchema
->
colId
=
htonl
(
1
);
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
type
=
TSDB_DATA_TYPE_INT
;
pSchema
->
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
->
name
,
"col1"
);
strcpy
(
pSchema
->
name
,
"col1"
);
...
@@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
2
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
2
];
pSchema
->
colId
=
htonl
(
2
);
pSchema
->
bytes
=
htonl
(
2
);
pSchema
->
bytes
=
htonl
(
2
);
pSchema
->
type
=
TSDB_DATA_TYPE_TINYINT
;
pSchema
->
type
=
TSDB_DATA_TYPE_TINYINT
;
strcpy
(
pSchema
->
name
,
"tag1"
);
strcpy
(
pSchema
->
name
,
"tag1"
);
...
@@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
3
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
3
];
pSchema
->
colId
=
htonl
(
3
);
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_BIGINT
;
pSchema
->
type
=
TSDB_DATA_TYPE_BIGINT
;
strcpy
(
pSchema
->
name
,
"tag2"
);
strcpy
(
pSchema
->
name
,
"tag2"
);
...
@@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
4
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
4
];
pSchema
->
colId
=
htonl
(
4
);
pSchema
->
bytes
=
htonl
(
16
);
pSchema
->
bytes
=
htonl
(
16
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
"tag3"
);
strcpy
(
pSchema
->
name
,
"tag3"
);
...
@@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
{
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
0
];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
0
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
colId
,
1
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_STREQ
(
pSchema
->
name
,
"ts"
);
EXPECT_STREQ
(
pSchema
->
name
,
"ts"
);
}
}
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
1
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
EXPECT_EQ
(
pSchema
->
colId
,
2
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"col1"
);
}
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
2
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TINYINT
);
EXPECT_EQ
(
pSchema
->
colId
,
3
);
EXPECT_EQ
(
pSchema
->
bytes
,
2
);
EXPECT_STREQ
(
pSchema
->
name
,
"tag1"
);
}
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
3
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BIGINT
);
EXPECT_EQ
(
pSchema
->
colId
,
4
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_STREQ
(
pSchema
->
name
,
"tag2"
);
}
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
4
];
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
colId
,
5
);
EXPECT_EQ
(
pSchema
->
bytes
,
16
);
EXPECT_STREQ
(
pSchema
->
name
,
"tag3"
);
}
}
}
// restart
// restart
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
f3067eb2
...
@@ -124,12 +124,8 @@ typedef struct {
...
@@ -124,12 +124,8 @@ typedef struct {
int64_t
rebootTime
;
int64_t
rebootTime
;
int64_t
lastAccessTime
;
int64_t
lastAccessTime
;
int32_t
accessTimes
;
int32_t
accessTimes
;
int16_t
numOfMnodes
;
int16_t
numOfVnodes
;
int16_t
numOfVnodes
;
int16_t
numOfQnodes
;
int16_t
numOfSupportMnodes
;
int16_t
numOfSupportVnodes
;
int16_t
numOfSupportVnodes
;
int16_t
numOfSupportQnodes
;
int16_t
numOfCores
;
int16_t
numOfCores
;
EDndStatus
status
;
EDndStatus
status
;
EDndReason
offlineReason
;
EDndReason
offlineReason
;
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
f3067eb2
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "mndDef.h"
#include "mndDef.h"
#include "sdb.h"
#include "sdb.h"
#include "tcache.h"
#include "tcache.h"
#include "tep.h"
#include "tqueue.h"
#include "tqueue.h"
#include "ttime.h"
#include "ttime.h"
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
f3067eb2
...
@@ -29,6 +29,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup);
...
@@ -29,6 +29,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup);
SSdbRaw
*
mndVgroupActionEncode
(
SVgObj
*
pVgroup
);
SSdbRaw
*
mndVgroupActionEncode
(
SVgObj
*
pVgroup
);
int32_t
mndAllocVgroup
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SVgObj
**
ppVgroups
);
int32_t
mndAllocVgroup
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SVgObj
**
ppVgroups
);
SEpSet
mndGetVgroupEpset
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
);
SEpSet
mndGetVgroupEpset
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
);
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
SCreateVnodeMsg
*
mndBuildCreateVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
SCreateVnodeMsg
*
mndBuildCreateVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
SDropVnodeMsg
*
mndBuildDropVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
SDropVnodeMsg
*
mndBuildDropVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
f3067eb2
...
@@ -18,8 +18,7 @@
...
@@ -18,8 +18,7 @@
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "tep.h"
#include "mndVgroup.h"
#include "ttime.h"
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_RESERVE_SIZE 64
#define TSDB_DNODE_RESERVE_SIZE 64
...
@@ -370,7 +369,6 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
...
@@ -370,7 +369,6 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
}
}
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
dropped
=
0
;
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
...
@@ -388,7 +386,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
...
@@ -388,7 +386,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
dnodeObj
.
updateTime
=
dnodeObj
.
createdTime
;
dnodeObj
.
updateTime
=
dnodeObj
.
createdTime
;
dnodeObj
.
port
=
pCreate
->
port
;
dnodeObj
.
port
=
pCreate
->
port
;
memcpy
(
dnodeObj
.
fqdn
,
pCreate
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
dnodeObj
.
fqdn
,
pCreate
->
fqdn
,
TSDB_FQDN_LEN
);
snprintf
(
dnodeObj
.
ep
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
...
@@ -700,7 +698,7 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
...
@@ -700,7 +698,7 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pDnode
->
numOfVnodes
;
*
(
int16_t
*
)
pWrite
=
mndGetVnodesNum
(
pMnode
,
pDnode
->
id
)
;
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
f3067eb2
...
@@ -118,17 +118,17 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
...
@@ -118,17 +118,17 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
SConnObj
*
pConn
=
taosCachePut
(
pMgmt
->
cache
,
&
connId
,
sizeof
(
int32_t
),
&
connObj
,
sizeof
(
connObj
),
keepTime
*
1000
);
SConnObj
*
pConn
=
taosCachePut
(
pMgmt
->
cache
,
&
connId
,
sizeof
(
int32_t
),
&
connObj
,
sizeof
(
connObj
),
keepTime
*
1000
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"conn:%d,
data:%p failed to put into cache since %s, user:%s"
,
connId
,
pConn
,
pInfo
->
user
,
terrstr
());
mError
(
"conn:%d,
failed to put into cache since %s, user:%s"
,
connId
,
pInfo
->
user
,
terrstr
());
return
NULL
;
return
NULL
;
}
else
{
}
else
{
mTrace
(
"conn:%d,
data:%p created,
user:%s"
,
pConn
->
id
,
pConn
,
pInfo
->
user
);
mTrace
(
"conn:%d,
is created, data:%p
user:%s"
,
pConn
->
id
,
pConn
,
pInfo
->
user
);
return
pConn
;
return
pConn
;
}
}
}
}
static
void
mndFreeConn
(
SConnObj
*
pConn
)
{
static
void
mndFreeConn
(
SConnObj
*
pConn
)
{
tfree
(
pConn
->
pQueries
);
tfree
(
pConn
->
pQueries
);
mTrace
(
"conn:%d,
data:%p destroyed
"
,
pConn
->
id
,
pConn
);
mTrace
(
"conn:%d,
is destroyed, data:%p
"
,
pConn
->
id
,
pConn
);
}
}
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
int32_t
connId
)
{
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
int32_t
connId
)
{
...
@@ -143,13 +143,13 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) {
...
@@ -143,13 +143,13 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) {
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
3
;
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
3
;
pConn
->
lastAccessTimeMs
=
keepTime
*
1000
+
(
uint64_t
)
taosGetTimestampMs
();
pConn
->
lastAccessTimeMs
=
keepTime
*
1000
+
(
uint64_t
)
taosGetTimestampMs
();
mTrace
(
"conn:%d,
data:%p acquired from cache
"
,
pConn
->
id
,
pConn
);
mTrace
(
"conn:%d,
acquired from cache, data:%p
"
,
pConn
->
id
,
pConn
);
return
pConn
;
return
pConn
;
}
}
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
)
{
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
)
{
if
(
pConn
==
NULL
)
return
;
if
(
pConn
==
NULL
)
return
;
mTrace
(
"conn:%d,
data:%p released from cache
"
,
pConn
->
id
,
pConn
);
mTrace
(
"conn:%d,
released from cache, data:%p
"
,
pConn
->
id
,
pConn
);
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
f3067eb2
...
@@ -55,32 +55,25 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) {
...
@@ -55,32 +55,25 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) {
int32_t
showId
=
atomic_add_fetch_32
(
&
pMgmt
->
showId
,
1
);
int32_t
showId
=
atomic_add_fetch_32
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_32
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_32
(
&
pMgmt
->
showId
,
1
);
int32_t
size
=
sizeof
(
SShowObj
)
+
pMsg
->
payloadLen
;
int32_t
size
=
sizeof
(
SShowObj
)
+
pMsg
->
payloadLen
;
SShowObj
*
pShow
=
calloc
(
1
,
size
);
SShowObj
showObj
=
{
0
};
if
(
pShow
!=
NULL
)
{
showObj
.
id
=
showId
;
pShow
->
id
=
showId
;
showObj
.
pMnode
=
pMnode
;
pShow
->
pMnode
=
pMnode
;
showObj
.
type
=
pMsg
->
type
;
pShow
->
type
=
pMsg
->
type
;
showObj
.
payloadLen
=
pMsg
->
payloadLen
;
pShow
->
payloadLen
=
pMsg
->
payloadLen
;
memcpy
(
showObj
.
db
,
pMsg
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
pShow
->
db
,
pMsg
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
payload
,
pMsg
->
payload
,
pMsg
->
payloadLen
);
memcpy
(
pShow
->
payload
,
pMsg
->
payload
,
pMsg
->
payloadLen
);
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"failed to process show-meta msg:%s since %s"
,
mndShowStr
(
pMsg
->
type
),
terrstr
());
return
NULL
;
}
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
6
*
1000
;
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
6
*
1000
;
SShowObj
*
pShowRet
=
taosCachePut
(
pMgmt
->
cache
,
&
showId
,
sizeof
(
int32_t
),
pShow
,
size
,
keepTime
);
SShowObj
*
pShow
=
taosCachePut
(
pMgmt
->
cache
,
&
showId
,
sizeof
(
int32_t
),
&
showObj
,
size
,
keepTime
);
free
(
pShow
);
if
(
pShow
==
NULL
)
{
if
(
pShowRet
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:%d, failed to put into cache since %s"
,
showId
,
terrstr
());
mError
(
"show:%d, failed to put into cache since %s"
,
showId
,
terrstr
());
return
NULL
;
return
NULL
;
}
else
{
mTrace
(
"show:%d, data:%p created"
,
showId
,
pShowRet
);
return
pShowRet
;
}
}
mTrace
(
"show:%d, is created, data:%p"
,
showId
,
pShow
);
return
pShow
;
}
}
static
void
mndFreeShowObj
(
SShowObj
*
pShow
)
{
static
void
mndFreeShowObj
(
SShowObj
*
pShow
)
{
...
@@ -94,7 +87,7 @@ static void mndFreeShowObj(SShowObj *pShow) {
...
@@ -94,7 +87,7 @@ static void mndFreeShowObj(SShowObj *pShow) {
}
}
}
}
mTrace
(
"show:%d,
data:%p destroyed
"
,
pShow
->
id
,
pShow
);
mTrace
(
"show:%d,
is destroyed, data:%p
"
,
pShow
->
id
,
pShow
);
}
}
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
)
{
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
)
{
...
@@ -106,14 +99,14 @@ static SShowObj *mndAcquireShowObj(SMnode *pMnode, int32_t showId) {
...
@@ -106,14 +99,14 @@ static SShowObj *mndAcquireShowObj(SMnode *pMnode, int32_t showId) {
return
NULL
;
return
NULL
;
}
}
mTrace
(
"show:%d,
data:%p acquired from cache
"
,
pShow
->
id
,
pShow
);
mTrace
(
"show:%d,
acquired from cache, data:%p
"
,
pShow
->
id
,
pShow
);
return
pShow
;
return
pShow
;
}
}
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
)
{
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
)
{
if
(
pShow
==
NULL
)
return
;
if
(
pShow
==
NULL
)
return
;
mTrace
(
"show:%d,
data:%p released from cache,
force:%d"
,
pShow
->
id
,
pShow
,
forceRemove
);
mTrace
(
"show:%d,
released from cache, data:%p
force:%d"
,
pShow
->
id
,
pShow
,
forceRemove
);
// A bug in tcache.c
// A bug in tcache.c
forceRemove
=
0
;
forceRemove
=
0
;
...
@@ -158,8 +151,8 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -158,8 +151,8 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
}
}
int32_t
code
=
(
*
metaFp
)(
pMnodeMsg
,
pShow
,
&
pRsp
->
tableMeta
);
int32_t
code
=
(
*
metaFp
)(
pMnodeMsg
,
pShow
,
&
pRsp
->
tableMeta
);
mDebug
(
"show:%d,
data:%p get meta finished, numOfRows:%d cols:%d type:%s result:%s"
,
pShow
->
id
,
pShow
,
mDebug
(
"show:%d,
get meta finished, numOfRows:%d cols:%d type:%s result:%s"
,
pShow
->
id
,
pShow
->
numOfRows
,
pShow
->
numOf
Rows
,
pShow
->
numOf
Columns
,
mndShowStr
(
type
),
tstrerror
(
code
));
pShow
->
numOfColumns
,
mndShowStr
(
type
),
tstrerror
(
code
));
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pMnodeMsg
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
pMnodeMsg
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
...
@@ -195,16 +188,15 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -195,16 +188,15 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
if
(
retrieveFp
==
NULL
)
{
if
(
retrieveFp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"show:%d,
data:%p failed to retrieve data since %s"
,
pShow
->
id
,
pShow
,
terrstr
());
mError
(
"show:%d,
failed to retrieve data since %s"
,
pShow
->
id
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
mDebug
(
"show:%d,
data:%p start retrieve data, numOfReads:%d numOfRows:%d type:%s"
,
pShow
->
id
,
pShow
,
mDebug
(
"show:%d,
start retrieve data, numOfReads:%d numOfRows:%d type:%s"
,
pShow
->
id
,
pShow
->
numOfReads
,
pShow
->
numOfR
eads
,
pShow
->
numOfR
ows
,
mndShowStr
(
pShow
->
type
));
pShow
->
numOfRows
,
mndShowStr
(
pShow
->
type
));
if
(
mndCheckRetrieveFinished
(
pShow
))
{
if
(
mndCheckRetrieveFinished
(
pShow
))
{
mDebug
(
"show:%d, data:%p read finished, numOfReads:%d numOfRows:%d"
,
pShow
->
id
,
pShow
,
pShow
->
numOfReads
,
mDebug
(
"show:%d, read finished, numOfReads:%d numOfRows:%d"
,
pShow
->
id
,
pShow
->
numOfReads
,
pShow
->
numOfRows
);
pShow
->
numOfRows
);
pShow
->
numOfReads
=
pShow
->
numOfRows
;
pShow
->
numOfReads
=
pShow
->
numOfRows
;
}
}
...
@@ -227,7 +219,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -227,7 +219,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:%d,
data:%p failed to retrieve data since %s"
,
pShow
->
id
,
pShow
,
terrstr
());
mError
(
"show:%d,
failed to retrieve data since %s"
,
pShow
->
id
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -236,7 +228,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -236,7 +228,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
rowsRead
=
(
*
retrieveFp
)(
pMnodeMsg
,
pShow
,
pRsp
->
data
,
rowsToRead
);
rowsRead
=
(
*
retrieveFp
)(
pMnodeMsg
,
pShow
,
pRsp
->
data
,
rowsToRead
);
}
}
mDebug
(
"show:%d,
data:%p stop retrieve data, rowsRead:%d rowsToRead:%d"
,
pShow
->
id
,
pShow
,
rowsRead
,
rowsToRead
);
mDebug
(
"show:%d,
stop retrieve data, rowsRead:%d rowsToRead:%d"
,
pShow
->
id
,
rowsRead
,
rowsToRead
);
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
...
@@ -246,10 +238,10 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -246,10 +238,10 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
if
(
rowsRead
==
0
||
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
&&
pShow
->
numOfRows
==
pShow
->
numOfReads
))
{
if
(
rowsRead
==
0
||
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
&&
pShow
->
numOfRows
==
pShow
->
numOfReads
))
{
pRsp
->
completed
=
1
;
pRsp
->
completed
=
1
;
mDebug
(
"show:%d,
data:%p retrieve completed"
,
pShow
->
id
,
pShow
);
mDebug
(
"show:%d,
retrieve completed"
,
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
true
);
mndReleaseShowObj
(
pShow
,
true
);
}
else
{
}
else
{
mDebug
(
"show:%d,
data:%p retrieve not completed yet"
,
pShow
->
id
,
pShow
);
mDebug
(
"show:%d,
retrieve not completed yet"
,
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
f3067eb2
...
@@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
...
@@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
int32_t
totalCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
totalCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pCreate
->
pSchema
[
i
];
SSchema
*
pSchema
=
&
pCreate
->
pSchema
[
i
];
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
}
}
...
@@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
...
@@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) {
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
if
(
pSchema
->
colId
<
0
||
pSchema
->
colId
>=
maxColId
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
if
(
pSchema
->
bytes
<=
0
)
{
if
(
pSchema
->
bytes
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
...
@@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
...
@@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
}
}
memcpy
(
stbObj
.
pSchema
,
pCreate
->
pSchema
,
totalSize
);
memcpy
(
stbObj
.
pSchema
,
pCreate
->
pSchema
,
totalSize
);
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
stbObj
.
pSchema
[
i
].
colId
=
i
+
1
;
}
int32_t
code
=
0
;
int32_t
code
=
0
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
...
@@ -767,7 +766,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
...
@@ -767,7 +766,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
memcpy
(
pMeta
->
s
tbFname
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
pMeta
->
tbFname
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
pMeta
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pMeta
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pMeta
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pMeta
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
f3067eb2
...
@@ -294,18 +294,18 @@ TRANS_DECODE_OVER:
...
@@ -294,18 +294,18 @@ TRANS_DECODE_OVER:
return
NULL
;
return
NULL
;
}
}
mTrace
(
"trans:%d, decode from raw:%p
"
,
pTrans
->
id
,
pRaw
);
mTrace
(
"trans:%d, decode from raw:%p
, data:%p"
,
pTrans
->
id
,
pRaw
,
pTrans
);
return
pRow
;
return
pRow
;
}
}
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
mTrace
(
"trans:%d, perform insert action
"
,
pTrans
->
id
);
mTrace
(
"trans:%d, perform insert action
, data:%p"
,
pTrans
->
id
,
pTrans
);
return
0
;
return
0
;
}
}
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
mTrace
(
"trans:%d, perform delete action
"
,
pTrans
->
id
);
mTrace
(
"trans:%d, perform delete action
, data:%p"
,
pTrans
->
id
,
pTrans
);
mndTransDropLogs
(
pTrans
->
redoLogs
);
mndTransDropLogs
(
pTrans
->
redoLogs
);
mndTransDropLogs
(
pTrans
->
undoLogs
);
mndTransDropLogs
(
pTrans
->
undoLogs
);
...
@@ -317,7 +317,7 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) {
...
@@ -317,7 +317,7 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) {
}
}
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pOldTrans
,
STrans
*
pNewTrans
)
{
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pOldTrans
,
STrans
*
pNewTrans
)
{
mTrace
(
"trans:%d, perform update action
"
,
pOldTrans
->
id
);
mTrace
(
"trans:%d, perform update action
, data:%p"
,
pOldTrans
->
id
,
pOldTrans
);
pOldTrans
->
stage
=
pNewTrans
->
stage
;
pOldTrans
->
stage
=
pNewTrans
->
stage
;
return
0
;
return
0
;
}
}
...
@@ -362,14 +362,14 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, SRpcMsg *pMsg) {
...
@@ -362,14 +362,14 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, SRpcMsg *pMsg) {
return
NULL
;
return
NULL
;
}
}
mDebug
(
"trans:%d, is created
"
,
pTrans
->
id
);
mDebug
(
"trans:%d, is created
, data:%p"
,
pTrans
->
id
,
pTrans
);
return
pTrans
;
return
pTrans
;
}
}
static
void
mndTransDropLogs
(
SArray
*
pArray
)
{
static
void
mndTransDropLogs
(
SArray
*
pArray
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
tfree
(
pRaw
);
sdbFreeRaw
(
pRaw
);
}
}
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
...
@@ -391,7 +391,7 @@ void mndTransDrop(STrans *pTrans) {
...
@@ -391,7 +391,7 @@ void mndTransDrop(STrans *pTrans) {
mndTransDropActions
(
pTrans
->
redoActions
);
mndTransDropActions
(
pTrans
->
redoActions
);
mndTransDropActions
(
pTrans
->
undoActions
);
mndTransDropActions
(
pTrans
->
undoActions
);
//
mDebug("trans:%d, is dropped, data:%p", pTrans->id, pTrans);
mDebug
(
"trans:%d, is dropped, data:%p"
,
pTrans
->
id
,
pTrans
);
tfree
(
pTrans
);
tfree
(
pTrans
);
}
}
...
@@ -442,7 +442,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
...
@@ -442,7 +442,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
}
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
m
Trace
(
"trans:%d, sync to other nodes"
,
pTrans
->
id
);
m
Debug
(
"trans:%d, sync to other nodes"
,
pTrans
->
id
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to sync since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to sync since %s"
,
pTrans
->
id
,
terrstr
());
...
@@ -450,7 +450,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
...
@@ -450,7 +450,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
return
-
1
;
return
-
1
;
}
}
m
Trace
(
"trans:%d, sync finished"
,
pTrans
->
id
);
m
Debug
(
"trans:%d, sync finished"
,
pTrans
->
id
);
code
=
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
code
=
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
f3067eb2
...
@@ -86,7 +86,6 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup) {
...
@@ -86,7 +86,6 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup) {
for
(
int8_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SDB_SET_INT32
(
pRaw
,
dataPos
,
pVgid
->
dnodeId
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pVgid
->
dnodeId
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pVgid
->
role
)
}
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_VGROUP_RESERVE_SIZE
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_VGROUP_RESERVE_SIZE
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
...
@@ -121,7 +120,6 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
...
@@ -121,7 +120,6 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
for
(
int8_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pVgid
->
dnodeId
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pVgid
->
dnodeId
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
(
int8_t
*
)
&
pVgid
->
role
)
}
}
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB_VGROUP_RESERVE_SIZE
)
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB_VGROUP_RESERVE_SIZE
)
...
@@ -237,44 +235,95 @@ SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *p
...
@@ -237,44 +235,95 @@ SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *p
return
pDrop
;
return
pDrop
;
}
}
static
int32_t
mndGetAvailableDnode
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
)
{
static
SArray
*
mndBuildDnodesArray
(
SMnode
*
pMnode
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
allocedVnodes
=
0
;
int32_t
numOfDnodes
=
mndGetDnodeSize
(
pMnode
);
void
*
pIter
=
NULL
;
SArray
*
pArray
=
taosArrayInit
(
numOfDnodes
,
sizeof
(
SDnodeObj
));
if
(
pArray
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
while
(
allocedVnodes
<
pVgroup
->
replica
)
{
void
*
pIter
=
NULL
;
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
// todo
int32_t
numOfVnodes
=
mndGetVnodesNum
(
pMnode
,
pDnode
->
id
);
if
(
mndIsDnodeInReadyStatus
(
pMnode
,
pDnode
))
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
allocedVnodes
]
;
bool
isMnode
=
mndIsMnode
(
pMnode
,
pDnode
->
id
)
;
pVgid
->
dnodeId
=
pDnode
->
id
;
if
(
isMnode
)
{
if
(
pVgroup
->
replica
==
1
)
{
pDnode
->
numOfVnodes
++
;
pVgid
->
role
=
TAOS_SYNC_STATE_LEADER
;
}
}
else
{
pVgid
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
bool
isReady
=
mndIsDnodeInReadyStatus
(
pMnode
,
pDnode
)
;
}
if
(
isReady
)
{
allocedVnodes
++
;
taosArrayPush
(
pArray
,
pDnode
)
;
}
}
mDebug
(
"dnode:%d, numOfVnodes:%d numOfSupportVnodes:%d isMnode:%d ready:%d"
,
pDnode
->
id
,
numOfVnodes
,
pDnode
->
numOfSupportVnodes
,
isMnode
,
isReady
);
sdbRelease
(
pSdb
,
pDnode
);
sdbRelease
(
pSdb
,
pDnode
);
}
}
if
(
allocedVnodes
!=
pVgroup
->
replica
)
{
return
pArray
;
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
}
return
-
1
;
static
int32_t
mndCompareDnodeVnodes
(
SDnodeObj
*
pDnode1
,
SDnodeObj
*
pDnode2
)
{
float
d1Score
=
(
float
)
pDnode1
->
numOfVnodes
/
pDnode1
->
numOfSupportVnodes
;
float
d2Score
=
(
float
)
pDnode2
->
numOfVnodes
/
pDnode2
->
numOfSupportVnodes
;
return
d1Score
>
d2Score
?
0
:
1
;
}
static
int32_t
mndGetAvailableDnode
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SArray
*
pArray
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
allocedVnodes
=
0
;
void
*
pIter
=
NULL
;
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
v
];
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
v
);
if
(
pDnode
==
NULL
||
pDnode
->
numOfVnodes
>
pDnode
->
numOfSupportVnodes
)
{
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
return
-
1
;
}
pVgid
->
dnodeId
=
pDnode
->
id
;
if
(
pVgroup
->
replica
==
1
)
{
pVgid
->
role
=
TAOS_SYNC_STATE_LEADER
;
}
else
{
pVgid
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
}
mDebug
(
"db:%s, vgId:%d, vindex:%d dnodeId:%d is alloced"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
,
v
,
pVgid
->
dnodeId
);
pDnode
->
numOfVnodes
++
;
}
}
return
0
;
return
0
;
}
}
int32_t
mndAllocVgroup
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SVgObj
**
ppVgroups
)
{
int32_t
mndAllocVgroup
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SVgObj
**
ppVgroups
)
{
SVgObj
*
pVgroups
=
calloc
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgObj
));
int32_t
code
=
-
1
;
SArray
*
pArray
=
NULL
;
SVgObj
*
pVgroups
=
NULL
;
pVgroups
=
calloc
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgObj
));
if
(
pVgroups
==
NULL
)
{
if
(
pVgroups
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
goto
ALLOC_VGROUP_OVER
;
}
}
pArray
=
mndBuildDnodesArray
(
pMnode
);
if
(
pArray
==
NULL
)
{
goto
ALLOC_VGROUP_OVER
;
}
mDebug
(
"db:%s, total %d dnodes used to create %d vgroups (%d vnodes)"
,
pDb
->
name
,
(
int32_t
)
taosArrayGetSize
(
pArray
),
pDb
->
cfg
.
numOfVgroups
,
pDb
->
cfg
.
numOfVgroups
*
pDb
->
cfg
.
replications
);
int32_t
allocedVgroups
=
0
;
int32_t
allocedVgroups
=
0
;
int32_t
maxVgId
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_VGROUP
);
int32_t
maxVgId
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_VGROUP
);
uint32_t
hashMin
=
0
;
uint32_t
hashMin
=
0
;
...
@@ -298,17 +347,23 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
...
@@ -298,17 +347,23 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
pVgroup
->
dbUid
=
pDb
->
uid
;
pVgroup
->
dbUid
=
pDb
->
uid
;
pVgroup
->
replica
=
pDb
->
cfg
.
replications
;
pVgroup
->
replica
=
pDb
->
cfg
.
replications
;
if
(
mndGetAvailableDnode
(
pMnode
,
pVgroup
)
!=
0
)
{
if
(
mndGetAvailableDnode
(
pMnode
,
pVgroup
,
pArray
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
free
(
pVgroups
);
goto
ALLOC_VGROUP_OVER
;
return
-
1
;
}
}
allocedVgroups
++
;
allocedVgroups
++
;
}
}
*
ppVgroups
=
pVgroups
;
*
ppVgroups
=
pVgroups
;
return
0
;
code
=
0
;
mDebug
(
"db:%s, %d vgroups is alloced, replica:%d"
,
pDb
->
name
,
pDb
->
cfg
.
numOfVgroups
,
pDb
->
cfg
.
replications
);
ALLOC_VGROUP_OVER:
if
(
code
!=
0
)
free
(
pVgroups
);
taosArrayDestroy
(
pArray
);
return
code
;
}
}
SEpSet
mndGetVgroupEpset
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
)
{
SEpSet
mndGetVgroupEpset
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
)
{
...
@@ -348,6 +403,7 @@ static int32_t mndProcessDropVnodeRsp(SMnodeMsg *pMsg) {
...
@@ -348,6 +403,7 @@ static int32_t mndProcessDropVnodeRsp(SMnodeMsg *pMsg) {
}
}
static
int32_t
mndProcessSyncVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessSyncVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessCompactVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessCompactVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndGetVgroupMaxReplica
(
SMnode
*
pMnode
,
char
*
dbName
,
int8_t
*
pReplica
,
int32_t
*
pNumOfVgroups
)
{
static
int32_t
mndGetVgroupMaxReplica
(
SMnode
*
pMnode
,
char
*
dbName
,
int8_t
*
pReplica
,
int32_t
*
pNumOfVgroups
)
{
...
@@ -478,7 +534,7 @@ static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter) {
...
@@ -478,7 +534,7 @@ static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter) {
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
}
}
static
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
)
{
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfVnodes
=
0
;
int32_t
numOfVnodes
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
f3067eb2
...
@@ -146,15 +146,15 @@ static int32_t mndInitSteps(SMnode *pMnode) {
...
@@ -146,15 +146,15 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb"
,
mndInitSdb
,
mndCleanupSdb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb"
,
mndInitSdb
,
mndCleanupSdb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-trans"
,
mndInitTrans
,
mndCleanupTrans
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-trans"
,
mndInitTrans
,
mndCleanupTrans
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-mnode"
,
mndInitMnode
,
mndCleanupMnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-mnode"
,
mndInitMnode
,
mndCleanupMnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stb"
,
mndInitStb
,
mndCleanupStb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stb"
,
mndInitStb
,
mndCleanupStb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-func"
,
mndInitFunc
,
mndCleanupFunc
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-func"
,
mndInitFunc
,
mndCleanupFunc
)
!=
0
)
return
-
1
;
if
(
pMnode
->
clusterId
<=
0
)
{
if
(
pMnode
->
clusterId
<=
0
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb-deploy"
,
mndDeploySdb
,
NULL
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb-deploy"
,
mndDeploySdb
,
NULL
)
!=
0
)
return
-
1
;
...
@@ -390,7 +390,7 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) {
...
@@ -390,7 +390,7 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) {
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
static
void
mndProcessRpc
Msg
(
SMnodeMsg
*
pMsg
)
{
void
mndProcess
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
int32_t
code
=
0
;
int32_t
code
=
0
;
tmsg_t
msgType
=
pMsg
->
rpcMsg
.
msgType
;
tmsg_t
msgType
=
pMsg
->
rpcMsg
.
msgType
;
...
@@ -451,12 +451,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
...
@@ -451,12 +451,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
}
}
}
}
void
mndProcessReadMsg
(
SMnodeMsg
*
pMsg
)
{
mndProcessRpcMsg
(
pMsg
);
}
void
mndProcessWriteMsg
(
SMnodeMsg
*
pMsg
)
{
mndProcessRpcMsg
(
pMsg
);
}
void
mndProcessSyncMsg
(
SMnodeMsg
*
pMsg
)
{
mndProcessRpcMsg
(
pMsg
);
}
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
{
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
{
int64_t
us
=
taosGetTimestampUs
();
int64_t
us
=
taosGetTimestampUs
();
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
...
...
source/dnode/mnode/sdb/inc/sdbInt.h
浏览文件 @
f3067eb2
...
@@ -72,6 +72,7 @@ typedef struct SSdb {
...
@@ -72,6 +72,7 @@ typedef struct SSdb {
}
SSdb
;
}
SSdb
;
int32_t
sdbWriteFile
(
SSdb
*
pSdb
);
int32_t
sdbWriteFile
(
SSdb
*
pSdb
);
void
sdbPrintOper
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
,
const
char
*
oper
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
f3067eb2
...
@@ -80,16 +80,12 @@ void sdbCleanup(SSdb *pSdb) {
...
@@ -80,16 +80,12 @@ void sdbCleanup(SSdb *pSdb) {
SHashObj
*
hash
=
pSdb
->
hashObjs
[
i
];
SHashObj
*
hash
=
pSdb
->
hashObjs
[
i
];
if
(
hash
==
NULL
)
continue
;
if
(
hash
==
NULL
)
continue
;
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
i
];
SSdbRow
**
ppRow
=
taosHashIterate
(
hash
,
NULL
);
SSdbRow
**
ppRow
=
taosHashIterate
(
hash
,
NULL
);
while
(
ppRow
!=
NULL
)
{
while
(
ppRow
!=
NULL
)
{
SSdbRow
*
pRow
=
*
ppRow
;
SSdbRow
*
pRow
=
*
ppRow
;
if
(
pRow
==
NULL
)
continue
;
if
(
pRow
==
NULL
)
continue
;
if
(
deleteFp
!=
NULL
)
{
sdbFreeRow
(
pSdb
,
pRow
);
(
*
deleteFp
)(
pSdb
,
pRow
->
pObj
);
}
sdbFreeRow
(
pRow
);
ppRow
=
taosHashIterate
(
hash
,
ppRow
);
ppRow
=
taosHashIterate
(
hash
,
ppRow
);
}
}
}
}
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
f3067eb2
...
@@ -151,7 +151,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
...
@@ -151,7 +151,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
if
(
taosWriteFile
(
fd
,
pRaw
,
writeLen
)
!=
writeLen
)
{
if
(
taosWriteFile
(
fd
,
pRaw
,
writeLen
)
!=
writeLen
)
{
code
=
TAOS_SYSTEM_ERROR
(
terrno
);
code
=
TAOS_SYSTEM_ERROR
(
terrno
);
taosHashCancelIterate
(
hash
,
ppRow
);
taosHashCancelIterate
(
hash
,
ppRow
);
free
(
pRaw
);
sdbFreeRaw
(
pRaw
);
break
;
break
;
}
}
...
@@ -159,7 +159,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
...
@@ -159,7 +159,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
if
(
taosWriteFile
(
fd
,
&
cksum
,
sizeof
(
int32_t
))
!=
sizeof
(
int32_t
))
{
if
(
taosWriteFile
(
fd
,
&
cksum
,
sizeof
(
int32_t
))
!=
sizeof
(
int32_t
))
{
code
=
TAOS_SYSTEM_ERROR
(
terrno
);
code
=
TAOS_SYSTEM_ERROR
(
terrno
);
taosHashCancelIterate
(
hash
,
ppRow
);
taosHashCancelIterate
(
hash
,
ppRow
);
free
(
pRaw
);
sdbFreeRaw
(
pRaw
);
break
;
break
;
}
}
}
else
{
}
else
{
...
@@ -168,7 +168,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
...
@@ -168,7 +168,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
break
;
break
;
}
}
free
(
pRaw
);
sdbFreeRaw
(
pRaw
);
ppRow
=
taosHashIterate
(
hash
,
ppRow
);
ppRow
=
taosHashIterate
(
hash
,
ppRow
);
}
}
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
f3067eb2
...
@@ -16,6 +16,50 @@
...
@@ -16,6 +16,50 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "sdbInt.h"
#include "sdbInt.h"
static
const
char
*
sdbTableName
(
ESdbType
type
)
{
switch
(
type
)
{
case
SDB_TRANS
:
return
"trans"
;
case
SDB_CLUSTER
:
return
"cluster"
;
case
SDB_MNODE
:
return
"mnode"
;
case
SDB_DNODE
:
return
"dnode"
;
case
SDB_USER
:
return
"user"
;
case
SDB_AUTH
:
return
"auth"
;
case
SDB_ACCT
:
return
"acct"
;
case
SDB_TOPIC
:
return
"topic"
;
case
SDB_VGROUP
:
return
"vgId"
;
case
SDB_STB
:
return
"stb"
;
case
SDB_DB
:
return
"db"
;
case
SDB_FUNC
:
return
"func"
;
default:
return
"undefine"
;
}
}
void
sdbPrintOper
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
,
const
char
*
oper
)
{
EKeyType
keyType
=
pSdb
->
keyTypes
[
pRow
->
type
];
if
(
keyType
==
SDB_KEY_BINARY
)
{
mTrace
(
"%s:%s, refCount:%d oper:%s"
,
sdbTableName
(
pRow
->
type
),
(
char
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
}
else
if
(
keyType
==
SDB_KEY_INT32
)
{
mTrace
(
"%s:%d, refCount:%d oper:%s"
,
sdbTableName
(
pRow
->
type
),
*
(
int32_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
}
else
if
(
keyType
==
SDB_KEY_INT64
)
{
mTrace
(
"%s:%"
PRId64
", refCount:%d oper:%s"
,
sdbTableName
(
pRow
->
type
),
*
(
int64_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
}
else
{
}
}
static
SHashObj
*
sdbGetHash
(
SSdb
*
pSdb
,
int32_t
type
)
{
static
SHashObj
*
sdbGetHash
(
SSdb
*
pSdb
,
int32_t
type
)
{
if
(
type
>=
SDB_MAX
||
type
<=
SDB_START
)
{
if
(
type
>=
SDB_MAX
||
type
<=
SDB_START
)
{
terrno
=
TSDB_CODE_SDB_INVALID_TABLE_TYPE
;
terrno
=
TSDB_CODE_SDB_INVALID_TABLE_TYPE
;
...
@@ -55,17 +99,18 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
...
@@ -55,17 +99,18 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
SSdbRow
*
pOldRow
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
SSdbRow
*
pOldRow
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
pOldRow
!=
NULL
)
{
if
(
pOldRow
!=
NULL
)
{
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
Sdb
,
p
Row
);
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
return
terrno
;
return
terrno
;
}
}
pRow
->
refCount
=
1
;
pRow
->
refCount
=
0
;
pRow
->
status
=
pRaw
->
status
;
pRow
->
status
=
pRaw
->
status
;
sdbPrintOper
(
pSdb
,
pRow
,
"insertRow"
);
if
(
taosHashPut
(
hash
,
pRow
->
pObj
,
keySize
,
&
pRow
,
sizeof
(
void
*
))
!=
0
)
{
if
(
taosHashPut
(
hash
,
pRow
->
pObj
,
keySize
,
&
pRow
,
sizeof
(
void
*
))
!=
0
)
{
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
Sdb
,
p
Row
);
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_ALREADY_THERE
;
return
terrno
;
return
terrno
;
}
}
...
@@ -83,7 +128,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
...
@@ -83,7 +128,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
taosWLockLatch
(
pLock
);
taosWLockLatch
(
pLock
);
taosHashRemove
(
hash
,
pRow
->
pObj
,
keySize
);
taosHashRemove
(
hash
,
pRow
->
pObj
,
keySize
);
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
Sdb
,
p
Row
);
terrno
=
code
;
terrno
=
code
;
return
terrno
;
return
terrno
;
}
}
...
@@ -113,7 +158,7 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
...
@@ -113,7 +158,7 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
code
=
(
*
updateFp
)(
pSdb
,
pOldRow
->
pObj
,
pNewRow
->
pObj
);
code
=
(
*
updateFp
)(
pSdb
,
pOldRow
->
pObj
,
pNewRow
->
pObj
);
}
}
sdbFreeRow
(
pNewRow
);
sdbFreeRow
(
p
Sdb
,
p
NewRow
);
return
code
;
return
code
;
}
}
...
@@ -123,14 +168,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
...
@@ -123,14 +168,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
taosWLockLatch
(
pLock
);
taosWLockLatch
(
pLock
);
// remove attached object such as trans
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
pRow
->
type
];
if
(
deleteFp
!=
NULL
)
(
*
deleteFp
)(
pSdb
,
pRow
->
pObj
);
SSdbRow
**
ppOldRow
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
SSdbRow
**
ppOldRow
=
taosHashGet
(
hash
,
pRow
->
pObj
,
keySize
);
if
(
ppOldRow
==
NULL
||
*
ppOldRow
==
NULL
)
{
if
(
ppOldRow
==
NULL
||
*
ppOldRow
==
NULL
)
{
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
Sdb
,
p
Row
);
terrno
=
TSDB_CODE_SDB_OBJ_NOT_THERE
;
terrno
=
TSDB_CODE_SDB_OBJ_NOT_THERE
;
return
terrno
;
return
terrno
;
}
}
...
@@ -140,8 +181,8 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
...
@@ -140,8 +181,8 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
taosHashRemove
(
hash
,
pOldRow
->
pObj
,
keySize
);
taosHashRemove
(
hash
,
pOldRow
->
pObj
,
keySize
);
taosWUnLockLatch
(
pLock
);
taosWUnLockLatch
(
pLock
);
sdbRelease
(
pSdb
,
pOldRow
->
pObj
);
//
sdbRelease(pSdb, pOldRow->pObj);
sdbFreeRow
(
pRow
);
sdbFreeRow
(
p
Sdb
,
p
Row
);
return
code
;
return
code
;
}
}
...
@@ -206,6 +247,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey) {
...
@@ -206,6 +247,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey) {
case
SDB_STATUS_UPDATING
:
case
SDB_STATUS_UPDATING
:
atomic_add_fetch_32
(
&
pRow
->
refCount
,
1
);
atomic_add_fetch_32
(
&
pRow
->
refCount
,
1
);
pRet
=
pRow
->
pObj
;
pRet
=
pRow
->
pObj
;
sdbPrintOper
(
pSdb
,
pRow
,
"acquireRow"
);
break
;
break
;
case
SDB_STATUS_CREATING
:
case
SDB_STATUS_CREATING
:
terrno
=
TSDB_CODE_SDB_OBJ_CREATING
;
terrno
=
TSDB_CODE_SDB_OBJ_CREATING
;
...
@@ -232,13 +274,9 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
...
@@ -232,13 +274,9 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
taosRLockLatch
(
pLock
);
taosRLockLatch
(
pLock
);
int32_t
ref
=
atomic_sub_fetch_32
(
&
pRow
->
refCount
,
1
);
int32_t
ref
=
atomic_sub_fetch_32
(
&
pRow
->
refCount
,
1
);
sdbPrintOper
(
pSdb
,
pRow
,
"releaseRow"
);
if
(
ref
<=
0
&&
pRow
->
status
==
SDB_STATUS_DROPPED
)
{
if
(
ref
<=
0
&&
pRow
->
status
==
SDB_STATUS_DROPPED
)
{
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
pRow
->
type
];
sdbFreeRow
(
pSdb
,
pRow
);
if
(
deleteFp
!=
NULL
)
{
(
*
deleteFp
)(
pSdb
,
pRow
->
pObj
);
}
sdbFreeRow
(
pRow
);
}
}
taosRUnLockLatch
(
pLock
);
taosRUnLockLatch
(
pLock
);
...
@@ -255,9 +293,9 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
...
@@ -255,9 +293,9 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
if
(
pIter
!=
NULL
)
{
if
(
pIter
!=
NULL
)
{
SSdbRow
*
pLastRow
=
*
(
SSdbRow
**
)
pIter
;
SSdbRow
*
pLastRow
=
*
(
SSdbRow
**
)
pIter
;
int32_t
ref
=
atomic_
sub_fetch_32
(
&
pLastRow
->
refCount
,
1
);
int32_t
ref
=
atomic_
load_32
(
&
pLastRow
->
refCount
);
if
(
ref
<=
0
&&
pLastRow
->
status
==
SDB_STATUS_DROPPED
)
{
if
(
ref
<=
0
&&
pLastRow
->
status
==
SDB_STATUS_DROPPED
)
{
sdbFreeRow
(
pLastRow
);
sdbFreeRow
(
p
Sdb
,
p
LastRow
);
}
}
}
}
...
@@ -270,6 +308,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
...
@@ -270,6 +308,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
}
}
atomic_add_fetch_32
(
&
pRow
->
refCount
,
1
);
atomic_add_fetch_32
(
&
pRow
->
refCount
,
1
);
sdbPrintOper
(
pSdb
,
pRow
,
"fetchRow"
);
*
ppObj
=
pRow
->
pObj
;
*
ppObj
=
pRow
->
pObj
;
break
;
break
;
}
}
...
...
source/dnode/mnode/sdb/src/sdbRaw.c
浏览文件 @
f3067eb2
...
@@ -27,12 +27,12 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) {
...
@@ -27,12 +27,12 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) {
pRaw
->
sver
=
sver
;
pRaw
->
sver
=
sver
;
pRaw
->
dataLen
=
dataLen
;
pRaw
->
dataLen
=
dataLen
;
//
mTrace("raw:%p, is created, len:%d", pRaw, dataLen);
mTrace
(
"raw:%p, is created, len:%d"
,
pRaw
,
dataLen
);
return
pRaw
;
return
pRaw
;
}
}
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
)
{
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
)
{
//
mTrace("raw:%p, is freed", pRaw);
mTrace
(
"raw:%p, is freed"
,
pRaw
);
free
(
pRaw
);
free
(
pRaw
);
}
}
...
...
source/dnode/mnode/sdb/src/sdbRow.c
浏览文件 @
f3067eb2
...
@@ -35,4 +35,13 @@ void *sdbGetRowObj(SSdbRow *pRow) {
...
@@ -35,4 +35,13 @@ void *sdbGetRowObj(SSdbRow *pRow) {
return
pRow
->
pObj
;
return
pRow
->
pObj
;
}
}
void
sdbFreeRow
(
SSdbRow
*
pRow
)
{
tfree
(
pRow
);
}
void
sdbFreeRow
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
)
{
// remove attached object such as trans
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
pRow
->
type
];
if
(
deleteFp
!=
NULL
)
{
(
*
deleteFp
)(
pSdb
,
pRow
->
pObj
);
}
sdbPrintOper
(
pSdb
,
pRow
,
"freeRow"
);
tfree
(
pRow
);
}
source/dnode/snode/src/snode.c
浏览文件 @
f3067eb2
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "sndInt.h"
#include "sndInt.h"
SSnode
*
sndOpen
(
const
SSnodeOpt
*
pOption
)
{
SSnode
*
sndOpen
(
const
char
*
path
,
const
SSnodeOpt
*
pOption
)
{
SSnode
*
pSnode
=
calloc
(
1
,
sizeof
(
SSnode
));
SSnode
*
pSnode
=
calloc
(
1
,
sizeof
(
SSnode
));
return
pSnode
;
return
pSnode
;
}
}
...
@@ -28,3 +28,5 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -28,3 +28,5 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
*
pRsp
=
NULL
;
*
pRsp
=
NULL
;
return
0
;
return
0
;
}
}
void
sndDestroy
(
const
char
*
path
)
{}
\ No newline at end of file
source/dnode/vnode/impl/inc/vnodeRequest.h
浏览文件 @
f3067eb2
...
@@ -23,8 +23,8 @@ extern "C" {
...
@@ -23,8 +23,8 @@ extern "C" {
#endif
#endif
// SVDropTableReq
// SVDropTableReq
int
vnodeBuildDropTableReq
(
void
**
buf
,
const
SVDropTableReq
*
pReq
);
//
int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq);
void
*
vnodeParseDropTableReq
(
void
*
buf
,
SVDropTableReq
*
pReq
);
//
void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/impl/src/vnodeInt.c
浏览文件 @
f3067eb2
...
@@ -28,8 +28,3 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -28,8 +28,3 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vInfo
(
"sync message is processed"
);
vInfo
(
"sync message is processed"
);
return
0
;
return
0
;
}
}
int
vnodeProcessConsumeReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
vInfo
(
"consume message is processed"
);
return
0
;
}
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
f3067eb2
...
@@ -13,12 +13,10 @@
...
@@ -13,12 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnodeDef.h"
#include "vnodeQuery.h"
#include "vnodeQuery.h"
#include "vnodeDef.h"
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
NULL
,
&
pVnode
->
pQuery
);
}
return
qWorkerInit
(
NULL
,
&
pVnode
->
pQuery
);
}
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
vInfo
(
"query message is processed"
);
vInfo
(
"query message is processed"
);
...
@@ -46,4 +44,24 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -46,4 +44,24 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
return
0
;
return
0
;
}
}
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
STableInfoMsg
*
pReq
=
(
STableInfoMsg
*
)(
pMsg
->
pCont
);
STableMetaMsg
*
pRspMsg
;
int
ret
;
if
(
metaGetTableInfo
(
pVnode
->
pMeta
,
pReq
->
tableFname
,
&
pRspMsg
)
<
0
)
{
return
-
1
;
}
*
pRsp
=
malloc
(
sizeof
(
SRpcMsg
));
if
(
TD_IS_NULL
(
*
pRsp
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
free
(
pMsg
);
return
-
1
;
}
// TODO
(
*
pRsp
)
->
pCont
=
pRspMsg
;
return
0
;
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeRequest.c
浏览文件 @
f3067eb2
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
#include "vnodeDef.h"
#include "vnodeDef.h"
#if 0
static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq);
static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq);
static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq);
static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq);
...
@@ -113,4 +115,5 @@ int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq) {
...
@@ -113,4 +115,5 @@ int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq) {
void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq) {
void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq) {
// TODO
// TODO
}
}
\ No newline at end of file
#endif
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
f3067eb2
...
@@ -28,7 +28,6 @@ int vnodeProcessNoWalWMsgs(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -28,7 +28,6 @@ int vnodeProcessNoWalWMsgs(SVnode *pVnode, SRpcMsg *pMsg) {
int
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
int
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
SRpcMsg
*
pMsg
;
SRpcMsg
*
pMsg
;
SVnodeReq
*
pVnodeReq
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
...
@@ -51,7 +50,6 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
...
@@ -51,7 +50,6 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
}
}
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
SVnodeReq
vReq
;
SVCreateTbReq
vCreateTbReq
;
SVCreateTbReq
vCreateTbReq
;
void
*
ptr
=
vnodeMalloc
(
pVnode
,
pMsg
->
contLen
);
void
*
ptr
=
vnodeMalloc
(
pVnode
,
pMsg
->
contLen
);
if
(
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
...
@@ -70,6 +68,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -70,6 +68,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_CREATE_STB
:
case
TDMT_VND_CREATE_STB
:
case
TDMT_VND_CREATE_TABLE
:
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vCreateTbReq
);
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
// TODO: handle error
// TODO: handle error
...
@@ -79,9 +78,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -79,9 +78,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
break
;
break
;
case
TDMT_VND_DROP_STB
:
case
TDMT_VND_DROP_STB
:
case
TDMT_VND_DROP_TABLE
:
case
TDMT_VND_DROP_TABLE
:
if
(
metaDropTable
(
pVnode
->
pMeta
,
vReq
.
dtReq
.
uid
)
<
0
)
{
//
if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) {
// TODO: handle error
//
// TODO: handle error
}
//
}
break
;
break
;
case
TDMT_VND_SUBMIT
:
case
TDMT_VND_SUBMIT
:
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
(
SSubmitMsg
*
)
ptr
)
<
0
)
{
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
(
SSubmitMsg
*
)
ptr
)
<
0
)
{
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
f3067eb2
...
@@ -351,7 +351,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
...
@@ -351,7 +351,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
pDbt
[
0
].
size
=
sizeof
(
pTbCfg
->
ctbCfg
.
suid
);
pDbt
[
0
].
size
=
sizeof
(
pTbCfg
->
ctbCfg
.
suid
);
// Second key is the first tag
// Second key is the first tag
void
*
pTagVal
=
tdGetKVRowValOfCol
(
pTbCfg
->
ctbCfg
.
pTag
,
0
);
void
*
pTagVal
=
tdGetKVRowValOfCol
(
pTbCfg
->
ctbCfg
.
pTag
,
(
kvRowColIdx
(
pTbCfg
->
ctbCfg
.
pTag
))[
0
].
colId
);
pDbt
[
1
].
data
=
varDataVal
(
pTagVal
);
pDbt
[
1
].
data
=
varDataVal
(
pTagVal
);
pDbt
[
1
].
size
=
varDataLen
(
pTagVal
);
pDbt
[
1
].
size
=
varDataLen
(
pTagVal
);
...
@@ -403,10 +403,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
...
@@ -403,10 +403,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTbCfg
->
type
));
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTbCfg
->
type
));
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
buf
=
taosDecodeVariantU32
(
buf
,
pTbCfg
->
stbCfg
.
nTagCols
);
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pTbCfg
->
stbCfg
.
nTagCols
)
);
pTbCfg
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
pTbCfg
->
stbCfg
.
nTagCols
);
pTbCfg
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
pTbCfg
->
stbCfg
.
nTagCols
);
for
(
uint32_t
i
=
0
;
i
<
pTbCfg
->
stbCfg
.
nTagCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pTbCfg
->
stbCfg
.
nTagCols
;
i
++
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pTbCfg
->
stbCfg
.
pSchema
[
i
].
type
)
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pTbCfg
->
stbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pTbCfg
->
stbCfg
.
pSchema
[
i
].
name
);
...
@@ -428,4 +428,82 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
...
@@ -428,4 +428,82 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
tfree
(
pTbCfg
->
ctbCfg
.
pTag
);
tfree
(
pTbCfg
->
ctbCfg
.
pTag
);
}
}
}
/* ------------------------ FOR QUERY ------------------------ */
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
)
{
DBT
key
=
{
0
};
DBT
value
=
{
0
};
SMetaDB
*
pMetaDB
=
pMeta
->
pDB
;
int
ret
;
STbCfg
tbCfg
;
SSchemaKey
schemaKey
;
DBT
key1
=
{
0
};
DBT
value1
=
{
0
};
uint32_t
ncols
;
void
*
pBuf
;
int
tlen
;
STableMetaMsg
*
pMsg
;
key
.
data
=
tbname
;
key
.
size
=
strlen
(
tbname
)
+
1
;
ret
=
pMetaDB
->
pNameIdx
->
get
(
pMetaDB
->
pNameIdx
,
NULL
,
&
key
,
&
value
,
0
);
if
(
ret
!=
0
)
{
// TODO
return
-
1
;
}
metaDecodeTbInfo
(
value
.
data
,
&
tbCfg
);
switch
(
tbCfg
.
type
)
{
case
META_SUPER_TABLE
:
schemaKey
.
uid
=
tbCfg
.
stbCfg
.
suid
;
schemaKey
.
sver
=
0
;
key1
.
data
=
&
schemaKey
;
key1
.
size
=
sizeof
(
schemaKey
);
ret
=
pMetaDB
->
pSchemaDB
->
get
(
pMetaDB
->
pSchemaDB
,
&
key1
,
&
value1
,
NULL
,
0
);
if
(
ret
!=
0
)
{
// TODO
return
-
1
;
}
pBuf
=
value1
.
data
;
pBuf
=
taosDecodeFixedU32
(
pBuf
,
&
ncols
);
tlen
=
sizeof
(
STableMetaMsg
)
+
(
tbCfg
.
stbCfg
.
nTagCols
+
ncols
)
*
sizeof
(
SSchema
);
pMsg
=
calloc
(
1
,
tlen
);
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pMsg
->
tbFname
,
tbCfg
.
name
);
pMsg
->
numOfTags
=
tbCfg
.
stbCfg
.
nTagCols
;
pMsg
->
numOfColumns
=
ncols
;
pMsg
->
tableType
=
tbCfg
.
type
;
pMsg
->
sversion
=
0
;
pMsg
->
tversion
=
0
;
pMsg
->
suid
=
tbCfg
.
stbCfg
.
suid
;
pMsg
->
tuid
=
tbCfg
.
stbCfg
.
suid
;
for
(
size_t
i
=
0
;
i
<
tbCfg
.
stbCfg
.
nTagCols
;
i
++
)
{
}
break
;
case
META_CHILD_TABLE
:
ASSERT
(
0
);
break
;
case
META_NORMAL_TABLE
:
ASSERT
(
0
);
break
;
default:
ASSERT
(
0
);
break
;
}
*
ppMsg
=
pMsg
;
return
0
;
}
}
\ No newline at end of file
source/dnode/vnode/meta/src/metaTbCfg.c
浏览文件 @
f3067eb2
...
@@ -46,58 +46,4 @@ size_t metaEncodeTbObjFromTbOptions(const STbCfg *pTbOptions, void *pBuf, size_t
...
@@ -46,58 +46,4 @@ size_t metaEncodeTbObjFromTbOptions(const STbCfg *pTbOptions, void *pBuf, size_t
}
}
return
tlen
;
return
tlen
;
}
int
metaEncodeTbCfg
(
void
**
pBuf
,
STbCfg
*
pTbCfg
)
{
int
tsize
=
0
;
tsize
+=
taosEncodeString
(
pBuf
,
pTbCfg
->
name
);
tsize
+=
taosEncodeFixedU32
(
pBuf
,
pTbCfg
->
ttl
);
tsize
+=
taosEncodeFixedU32
(
pBuf
,
pTbCfg
->
keep
);
tsize
+=
taosEncodeFixedU8
(
pBuf
,
pTbCfg
->
type
);
switch
(
pTbCfg
->
type
)
{
case
META_SUPER_TABLE
:
tsize
+=
taosEncodeFixedU64
(
pBuf
,
pTbCfg
->
stbCfg
.
suid
);
tsize
+=
tdEncodeSchema
(
pBuf
,
pTbCfg
->
stbCfg
.
pSchema
);
tsize
+=
tdEncodeSchema
(
pBuf
,
pTbCfg
->
stbCfg
.
pTagSchema
);
break
;
case
META_CHILD_TABLE
:
tsize
+=
taosEncodeFixedU64
(
pBuf
,
pTbCfg
->
ctbCfg
.
suid
);
tsize
+=
tdEncodeKVRow
(
pBuf
,
pTbCfg
->
ctbCfg
.
pTag
);
break
;
case
META_NORMAL_TABLE
:
tsize
+=
tdEncodeSchema
(
pBuf
,
pTbCfg
->
ntbCfg
.
pSchema
);
break
;
default:
break
;
}
return
tsize
;
}
void
*
metaDecodeTbCfg
(
void
*
pBuf
,
STbCfg
*
pTbCfg
)
{
pBuf
=
taosDecodeString
(
pBuf
,
&
(
pTbCfg
->
name
));
pBuf
=
taosDecodeFixedU32
(
pBuf
,
&
(
pTbCfg
->
ttl
));
pBuf
=
taosDecodeFixedU32
(
pBuf
,
&
(
pTbCfg
->
keep
));
pBuf
=
taosDecodeFixedU8
(
pBuf
,
&
(
pTbCfg
->
type
));
switch
(
pTbCfg
->
type
)
{
case
META_SUPER_TABLE
:
pBuf
=
taosDecodeFixedU64
(
pBuf
,
&
(
pTbCfg
->
stbCfg
.
suid
));
pBuf
=
tdDecodeSchema
(
pBuf
,
&
(
pTbCfg
->
stbCfg
.
pSchema
));
pBuf
=
tdDecodeSchema
(
pBuf
,
&
(
pTbCfg
->
stbCfg
.
pTagSchema
));
break
;
case
META_CHILD_TABLE
:
pBuf
=
taosDecodeFixedU64
(
pBuf
,
&
(
pTbCfg
->
ctbCfg
.
suid
));
pBuf
=
tdDecodeKVRow
(
pBuf
,
&
(
pTbCfg
->
ctbCfg
.
pTag
));
break
;
case
META_NORMAL_TABLE
:
pBuf
=
tdDecodeSchema
(
pBuf
,
&
(
pTbCfg
->
ntbCfg
.
pSchema
));
break
;
default:
break
;
}
return
pBuf
;
}
}
\ No newline at end of file
source/libs/catalog/inc/catalogInt.h
浏览文件 @
f3067eb2
...
@@ -66,8 +66,6 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
...
@@ -66,8 +66,6 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
#define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define CTG_CACHE_ENABLED() (ctgMgmt.cfg.maxDBCacheNum > 0 || ctgMgmt.cfg.maxTblCacheNum > 0)
#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
f3067eb2
...
@@ -388,7 +388,11 @@ TEST(tableMeta, normalTable) {
...
@@ -388,7 +388,11 @@ TEST(tableMeta, normalTable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
vgInfo
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
vgInfo
.
vgId
,
8
);
ASSERT_EQ
(
vgInfo
.
vgId
,
8
);
ASSERT_EQ
(
vgInfo
.
numOfEps
,
3
);
ASSERT_EQ
(
vgInfo
.
numOfEps
,
3
);
...
@@ -396,7 +400,7 @@ TEST(tableMeta, normalTable) {
...
@@ -396,7 +400,7 @@ TEST(tableMeta, normalTable) {
ctgTestSetPrepareTableMeta
();
ctgTestSetPrepareTableMeta
();
STableMeta
*
tableMeta
=
NULL
;
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
...
@@ -408,7 +412,7 @@ TEST(tableMeta, normalTable) {
...
@@ -408,7 +412,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
...
@@ -433,14 +437,15 @@ TEST(tableMeta, childTableCase) {
...
@@ -433,14 +437,15 @@ TEST(tableMeta, childTableCase) {
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalog
Init
(
NULL
);
int32_t
code
=
catalog
GetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
ASSERT_EQ
(
code
,
0
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
STableMeta
*
tableMeta
=
NULL
;
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
...
@@ -452,7 +457,7 @@ TEST(tableMeta, childTableCase) {
...
@@ -452,7 +457,7 @@ TEST(tableMeta, childTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
...
@@ -464,7 +469,9 @@ TEST(tableMeta, childTableCase) {
...
@@ -464,7 +469,9 @@ TEST(tableMeta, childTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestSTablename
,
&
tableMeta
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
...
@@ -488,15 +495,15 @@ TEST(tableMeta, superTableCase) {
...
@@ -488,15 +495,15 @@ TEST(tableMeta, superTableCase) {
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
ASSERT_EQ
(
code
,
0
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
STableMeta
*
tableMeta
=
NULL
;
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestSTablename
,
&
tableMeta
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
...
@@ -510,7 +517,10 @@ TEST(tableMeta, superTableCase) {
...
@@ -510,7 +517,10 @@ TEST(tableMeta, superTableCase) {
ctgTestSetPrepareCTableMeta
();
ctgTestSetPrepareCTableMeta
();
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
...
@@ -522,7 +532,7 @@ TEST(tableMeta, superTableCase) {
...
@@ -522,7 +532,7 @@ TEST(tableMeta, superTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
tableMeta
=
NULL
;
code
=
catalogRenewAndGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
code
=
catalogRenewAndGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
...
@@ -550,14 +560,14 @@ TEST(tableDistVgroup, normalTable) {
...
@@ -550,14 +560,14 @@ TEST(tableDistVgroup, normalTable) {
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalog
Init
(
NULL
);
int32_t
code
=
catalog
GetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
ASSERT_EQ
(
code
,
0
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgList
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
vgList
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
1
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
1
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
...
@@ -585,7 +595,11 @@ TEST(tableDistVgroup, childTableCase) {
...
@@ -585,7 +595,11 @@ TEST(tableDistVgroup, childTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
vgList
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgList
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
1
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
1
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
...
@@ -607,14 +621,14 @@ TEST(tableDistVgroup, superTableCase) {
...
@@ -607,14 +621,14 @@ TEST(tableDistVgroup, superTableCase) {
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
SName
n
=
{.
type
=
T_NAME_TABLE
,
.
acctId
=
1
};
ASSERT_EQ
(
code
,
0
);
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestSTablename
,
&
vgList
);
code
=
catalogGetTableDistVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgList
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
10
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
10
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
vgInfo
=
(
SVgroupInfo
*
)
taosArrayGet
(
vgList
,
0
);
...
...
source/libs/index/inc/index_cache.h
浏览文件 @
f3067eb2
...
@@ -30,14 +30,18 @@
...
@@ -30,14 +30,18 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
MemTable
{
T_REF_DECLARE
()
SSkipList
*
mem
;
}
MemTable
;
typedef
struct
IndexCache
{
typedef
struct
IndexCache
{
T_REF_DECLARE
()
T_REF_DECLARE
()
SSkipList
*
mem
,
*
imm
;
MemTable
*
mem
,
*
imm
;
SIndex
*
index
;
SIndex
*
index
;
char
*
colName
;
char
*
colName
;
int32_t
version
;
int32_t
version
;
int32_t
nTerm
;
int32_t
nTerm
;
int8_t
type
;
int8_t
type
;
pthread_mutex_t
mtx
;
pthread_mutex_t
mtx
;
}
IndexCache
;
}
IndexCache
;
...
@@ -45,7 +49,6 @@ typedef struct IndexCache {
...
@@ -45,7 +49,6 @@ typedef struct IndexCache {
#define CACHE_VERSION(cache) atomic_load_32(&cache->version)
#define CACHE_VERSION(cache) atomic_load_32(&cache->version)
typedef
struct
CacheTerm
{
typedef
struct
CacheTerm
{
// key
// key
int32_t
nColVal
;
char
*
colVal
;
char
*
colVal
;
int32_t
version
;
int32_t
version
;
// value
// value
...
...
source/libs/index/src/index.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/index/src/index_cache.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/index/src/index_tfile.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/index/test/indexTests.cc
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/inc/astGenerator.h
浏览文件 @
f3067eb2
...
@@ -156,7 +156,7 @@ typedef struct SCreateDbInfo {
...
@@ -156,7 +156,7 @@ typedef struct SCreateDbInfo {
SToken
dbname
;
SToken
dbname
;
int32_t
replica
;
int32_t
replica
;
int32_t
cacheBlockSize
;
int32_t
cacheBlockSize
;
int32_t
maxTablesPerVnode
;
int32_t
numOfVgroups
;
int32_t
numOfBlocks
;
int32_t
numOfBlocks
;
int32_t
daysPerFile
;
int32_t
daysPerFile
;
int32_t
minRowsPerBlock
;
int32_t
minRowsPerBlock
;
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
f3067eb2
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#include "parserInt.h"
#include "parserInt.h"
#include "tmsg.h"
#include "tmsg.h"
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcctMsg
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcctMsg
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
...
...
source/libs/parser/inc/parserUtil.h
浏览文件 @
f3067eb2
...
@@ -62,7 +62,7 @@ void cleanupTagCond(STagCond* pTagCond);
...
@@ -62,7 +62,7 @@ void cleanupTagCond(STagCond* pTagCond);
void
cleanupColumnCond
(
SArray
**
pCond
);
void
cleanupColumnCond
(
SArray
**
pCond
);
uint32_t
convertRelationalOperator
(
SToken
*
pToken
);
uint32_t
convertRelationalOperator
(
SToken
*
pToken
);
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
);
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
);
STableMeta
*
tableMetaDup
(
const
STableMeta
*
pTableMeta
);
STableMeta
*
tableMetaDup
(
const
STableMeta
*
pTableMeta
);
...
@@ -70,6 +70,19 @@ bool isDclSqlStatement(SSqlInfo* pSqlInfo);
...
@@ -70,6 +70,19 @@ bool isDclSqlStatement(SSqlInfo* pSqlInfo);
bool
isDdlSqlStatement
(
SSqlInfo
*
pSqlInfo
);
bool
isDdlSqlStatement
(
SSqlInfo
*
pSqlInfo
);
bool
isDqlSqlStatement
(
SSqlInfo
*
pSqlInfo
);
bool
isDqlSqlStatement
(
SSqlInfo
*
pSqlInfo
);
typedef
struct
SKvParam
{
SKVRowBuilder
*
builder
;
SSchema
*
schema
;
char
buf
[
TSDB_MAX_TAGS_LEN
];
}
SKvParam
;
int32_t
KvRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
);
typedef
int32_t
(
*
_row_append_fn_t
)(
const
void
*
value
,
int32_t
len
,
void
*
param
);
int32_t
parseValueToken
(
char
**
end
,
SToken
*
pToken
,
SSchema
*
pSchema
,
int16_t
timePrec
,
char
*
tmpTokenBuf
,
_row_append_fn_t
func
,
void
*
param
,
SMsgBuf
*
pMsgBuf
);
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/parser/inc/sql.y
浏览文件 @
f3067eb2
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
%default_type {SToken}
%default_type {SToken}
%extra_argument {SSqlInfo* pInfo}
%extra_argument {SSqlInfo* pInfo}
%fallback ID BOOL
TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR
.
%fallback ID BOOL
INTEGER FLOAT STRING TIMESTAMP
.
%left OR.
%left OR.
%left AND.
%left AND.
...
@@ -200,7 +200,8 @@ ifnotexists(X) ::= . { X.n = 0;}
...
@@ -200,7 +200,8 @@ ifnotexists(X) ::= . { X.n = 0;}
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
//create option for dnode/db/user/account
//create option for dnode/db/user/account
cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
cmd ::= CREATE DNODE IPTOKEN(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);}
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
...
@@ -279,6 +280,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
...
@@ -279,6 +280,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; }
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
vgroups(Y) ::= VGROUPS INTEGER(X). { Y = X; }
//partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; }
//partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; }
%type db_optr {SCreateDbInfo}
%type db_optr {SCreateDbInfo}
...
@@ -299,6 +301,7 @@ db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
...
@@ -299,6 +301,7 @@ db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) vgroups(X). { Y = Z; Y.numOfVgroups = strtol(X.z, NULL, 10); }
//%type topic_optr {SCreateDbInfo}
//%type topic_optr {SCreateDbInfo}
//
//
...
...
source/libs/parser/inc/ttokendef.h
已删除
100644 → 0
浏览文件 @
335de535
此差异已折叠。
点击以展开。
source/libs/parser/src/astGenerator.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/astToMsg.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/insertParser.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/parserUtil.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/queryInfoUtil.c
浏览文件 @
f3067eb2
...
@@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) {
...
@@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) {
}
}
SSchema
*
getOneColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
)
{
SSchema
*
getOneColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
)
{
assert
(
pTableMeta
!=
NULL
&&
pTableMeta
->
schema
!=
NULL
&&
colIndex
>=
0
&&
colIndex
<
getNumOfColumns
(
pTableMeta
));
assert
(
pTableMeta
!=
NULL
&&
pTableMeta
->
schema
!=
NULL
&&
colIndex
>=
0
&&
colIndex
<
(
getNumOfColumns
(
pTableMeta
)
+
getNumOfTags
(
pTableMeta
)
));
SSchema
*
pSchema
=
(
SSchema
*
)
pTableMeta
->
schema
;
SSchema
*
pSchema
=
(
SSchema
*
)
pTableMeta
->
schema
;
return
&
pSchema
[
colIndex
];
return
&
pSchema
[
colIndex
];
...
...
source/libs/parser/src/sql.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/src/ttokenizer.c
浏览文件 @
f3067eb2
...
@@ -31,17 +31,17 @@ typedef struct SKeyword {
...
@@ -31,17 +31,17 @@ typedef struct SKeyword {
static
SKeyword
keywordTable
[]
=
{
static
SKeyword
keywordTable
[]
=
{
{
"ID"
,
TK_ID
},
{
"ID"
,
TK_ID
},
{
"BOOL"
,
TK_BOOL
},
{
"BOOL"
,
TK_BOOL
},
{
"TINYINT"
,
TK_TINYINT
},
//
{"TINYINT", TK_TINYINT},
{
"SMALLINT"
,
TK_SMALLINT
},
//
{"SMALLINT", TK_SMALLINT},
{
"INTEGER"
,
TK_INTEGER
},
{
"INTEGER"
,
TK_INTEGER
},
{
"INT"
,
TK_INTEGER
},
{
"INT"
,
TK_INTEGER
},
{
"BIGINT"
,
TK_BIGINT
},
//
{"BIGINT", TK_BIGINT},
{
"FLOAT"
,
TK_FLOAT
},
{
"FLOAT"
,
TK_FLOAT
},
{
"DOUBLE"
,
TK_DOUBLE
},
//
{"DOUBLE", TK_DOUBLE},
{
"STRING"
,
TK_STRING
},
{
"STRING"
,
TK_STRING
},
{
"TIMESTAMP"
,
TK_TIMESTAMP
},
{
"TIMESTAMP"
,
TK_TIMESTAMP
},
{
"BINARY"
,
TK_BINARY
},
//
{"BINARY", TK_BINARY},
{
"NCHAR"
,
TK_NCHAR
},
//
{"NCHAR", TK_NCHAR},
{
"OR"
,
TK_OR
},
{
"OR"
,
TK_OR
},
{
"AND"
,
TK_AND
},
{
"AND"
,
TK_AND
},
{
"NOT"
,
TK_NOT
},
{
"NOT"
,
TK_NOT
},
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.h
浏览文件 @
f3067eb2
...
@@ -57,8 +57,8 @@ public:
...
@@ -57,8 +57,8 @@ public:
void
showTables
()
const
;
void
showTables
()
const
;
std
::
shared_ptr
<
MockTableMeta
>
getTableMeta
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
)
const
;
std
::
shared_ptr
<
MockTableMeta
>
getTableMeta
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
)
const
;
int32_t
catalogGetTableMeta
(
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
char
*
pDBName
,
const
char
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
private:
private:
std
::
unique_ptr
<
MockCatalogServiceImpl
>
impl_
;
std
::
unique_ptr
<
MockCatalogServiceImpl
>
impl_
;
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
source/util/src/tbuffer.c
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
tests/script/general/db/basic1.sim
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
tests/script/general/table/basic1.sim
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
tests/script/sh/exec.sh
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
tests/script/tmp/dnodes.sim
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
tests/script/unique/dnode/basic1.sim
浏览文件 @
f3067eb2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录