Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
962ed386
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看板
提交
962ed386
编写于
11月 07, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt reqid incr one
上级
1102a88a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
14 deletion
+56
-14
source/libs/transport/test/svrBench.c
source/libs/transport/test/svrBench.c
+56
-14
未找到文件。
source/libs/transport/test/svrBench.c
浏览文件 @
962ed386
...
...
@@ -26,21 +26,40 @@ TdFilePtr pDataFile = NULL;
STaosQueue
*
qhandle
=
NULL
;
STaosQset
*
qset
=
NULL
;
int32_t
balance
=
0
;
typedef
struct
{
int32_t
numOfThread
;
STaosQueue
**
qhandle
;
STaosQset
**
qset
;
}
MultiThreadQhandle
;
typedef
struct
TThread
{
TdThread
thread
;
int
idx
;
}
TThread
;
MultiThreadQhandle
*
multiQ
=
NULL
;
void
initLogEnv
()
{
const
char
*
logDir
=
"/tmp/trans_svr"
;
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
char
*
logDir
=
"/tmp/trans_svr"
;
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
int32_t
maxLogFileNum
=
10000
;
tsAsyncLog
=
0
;
//idxDebugFlag = 143;
//
idxDebugFlag = 143;
strcpy
(
tsLogDir
,
logDir
);
taosRemoveDir
(
tsLogDir
);
taosMkDir
(
tsLogDir
);
taosMkDir
(
tsLogDir
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
void
processShellMsg
()
{
void
*
processShellMsg
(
void
*
arg
)
{
TThread
*
thread
=
(
TThread
*
)
arg
;
int32_t
idx
=
thread
->
idx
;
static
int
num
=
0
;
STaosQall
*
qall
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
...
...
@@ -50,7 +69,7 @@ void processShellMsg() {
qall
=
taosAllocateQall
();
while
(
1
)
{
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
qset
,
qall
,
&
qinfo
);
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
multiQ
->
qset
[
idx
]
,
qall
,
&
qinfo
);
tDebug
(
"%d shell msgs are received"
,
numOfMsgs
);
if
(
numOfMsgs
<=
0
)
break
;
...
...
@@ -103,6 +122,7 @@ void processShellMsg() {
}
taosFreeQall
(
qall
);
return
NULL
;
}
void
processRequestMsg
(
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
...
...
@@ -111,8 +131,11 @@ void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
pTemp
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
DEF_QITEM
);
memcpy
(
pTemp
,
pMsg
,
sizeof
(
SRpcMsg
));
int32_t
idx
=
balance
%
multiQ
->
numOfThread
;
tDebug
(
"request is received, type:%d, contLen:%d, item:%p"
,
pMsg
->
msgType
,
pMsg
->
contLen
,
pTemp
);
taosWriteQitem
(
qhandle
,
pTemp
);
taosWriteQitem
(
multiQ
->
qhandle
[
idx
],
pTemp
);
balance
++
;
if
(
balance
>=
multiQ
->
numOfThread
)
balance
=
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -162,7 +185,7 @@ int main(int argc, char *argv[]) {
}
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
initLogEnv
();
void
*
pRpc
=
rpcOpen
(
&
rpcInit
);
...
...
@@ -178,16 +201,35 @@ int main(int argc, char *argv[]) {
pDataFile
=
taosOpenFile
(
dataName
,
TD_FILE_APPEND
|
TD_FILE_CREATE
|
TD_FILE_WRITE
);
if
(
pDataFile
==
NULL
)
tInfo
(
"failed to open data file, reason:%s"
,
strerror
(
errno
));
}
qhandle
=
taosOpenQueue
();
qset
=
taosOpenQset
();
taosAddIntoQset
(
qset
,
qhandle
,
NULL
);
processShellMsg
();
int32_t
numOfAthread
=
5
;
multiQ
=
taosMemoryMalloc
(
sizeof
(
numOfAthread
));
multiQ
->
numOfThread
=
numOfAthread
;
multiQ
->
qhandle
=
(
STaosQueue
**
)
taosMemoryMalloc
(
sizeof
(
STaosQueue
*
)
*
numOfAthread
);
multiQ
->
qset
=
(
STaosQset
**
)
taosMemoryMalloc
(
sizeof
(
STaosQset
*
)
*
numOfAthread
);
for
(
int
i
=
0
;
i
<
numOfAthread
;
i
++
)
{
multiQ
->
qhandle
[
i
]
=
taosOpenQueue
();
multiQ
->
qset
[
i
]
=
taosOpenQset
();
taosAddIntoQset
(
multiQ
->
qset
[
i
],
multiQ
->
qhandle
[
i
],
NULL
);
}
TThread
*
threads
=
taosMemoryMalloc
(
sizeof
(
TThread
)
*
numOfAthread
);
for
(
int
i
=
0
;
i
<
numOfAthread
;
i
++
)
{
threads
[
i
].
idx
=
i
;
taosThreadCreate
(
&
(
threads
[
i
].
thread
),
NULL
,
processShellMsg
,
(
void
*
)
&
threads
[
i
]);
}
// qhandle = taosOpenQueue();
// qset = taosOpenQset();
// taosAddIntoQset(qset, qhandle, NULL);
// processShellMsg();
if
(
pDataFile
!=
NULL
)
{
taosCloseFile
(
&
pDataFile
);
taosRemoveFile
(
dataName
);
}
int
ch
=
getchar
();
UNUSED
(
ch
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录