Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
2a7b9134
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2a7b9134
编写于
9月 15, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3521 from taosdata/feature/http
Feature/http
上级
ba826f20
c8cf0720
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
83 addition
and
21 deletion
+83
-21
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+1
-1
src/plugins/http/inc/httpSql.h
src/plugins/http/inc/httpSql.h
+3
-3
src/plugins/http/src/httpGcHandle.c
src/plugins/http/src/httpGcHandle.c
+1
-1
src/plugins/http/src/httpGcJson.c
src/plugins/http/src/httpGcJson.c
+13
-13
src/plugins/http/src/httpServer.c
src/plugins/http/src/httpServer.c
+5
-1
tests/test/c/CMakeLists.txt
tests/test/c/CMakeLists.txt
+12
-2
tests/test/c/httpTest.c
tests/test/c/httpTest.c
+48
-0
未找到文件。
src/plugins/http/inc/httpInt.h
浏览文件 @
2a7b9134
...
...
@@ -36,7 +36,7 @@
#define HTTP_BUFFER_SIZE 8388608
#define HTTP_STEP_SIZE 4096 //http message get process step by step
#define HTTP_METHOD_SCANNER_SIZE 7 //http method fp size
#define
TSDB_CODE_
HTTP_GC_TARGET_SIZE 512
#define HTTP_GC_TARGET_SIZE 512
#define HTTP_WRITE_RETRY_TIMES 500
#define HTTP_WRITE_WAIT_TIME_MS 5
#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN)
...
...
src/plugins/http/inc/httpSql.h
浏览文件 @
2a7b9134
...
...
@@ -29,10 +29,10 @@ void httpFreeMultiCmds(HttpContext *pContext);
HttpSqlCmd
*
httpNewSqlCmd
(
HttpContext
*
pContext
);
HttpSqlCmd
*
httpCurrSqlCmd
(
HttpContext
*
pContext
);
int32_t
httpCurSqlCmdPos
(
HttpContext
*
pContext
);
int32_t
httpCurSqlCmdPos
(
HttpContext
*
pContext
);
void
httpTrimTableName
(
char
*
name
);
void
httpTrimTableName
(
char
*
name
);
int32_t
httpShrinkTableName
(
HttpContext
*
pContext
,
int32_t
pos
,
char
*
name
);
char
*
httpGetCmdsString
(
HttpContext
*
pContext
,
int32_t
pos
);
char
*
httpGetCmdsString
(
HttpContext
*
pContext
,
int32_t
pos
);
#endif
src/plugins/http/src/httpGcHandle.c
浏览文件 @
2a7b9134
...
...
@@ -228,7 +228,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
cmd
->
values
=
refIdBuffer
;
cmd
->
table
=
aliasBuffer
;
cmd
->
numOfRows
=
0
;
// hack way as target flags
cmd
->
timestamp
=
httpAddToSqlCmdBufferWithSize
(
pContext
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
+
1
);
// hack way
cmd
->
timestamp
=
httpAddToSqlCmdBufferWithSize
(
pContext
,
HTTP_GC_TARGET_SIZE
+
1
);
// hack way
if
(
cmd
->
timestamp
==
-
1
)
{
httpWarn
(
"context:%p, fd:%d, user:%s, cant't malloc target size, sql buffer is full"
,
pContext
,
pContext
->
fd
,
...
...
src/plugins/http/src/httpGcJson.c
浏览文件 @
2a7b9134
...
...
@@ -129,48 +129,48 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
// for group by
if
(
groupFields
!=
-
1
)
{
char
target
[
TSDB_CODE_
HTTP_GC_TARGET_SIZE
]
=
{
0
};
char
target
[
HTTP_GC_TARGET_SIZE
]
=
{
0
};
int32_t
len
;
len
=
snprintf
(
target
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
,
"%s{"
,
aliasBuffer
);
len
=
snprintf
(
target
,
HTTP_GC_TARGET_SIZE
,
"%s{"
,
aliasBuffer
);
for
(
int32_t
i
=
dataFields
+
1
;
i
<
num_fields
;
i
++
){
switch
(
fields
[
i
].
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int8_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int16_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d"
,
fields
[
i
].
name
,
*
((
int16_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d,"
,
fields
[
i
].
name
,
*
((
int32_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%d,"
,
fields
[
i
].
name
,
*
((
int32_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%ld"
,
fields
[
i
].
name
,
*
((
int64_t
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%ld"
,
fields
[
i
].
name
,
*
((
int64_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.5f"
,
fields
[
i
].
name
,
*
((
float
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.5f"
,
fields
[
i
].
name
,
*
((
float
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.9f"
,
fields
[
i
].
name
,
*
((
double
*
)
row
[
i
]));
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%.9f"
,
fields
[
i
].
name
,
*
((
double
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
row
[
i
]
!=
NULL
){
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:"
,
fields
[
i
].
name
);
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:"
,
fields
[
i
].
name
);
memcpy
(
target
+
len
,
(
char
*
)
row
[
i
],
length
[
i
]);
len
=
strlen
(
target
);
}
break
;
default:
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%s"
,
fields
[
i
].
name
,
"-"
);
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"%s:%s"
,
fields
[
i
].
name
,
"-"
);
break
;
}
if
(
i
<
num_fields
-
1
){
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
", "
);
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
", "
);
}
}
len
+=
snprintf
(
target
+
len
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
-
len
,
"}"
);
len
+=
snprintf
(
target
+
len
,
HTTP_GC_TARGET_SIZE
-
len
,
"}"
);
if
(
strcmp
(
target
,
targetBuffer
)
!=
0
)
{
// first target not write this section
...
...
@@ -180,7 +180,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
// start new target
gcWriteTargetStartJson
(
jsonBuf
,
refIdBuffer
,
target
);
strncpy
(
targetBuffer
,
target
,
TSDB_CODE_
HTTP_GC_TARGET_SIZE
);
strncpy
(
targetBuffer
,
target
,
HTTP_GC_TARGET_SIZE
);
}
}
// end of group by
...
...
src/plugins/http/src/httpServer.c
浏览文件 @
2a7b9134
...
...
@@ -308,7 +308,11 @@ static bool httpReadData(HttpContext *pContext) {
httpInitParser
(
pParser
);
}
ASSERT
(
!
pParser
->
parsed
);
if
(
pParser
->
parsed
)
{
httpDebug
(
"context:%p, fd:%d, not in ready state, parsed:%d"
,
pContext
,
pContext
->
fd
,
pParser
->
parsed
);
return
false
;
}
pContext
->
accessTimes
++
;
pContext
->
lastAccessTime
=
taosGetTimestampSec
();
...
...
tests/test/c/CMakeLists.txt
浏览文件 @
2a7b9134
...
...
@@ -5,6 +5,12 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/mnode/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/tsdb/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/plugins/http/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_ENTERPRISE_DIR
}
/src/inc
)
IF
(
TD_LINUX
)
#add_executable(insertPerTable insertPerTable.c)
...
...
@@ -28,6 +34,10 @@ IF (TD_LINUX)
#add_executable(createNormalTable createNormalTable.c)
#target_link_libraries(createNormalTable taos_static tutil common pthread)
add_executable
(
queryPerformance queryPerformance.c
)
target_link_libraries
(
queryPerformance taos_static tutil common pthread
)
#add_executable(queryPerformance queryPerformance.c)
#target_link_libraries(queryPerformance taos_static tutil common pthread)
add_executable
(
httpTest httpTest.c
)
target_link_libraries
(
httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4
)
ENDIF
()
tests/test/c/httpTest.c
0 → 100644
浏览文件 @
2a7b9134
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "os.h"
#include "tglobal.h"
#include "taoserror.h"
#include "httpSystem.h"
void
signal_handler
(
int
signum
)
{
httpStopSystem
();
httpCleanUpSystem
();
exit
(
EXIT_SUCCESS
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
sigaction
act
;
act
.
sa_handler
=
signal_handler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGABRT
,
&
act
,
NULL
);
// Initialize the system
if
(
httpInitSystem
()
<
0
)
{
exit
(
EXIT_FAILURE
);
}
if
(
httpStartSystem
()
<
0
)
{
exit
(
EXIT_FAILURE
);
}
while
(
1
)
{
sleep
(
1000
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录