commit
2a7b913484
|
@ -36,7 +36,7 @@
|
||||||
#define HTTP_BUFFER_SIZE 8388608
|
#define HTTP_BUFFER_SIZE 8388608
|
||||||
#define HTTP_STEP_SIZE 4096 //http message get process step by step
|
#define HTTP_STEP_SIZE 4096 //http message get process step by step
|
||||||
#define HTTP_METHOD_SCANNER_SIZE 7 //http method fp size
|
#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_RETRY_TIMES 500
|
||||||
#define HTTP_WRITE_WAIT_TIME_MS 5
|
#define HTTP_WRITE_WAIT_TIME_MS 5
|
||||||
#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN)
|
#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN)
|
||||||
|
|
|
@ -29,10 +29,10 @@ void httpFreeMultiCmds(HttpContext *pContext);
|
||||||
|
|
||||||
HttpSqlCmd *httpNewSqlCmd(HttpContext *pContext);
|
HttpSqlCmd *httpNewSqlCmd(HttpContext *pContext);
|
||||||
HttpSqlCmd *httpCurrSqlCmd(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);
|
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
|
#endif
|
||||||
|
|
|
@ -228,7 +228,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
|
||||||
cmd->values = refIdBuffer;
|
cmd->values = refIdBuffer;
|
||||||
cmd->table = aliasBuffer;
|
cmd->table = aliasBuffer;
|
||||||
cmd->numOfRows = 0; // hack way as target flags
|
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) {
|
if (cmd->timestamp == -1) {
|
||||||
httpWarn("context:%p, fd:%d, user:%s, cant't malloc target size, sql buffer is full", pContext, pContext->fd,
|
httpWarn("context:%p, fd:%d, user:%s, cant't malloc target size, sql buffer is full", pContext, pContext->fd,
|
||||||
|
|
|
@ -129,48 +129,48 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
||||||
|
|
||||||
// for group by
|
// for group by
|
||||||
if (groupFields != -1) {
|
if (groupFields != -1) {
|
||||||
char target[TSDB_CODE_HTTP_GC_TARGET_SIZE] = {0};
|
char target[HTTP_GC_TARGET_SIZE] = {0};
|
||||||
int32_t len;
|
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++){
|
for (int32_t i = dataFields + 1; i<num_fields; i++){
|
||||||
switch (fields[i].type) {
|
switch (fields[i].type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_INT:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
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;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
if (row[i]!= NULL){
|
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]);
|
memcpy(target + len, (char *) row[i], length[i]);
|
||||||
len = strlen(target);
|
len = strlen(target);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if(i < num_fields - 1 ){
|
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) {
|
if (strcmp(target, targetBuffer) != 0) {
|
||||||
// first target not write this section
|
// first target not write this section
|
||||||
|
@ -180,7 +180,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
||||||
|
|
||||||
// start new target
|
// start new target
|
||||||
gcWriteTargetStartJson(jsonBuf, refIdBuffer, 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
|
} // end of group by
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,11 @@ static bool httpReadData(HttpContext *pContext) {
|
||||||
httpInitParser(pParser);
|
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->accessTimes++;
|
||||||
pContext->lastAccessTime = taosGetTimestampSec();
|
pContext->lastAccessTime = taosGetTimestampSec();
|
||||||
|
|
||||||
|
|
|
@ -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/os/inc)
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/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)
|
IF (TD_LINUX)
|
||||||
#add_executable(insertPerTable insertPerTable.c)
|
#add_executable(insertPerTable insertPerTable.c)
|
||||||
|
@ -28,6 +34,10 @@ IF (TD_LINUX)
|
||||||
#add_executable(createNormalTable createNormalTable.c)
|
#add_executable(createNormalTable createNormalTable.c)
|
||||||
#target_link_libraries(createNormalTable taos_static tutil common pthread)
|
#target_link_libraries(createNormalTable taos_static tutil common pthread)
|
||||||
|
|
||||||
add_executable(queryPerformance queryPerformance.c)
|
#add_executable(queryPerformance queryPerformance.c)
|
||||||
target_link_libraries(queryPerformance taos_static tutil common pthread)
|
#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()
|
ENDIF()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue