Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
563c0ddd
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
563c0ddd
编写于
12月 24, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] refactor.
上级
5ef4444c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
48 addition
and
56 deletion
+48
-56
include/libs/qcom/query.h
include/libs/qcom/query.h
+20
-3
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+8
-30
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+5
-6
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+7
-9
source/client/src/clientMain.c
source/client/src/clientMain.c
+2
-2
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+2
-2
source/client/test/CMakeLists.txt
source/client/test/CMakeLists.txt
+1
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+2
-2
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
未找到文件。
include/libs/qcom/query.h
浏览文件 @
563c0ddd
...
...
@@ -88,12 +88,27 @@ typedef struct SUseDbOutput {
typedef
struct
STableMetaOutput
{
int32_t
metaNum
;
char
ctbFname
[
TSDB_TABLE_FNAME_LEN
];
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
SCTableMeta
ctbMeta
;
STableMeta
*
tbMeta
;
}
STableMetaOutput
;
typedef
int32_t
__async_exec_fn_t
(
void
*
param
);
typedef
struct
SDataBuf
{
void
*
pData
;
uint32_t
len
;
}
SDataBuf
;
typedef
int32_t
(
*
__async_send_cb_fn_t
)(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
typedef
int32_t
(
*
__async_exec_fn_t
)(
void
*
param
);
typedef
struct
SMsgSendInfo
{
__async_send_cb_fn_t
fp
;
//async callback function
void
*
param
;
uint64_t
requestId
;
uint64_t
requestObjRefId
;
int32_t
msgType
;
SDataBuf
msgInfo
;
}
SMsgSendInfo
;
bool
tIsValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
,
int32_t
numOfTags
);
...
...
@@ -109,7 +124,9 @@ int32_t cleanupTaskQueue();
*/
int32_t
taosAsyncExec
(
__async_exec_fn_t
execFn
,
void
*
execParam
,
int32_t
*
code
);
SSchema
*
tGetTbnameColumnSchema
();
int32_t
asyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
);
const
SSchema
*
tGetTbnameColumnSchema
();
void
initQueryModuleMsgHandle
();
extern
int32_t
(
*
queryBuildMsg
[
TSDB_MSG_TYPE_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
...
...
source/client/inc/clientInt.h
浏览文件 @
563c0ddd
...
...
@@ -29,6 +29,7 @@ extern "C" {
#include "tlist.h"
#include "tmsgtype.h"
#include "trpc.h"
#include "query.h"
typedef
struct
SQueryExecMetric
{
int64_t
start
;
// start timestamp
...
...
@@ -100,11 +101,6 @@ typedef struct SReqResultInfo {
uint32_t
current
;
}
SReqResultInfo
;
typedef
struct
SDataBuf
{
void
*
pData
;
uint32_t
len
;
}
SDataBuf
;
typedef
struct
SRequestSendRecvBody
{
tsem_t
rspSem
;
// not used now
void
*
fp
;
...
...
@@ -119,39 +115,21 @@ typedef struct SRequestObj {
uint64_t
requestId
;
int32_t
type
;
// request type
STscObj
*
pTscObj
;
SQueryExecMetric
metric
;
char
*
sqlstr
;
// sql string
SRequestSendRecvBody
body
;
int64_t
self
;
char
*
msgBuf
;
void
*
pInfo
;
// sql parse info, generated by parser module
int32_t
code
;
SQueryExecMetric
metric
;
SRequestSendRecvBody
body
;
}
SRequestObj
;
typedef
struct
SRequestMsgBody
{
int32_t
msgType
;
SDataBuf
msgInfo
;
uint64_t
requestId
;
uint64_t
requestObjRefId
;
}
SRequestMsgBody
;
typedef
int
(
*
__async_send_cb_fn_t
)(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
typedef
struct
SMsgSendInfo
{
__async_send_cb_fn_t
fp
;
void
*
param
;
uint64_t
requestId
;
uint64_t
requestObjRefId
;
int32_t
msgType
;
SDataBuf
msgInfo
;
}
SMsgSendInfo
;
extern
SAppInfo
appInfo
;
extern
int32_t
msgObj
RefPool
;
extern
int32_t
clientReq
RefPool
;
extern
int32_t
clientConnRefPool
;
SMsgSendInfo
*
buildSendMsgInfoImpl
(
SRequestObj
*
pRequest
);
int
generic
Exec
Callback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
int
generic
Rsp
Callback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
extern
int
(
*
handleRequestRspFp
[
TSDB_MSG_TYPE_MAX
])(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
int
taos_init
();
...
...
@@ -166,7 +144,7 @@ char *getConnectionDB(STscObj* pObj);
void
setConnectionDB
(
STscObj
*
pTscObj
,
const
char
*
db
);
void
taos_init_imp
(
void
);
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
str
);
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
str
);
void
*
openTransporter
(
const
char
*
user
,
const
char
*
auth
,
int32_t
numOfThreads
);
...
...
@@ -176,8 +154,8 @@ void initMsgHandleFp();
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
);
void
*
doFetchRow
(
SRequestObj
*
pRequest
);
void
setResultDataPtr
(
SReqResultInfo
*
pResultInfo
,
TAOS_FIELD
*
pFields
,
int32_t
numOfCols
,
int32_t
numOfRows
);
void
*
doFetchRow
(
SRequestObj
*
pRequest
);
void
setResultDataPtr
(
SReqResultInfo
*
pResultInfo
,
TAOS_FIELD
*
pFields
,
int32_t
numOfCols
,
int32_t
numOfRows
);
#ifdef __cplusplus
}
...
...
source/client/src/clientEnv.c
浏览文件 @
563c0ddd
...
...
@@ -32,7 +32,7 @@
#define TSC_VAR_RELEASED 0
SAppInfo
appInfo
;
int32_t
msgObj
RefPool
=
-
1
;
int32_t
clientReq
RefPool
=
-
1
;
int32_t
clientConnRefPool
=
-
1
;
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
...
...
@@ -43,7 +43,7 @@ static void registerRequest(SRequestObj* pRequest) {
assert
(
pTscObj
!=
NULL
);
// connection has been released already, abort creating request.
pRequest
->
self
=
taosAddRef
(
msgObj
RefPool
,
pRequest
);
pRequest
->
self
=
taosAddRef
(
clientReq
RefPool
,
pRequest
);
int32_t
num
=
atomic_add_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
...
...
@@ -167,12 +167,11 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
// TODO generated request uuid
pRequest
->
requestId
=
0
;
pRequest
->
metric
.
start
=
taosGetTimestampMs
();
pRequest
->
type
=
type
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
body
.
fp
=
fp
;
pRequest
->
body
.
fp
=
fp
;
// not used it yet
pRequest
->
msgBuf
=
calloc
(
1
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
...
...
@@ -201,7 +200,7 @@ void destroyRequest(SRequestObj* pRequest) {
return
;
}
taosReleaseRef
(
msgObj
RefPool
,
pRequest
->
self
);
taosReleaseRef
(
clientReq
RefPool
,
pRequest
->
self
);
}
void
taos_init_imp
(
void
)
{
...
...
@@ -238,7 +237,7 @@ void taos_init_imp(void) {
initTaskQueue
();
clientConnRefPool
=
taosOpenRef
(
200
,
destroyTscObj
);
msgObj
RefPool
=
taosOpenRef
(
40960
,
doDestroyRequest
);
clientReq
RefPool
=
taosOpenRef
(
40960
,
doDestroyRequest
);
taosGetAppName
(
appInfo
.
appName
,
NULL
);
appInfo
.
pid
=
taosGetPId
();
...
...
source/client/src/clientImpl.c
浏览文件 @
563c0ddd
...
...
@@ -14,8 +14,6 @@ static int32_t initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorE
static
SMsgSendInfo
*
buildConnectMsg
(
SRequestObj
*
pRequest
);
static
void
destroySendMsgInfo
(
SMsgSendInfo
*
pMsgBody
);
static
int32_t
sendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
);
static
bool
stringLengthCheck
(
const
char
*
str
,
size_t
maxsize
)
{
if
(
str
==
NULL
)
{
return
false
;
...
...
@@ -201,10 +199,10 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
tstrncpy
(
ep
.
fqdn
[
i
],
info
.
epAddr
[
i
].
fqdn
,
tListLen
(
ep
.
fqdn
[
i
]));
}
s
endMsgToServer
(
pTscObj
->
pTransporter
,
&
ep
,
&
transporterId
,
body
);
asyncS
endMsgToServer
(
pTscObj
->
pTransporter
,
&
ep
,
&
transporterId
,
body
);
}
else
{
int64_t
transporterId
=
0
;
s
endMsgToServer
(
pTscObj
->
pTransporter
,
pEpSet
,
&
transporterId
,
body
);
asyncS
endMsgToServer
(
pTscObj
->
pTransporter
,
pEpSet
,
&
transporterId
,
body
);
}
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
...
...
@@ -274,7 +272,7 @@ STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, con
SMsgSendInfo
*
body
=
buildConnectMsg
(
pRequest
);
int64_t
transporterId
=
0
;
s
endMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncS
endMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
destroySendMsgInfo
(
body
);
...
...
@@ -335,7 +333,7 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
tfree
(
pMsgBody
);
}
int32_t
s
endMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
)
{
int32_t
asyncS
endMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
)
{
char
*
pMsg
=
rpcMallocCont
(
pInfo
->
msgInfo
.
len
);
if
(
NULL
==
pMsg
)
{
tscError
(
"0x%"
PRIx64
" msg:%s malloc failed"
,
pInfo
->
requestId
,
taosMsg
[
pInfo
->
msgType
]);
...
...
@@ -364,7 +362,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
assert
(
pMsg
->
ahandle
!=
NULL
);
if
(
pSendInfo
->
requestObjRefId
!=
0
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosAcquireRef
(
msgObj
RefPool
,
pSendInfo
->
requestObjRefId
);
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosAcquireRef
(
clientReq
RefPool
,
pSendInfo
->
requestObjRefId
);
assert
(
pRequest
->
self
==
pSendInfo
->
requestObjRefId
);
pRequest
->
metric
.
rsp
=
taosGetTimestampMs
();
...
...
@@ -391,7 +389,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
pRequest
->
metric
.
rsp
-
pRequest
->
metric
.
start
);
}
taosReleaseRef
(
msgObj
RefPool
,
pSendInfo
->
requestObjRefId
);
taosReleaseRef
(
clientReq
RefPool
,
pSendInfo
->
requestObjRefId
);
}
SDataBuf
buf
=
{.
pData
=
pMsg
->
pCont
,
.
len
=
pMsg
->
contLen
};
...
...
@@ -437,7 +435,7 @@ void* doFetchRow(SRequestObj* pRequest) {
int64_t
transporterId
=
0
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
s
endMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncS
endMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
destroySendMsgInfo
(
body
);
...
...
source/client/src/clientMain.c
浏览文件 @
563c0ddd
...
...
@@ -35,8 +35,8 @@ void taos_cleanup(void) {
return
;
}
int32_t
id
=
msgObj
RefPool
;
msgObj
RefPool
=
-
1
;
int32_t
id
=
clientReq
RefPool
;
clientReq
RefPool
=
-
1
;
taosCloseRef
(
id
);
cleanupTaskQueue
();
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
563c0ddd
...
...
@@ -22,7 +22,7 @@
int
(
*
handleRequestRspFp
[
TSDB_MSG_TYPE_MAX
])(
void
*
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
int
generic
Exec
Callback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
int
generic
Rsp
Callback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
param
;
pRequest
->
code
=
code
;
sem_post
(
&
pRequest
->
body
.
rspSem
);
...
...
@@ -96,7 +96,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) {
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
fp
=
(
handleRequestRspFp
[
pRequest
->
type
]
==
NULL
)
?
generic
Exec
Callback
:
handleRequestRspFp
[
pRequest
->
type
];
pMsgSendInfo
->
fp
=
(
handleRequestRspFp
[
pRequest
->
type
]
==
NULL
)
?
generic
Rsp
Callback
:
handleRequestRspFp
[
pRequest
->
type
];
}
return
pMsgSendInfo
;
...
...
source/client/test/CMakeLists.txt
浏览文件 @
563c0ddd
...
...
@@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE
(
clientTest
${
SOURCE_LIST
}
)
TARGET_LINK_LIBRARIES
(
clientTest
PUBLIC os util common transport gtest taos
PUBLIC os util common transport gtest taos
qcom
)
TARGET_INCLUDE_DIRECTORIES
(
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
563c0ddd
...
...
@@ -14,7 +14,7 @@ static struct SSchema _s = {
.
name
=
"tbname"
,
};
SSchema
*
tGetTbnameColumnSchema
()
{
const
SSchema
*
tGetTbnameColumnSchema
()
{
return
&
_s
;
}
...
...
@@ -103,7 +103,7 @@ int32_t cleanupTaskQueue() {
static
void
execHelper
(
struct
SSchedMsg
*
pSchedMsg
)
{
assert
(
pSchedMsg
!=
NULL
&&
pSchedMsg
->
ahandle
!=
NULL
);
__async_exec_fn_t
*
execFn
=
(
__async_exec_fn_t
*
)
pSchedMsg
->
ahandle
;
__async_exec_fn_t
execFn
=
(
__async_exec_fn_t
)
pSchedMsg
->
ahandle
;
int32_t
code
=
execFn
(
pSchedMsg
->
thandle
);
if
(
code
!=
0
&&
pSchedMsg
->
msg
!=
NULL
)
{
*
(
int32_t
*
)
pSchedMsg
->
msg
=
code
;
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
563c0ddd
...
...
@@ -32,7 +32,7 @@ int32_t schBuildAndSendRequest(void *pRpc, const SEpSet* pMgmtEps, __taos_async_
buildConnectMsg(pRequest, &body);
int64_t transporterId = 0;
s
endMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
asyncS
endMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &body, &transporterId);
tsem_wait(&pRequest->body.rspSem);
destroyConnectMsg(&body);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录