Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/tdb
This commit is contained in:
commit
a2b1908733
|
@ -5,7 +5,6 @@ AccessModifierOffset: -1
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignConsecutiveAssignments: false
|
AlignConsecutiveAssignments: false
|
||||||
AlignConsecutiveDeclarations: true
|
AlignConsecutiveDeclarations: true
|
||||||
AlignConsecutiveMacros: true
|
|
||||||
AlignEscapedNewlinesLeft: true
|
AlignEscapedNewlinesLeft: true
|
||||||
AlignOperands: true
|
AlignOperands: true
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
|
|
|
@ -574,11 +574,11 @@ typedef struct SMultiwayMergeInfo {
|
||||||
} SMultiwayMergeInfo;
|
} SMultiwayMergeInfo;
|
||||||
|
|
||||||
// todo support the disk-based sort
|
// todo support the disk-based sort
|
||||||
typedef struct SOrderOperatorInfo {
|
typedef struct SSortOperatorInfo {
|
||||||
int32_t colIndex;
|
int32_t colIndex;
|
||||||
int32_t order;
|
int32_t order;
|
||||||
SSDataBlock *pDataBlock;
|
SSDataBlock *pDataBlock;
|
||||||
} SOrderOperatorInfo;
|
} SSortOperatorInfo;
|
||||||
|
|
||||||
void appendUpstream(SOperatorInfo* p, SOperatorInfo* pUpstream);
|
void appendUpstream(SOperatorInfo* p, SOperatorInfo* pUpstream);
|
||||||
|
|
||||||
|
@ -609,7 +609,7 @@ SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
|
||||||
int32_t numOfOutput, SColumnInfo* pCols, int32_t numOfFilter);
|
int32_t numOfOutput, SColumnInfo* pCols, int32_t numOfFilter);
|
||||||
|
|
||||||
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pUpstream, int32_t numOfUpstream, SSchema* pSchema, int32_t numOfOutput);
|
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pUpstream, int32_t numOfUpstream, SSchema* pSchema, int32_t numOfOutput);
|
||||||
SOperatorInfo* createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, SOrderVal* pOrderVal);
|
SOperatorInfo* createSortOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, SOrderVal* pOrderVal);
|
||||||
|
|
||||||
SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
|
SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
|
||||||
SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
|
SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
|
||||||
|
|
|
@ -2301,7 +2301,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
||||||
}
|
}
|
||||||
|
|
||||||
case OP_Order: {
|
case OP_Order: {
|
||||||
pRuntimeEnv->proot = createOrderOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, &pQueryAttr->order);
|
pRuntimeEnv->proot = createSortOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, &pQueryAttr->order);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5516,7 +5516,7 @@ static SSDataBlock* doSort(void* param, bool* newgroup) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOrderOperatorInfo* pInfo = pOperator->info;
|
SSortOperatorInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
SSDataBlock* pBlock = NULL;
|
SSDataBlock* pBlock = NULL;
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -5556,8 +5556,8 @@ static SSDataBlock* doSort(void* param, bool* newgroup) {
|
||||||
return (pInfo->pDataBlock->info.rows > 0)? pInfo->pDataBlock:NULL;
|
return (pInfo->pDataBlock->info.rows > 0)? pInfo->pDataBlock:NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, SOrderVal* pOrderVal) {
|
SOperatorInfo *createSortOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, SOrderVal* pOrderVal) {
|
||||||
SOrderOperatorInfo* pInfo = calloc(1, sizeof(SOrderOperatorInfo));
|
SSortOperatorInfo* pInfo = calloc(1, sizeof(SSortOperatorInfo));
|
||||||
|
|
||||||
{
|
{
|
||||||
SSDataBlock* pDataBlock = calloc(1, sizeof(SSDataBlock));
|
SSDataBlock* pDataBlock = calloc(1, sizeof(SSDataBlock));
|
||||||
|
@ -6611,7 +6611,7 @@ static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SOrderOperatorInfo* pInfo = (SOrderOperatorInfo*) param;
|
SSortOperatorInfo* pInfo = (SSortOperatorInfo*) param;
|
||||||
pInfo->pDataBlock = blockDataDestroy(pInfo->pDataBlock);
|
pInfo->pDataBlock = blockDataDestroy(pInfo->pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,9 @@ int32_t create_topic() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char* sql = "select * from tu1";
|
/*const char* sql = "select * from tu1";*/
|
||||||
pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));
|
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/
|
||||||
|
pRes = taos_query(pConn, "create topic test_stb_topic_1 as select * from tu1");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create topic test_stb_topic_1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create topic test_stb_topic_1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
int32_t init_env() {
|
int32_t init_env() {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 7010);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ int32_t init_env() {
|
||||||
int32_t create_stream() {
|
int32_t create_stream() {
|
||||||
printf("create stream\n");
|
printf("create stream\n");
|
||||||
TAOS_RES* pRes;
|
TAOS_RES* pRes;
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 7010);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* 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_CONSUMER_H_
|
|
||||||
#define _TD_CONSUMER_H_
|
|
||||||
|
|
||||||
#include "tlist.h"
|
|
||||||
#include "tarray.h"
|
|
||||||
#include "hash.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//consumer handle
|
|
||||||
struct tmq_consumer_t;
|
|
||||||
typedef struct tmq_consumer_t tmq_consumer_t;
|
|
||||||
|
|
||||||
//consumer config
|
|
||||||
struct tmq_consumer_config_t;
|
|
||||||
typedef struct tmq_consumer_config_t tmq_consumer_config_t;
|
|
||||||
|
|
||||||
//response err
|
|
||||||
struct tmq_resp_err_t;
|
|
||||||
typedef struct tmq_resp_err_t tmq_resp_err_t;
|
|
||||||
|
|
||||||
struct tmq_message_t;
|
|
||||||
typedef struct tmq_message_t tmq_message_t;
|
|
||||||
|
|
||||||
struct tmq_col_batch_t;
|
|
||||||
typedef struct tmq_col_batch_t tmq_col_batch_t;
|
|
||||||
|
|
||||||
//get content of message
|
|
||||||
tmq_col_batch_t* tmq_get_msg_col_by_idx(tmq_message_t*, int32_t col_id);
|
|
||||||
tmq_col_batch_t* tmq_get_msg_col_by_name(tmq_message_t*, const char*);
|
|
||||||
|
|
||||||
//consumer config
|
|
||||||
int32_t tmq_conf_set(tmq_consumer_config_t* , const char* config_key, const char* config_value, char* errstr, int32_t errstr_cap);
|
|
||||||
|
|
||||||
//consumer initialization
|
|
||||||
//resouces are supposed to be free by users by calling tmq_consumer_destroy
|
|
||||||
tmq_consumer_t* tmq_consumer_new(tmq_consumer_config_t* , char* errstr, int32_t errstr_cap);
|
|
||||||
|
|
||||||
//subscribe
|
|
||||||
tmq_resp_err_t tmq_subscribe(tmq_consumer_t*, const SList*);
|
|
||||||
tmq_resp_err_t tmq_unsubscribe(tmq_consumer_t*);
|
|
||||||
|
|
||||||
//consume
|
|
||||||
//resouces are supposed to be free by users by calling tmq_message_destroy
|
|
||||||
tmq_message_t* tmq_consume_poll(tmq_consumer_t*, int64_t blocking_time);
|
|
||||||
|
|
||||||
//destroy message and free memory
|
|
||||||
void tmq_message_destroy(tmq_message_t*);
|
|
||||||
|
|
||||||
//close consumer
|
|
||||||
int32_t tmq_consumer_close(tmq_consumer_t*);
|
|
||||||
|
|
||||||
//destroy consumer
|
|
||||||
void tmq_consumer_destroy(tmq_message_t*);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_CONSUMER_H_*/
|
|
|
@ -26,9 +26,11 @@ extern "C" {
|
||||||
typedef void TAOS;
|
typedef void TAOS;
|
||||||
typedef void TAOS_STMT;
|
typedef void TAOS_STMT;
|
||||||
typedef void TAOS_RES;
|
typedef void TAOS_RES;
|
||||||
typedef void TAOS_STREAM;
|
|
||||||
typedef void TAOS_SUB;
|
|
||||||
typedef void **TAOS_ROW;
|
typedef void **TAOS_ROW;
|
||||||
|
#if 0
|
||||||
|
typedef void TAOS_STREAM;
|
||||||
|
#endif
|
||||||
|
typedef void TAOS_SUB;
|
||||||
|
|
||||||
// Data type definition
|
// Data type definition
|
||||||
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
|
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
|
||||||
|
@ -149,6 +151,7 @@ DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
|
||||||
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
|
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
|
||||||
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
|
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
|
||||||
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
|
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
|
||||||
|
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
|
||||||
|
|
||||||
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
||||||
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
||||||
|
@ -179,15 +182,20 @@ DLL_EXPORT int taos_errno(TAOS_RES *tres);
|
||||||
DLL_EXPORT void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param);
|
DLL_EXPORT void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param);
|
||||||
DLL_EXPORT void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param);
|
DLL_EXPORT void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param);
|
||||||
|
|
||||||
|
// Shuduo: temporary enable for app build
|
||||||
|
#if 1
|
||||||
typedef void (*__taos_sub_fn_t)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
|
typedef void (*__taos_sub_fn_t)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
|
||||||
DLL_EXPORT TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char *topic, const char *sql, __taos_sub_fn_t fp,
|
DLL_EXPORT TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char *topic, const char *sql, __taos_sub_fn_t fp,
|
||||||
void *param, int interval);
|
void *param, int interval);
|
||||||
DLL_EXPORT TAOS_RES *taos_consume(TAOS_SUB *tsub);
|
DLL_EXPORT TAOS_RES *taos_consume(TAOS_SUB *tsub);
|
||||||
DLL_EXPORT void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress);
|
DLL_EXPORT void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
DLL_EXPORT TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
|
DLL_EXPORT TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
|
||||||
int64_t stime, void *param, void (*callback)(void *));
|
int64_t stime, void *param, void (*callback)(void *));
|
||||||
DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
|
DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
|
||||||
|
#endif
|
||||||
|
|
||||||
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
||||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||||
|
@ -215,8 +223,12 @@ DLL_EXPORT tmq_list_t *tmq_list_new();
|
||||||
DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
|
DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
|
||||||
DLL_EXPORT void tmq_list_destroy(tmq_list_t *);
|
DLL_EXPORT void tmq_list_destroy(tmq_list_t *);
|
||||||
|
|
||||||
DLL_EXPORT tmq_t *tmq_consumer_new(void *conn, tmq_conf_t *conf, char *errstr, int32_t errstrLen);
|
// will be removed in 3.0
|
||||||
DLL_EXPORT tmq_t *tmq_consumer_new1(tmq_conf_t *conf, char *errstr, int32_t errstrLen);
|
DLL_EXPORT tmq_t *tmq_consumer_new(void *conn, tmq_conf_t *conf, char *errstr, int32_t errstrLen);
|
||||||
|
|
||||||
|
// will replace last one
|
||||||
|
DLL_EXPORT tmq_t *tmq_consumer_new1(tmq_conf_t *conf, char *errstr, int32_t errstrLen);
|
||||||
|
|
||||||
DLL_EXPORT const char *tmq_err2str(tmq_resp_err_t);
|
DLL_EXPORT const char *tmq_err2str(tmq_resp_err_t);
|
||||||
|
|
||||||
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
|
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
|
||||||
|
@ -255,20 +267,26 @@ int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message);
|
||||||
|
|
||||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||||
|
|
||||||
DLL_EXPORT TAOS_ROW tmq_get_row(tmq_message_t *message);
|
DLL_EXPORT TAOS_ROW tmq_get_row(tmq_message_t *message);
|
||||||
DLL_EXPORT char *tmq_get_topic_name(tmq_message_t *message);
|
DLL_EXPORT char *tmq_get_topic_name(tmq_message_t *message);
|
||||||
DLL_EXPORT void *tmq_get_topic_schema(tmq_t *tmq, const char *topic);
|
DLL_EXPORT int32_t tmq_get_vgroup_id(tmq_message_t *message);
|
||||||
DLL_EXPORT void tmq_message_destroy(tmq_message_t *tmq_message);
|
DLL_EXPORT int64_t tmq_get_request_offset(tmq_message_t *message);
|
||||||
|
DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
|
||||||
|
DLL_EXPORT TAOS_FIELD *tmq_get_fields(tmq_t *tmq, const char *topic);
|
||||||
|
DLL_EXPORT int32_t tmq_field_count(tmq_t *tmq, const char *topic);
|
||||||
|
DLL_EXPORT void tmq_message_destroy(tmq_message_t *tmq_message);
|
||||||
|
|
||||||
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
||||||
|
#if 0
|
||||||
DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS *taos, const char *name, const char *sql, int sqlLen);
|
DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS *taos, const char *name, const char *sql, int sqlLen);
|
||||||
|
#endif
|
||||||
|
|
||||||
DLL_EXPORT TAOS_RES *tmq_create_stream(TAOS *taos, const char *streamName, const char *tbName, const char *sql);
|
DLL_EXPORT TAOS_RES *tmq_create_stream(TAOS *taos, const char *streamName, const char *tbName, const char *sql);
|
||||||
|
|
||||||
/* -------------------------------- OTHER -------------------------------- */
|
/* ------------------------------ TMQ END -------------------------------- */
|
||||||
|
#if 1 // Shuduo: temporary enable for app build
|
||||||
typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
|
typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
|
||||||
|
#endif
|
||||||
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,16 +54,13 @@ typedef struct SColumnDataAgg {
|
||||||
} SColumnDataAgg;
|
} SColumnDataAgg;
|
||||||
|
|
||||||
typedef struct SDataBlockInfo {
|
typedef struct SDataBlockInfo {
|
||||||
STimeWindow window;
|
STimeWindow window;
|
||||||
int32_t rows;
|
int32_t rows;
|
||||||
int32_t rowSize;
|
int32_t rowSize;
|
||||||
int16_t numOfCols;
|
int16_t numOfCols;
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
union {
|
union {int64_t uid; int64_t blockId;};
|
||||||
int64_t uid;
|
int64_t groupId; // no need to serialize
|
||||||
int64_t blockId;
|
|
||||||
};
|
|
||||||
int64_t groupId; // no need to serialize
|
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
|
@ -96,6 +93,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
||||||
void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
||||||
|
void colDataDestroy(SColumnInfoData* pColData) ;
|
||||||
|
|
||||||
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||||
// WARNING: do not use info.numOfCols,
|
// WARNING: do not use info.numOfCols,
|
||||||
|
@ -103,13 +101,7 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
colDataDestroy(pColInfoData);
|
||||||
taosMemoryFreeClear(pColInfoData->varmeta.offset);
|
|
||||||
} else {
|
|
||||||
taosMemoryFreeClear(pColInfoData->nullbitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pColInfoData->pData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pBlock->pDataBlock);
|
taosArrayDestroy(pBlock->pDataBlock);
|
||||||
|
@ -205,6 +197,11 @@ typedef struct SGroupbyExpr {
|
||||||
bool groupbyTag; // group by tag or column
|
bool groupbyTag; // group by tag or column
|
||||||
} SGroupbyExpr;
|
} SGroupbyExpr;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FUNC_PARAM_TYPE_VALUE = 0,
|
||||||
|
FUNC_PARAM_TYPE_COLUMN,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct SFunctParam {
|
typedef struct SFunctParam {
|
||||||
int32_t type;
|
int32_t type;
|
||||||
SColumn* pCol;
|
SColumn* pCol;
|
||||||
|
|
|
@ -29,8 +29,9 @@ typedef struct SCorEpSet {
|
||||||
} SCorEpSet;
|
} SCorEpSet;
|
||||||
|
|
||||||
typedef struct SBlockOrderInfo {
|
typedef struct SBlockOrderInfo {
|
||||||
|
bool nullFirst;
|
||||||
int32_t order;
|
int32_t order;
|
||||||
int32_t colIndex;
|
int32_t slotId;
|
||||||
SColumnInfoData* pColData;
|
SColumnInfoData* pColData;
|
||||||
} SBlockOrderInfo;
|
} SBlockOrderInfo;
|
||||||
|
|
||||||
|
@ -101,6 +102,54 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
|
||||||
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \
|
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \
|
||||||
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
|
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
|
||||||
|
|
||||||
|
static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uint32_t currentRow) {
|
||||||
|
// There is a placehold for each NULL value of binary or nchar type.
|
||||||
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
|
pColumnInfoData->varmeta.offset[currentRow] = -1; // it is a null value of VAR type.
|
||||||
|
} else {
|
||||||
|
colDataSetNull_f(pColumnInfoData->nullbitmap, currentRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
pColumnInfoData->hasNull = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_TINYINT ||
|
||||||
|
pColumnInfoData->info.type == TSDB_DATA_TYPE_UTINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_BOOL);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(int8_t*)p = *(int8_t*)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendInt16(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int16_t* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_SMALLINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_USMALLINT);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(int16_t*)p = *(int16_t*)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendInt32(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int32_t* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_INT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UINT);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(int32_t*)p = *(int32_t*)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendInt64(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int64_t* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_BIGINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UBIGINT);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(int64_t*)p = *(int64_t*)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendFloat(SColumnInfoData* pColumnInfoData, uint32_t currentRow, float* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_FLOAT);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(float*)p = *(float*)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t colDataAppendDouble(SColumnInfoData* pColumnInfoData, uint32_t currentRow, double* v) {
|
||||||
|
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_DOUBLE);
|
||||||
|
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||||
|
*(double*)p = *(double*)v;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource,
|
||||||
uint32_t numOfRow2);
|
uint32_t numOfRow2);
|
||||||
|
@ -128,7 +177,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock);
|
||||||
|
|
||||||
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols);
|
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols);
|
||||||
|
|
||||||
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
|
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
||||||
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
|
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
|
||||||
|
|
||||||
int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows);
|
int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||||
|
|
|
@ -63,7 +63,7 @@ extern "C" {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
|
col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
|
||||||
int32_t type : 8; // column type
|
int32_t type : 8; // column type
|
||||||
int32_t bytes : 24; // column bytes (restore to int32_t in case of misuse)
|
int32_t bytes : 24; // column bytes (0~16M)
|
||||||
int32_t sma : 8; // block SMA: 0, no SMA, 1, sum/min/max, 2, ...
|
int32_t sma : 8; // block SMA: 0, no SMA, 1, sum/min/max, 2, ...
|
||||||
int32_t offset : 24; // point offset in STpRow after the header part.
|
int32_t offset : 24; // point offset in STpRow after the header part.
|
||||||
} STColumn;
|
} STColumn;
|
||||||
|
@ -81,12 +81,12 @@ typedef struct {
|
||||||
|
|
||||||
// ----------------- TSDB SCHEMA DEFINITION
|
// ----------------- TSDB SCHEMA DEFINITION
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t version; // version
|
int32_t numOfCols; // Number of columns appended
|
||||||
int32_t numOfCols; // Number of columns appended
|
schema_ver_t version; // schema version
|
||||||
int32_t tlen; // maximum length of a STpRow without the header part (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) +
|
uint16_t flen; // First part length in a STpRow after the header part
|
||||||
// (bytes))
|
int32_t vlen; // pure value part length, excluded the overhead (bytes only)
|
||||||
uint16_t flen; // First part length in a STpRow after the header part
|
int32_t tlen; // maximum length of a STpRow without the header part
|
||||||
uint16_t vlen; // pure value part length, excluded the overhead (bytes only)
|
// (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + (bytes))
|
||||||
STColumn columns[];
|
STColumn columns[];
|
||||||
} STSchema;
|
} STSchema;
|
||||||
|
|
||||||
|
@ -120,13 +120,13 @@ static FORCE_INLINE STColumn *tdGetColOfID(STSchema *pSchema, int16_t colId) {
|
||||||
|
|
||||||
// ----------------- SCHEMA BUILDER DEFINITION
|
// ----------------- SCHEMA BUILDER DEFINITION
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t tCols;
|
int32_t tCols;
|
||||||
int32_t nCols;
|
int32_t nCols;
|
||||||
int32_t tlen;
|
schema_ver_t version;
|
||||||
uint16_t flen;
|
uint16_t flen;
|
||||||
uint16_t vlen;
|
int32_t vlen;
|
||||||
int32_t version;
|
int32_t tlen;
|
||||||
STColumn *columns;
|
STColumn *columns;
|
||||||
} STSchemaBuilder;
|
} STSchemaBuilder;
|
||||||
|
|
||||||
#define TD_VTYPE_BITS 2 // val type
|
#define TD_VTYPE_BITS 2 // val type
|
||||||
|
@ -136,9 +136,9 @@ typedef struct {
|
||||||
#define TD_BITMAP_BYTES(cnt) (ceil((double)cnt / TD_VTYPE_PARTS))
|
#define TD_BITMAP_BYTES(cnt) (ceil((double)cnt / TD_VTYPE_PARTS))
|
||||||
#define TD_BIT_TO_BYTES(cnt) (ceil((double)cnt / 8))
|
#define TD_BIT_TO_BYTES(cnt) (ceil((double)cnt / 8))
|
||||||
|
|
||||||
int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
|
int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
||||||
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
|
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||||
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, col_id_t colId, col_bytes_t bytes);
|
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, col_id_t colId, col_bytes_t bytes);
|
||||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ typedef struct {
|
||||||
int8_t createType;
|
int8_t createType;
|
||||||
int8_t superUser; // denote if it is a super user or not
|
int8_t superUser; // denote if it is a super user or not
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
} SCreateUserReq;
|
} SCreateUserReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
|
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
|
||||||
|
@ -373,7 +373,7 @@ typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
char dbname[TSDB_DB_FNAME_LEN];
|
char dbname[TSDB_DB_FNAME_LEN];
|
||||||
} SAlterUserReq;
|
} SAlterUserReq;
|
||||||
|
|
||||||
|
@ -565,8 +565,10 @@ typedef struct {
|
||||||
SArray* pVgroupInfos; // Array of SVgroupInfo
|
SArray* pVgroupInfos; // Array of SVgroupInfo
|
||||||
} SUseDbRsp;
|
} SUseDbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
|
||||||
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
||||||
|
int32_t tSerializeSUseDbRspImp(SCoder* pEncoder, const SUseDbRsp* pRsp);
|
||||||
|
int32_t tDeserializeSUseDbRspImp(SCoder* pDecoder, SUseDbRsp* pRsp);
|
||||||
void tFreeSUsedbRsp(SUseDbRsp* pRsp);
|
void tFreeSUsedbRsp(SUseDbRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -799,7 +801,10 @@ typedef struct SVgroupInfo {
|
||||||
uint32_t hashBegin;
|
uint32_t hashBegin;
|
||||||
uint32_t hashEnd;
|
uint32_t hashEnd;
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
union {
|
||||||
|
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
||||||
|
int32_t taskId; // used in stream
|
||||||
|
};
|
||||||
} SVgroupInfo;
|
} SVgroupInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2210,23 +2215,6 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int64_t uid;
|
|
||||||
int32_t numOfRows;
|
|
||||||
char* colData;
|
|
||||||
} SMqTbData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char topicName[TSDB_TOPIC_FNAME_LEN];
|
|
||||||
int64_t committedOffset;
|
|
||||||
int64_t reqOffset;
|
|
||||||
int64_t rspOffset;
|
|
||||||
int32_t skipLogNum;
|
|
||||||
int32_t bodyLen;
|
|
||||||
int32_t numOfTb;
|
|
||||||
SMqTbData* tbData;
|
|
||||||
} SMqTopicData;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t mqMsgType;
|
int8_t mqMsgType;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
@ -2254,8 +2242,11 @@ typedef struct {
|
||||||
} SMqSubVgEp;
|
} SMqSubVgEp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||||
SArray* vgs; // SArray<SMqSubVgEp>
|
int8_t isSchemaAdaptive;
|
||||||
|
SArray* vgs; // SArray<SMqSubVgEp>
|
||||||
|
int32_t numOfFields;
|
||||||
|
TAOS_FIELD* fields;
|
||||||
} SMqSubTopicEp;
|
} SMqSubTopicEp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2276,32 +2267,6 @@ typedef struct {
|
||||||
SArray* topics; // SArray<SMqSubTopicEp>
|
SArray* topics; // SArray<SMqSubTopicEp>
|
||||||
} SMqCMGetSubEpRsp;
|
} SMqCMGetSubEpRsp;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t curBlock;
|
|
||||||
int32_t curRow;
|
|
||||||
void** uData;
|
|
||||||
} SMqRowIter;
|
|
||||||
|
|
||||||
struct tmq_message_t {
|
|
||||||
SMqPollRsp msg;
|
|
||||||
void* vg;
|
|
||||||
SMqRowIter iter;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct tmq_message_t {
|
|
||||||
SMqRspHead head;
|
|
||||||
union {
|
|
||||||
SMqPollRsp consumeRsp;
|
|
||||||
SMqCMGetSubEpRsp getEpRsp;
|
|
||||||
};
|
|
||||||
void* extra;
|
|
||||||
int32_t curBlock;
|
|
||||||
int32_t curRow;
|
|
||||||
void** uData;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { taosArrayDestroy(pSubTopicEp->vgs); }
|
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { taosArrayDestroy(pSubTopicEp->vgs); }
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
|
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
|
||||||
|
@ -2326,17 +2291,21 @@ static FORCE_INLINE void tDeleteSMqCMGetSubEpRsp(SMqCMGetSubEpRsp* pRsp) {
|
||||||
static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) {
|
static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeString(buf, pTopicEp->topic);
|
tlen += taosEncodeString(buf, pTopicEp->topic);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pTopicEp->isSchemaAdaptive);
|
||||||
int32_t sz = taosArrayGetSize(pTopicEp->vgs);
|
int32_t sz = taosArrayGetSize(pTopicEp->vgs);
|
||||||
tlen += taosEncodeFixedI32(buf, sz);
|
tlen += taosEncodeFixedI32(buf, sz);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqSubVgEp* pVgEp = (SMqSubVgEp*)taosArrayGet(pTopicEp->vgs, i);
|
SMqSubVgEp* pVgEp = (SMqSubVgEp*)taosArrayGet(pTopicEp->vgs, i);
|
||||||
tlen += tEncodeSMqSubVgEp(buf, pVgEp);
|
tlen += tEncodeSMqSubVgEp(buf, pVgEp);
|
||||||
}
|
}
|
||||||
|
tlen += taosEncodeFixedI32(buf, pTopicEp->numOfFields);
|
||||||
|
// tlen += taosEncodeBinary(buf, pTopicEp->fields, pTopicEp->numOfFields * sizeof(TAOS_FIELD));
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp) {
|
static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp) {
|
||||||
buf = taosDecodeStringTo(buf, pTopicEp->topic);
|
buf = taosDecodeStringTo(buf, pTopicEp->topic);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pTopicEp->isSchemaAdaptive);
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
buf = taosDecodeFixedI32(buf, &sz);
|
buf = taosDecodeFixedI32(buf, &sz);
|
||||||
pTopicEp->vgs = taosArrayInit(sz, sizeof(SMqSubVgEp));
|
pTopicEp->vgs = taosArrayInit(sz, sizeof(SMqSubVgEp));
|
||||||
|
@ -2348,6 +2317,8 @@ static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicE
|
||||||
buf = tDecodeSMqSubVgEp(buf, &vgEp);
|
buf = tDecodeSMqSubVgEp(buf, &vgEp);
|
||||||
taosArrayPush(pTopicEp->vgs, &vgEp);
|
taosArrayPush(pTopicEp->vgs, &vgEp);
|
||||||
}
|
}
|
||||||
|
buf = taosDecodeFixedI32(buf, &pTopicEp->numOfFields);
|
||||||
|
// buf = taosDecodeBinary(buf, (void**)&pTopicEp->fields, pTopicEp->numOfFields * sizeof(TAOS_FIELD));
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
typedef struct SRpcMsg SRpcMsg;
|
typedef struct SRpcMsg SRpcMsg;
|
||||||
typedef struct SEpSet SEpSet;
|
typedef struct SEpSet SEpSet;
|
||||||
typedef struct SMgmtWrapper SMgmtWrapper;
|
typedef struct SMgmtWrapper SMgmtWrapper;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
QUERY_QUEUE,
|
QUERY_QUEUE,
|
||||||
FETCH_QUEUE,
|
FETCH_QUEUE,
|
||||||
|
@ -38,24 +39,31 @@ typedef enum {
|
||||||
|
|
||||||
typedef int32_t (*PutToQueueFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
typedef int32_t (*PutToQueueFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
||||||
typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueType qtype);
|
typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueType qtype);
|
||||||
typedef int32_t (*SendReqFp)(SMgmtWrapper* pWrapper, SEpSet* epSet, SRpcMsg* pReq);
|
typedef int32_t (*SendReqFp)(SMgmtWrapper* pWrapper, const SEpSet* epSet, SRpcMsg* pReq);
|
||||||
typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
||||||
typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, SRpcMsg* pRsp);
|
typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp);
|
||||||
|
typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg);
|
||||||
|
typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMgmtWrapper* pWrapper;
|
SMgmtWrapper* pWrapper;
|
||||||
PutToQueueFp queueFps[QUEUE_MAX];
|
PutToQueueFp queueFps[QUEUE_MAX];
|
||||||
GetQueueSizeFp qsizeFp;
|
GetQueueSizeFp qsizeFp;
|
||||||
SendReqFp sendReqFp;
|
SendReqFp sendReqFp;
|
||||||
SendMnodeReqFp sendMnodeReqFp;
|
SendMnodeReqFp sendMnodeReqFp;
|
||||||
SendRspFp sendRspFp;
|
SendRspFp sendRspFp;
|
||||||
|
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
||||||
|
ReleaseHandleFp releaseHandleFp;
|
||||||
} SMsgCb;
|
} SMsgCb;
|
||||||
|
|
||||||
|
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb);
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
|
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
||||||
int32_t tmsgSendReq(const SMsgCb* pMsgCb, SEpSet* epSet, SRpcMsg* pReq);
|
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
|
||||||
int32_t tmsgSendMnodeReq(const SMsgCb* pMsgCb, SRpcMsg* pReq);
|
int32_t tmsgSendMnodeReq(const SMsgCb* pMsgCb, SRpcMsg* pReq);
|
||||||
void tmsgSendRsp(const SMsgCb* pMsgCb, SRpcMsg* pRsp);
|
void tmsgSendRsp(const SRpcMsg* pRsp);
|
||||||
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
|
||||||
|
void tmsgReleaseHandle(void* handle, int8_t type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,102 +82,111 @@
|
||||||
#define TK_SINGLE_STABLE 64
|
#define TK_SINGLE_STABLE 64
|
||||||
#define TK_STREAM_MODE 65
|
#define TK_STREAM_MODE 65
|
||||||
#define TK_RETENTIONS 66
|
#define TK_RETENTIONS 66
|
||||||
#define TK_FILE_FACTOR 67
|
#define TK_TABLE 67
|
||||||
#define TK_NK_FLOAT 68
|
#define TK_NK_LP 68
|
||||||
#define TK_TABLE 69
|
#define TK_NK_RP 69
|
||||||
#define TK_NK_LP 70
|
#define TK_STABLE 70
|
||||||
#define TK_NK_RP 71
|
#define TK_ADD 71
|
||||||
#define TK_STABLE 72
|
#define TK_COLUMN 72
|
||||||
#define TK_ADD 73
|
#define TK_MODIFY 73
|
||||||
#define TK_COLUMN 74
|
#define TK_RENAME 74
|
||||||
#define TK_MODIFY 75
|
#define TK_TAG 75
|
||||||
#define TK_RENAME 76
|
#define TK_SET 76
|
||||||
#define TK_TAG 77
|
#define TK_NK_EQ 77
|
||||||
#define TK_SET 78
|
#define TK_USING 78
|
||||||
#define TK_NK_EQ 79
|
#define TK_TAGS 79
|
||||||
#define TK_USING 80
|
#define TK_NK_DOT 80
|
||||||
#define TK_TAGS 81
|
#define TK_NK_COMMA 81
|
||||||
#define TK_NK_DOT 82
|
#define TK_COMMENT 82
|
||||||
#define TK_NK_COMMA 83
|
#define TK_BOOL 83
|
||||||
#define TK_COMMENT 84
|
#define TK_TINYINT 84
|
||||||
#define TK_BOOL 85
|
#define TK_SMALLINT 85
|
||||||
#define TK_TINYINT 86
|
#define TK_INT 86
|
||||||
#define TK_SMALLINT 87
|
#define TK_INTEGER 87
|
||||||
#define TK_INT 88
|
#define TK_BIGINT 88
|
||||||
#define TK_INTEGER 89
|
#define TK_FLOAT 89
|
||||||
#define TK_BIGINT 90
|
#define TK_DOUBLE 90
|
||||||
#define TK_FLOAT 91
|
#define TK_BINARY 91
|
||||||
#define TK_DOUBLE 92
|
#define TK_TIMESTAMP 92
|
||||||
#define TK_BINARY 93
|
#define TK_NCHAR 93
|
||||||
#define TK_TIMESTAMP 94
|
#define TK_UNSIGNED 94
|
||||||
#define TK_NCHAR 95
|
#define TK_JSON 95
|
||||||
#define TK_UNSIGNED 96
|
#define TK_VARCHAR 96
|
||||||
#define TK_JSON 97
|
#define TK_MEDIUMBLOB 97
|
||||||
#define TK_VARCHAR 98
|
#define TK_BLOB 98
|
||||||
#define TK_MEDIUMBLOB 99
|
#define TK_VARBINARY 99
|
||||||
#define TK_BLOB 100
|
#define TK_DECIMAL 100
|
||||||
#define TK_VARBINARY 101
|
#define TK_SMA 101
|
||||||
#define TK_DECIMAL 102
|
#define TK_ROLLUP 102
|
||||||
#define TK_SMA 103
|
#define TK_FILE_FACTOR 103
|
||||||
#define TK_ROLLUP 104
|
#define TK_NK_FLOAT 104
|
||||||
#define TK_SHOW 105
|
#define TK_DELAY 105
|
||||||
#define TK_DATABASES 106
|
#define TK_SHOW 106
|
||||||
#define TK_TABLES 107
|
#define TK_DATABASES 107
|
||||||
#define TK_STABLES 108
|
#define TK_TABLES 108
|
||||||
#define TK_MNODES 109
|
#define TK_STABLES 109
|
||||||
#define TK_MODULES 110
|
#define TK_MNODES 110
|
||||||
#define TK_QNODES 111
|
#define TK_MODULES 111
|
||||||
#define TK_FUNCTIONS 112
|
#define TK_QNODES 112
|
||||||
#define TK_INDEXES 113
|
#define TK_FUNCTIONS 113
|
||||||
#define TK_FROM 114
|
#define TK_INDEXES 114
|
||||||
#define TK_LIKE 115
|
#define TK_FROM 115
|
||||||
#define TK_INDEX 116
|
#define TK_LIKE 116
|
||||||
#define TK_FULLTEXT 117
|
#define TK_INDEX 117
|
||||||
#define TK_FUNCTION 118
|
#define TK_FULLTEXT 118
|
||||||
#define TK_INTERVAL 119
|
#define TK_FUNCTION 119
|
||||||
#define TK_TOPIC 120
|
#define TK_INTERVAL 120
|
||||||
#define TK_AS 121
|
#define TK_TOPIC 121
|
||||||
#define TK_NK_BOOL 122
|
#define TK_AS 122
|
||||||
#define TK_NK_VARIABLE 123
|
#define TK_NK_BOOL 123
|
||||||
#define TK_BETWEEN 124
|
#define TK_NULL 124
|
||||||
#define TK_IS 125
|
#define TK_NK_VARIABLE 125
|
||||||
#define TK_NULL 126
|
#define TK_NK_UNDERLINE 126
|
||||||
#define TK_NK_LT 127
|
#define TK_ROWTS 127
|
||||||
#define TK_NK_GT 128
|
#define TK_TBNAME 128
|
||||||
#define TK_NK_LE 129
|
#define TK_QSTARTTS 129
|
||||||
#define TK_NK_GE 130
|
#define TK_QENDTS 130
|
||||||
#define TK_NK_NE 131
|
#define TK_WSTARTTS 131
|
||||||
#define TK_MATCH 132
|
#define TK_WENDTS 132
|
||||||
#define TK_NMATCH 133
|
#define TK_WDURATION 133
|
||||||
#define TK_IN 134
|
#define TK_BETWEEN 134
|
||||||
#define TK_JOIN 135
|
#define TK_IS 135
|
||||||
#define TK_INNER 136
|
#define TK_NK_LT 136
|
||||||
#define TK_SELECT 137
|
#define TK_NK_GT 137
|
||||||
#define TK_DISTINCT 138
|
#define TK_NK_LE 138
|
||||||
#define TK_WHERE 139
|
#define TK_NK_GE 139
|
||||||
#define TK_PARTITION 140
|
#define TK_NK_NE 140
|
||||||
#define TK_BY 141
|
#define TK_MATCH 141
|
||||||
#define TK_SESSION 142
|
#define TK_NMATCH 142
|
||||||
#define TK_STATE_WINDOW 143
|
#define TK_IN 143
|
||||||
#define TK_SLIDING 144
|
#define TK_JOIN 144
|
||||||
#define TK_FILL 145
|
#define TK_INNER 145
|
||||||
#define TK_VALUE 146
|
#define TK_SELECT 146
|
||||||
#define TK_NONE 147
|
#define TK_DISTINCT 147
|
||||||
#define TK_PREV 148
|
#define TK_WHERE 148
|
||||||
#define TK_LINEAR 149
|
#define TK_PARTITION 149
|
||||||
#define TK_NEXT 150
|
#define TK_BY 150
|
||||||
#define TK_GROUP 151
|
#define TK_SESSION 151
|
||||||
#define TK_HAVING 152
|
#define TK_STATE_WINDOW 152
|
||||||
#define TK_ORDER 153
|
#define TK_SLIDING 153
|
||||||
#define TK_SLIMIT 154
|
#define TK_FILL 154
|
||||||
#define TK_SOFFSET 155
|
#define TK_VALUE 155
|
||||||
#define TK_LIMIT 156
|
#define TK_NONE 156
|
||||||
#define TK_OFFSET 157
|
#define TK_PREV 157
|
||||||
#define TK_ASC 158
|
#define TK_LINEAR 158
|
||||||
#define TK_DESC 159
|
#define TK_NEXT 159
|
||||||
#define TK_NULLS 160
|
#define TK_GROUP 160
|
||||||
#define TK_FIRST 161
|
#define TK_HAVING 161
|
||||||
#define TK_LAST 162
|
#define TK_ORDER 162
|
||||||
|
#define TK_SLIMIT 163
|
||||||
|
#define TK_SOFFSET 164
|
||||||
|
#define TK_LIMIT 165
|
||||||
|
#define TK_OFFSET 166
|
||||||
|
#define TK_ASC 167
|
||||||
|
#define TK_DESC 168
|
||||||
|
#define TK_NULLS 169
|
||||||
|
#define TK_FIRST 170
|
||||||
|
#define TK_LAST 171
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef uint8_t TDRowValT;
|
||||||
typedef int16_t col_id_t;
|
typedef int16_t col_id_t;
|
||||||
typedef int8_t col_type_t;
|
typedef int8_t col_type_t;
|
||||||
typedef int32_t col_bytes_t;
|
typedef int32_t col_bytes_t;
|
||||||
|
typedef uint16_t schema_ver_t;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tcommon.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "tcommon.h"
|
||||||
|
|
||||||
typedef void* qTaskInfo_t;
|
typedef void* qTaskInfo_t;
|
||||||
typedef void* DataSinkHandle;
|
typedef void* DataSinkHandle;
|
||||||
|
@ -36,7 +36,7 @@ typedef struct SReadHandle {
|
||||||
|
|
||||||
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
||||||
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
|
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the exec task for streaming mode
|
* Create the exec task for streaming mode
|
||||||
* @param pMsg
|
* @param pMsg
|
||||||
|
@ -54,6 +54,16 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle);
|
||||||
*/
|
*/
|
||||||
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type);
|
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set multiple input data blocks for the stream scan.
|
||||||
|
* @param tinfo
|
||||||
|
* @param pBlocks
|
||||||
|
* @param numOfInputBlock
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the table id list, add or remove.
|
* Update the table id list, add or remove.
|
||||||
*
|
*
|
||||||
|
@ -86,16 +96,6 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
*/
|
*/
|
||||||
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds);
|
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds);
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the produced results information, if current query is not paused or completed,
|
|
||||||
* this function will be blocked to wait for the query execution completed or paused,
|
|
||||||
* in which case enough results have been produced already.
|
|
||||||
*
|
|
||||||
* @param tinfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int32_t qRetrieveQueryResultInfo(qTaskInfo_t tinfo, bool* buildRes, void* pRspContext);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kill the ongoing query and free the query handle and corresponding resources automatically
|
* kill the ongoing query and free the query handle and corresponding resources automatically
|
||||||
* @param tinfo qhandle
|
* @param tinfo qhandle
|
||||||
|
@ -158,50 +158,6 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
|
||||||
*/
|
*/
|
||||||
int32_t qUpdateQueriedTableIdList(qTaskInfo_t tinfo, int64_t uid, int32_t type);
|
int32_t qUpdateQueriedTableIdList(qTaskInfo_t tinfo, int64_t uid, int32_t type);
|
||||||
|
|
||||||
//================================================================================================
|
|
||||||
// query handle management
|
|
||||||
/**
|
|
||||||
* Query handle mgmt object
|
|
||||||
* @param vgId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void* qOpenTaskMgmt(int32_t vgId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* broadcast the close information and wait for all query stop.
|
|
||||||
* @param pExecutor
|
|
||||||
*/
|
|
||||||
void qTaskMgmtNotifyClosing(void* pExecutor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-open the query handle management module when opening the vnode again.
|
|
||||||
* @param pExecutor
|
|
||||||
*/
|
|
||||||
void qQueryMgmtReOpen(void* pExecutor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close query mgmt and clean up resources.
|
|
||||||
* @param pExecutor
|
|
||||||
*/
|
|
||||||
void qCleanupTaskMgmt(void* pExecutor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the query into the query mgmt object
|
|
||||||
* @param pMgmt
|
|
||||||
* @param qId
|
|
||||||
* @param qInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void** qRegisterTask(void* pMgmt, uint64_t qId, void* qInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* acquire the query handle according to the key from query mgmt object.
|
|
||||||
* @param pMgmt
|
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void** qAcquireTask(void* pMgmt, uint64_t key);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* release the query handle and decrease the reference count in cache
|
* release the query handle and decrease the reference count in cache
|
||||||
* @param pMgmt
|
* @param pMgmt
|
||||||
|
@ -211,14 +167,6 @@ void** qAcquireTask(void* pMgmt, uint64_t key);
|
||||||
*/
|
*/
|
||||||
void** qReleaseTask(void* pMgmt, void* pQInfo, bool freeHandle);
|
void** qReleaseTask(void* pMgmt, void* pQInfo, bool freeHandle);
|
||||||
|
|
||||||
/**
|
|
||||||
* De-register the query handle from the management module and free it immediately.
|
|
||||||
* @param pMgmt
|
|
||||||
* @param pQInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void** qDeregisterQInfo(void* pMgmt, void* pQInfo);
|
|
||||||
|
|
||||||
void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -27,16 +27,22 @@ extern "C" {
|
||||||
struct SqlFunctionCtx;
|
struct SqlFunctionCtx;
|
||||||
struct SResultRowEntryInfo;
|
struct SResultRowEntryInfo;
|
||||||
|
|
||||||
typedef struct SFunctionNode SFunctionNode;
|
struct SFunctionNode;
|
||||||
|
typedef struct SScalarParam SScalarParam;
|
||||||
|
|
||||||
typedef struct SFuncExecEnv {
|
typedef struct SFuncExecEnv {
|
||||||
int32_t calcMemSize;
|
int32_t calcMemSize;
|
||||||
} SFuncExecEnv;
|
} SFuncExecEnv;
|
||||||
|
|
||||||
typedef bool (*FExecGetEnv)(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
typedef bool (*FExecGetEnv)(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
typedef bool (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo);
|
typedef bool (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo);
|
||||||
typedef void (*FExecProcess)(struct SqlFunctionCtx *pCtx);
|
typedef void (*FExecProcess)(struct SqlFunctionCtx *pCtx);
|
||||||
typedef void (*FExecFinalize)(struct SqlFunctionCtx *pCtx);
|
typedef void (*FExecFinalize)(struct SqlFunctionCtx *pCtx);
|
||||||
|
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
|
typedef struct SScalarFuncExecFuncs {
|
||||||
|
FScalarExecProcess process;
|
||||||
|
} SScalarFuncExecFuncs;
|
||||||
|
|
||||||
typedef struct SFuncExecFuncs {
|
typedef struct SFuncExecFuncs {
|
||||||
FExecGetEnv getEnv;
|
FExecGetEnv getEnv;
|
||||||
|
@ -191,6 +197,7 @@ typedef struct SqlFunctionCtx {
|
||||||
SPoint1 start;
|
SPoint1 start;
|
||||||
SPoint1 end;
|
SPoint1 end;
|
||||||
SFuncExecFuncs fpSet;
|
SFuncExecFuncs fpSet;
|
||||||
|
SScalarFuncExecFuncs sfp;
|
||||||
} SqlFunctionCtx;
|
} SqlFunctionCtx;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -203,7 +210,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct tExprNode {
|
typedef struct tExprNode {
|
||||||
uint8_t nodeType;
|
int32_t nodeType;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int32_t optr; // binary operator
|
int32_t optr; // binary operator
|
||||||
|
@ -219,7 +226,7 @@ typedef struct tExprNode {
|
||||||
char functionName[FUNCTIONS_NAME_MAX_LENGTH]; // todo refactor
|
char functionName[FUNCTIONS_NAME_MAX_LENGTH]; // todo refactor
|
||||||
int32_t functionId;
|
int32_t functionId;
|
||||||
int32_t num;
|
int32_t num;
|
||||||
SFunctionNode *pFunctNode;
|
struct SFunctionNode *pFunctNode;
|
||||||
// Note that the attribute of pChild is not the parameter of function, it is the columns that involved in the
|
// Note that the attribute of pChild is not the parameter of function, it is the columns that involved in the
|
||||||
// calculation instead.
|
// calculation instead.
|
||||||
// E.g., Cov(col1, col2), the column information, w.r.t. the col1 and col2, is kept in pChild nodes.
|
// E.g., Cov(col1, col2), the column information, w.r.t. the col1 and col2, is kept in pChild nodes.
|
||||||
|
@ -227,6 +234,10 @@ typedef struct tExprNode {
|
||||||
// operator and is kept in the attribute of _node.
|
// operator and is kept in the attribute of _node.
|
||||||
struct tExprNode **pChild;
|
struct tExprNode **pChild;
|
||||||
} _function;
|
} _function;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct SNode* pRootNode;
|
||||||
|
} _optrRoot;
|
||||||
};
|
};
|
||||||
} tExprNode;
|
} tExprNode;
|
||||||
|
|
||||||
|
@ -250,25 +261,11 @@ typedef struct SAggFunctionInfo {
|
||||||
int32_t (*dataReqFunc)(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId);
|
int32_t (*dataReqFunc)(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId);
|
||||||
} SAggFunctionInfo;
|
} SAggFunctionInfo;
|
||||||
|
|
||||||
typedef struct SScalarParam {
|
struct SScalarParam {
|
||||||
void *data;
|
SColumnInfoData *columnData;
|
||||||
union {
|
SHashObj *pHashFilter;
|
||||||
SColumnInfoData *columnData;
|
int32_t numOfRows;
|
||||||
void *data;
|
};
|
||||||
} orig;
|
|
||||||
char *bitmap;
|
|
||||||
bool dataInBlock;
|
|
||||||
int32_t num;
|
|
||||||
int32_t type;
|
|
||||||
int32_t bytes;
|
|
||||||
} SScalarParam;
|
|
||||||
|
|
||||||
typedef struct SScalarFunctionInfo {
|
|
||||||
char name[FUNCTIONS_NAME_MAX_LENGTH];
|
|
||||||
int8_t type; // scalar function or aggregation function
|
|
||||||
uint32_t functionId; // index of scalar function
|
|
||||||
void (*process)(struct SScalarParam* pOutput, size_t numOfInput, const struct SScalarParam *pInput);
|
|
||||||
} SScalarFunctionInfo;
|
|
||||||
|
|
||||||
typedef struct SMultiFunctionsDesc {
|
typedef struct SMultiFunctionsDesc {
|
||||||
bool stableQuery;
|
bool stableQuery;
|
||||||
|
|
|
@ -96,20 +96,22 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_SERVER_SERSION,
|
FUNCTION_TYPE_SERVER_SERSION,
|
||||||
FUNCTION_TYPE_SERVER_STATUS,
|
FUNCTION_TYPE_SERVER_STATUS,
|
||||||
FUNCTION_TYPE_CURRENT_USER,
|
FUNCTION_TYPE_CURRENT_USER,
|
||||||
FUNCTION_TYPE_USER
|
FUNCTION_TYPE_USER,
|
||||||
|
|
||||||
|
// pseudo column function
|
||||||
|
FUNCTION_TYPE_ROWTS = 3500,
|
||||||
|
FUNCTION_TYPE_TBNAME,
|
||||||
|
FUNCTION_TYPE_QSTARTTS,
|
||||||
|
FUNCTION_TYPE_QENDTS,
|
||||||
|
FUNCTION_TYPE_WSTARTTS,
|
||||||
|
FUNCTION_TYPE_WENDTS,
|
||||||
|
FUNCTION_TYPE_WDURATION
|
||||||
} EFunctionType;
|
} EFunctionType;
|
||||||
|
|
||||||
struct SqlFunctionCtx;
|
struct SqlFunctionCtx;
|
||||||
struct SResultRowEntryInfo;
|
struct SResultRowEntryInfo;
|
||||||
struct STimeWindow;
|
struct STimeWindow;
|
||||||
|
|
||||||
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
|
||||||
|
|
||||||
typedef struct SScalarFuncExecFuncs {
|
|
||||||
FScalarExecProcess process;
|
|
||||||
} SScalarFuncExecFuncs;
|
|
||||||
|
|
||||||
|
|
||||||
int32_t fmFuncMgtInit();
|
int32_t fmFuncMgtInit();
|
||||||
|
|
||||||
void fmFuncMgtDestroy();
|
void fmFuncMgtDestroy();
|
||||||
|
@ -125,6 +127,8 @@ bool fmIsStringFunc(int32_t funcId);
|
||||||
bool fmIsDatetimeFunc(int32_t funcId);
|
bool fmIsDatetimeFunc(int32_t funcId);
|
||||||
bool fmIsTimelineFunc(int32_t funcId);
|
bool fmIsTimelineFunc(int32_t funcId);
|
||||||
bool fmIsTimeorderFunc(int32_t funcId);
|
bool fmIsTimeorderFunc(int32_t funcId);
|
||||||
|
bool fmIsWindowPseudoColumnFunc(int32_t funcId);
|
||||||
|
bool fmIsWindowClauseFunc(int32_t funcId);
|
||||||
|
|
||||||
int32_t fmFuncScanType(int32_t funcId);
|
int32_t fmFuncScanType(int32_t funcId);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ typedef struct SDatabaseOptions {
|
||||||
int32_t numOfVgroups;
|
int32_t numOfVgroups;
|
||||||
int8_t singleStable;
|
int8_t singleStable;
|
||||||
int8_t streamMode;
|
int8_t streamMode;
|
||||||
|
SNodeList* pRetentions;
|
||||||
} SDatabaseOptions;
|
} SDatabaseOptions;
|
||||||
|
|
||||||
typedef struct SCreateDatabaseStmt {
|
typedef struct SCreateDatabaseStmt {
|
||||||
|
@ -73,6 +74,9 @@ typedef struct STableOptions {
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
char comments[TSDB_STB_COMMENT_LEN];
|
char comments[TSDB_STB_COMMENT_LEN];
|
||||||
SNodeList* pSma;
|
SNodeList* pSma;
|
||||||
|
SNodeList* pFuncs;
|
||||||
|
float filesFactor;
|
||||||
|
int32_t delay;
|
||||||
} STableOptions;
|
} STableOptions;
|
||||||
|
|
||||||
typedef struct SColumnDefNode {
|
typedef struct SColumnDefNode {
|
||||||
|
|
|
@ -121,6 +121,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
||||||
QUERY_NODE_LOGIC_PLAN_SORT,
|
QUERY_NODE_LOGIC_PLAN_SORT,
|
||||||
|
QUERY_NODE_LOGIC_PLAN_PARTITION,
|
||||||
QUERY_NODE_LOGIC_SUBPLAN,
|
QUERY_NODE_LOGIC_SUBPLAN,
|
||||||
QUERY_NODE_LOGIC_PLAN,
|
QUERY_NODE_LOGIC_PLAN,
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,11 @@ typedef struct SAggLogicNode {
|
||||||
typedef struct SProjectLogicNode {
|
typedef struct SProjectLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
|
int64_t limit;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t slimit;
|
||||||
|
int64_t soffset;
|
||||||
} SProjectLogicNode;
|
} SProjectLogicNode;
|
||||||
|
|
||||||
typedef struct SVnodeModifLogicNode {
|
typedef struct SVnodeModifLogicNode {
|
||||||
|
@ -106,6 +110,11 @@ typedef struct SSortLogicNode {
|
||||||
SNodeList* pSortKeys;
|
SNodeList* pSortKeys;
|
||||||
} SSortLogicNode;
|
} SSortLogicNode;
|
||||||
|
|
||||||
|
typedef struct SPartitionLogicNode {
|
||||||
|
SLogicNode node;
|
||||||
|
SNodeList* pPartitionKeys;
|
||||||
|
} SPartitionLogicNode;
|
||||||
|
|
||||||
typedef enum ESubplanType {
|
typedef enum ESubplanType {
|
||||||
SUBPLAN_TYPE_MERGE = 1,
|
SUBPLAN_TYPE_MERGE = 1,
|
||||||
SUBPLAN_TYPE_PARTIAL,
|
SUBPLAN_TYPE_PARTIAL,
|
||||||
|
@ -150,7 +159,8 @@ typedef struct SDataBlockDescNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
int16_t dataBlockId;
|
int16_t dataBlockId;
|
||||||
SNodeList* pSlots;
|
SNodeList* pSlots;
|
||||||
int32_t resultRowSize;
|
int32_t totalRowSize;
|
||||||
|
int32_t outputRowSize;
|
||||||
int16_t precision;
|
int16_t precision;
|
||||||
} SDataBlockDescNode;
|
} SDataBlockDescNode;
|
||||||
|
|
||||||
|
@ -195,6 +205,10 @@ typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
typedef struct SProjectPhysiNode {
|
typedef struct SProjectPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
|
int64_t limit;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t slimit;
|
||||||
|
int64_t soffset;
|
||||||
} SProjectPhysiNode;
|
} SProjectPhysiNode;
|
||||||
|
|
||||||
typedef struct SJoinPhysiNode {
|
typedef struct SJoinPhysiNode {
|
||||||
|
@ -283,10 +297,17 @@ typedef struct SSubplan {
|
||||||
SDataSinkNode* pDataSink; // data of the subplan flow into the datasink
|
SDataSinkNode* pDataSink; // data of the subplan flow into the datasink
|
||||||
} SSubplan;
|
} SSubplan;
|
||||||
|
|
||||||
|
typedef enum EQueryMode {
|
||||||
|
QUERY_MODE_NORMAL = 1,
|
||||||
|
QUERY_MODE_EXPLAIN,
|
||||||
|
QUERY_MODE_EXPLAIN_AN
|
||||||
|
} EQueryMode;
|
||||||
|
|
||||||
typedef struct SQueryPlan {
|
typedef struct SQueryPlan {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
int32_t numOfSubplans;
|
int32_t numOfSubplans;
|
||||||
|
|
||||||
SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0.
|
SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0.
|
||||||
} SQueryPlan;
|
} SQueryPlan;
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,8 @@ typedef struct SOrderByExprNode {
|
||||||
|
|
||||||
typedef struct SLimitNode {
|
typedef struct SLimitNode {
|
||||||
ENodeType type; // QUERY_NODE_LIMIT
|
ENodeType type; // QUERY_NODE_LIMIT
|
||||||
uint64_t limit;
|
int64_t limit;
|
||||||
uint64_t offset;
|
int64_t offset;
|
||||||
} SLimitNode;
|
} SLimitNode;
|
||||||
|
|
||||||
typedef struct SStateWindowNode {
|
typedef struct SStateWindowNode {
|
||||||
|
|
|
@ -40,7 +40,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type);
|
||||||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
||||||
|
|
||||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
||||||
int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut);
|
int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut);
|
||||||
|
|
||||||
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
|
@ -30,6 +30,11 @@ enum {
|
||||||
STREAM_TASK_STATUS__STOP,
|
STREAM_TASK_STATUS__STOP,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STREAM_CREATED_BY__USER = 1,
|
||||||
|
STREAM_CREATED_BY__SMA,
|
||||||
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// pipe -> fetch/pipe queue
|
// pipe -> fetch/pipe queue
|
||||||
// merge -> merge queue
|
// merge -> merge queue
|
||||||
|
@ -72,8 +77,9 @@ typedef struct {
|
||||||
} STaskDispatcherFixedEp;
|
} STaskDispatcherFixedEp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t hashMethod;
|
// int8_t hashMethod;
|
||||||
SArray* info;
|
char stbFullName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
SUseDbRsp dbInfo;
|
||||||
} STaskDispatcherShuffle;
|
} STaskDispatcherShuffle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -135,7 +141,6 @@ typedef struct {
|
||||||
int8_t sinkType;
|
int8_t sinkType;
|
||||||
int8_t dispatchType;
|
int8_t dispatchType;
|
||||||
int16_t dispatchMsgType;
|
int16_t dispatchMsgType;
|
||||||
int32_t downstreamTaskId;
|
|
||||||
|
|
||||||
int32_t nodeId;
|
int32_t nodeId;
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
|
|
|
@ -49,11 +49,13 @@ typedef struct SRpcMsg {
|
||||||
} SRpcMsg;
|
} SRpcMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
SRpcMsg rpcMsg;
|
uint32_t clientIp;
|
||||||
int32_t rspLen;
|
uint16_t clientPort;
|
||||||
void * pRsp;
|
SRpcMsg rpcMsg;
|
||||||
void * pNode;
|
int32_t rspLen;
|
||||||
|
void *pRsp;
|
||||||
|
void *pNode;
|
||||||
} SNodeMsg;
|
} SNodeMsg;
|
||||||
|
|
||||||
typedef struct SRpcInit {
|
typedef struct SRpcInit {
|
||||||
|
@ -105,20 +107,20 @@ void rpcClose(void *);
|
||||||
void * rpcMallocCont(int contLen);
|
void * rpcMallocCont(int contLen);
|
||||||
void rpcFreeCont(void *pCont);
|
void rpcFreeCont(void *pCont);
|
||||||
void * rpcReallocCont(void *ptr, int contLen);
|
void * rpcReallocCont(void *ptr, int contLen);
|
||||||
void rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
|
||||||
void rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
|
||||||
|
|
||||||
|
// Because taosd supports multi-process mode
|
||||||
|
// These functions should not be used on the server side
|
||||||
|
// Please use tmsg<xx> functions, which are defined in tmsgcb.h
|
||||||
|
void rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||||
void rpcSendResponse(const SRpcMsg *pMsg);
|
void rpcSendResponse(const SRpcMsg *pMsg);
|
||||||
|
void rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||||
|
void rpcReleaseHandle(void *handle, int8_t type); // just release client conn to rpc instance, no close sock
|
||||||
|
|
||||||
|
// These functions will not be called in the child process
|
||||||
void rpcSendRedirectRsp(void *pConn, const SEpSet *pEpSet);
|
void rpcSendRedirectRsp(void *pConn, const SEpSet *pEpSet);
|
||||||
|
void rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||||
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||||
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
|
||||||
void rpcCancelRequest(int64_t rid);
|
|
||||||
void rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
|
||||||
// just release client conn to rpc instance, no close sock
|
|
||||||
void rpcReleaseHandle(void *handle, int8_t type); //
|
|
||||||
void rpcRefHandle(void *handle, int8_t type);
|
|
||||||
void rpcUnrefHandle(void *handle, int8_t type);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,9 @@ extern "C" {
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#if defined(DARWIN)
|
#if defined(DARWIN)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#ifndef _TD_UTIL_TAOS_ERROR_H_
|
#ifndef _TD_UTIL_TAOS_ERROR_H_
|
||||||
#define _TD_UTIL_TAOS_ERROR_H_
|
#define _TD_UTIL_TAOS_ERROR_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -369,6 +369,18 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
|
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
|
||||||
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
|
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
|
||||||
|
|
||||||
|
#define TSDB_MIN_DB_STREAM_MODE 0
|
||||||
|
#define TSDB_MAX_DB_STREAM_MODE 1
|
||||||
|
#define TSDB_DEFAULT_DB_STREAM_MODE 0
|
||||||
|
|
||||||
|
#define TSDB_MIN_DB_FILE_FACTOR 0
|
||||||
|
#define TSDB_MAX_DB_FILE_FACTOR 1
|
||||||
|
#define TSDB_DEFAULT_DB_FILE_FACTOR 0.1
|
||||||
|
|
||||||
|
#define TSDB_MIN_DB_DELAY 1
|
||||||
|
#define TSDB_MAX_DB_DELAY 10
|
||||||
|
#define TSDB_DEFAULT_DB_DELAY 2
|
||||||
|
|
||||||
#define TSDB_MAX_JOIN_TABLE_NUM 10
|
#define TSDB_MAX_JOIN_TABLE_NUM 10
|
||||||
#define TSDB_MAX_UNION_CLAUSE 5
|
#define TSDB_MAX_UNION_CLAUSE 5
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum { PROC_REQ, PROC_RSP, PROC_REG, PROC_RELEASE } ProcFuncType;
|
||||||
|
|
||||||
typedef struct SProcQueue SProcQueue;
|
typedef struct SProcQueue SProcQueue;
|
||||||
typedef struct SProcObj SProcObj;
|
typedef struct SProcObj SProcObj;
|
||||||
typedef void *(*ProcMallocFp)(int32_t contLen);
|
typedef void *(*ProcMallocFp)(int32_t contLen);
|
||||||
typedef void *(*ProcFreeFp)(void *pCont);
|
typedef void *(*ProcFreeFp)(void *pCont);
|
||||||
typedef void *(*ProcConsumeFp)(void *pParent, void *pHead, int32_t headLen, void *pBody, int32_t bodyLen);
|
typedef void *(*ProcConsumeFp)(void *pParent, void *pHead, int16_t headLen, void *pBody, int32_t bodyLen,
|
||||||
|
ProcFuncType ftype);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t childQueueSize;
|
int32_t childQueueSize;
|
||||||
|
@ -52,9 +55,10 @@ int32_t taosProcRun(SProcObj *pProc);
|
||||||
void taosProcStop(SProcObj *pProc);
|
void taosProcStop(SProcObj *pProc);
|
||||||
bool taosProcIsChild(SProcObj *pProc);
|
bool taosProcIsChild(SProcObj *pProc);
|
||||||
int32_t taosProcChildId(SProcObj *pProc);
|
int32_t taosProcChildId(SProcObj *pProc);
|
||||||
|
int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||||
int32_t taosProcPutToChildQueue(SProcObj *pProc, void *pHead, int32_t headLen, void *pBody, int32_t bodyLen);
|
ProcFuncType ftype);
|
||||||
int32_t taosProcPutToParentQueue(SProcObj *pProc, void *pHead, int32_t headLen, void *pBody, int32_t bodyLen);
|
int32_t taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||||
|
ProcFuncType ftype);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void taosCloseQueue(STaosQueue *queue);
|
||||||
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
||||||
void *taosAllocateQitem(int32_t size);
|
void *taosAllocateQitem(int32_t size);
|
||||||
void taosFreeQitem(void *pItem);
|
void taosFreeQitem(void *pItem);
|
||||||
int32_t taosWriteQitem(STaosQueue *queue, void *pItem);
|
void taosWriteQitem(STaosQueue *queue, void *pItem);
|
||||||
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
||||||
bool taosQueueEmpty(STaosQueue *queue);
|
bool taosQueueEmpty(STaosQueue *queue);
|
||||||
int32_t taosQueueSize(STaosQueue *queue);
|
int32_t taosQueueSize(STaosQueue *queue);
|
||||||
|
|
|
@ -70,8 +70,8 @@ void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int32_t minNum;
|
int32_t min;
|
||||||
int32_t maxNum;
|
int32_t max;
|
||||||
FItem fp;
|
FItem fp;
|
||||||
void *param;
|
void *param;
|
||||||
} SSingleWorkerCfg;
|
} SSingleWorkerCfg;
|
||||||
|
@ -84,7 +84,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int32_t maxNum;
|
int32_t max;
|
||||||
FItems fp;
|
FItems fp;
|
||||||
void *param;
|
void *param;
|
||||||
} SMultiWorkerCfg;
|
} SMultiWorkerCfg;
|
||||||
|
|
|
@ -235,7 +235,7 @@ void initMsgHandleFp();
|
||||||
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port);
|
uint16_t port);
|
||||||
|
|
||||||
void* doFetchRow(SRequestObj* pRequest);
|
void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr);
|
||||||
|
|
||||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,33 @@ TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, c
|
||||||
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* doFetchRow(SRequestObj* pRequest) {
|
static void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||||
|
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||||
|
SResultColumn* pCol = &pResultInfo->pCol[i];
|
||||||
|
|
||||||
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
if (pCol->offset[pResultInfo->current] != -1) {
|
||||||
|
char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData;
|
||||||
|
|
||||||
|
pResultInfo->length[i] = varDataLen(pStart);
|
||||||
|
pResultInfo->row[i] = varDataVal(pStart);
|
||||||
|
} else {
|
||||||
|
pResultInfo->row[i] = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) {
|
||||||
|
pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current;
|
||||||
|
} else {
|
||||||
|
pResultInfo->row[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) {
|
||||||
assert(pRequest != NULL);
|
assert(pRequest != NULL);
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
|
@ -555,17 +581,20 @@ void* doFetchRow(SRequestObj* pRequest) {
|
||||||
if (pRequest->type == TDMT_VND_QUERY) {
|
if (pRequest->type == TDMT_VND_QUERY) {
|
||||||
// All data has returned to App already, no need to try again
|
// All data has returned to App already, no need to try again
|
||||||
if (pResultInfo->completed) {
|
if (pResultInfo->completed) {
|
||||||
|
pResultInfo->numOfRows = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||||
pRequest->code = schedulerFetchRows(pRequest->body.queryJob, (void**)&pResInfo->pData);
|
pRequest->code = schedulerFetchRows(pRequest->body.queryJob, (void**)&pResInfo->pData);
|
||||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||||
|
pResultInfo->numOfRows = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData);
|
pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData);
|
||||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||||
|
pResultInfo->numOfRows = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,41 +662,11 @@ void* doFetchRow(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
if (setupOneRowPtr) {
|
||||||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
doSetOneRowPtr(pResultInfo);
|
||||||
SResultColumn* pCol = &pResultInfo->pCol[i];
|
pResultInfo->current += 1;
|
||||||
|
|
||||||
int32_t type = pResultInfo->fields[i].type;
|
|
||||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
|
||||||
if (pCol->offset[pResultInfo->current] != -1) {
|
|
||||||
char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData;
|
|
||||||
|
|
||||||
pResultInfo->length[i] = varDataLen(pStart);
|
|
||||||
pResultInfo->row[i] = varDataVal(pStart);
|
|
||||||
|
|
||||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(pResultInfo->convertBuf[i]));
|
|
||||||
ASSERT(len <= bytes);
|
|
||||||
|
|
||||||
pResultInfo->row[i] = varDataVal(pResultInfo->convertBuf[i]);
|
|
||||||
varDataSetLen(pResultInfo->convertBuf[i], len);
|
|
||||||
pResultInfo->length[i] = len;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pResultInfo->row[i] = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) {
|
|
||||||
pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current;
|
|
||||||
} else {
|
|
||||||
pResultInfo->row[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pResultInfo->current += 1;
|
|
||||||
return pResultInfo->row;
|
return pResultInfo->row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,12 +680,6 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
||||||
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) {
|
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
|
||||||
if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
pResInfo->convertBuf[i] = taosMemoryCalloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -723,6 +716,35 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
pStart += colLength[i];
|
pStart += colLength[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
||||||
|
if (p == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
pResultInfo->convertBuf[i] = p;
|
||||||
|
|
||||||
|
SResultColumn* pCol = &pResultInfo->pCol[i];
|
||||||
|
for (int32_t j = 0; j < numOfRows; ++j) {
|
||||||
|
if (pCol->offset[j] != -1) {
|
||||||
|
pStart = pCol->offset[j] + pCol->pData;
|
||||||
|
|
||||||
|
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
||||||
|
ASSERT(len <= bytes);
|
||||||
|
|
||||||
|
varDataSetLen(p, len);
|
||||||
|
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
|
||||||
|
p += (len + VARSTR_HEADER_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
#include "os.h"
|
/*
|
||||||
#include "tref.h"
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
#include "trpc.h"
|
*
|
||||||
|
* 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 "catalog.h"
|
||||||
#include "clientInt.h"
|
#include "clientInt.h"
|
||||||
#include "clientLog.h"
|
#include "clientLog.h"
|
||||||
|
#include "os.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "tmsg.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "catalog.h"
|
#include "tmsg.h"
|
||||||
|
#include "tref.h"
|
||||||
|
#include "trpc.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#define TSC_VAR_NOT_RELEASE 1
|
#define TSC_VAR_NOT_RELEASE 1
|
||||||
|
@ -24,7 +39,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = taos_options_imp(option, (const char*)arg);
|
int ret = taos_options_imp(option, (const char *)arg);
|
||||||
atomic_store_32(&lock, 0);
|
atomic_store_32(&lock, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -69,13 +84,13 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
||||||
return taos_connect_internal(ip, user, pass, NULL, db, port);
|
return taos_connect_internal(ip, user, pass, NULL, db, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_close(TAOS* taos) {
|
void taos_close(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj *pTscObj = (STscObj *)taos;
|
STscObj *pTscObj = (STscObj *)taos;
|
||||||
tscDebug("0x%"PRIx64" try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs);
|
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs);
|
||||||
|
|
||||||
/*taosRemoveRef(clientConnRefPool, pTscObj->id);*/
|
/*taosRemoveRef(clientConnRefPool, pTscObj->id);*/
|
||||||
}
|
}
|
||||||
|
@ -85,48 +100,46 @@ int taos_errno(TAOS_RES *tres) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((SRequestObj*) tres)->code;
|
return ((SRequestObj *)tres)->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *taos_errstr(TAOS_RES *res) {
|
const char *taos_errstr(TAOS_RES *res) {
|
||||||
SRequestObj *pRequest = (SRequestObj *) res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
|
|
||||||
if (pRequest == NULL) {
|
if (pRequest == NULL) {
|
||||||
return (const char*) tstrerror(terrno);
|
return (const char *)tstrerror(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR) {
|
if (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR) {
|
||||||
return pRequest->msgBuf;
|
return pRequest->msgBuf;
|
||||||
} else {
|
} else {
|
||||||
return (const char*)tstrerror(pRequest->code);
|
return (const char *)tstrerror(pRequest->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_free_result(TAOS_RES *res) {
|
void taos_free_result(TAOS_RES *res) {
|
||||||
SRequestObj* pRequest = (SRequestObj*) res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_field_count(TAOS_RES *res) {
|
int taos_field_count(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* pRequest = (SRequestObj*) res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
return pResInfo->numOfCols;
|
return pResInfo->numOfCols;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_num_fields(TAOS_RES *res) {
|
int taos_num_fields(TAOS_RES *res) { return taos_field_count(res); }
|
||||||
return taos_field_count(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||||
if (taos_num_fields(res) == 0) {
|
if (taos_num_fields(res) == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SReqResultInfo* pResInfo = &(((SRequestObj*) res)->body.resInfo);
|
SReqResultInfo *pResInfo = &(((SRequestObj *)res)->body.resInfo);
|
||||||
return pResInfo->fields;
|
return pResInfo->fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,26 +148,24 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taos_query_l(taos, sql, (int32_t) strlen(sql));
|
return taos_query_l(taos, sql, (int32_t)strlen(sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_ROW taos_fetch_row(TAOS_RES *pRes) {
|
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
if (pRes == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = (SRequestObj *) pRes;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT ||
|
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||||
pRequest->type == TSDB_SQL_INSERT ||
|
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||||
pRequest->code != TSDB_CODE_SUCCESS ||
|
|
||||||
taos_num_fields(pRes) == 0) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doFetchRow(pRequest);
|
return doFetchRow(pRequest, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
for (int i = 0; i < num_fields; ++i) {
|
for (int i = 0; i < num_fields; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
@ -213,7 +224,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
int32_t charLen = varDataLen((char*)row[i] - VARSTR_HEADER_SIZE);
|
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||||
assert(charLen <= fields[i].bytes && charLen >= 0);
|
assert(charLen <= fields[i].bytes && charLen >= 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,28 +249,44 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int* taos_fetch_lengths(TAOS_RES *res) {
|
int *taos_fetch_lengths(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((SRequestObj*) res)->body.resInfo.length;
|
return ((SRequestObj *)res)->body.resInfo.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo intergrate with tDataTypes
|
||||||
const char *taos_data_type(int type) {
|
const char *taos_data_type(int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_NULL: return "TSDB_DATA_TYPE_NULL";
|
case TSDB_DATA_TYPE_NULL:
|
||||||
case TSDB_DATA_TYPE_BOOL: return "TSDB_DATA_TYPE_BOOL";
|
return "TSDB_DATA_TYPE_NULL";
|
||||||
case TSDB_DATA_TYPE_TINYINT: return "TSDB_DATA_TYPE_TINYINT";
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
case TSDB_DATA_TYPE_SMALLINT: return "TSDB_DATA_TYPE_SMALLINT";
|
return "TSDB_DATA_TYPE_BOOL";
|
||||||
case TSDB_DATA_TYPE_INT: return "TSDB_DATA_TYPE_INT";
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
case TSDB_DATA_TYPE_BIGINT: return "TSDB_DATA_TYPE_BIGINT";
|
return "TSDB_DATA_TYPE_TINYINT";
|
||||||
case TSDB_DATA_TYPE_FLOAT: return "TSDB_DATA_TYPE_FLOAT";
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
case TSDB_DATA_TYPE_DOUBLE: return "TSDB_DATA_TYPE_DOUBLE";
|
return "TSDB_DATA_TYPE_SMALLINT";
|
||||||
case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_BINARY";
|
case TSDB_DATA_TYPE_INT:
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP: return "TSDB_DATA_TYPE_TIMESTAMP";
|
return "TSDB_DATA_TYPE_INT";
|
||||||
case TSDB_DATA_TYPE_NCHAR: return "TSDB_DATA_TYPE_NCHAR";
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
default: return "UNKNOWN";
|
return "TSDB_DATA_TYPE_BIGINT";
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
return "TSDB_DATA_TYPE_FLOAT";
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
return "TSDB_DATA_TYPE_DOUBLE";
|
||||||
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
|
return "TSDB_DATA_TYPE_VARCHAR";
|
||||||
|
// case TSDB_DATA_TYPE_BINARY: return "TSDB_DATA_TYPE_VARCHAR";
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
return "TSDB_DATA_TYPE_TIMESTAMP";
|
||||||
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
return "TSDB_DATA_TYPE_NCHAR";
|
||||||
|
case TSDB_DATA_TYPE_JSON:
|
||||||
|
return "TSDB_DATA_TYPE_JSON";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +297,8 @@ int taos_affected_rows(TAOS_RES *res) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* pRequest = (SRequestObj*) res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
return pResInfo->numOfRows;
|
return pResInfo->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,8 +319,8 @@ int taos_select_db(TAOS *taos, const char *db) {
|
||||||
char sql[256] = {0};
|
char sql[256] = {0};
|
||||||
snprintf(sql, tListLen(sql), "use %s", db);
|
snprintf(sql, tListLen(sql), "use %s", db);
|
||||||
|
|
||||||
TAOS_RES* pRequest = taos_query(taos, sql);
|
TAOS_RES *pRequest = taos_query(taos, sql);
|
||||||
int32_t code = taos_errno(pRequest);
|
int32_t code = taos_errno(pRequest);
|
||||||
|
|
||||||
taos_free_result(pRequest);
|
taos_free_result(pRequest);
|
||||||
return code;
|
return code;
|
||||||
|
@ -304,35 +331,57 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj* pRequest = (SRequestObj*) res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
int32_t numOfFields = taos_num_fields(pRequest);
|
int32_t numOfFields = taos_num_fields(pRequest);
|
||||||
|
|
||||||
// It is not a query, no need to stop.
|
// It is not a query, no need to stop.
|
||||||
if (numOfFields == 0) {
|
if (numOfFields == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheduleCancelJob(pRequest->body.pQueryJob);
|
// scheduleCancelJob(pRequest->body.pQueryJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
||||||
return false;
|
SRequestObj *pRequestObj = res;
|
||||||
|
SReqResultInfo *pResultInfo = &pRequestObj->body.resInfo;
|
||||||
|
if (col >= pResultInfo->numOfCols || col < 0 || row >= pResultInfo->numOfRows || row < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SResultColumn *pCol = &pRequestObj->body.resInfo.pCol[col];
|
||||||
|
return colDataIsNull_f(pCol->nullbitmap, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
return 0;
|
if (res == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
|
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||||
|
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
doFetchRow(pRequest, false);
|
||||||
|
|
||||||
|
// TODO refactor
|
||||||
|
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||||
|
pResultInfo->current = pResultInfo->numOfRows;
|
||||||
|
*rows = pResultInfo->row;
|
||||||
|
|
||||||
|
return pResultInfo->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_validate_sql(TAOS *taos, const char *sql) {
|
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *taos_get_server_info(TAOS *taos) {
|
const char *taos_get_server_info(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj* pTscObj = (STscObj*) taos;
|
STscObj *pTscObj = (STscObj *)taos;
|
||||||
return pTscObj->ver;
|
return pTscObj->ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,52 +407,67 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT* taos_stmt_init(TAOS* taos) {
|
int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
// TODO
|
// TODO
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt_close(TAOS_STMT* stmt) {
|
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
||||||
// TODO
|
// TODO
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt_execute(TAOS_STMT* stmt) {
|
int taos_stmt_close(TAOS_STMT *stmt) {
|
||||||
// TODO
|
// TODO
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_execute(TAOS_STMT *stmt) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *taos_stmt_errstr(TAOS_STMT *stmt) {
|
char *taos_stmt_errstr(TAOS_STMT *stmt) {
|
||||||
// TODO
|
// TODO
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt_affected_rows(TAOS_STMT* stmt) {
|
int taos_stmt_affected_rows(TAOS_STMT *stmt) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) {
|
||||||
// TODO
|
// TODO
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
|
int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) {
|
||||||
// TODO
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) {
|
|
||||||
// TODO
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
|
||||||
// TODO
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags) {
|
|
||||||
// TODO
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) {
|
|
||||||
// TODO
|
// TODO
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -413,6 +477,11 @@ int taos_stmt_add_batch(TAOS_STMT* stmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) {
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
|
int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
|
||||||
// TODO
|
// TODO
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -26,6 +26,18 @@
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t curBlock;
|
||||||
|
int32_t curRow;
|
||||||
|
void** uData;
|
||||||
|
} SMqRowIter;
|
||||||
|
|
||||||
|
struct tmq_message_t {
|
||||||
|
SMqPollRsp msg;
|
||||||
|
void* vg;
|
||||||
|
SMqRowIter iter;
|
||||||
|
};
|
||||||
|
|
||||||
struct tmq_list_t {
|
struct tmq_list_t {
|
||||||
SArray container;
|
SArray container;
|
||||||
};
|
};
|
||||||
|
@ -99,13 +111,14 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// subscribe info
|
// subscribe info
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* topicName;
|
char* topicName;
|
||||||
int64_t topicId;
|
int64_t topicId;
|
||||||
int32_t nextVgIdx;
|
SArray* vgs; // SArray<SMqClientVg>
|
||||||
SArray* vgs; // SArray<SMqClientVg>
|
int8_t isSchemaAdaptive;
|
||||||
SSchemaWrapper schema;
|
int32_t numOfFields;
|
||||||
|
TAOS_FIELD* fields;
|
||||||
} SMqClientTopic;
|
} SMqClientTopic;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -130,11 +143,11 @@ typedef struct {
|
||||||
} SMqPollCbParam;
|
} SMqPollCbParam;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tmq_t* tmq;
|
tmq_t* tmq;
|
||||||
/*SMqClientVg* pVg;*/
|
|
||||||
int32_t async;
|
int32_t async;
|
||||||
tsem_t rspSem;
|
tsem_t rspSem;
|
||||||
tmq_resp_err_t rspErr;
|
tmq_resp_err_t rspErr;
|
||||||
|
/*SMqClientVg* pVg;*/
|
||||||
} SMqCommitCbParam;
|
} SMqCommitCbParam;
|
||||||
|
|
||||||
tmq_conf_t* tmq_conf_new() {
|
tmq_conf_t* tmq_conf_new() {
|
||||||
|
@ -471,7 +484,12 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
|
||||||
tNameExtractFullName(&name, topicFname);
|
tNameExtractFullName(&name, topicFname);
|
||||||
tscDebug("subscribe topic: %s", topicFname);
|
tscDebug("subscribe topic: %s", topicFname);
|
||||||
SMqClientTopic topic = {
|
SMqClientTopic topic = {
|
||||||
.nextVgIdx = 0, .sql = NULL, .sqlLen = 0, .topicId = 0, .topicName = topicFname, .vgs = NULL};
|
.sql = NULL,
|
||||||
|
.sqlLen = 0,
|
||||||
|
.topicId = 0,
|
||||||
|
.topicName = topicFname,
|
||||||
|
.vgs = NULL,
|
||||||
|
};
|
||||||
topic.vgs = taosArrayInit(0, sizeof(SMqClientVg));
|
topic.vgs = taosArrayInit(0, sizeof(SMqClientVg));
|
||||||
taosArrayPush(tmq->clientTopics, &topic);
|
taosArrayPush(tmq->clientTopics, &topic);
|
||||||
taosArrayPush(req.topicNames, &topicFname);
|
taosArrayPush(req.topicNames, &topicFname);
|
||||||
|
@ -615,6 +633,7 @@ _return:
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, int sqlLen) {
|
TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, int sqlLen) {
|
||||||
STscObj* pTscObj = (STscObj*)taos;
|
STscObj* pTscObj = (STscObj*)taos;
|
||||||
SRequestObj* pRequest = NULL;
|
SRequestObj* pRequest = NULL;
|
||||||
|
@ -700,6 +719,7 @@ _return:
|
||||||
|
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
time_t tt;
|
time_t tt;
|
||||||
|
|
|
@ -35,7 +35,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
TEST(testCase, driverInit_Test) {
|
TEST(testCase, driverInit_Test) {
|
||||||
// taosInitGlobalCfg();
|
// taosInitGlobalCfg();
|
||||||
// taos_init();
|
// taos_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, create_topic_ctb_Test) {
|
TEST(testCase, create_topic_ctb_Test) {
|
||||||
|
@ -55,8 +55,9 @@ TEST(testCase, create_topic_ctb_Test) {
|
||||||
|
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
char* sql = "select * from tu";
|
// char* sql = "select * from tu";
|
||||||
pRes = tmq_create_topic(pConn, "test_ctb_topic_1", sql, strlen(sql));
|
// pRes = tmq_create_topic(pConn, "test_ctb_topic_1", sql, strlen(sql));
|
||||||
|
pRes = taos_query(pConn, "create test_ctb_topic_1 as select * from tu");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ TEST(testCase, create_topic_stb_Test) {
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
}
|
||||||
//taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
ASSERT_TRUE(pFields == nullptr);
|
ASSERT_TRUE(pFields == nullptr);
|
||||||
|
@ -79,8 +80,9 @@ TEST(testCase, create_topic_stb_Test) {
|
||||||
|
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
char* sql = "select * from st1";
|
// char* sql = "select * from st1";
|
||||||
pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));
|
// pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));
|
||||||
|
pRes = taos_query(pConn, "create test_ctb_topic_1 as select * from st1");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -647,7 +647,6 @@ double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||||
typedef struct SSDataBlockSortHelper {
|
typedef struct SSDataBlockSortHelper {
|
||||||
SArray* orderInfo; // SArray<SBlockOrderInfo>
|
SArray* orderInfo; // SArray<SBlockOrderInfo>
|
||||||
SSDataBlock* pDataBlock;
|
SSDataBlock* pDataBlock;
|
||||||
bool nullFirst;
|
|
||||||
} SSDataBlockSortHelper;
|
} SSDataBlockSortHelper;
|
||||||
|
|
||||||
int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
|
int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
|
||||||
|
@ -672,11 +671,11 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rightNull) {
|
if (rightNull) {
|
||||||
return pHelper->nullFirst ? 1 : -1;
|
return pOrder->nullFirst ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftNull) {
|
if (leftNull) {
|
||||||
return pHelper->nullFirst ? -1 : 1;
|
return pOrder->nullFirst ? -1 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,7 +906,7 @@ static __compar_fn_t getComparFn(int32_t type, int32_t order) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) {
|
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
||||||
ASSERT(pDataBlock != NULL && pOrderInfo != NULL);
|
ASSERT(pDataBlock != NULL && pOrderInfo != NULL);
|
||||||
if (pDataBlock->info.rows <= 1) {
|
if (pDataBlock->info.rows <= 1) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -922,7 +921,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pOrderInfo); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pOrderInfo); ++i) {
|
||||||
SBlockOrderInfo* pInfo = taosArrayGet(pOrderInfo, i);
|
SBlockOrderInfo* pInfo = taosArrayGet(pOrderInfo, i);
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, pInfo->colIndex);
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, pInfo->slotId);
|
||||||
if (pColInfoData->hasNull) {
|
if (pColInfoData->hasNull) {
|
||||||
sortColumnHasNull = true;
|
sortColumnHasNull = true;
|
||||||
}
|
}
|
||||||
|
@ -961,10 +960,10 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs
|
||||||
|
|
||||||
int64_t p0 = taosGetTimestampUs();
|
int64_t p0 = taosGetTimestampUs();
|
||||||
|
|
||||||
SSDataBlockSortHelper helper = {.nullFirst = nullFirst, .pDataBlock = pDataBlock, .orderInfo = pOrderInfo};
|
SSDataBlockSortHelper helper = {.pDataBlock = pDataBlock, .orderInfo = pOrderInfo};
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(helper.orderInfo); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(helper.orderInfo); ++i) {
|
||||||
struct SBlockOrderInfo* pInfo = taosArrayGet(helper.orderInfo, i);
|
struct SBlockOrderInfo* pInfo = taosArrayGet(helper.orderInfo, i);
|
||||||
pInfo->pColData = taosArrayGet(pDataBlock->pDataBlock, pInfo->colIndex);
|
pInfo->pColData = taosArrayGet(pDataBlock->pDataBlock, pInfo->slotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosqsort(index, rows, sizeof(int32_t), &helper, dataBlockCompar);
|
taosqsort(index, rows, sizeof(int32_t), &helper, dataBlockCompar);
|
||||||
|
@ -1012,7 +1011,7 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock*
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SBlockOrderInfo* pInfo = taosArrayGet(pOrderInfo, i);
|
SBlockOrderInfo* pInfo = taosArrayGet(pOrderInfo, i);
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, pInfo->colIndex);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, pInfo->slotId);
|
||||||
pInfo->pColData = pColInfo;
|
pInfo->pColData = pColInfo;
|
||||||
sortValLengthPerRow += pColInfo->info.bytes;
|
sortValLengthPerRow += pColInfo->info.bytes;
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1105,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
||||||
// Allocate the additional buffer.
|
// Allocate the additional buffer.
|
||||||
int64_t p0 = taosGetTimestampUs();
|
int64_t p0 = taosGetTimestampUs();
|
||||||
|
|
||||||
SSDataBlockSortHelper helper = {.nullFirst = nullFirst, .pDataBlock = pDataBlock, .orderInfo = pOrderInfo};
|
SSDataBlockSortHelper helper = {.pDataBlock = pDataBlock, .orderInfo = pOrderInfo};
|
||||||
|
|
||||||
uint32_t rows = pDataBlock->info.rows;
|
uint32_t rows = pDataBlock->info.rows;
|
||||||
SHelper* index = createTupleIndex_rv(rows, helper.orderInfo, pDataBlock);
|
SHelper* index = createTupleIndex_rv(rows, helper.orderInfo, pDataBlock);
|
||||||
|
@ -1241,6 +1240,16 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
|
||||||
return pageSize / (blockDataGetSerialRowSize(pBlock) + blockDataGetSerialMetaSize(pBlock));
|
return pageSize / (blockDataGetSerialRowSize(pBlock) + blockDataGetSerialMetaSize(pBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void colDataDestroy(SColumnInfoData* pColData) {
|
||||||
|
if (IS_VAR_DATA_TYPE(pColData->info.type)) {
|
||||||
|
taosMemoryFree(pColData->varmeta.offset);
|
||||||
|
} else {
|
||||||
|
taosMemoryFree(pColData->nullbitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pColData->pData);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
|
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
|
||||||
int64_t tbUid = pBlock->info.uid;
|
int64_t tbUid = pBlock->info.uid;
|
||||||
int16_t numOfCols = pBlock->info.numOfCols;
|
int16_t numOfCols = pBlock->info.numOfCols;
|
||||||
|
|
|
@ -123,7 +123,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
|
int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version) {
|
||||||
if (pBuilder == NULL) return -1;
|
if (pBuilder == NULL) return -1;
|
||||||
|
|
||||||
pBuilder->tCols = 256;
|
pBuilder->tCols = 256;
|
||||||
|
@ -140,7 +140,7 @@ void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
|
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version) {
|
||||||
pBuilder->nCols = 0;
|
pBuilder->nCols = 0;
|
||||||
pBuilder->tlen = 0;
|
pBuilder->tlen = 0;
|
||||||
pBuilder->flen = 0;
|
pBuilder->flen = 0;
|
||||||
|
@ -168,6 +168,9 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, col_id_t colId, col
|
||||||
colSetOffset(pCol, pTCol->offset + TYPE_BYTES[pTCol->type]);
|
colSetOffset(pCol, pTCol->offset + TYPE_BYTES[pTCol->type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: set sma value by user input
|
||||||
|
pCol->sma = 1;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
colSetBytes(pCol, bytes);
|
colSetBytes(pCol, bytes);
|
||||||
pBuilder->tlen += (TYPE_BYTES[type] + bytes);
|
pBuilder->tlen += (TYPE_BYTES[type] + bytes);
|
||||||
|
|
|
@ -1829,7 +1829,7 @@ int32_t tDeserializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) {
|
int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, const SUseDbRsp *pRsp) {
|
||||||
if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pRsp->uid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pRsp->uid) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pRsp->vgVersion) < 0) return -1;
|
if (tEncodeI32(pEncoder, pRsp->vgVersion) < 0) return -1;
|
||||||
|
@ -1848,7 +1848,7 @@ static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, SUseDbRsp *pRsp) {
|
int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, const SUseDbRsp *pRsp) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
|
||||||
|
static SMsgCb tsDefaultMsgCb;
|
||||||
|
|
||||||
|
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; }
|
||||||
|
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq) {
|
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->queueFps[qtype])(pMsgCb->pWrapper, pReq);
|
return (*pMsgCb->queueFps[qtype])(pMsgCb->pWrapper, pReq);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +28,7 @@ int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
|
||||||
return (*pMsgCb->qsizeFp)(pMsgCb->pWrapper, vgId, qtype);
|
return (*pMsgCb->qsizeFp)(pMsgCb->pWrapper, vgId, qtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgSendReq(const SMsgCb* pMsgCb, SEpSet* epSet, SRpcMsg* pReq) {
|
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->sendReqFp)(pMsgCb->pWrapper, epSet, pReq);
|
return (*pMsgCb->sendReqFp)(pMsgCb->pWrapper, epSet, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,4 +36,12 @@ int32_t tmsgSendMnodeReq(const SMsgCb* pMsgCb, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->sendMnodeReqFp)(pMsgCb->pWrapper, pReq);
|
return (*pMsgCb->sendMnodeReqFp)(pMsgCb->pWrapper, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgSendRsp(const SMsgCb* pMsgCb, SRpcMsg* pRsp) { return (*pMsgCb->sendRspFp)(pMsgCb->pWrapper, pRsp); }
|
void tmsgSendRsp(const SRpcMsg* pRsp) { return (*tsDefaultMsgCb.sendRspFp)(tsDefaultMsgCb.pWrapper, pRsp); }
|
||||||
|
|
||||||
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) {
|
||||||
|
(*pMsgCb->registerBrokenLinkArgFp)(pMsgCb->pWrapper, pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmsgReleaseHandle(void* handle, int8_t type) {
|
||||||
|
(*tsDefaultMsgCb.releaseHandleFp)(tsDefaultMsgCb.pWrapper, handle, type);
|
||||||
|
}
|
|
@ -167,10 +167,10 @@ TEST(testCase, Datablock_test) {
|
||||||
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
||||||
|
|
||||||
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
||||||
SBlockOrderInfo order = {.order = TSDB_ORDER_ASC, .colIndex = 0};
|
SBlockOrderInfo order = {.nullFirst = true, .order = TSDB_ORDER_ASC, .slotId = 0};
|
||||||
taosArrayPush(pOrderInfo, &order);
|
taosArrayPush(pOrderInfo, &order);
|
||||||
|
|
||||||
blockDataSort(b, pOrderInfo, true);
|
blockDataSort(b, pOrderInfo);
|
||||||
blockDataDestroy(b);
|
blockDataDestroy(b);
|
||||||
|
|
||||||
taosArrayDestroy(pOrderInfo);
|
taosArrayDestroy(pOrderInfo);
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
aux_source_directory(src DNODE_SRC)
|
aux_source_directory(dm/src DNODE_SRC)
|
||||||
aux_source_directory(dnode/src DNODE_SRC)
|
aux_source_directory(qm/src DNODE_SRC)
|
||||||
aux_source_directory(qnode/src DNODE_SRC)
|
aux_source_directory(bm/src DNODE_SRC)
|
||||||
aux_source_directory(bnode/src DNODE_SRC)
|
aux_source_directory(sm/src DNODE_SRC)
|
||||||
aux_source_directory(snode/src DNODE_SRC)
|
aux_source_directory(vm/src DNODE_SRC)
|
||||||
aux_source_directory(vnode/src DNODE_SRC)
|
aux_source_directory(mm/src DNODE_SRC)
|
||||||
aux_source_directory(mnode/src DNODE_SRC)
|
aux_source_directory(main/src DNODE_SRC)
|
||||||
aux_source_directory(container/src DNODE_SRC)
|
|
||||||
|
|
||||||
add_library(dnode STATIC ${DNODE_SRC})
|
add_library(dnode STATIC ${DNODE_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode cjson mnode vnode qnode snode bnode wal sync taos tfs monitor
|
dnode cjson mnode vnode qnode snode bnode wal sync taos tfs monitor
|
||||||
|
@ -14,16 +12,22 @@ target_link_libraries(
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
dnode
|
dnode
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mgmt"
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mgmt"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/dnode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/dm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qnode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/bnode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/bm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/snode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/sm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/vnode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/vm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/mnode/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/mm/inc"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/container/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/main/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(main)
|
aux_source_directory(main/exe EXEC_SRC)
|
||||||
|
add_executable(taosd ${EXEC_SRC})
|
||||||
|
target_include_directories(
|
||||||
|
taosd
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/main/inc"
|
||||||
|
)
|
||||||
|
target_link_libraries(taosd dnode)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
|
@ -43,7 +43,7 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
// bmWorker.c
|
// bmWorker.c
|
||||||
int32_t bmStartWorker(SBnodeMgmt *pMgmt);
|
int32_t bmStartWorker(SBnodeMgmt *pMgmt);
|
||||||
void bmStopWorker(SBnodeMgmt *pMgmt);
|
void bmStopWorker(SBnodeMgmt *pMgmt);
|
||||||
int32_t bmProcessWriteMsg(SBnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,17 @@ static void bmProcessQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bmProcessWriteMsg(SBnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SBnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SMultiWorker *pWorker = &pMgmt->writeWorker;
|
SMultiWorker *pWorker = &pMgmt->writeWorker;
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
|
int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
|
||||||
SMultiWorkerCfg cfg = {.maxNum = 1, .name = "bnode-write", .fp = (FItems)bmProcessQueue, .param = pMgmt};
|
SMultiWorkerCfg cfg = {.max = 1, .name = "bnode-write", .fp = (FItems)bmProcessQueue, .param = pMgmt};
|
||||||
if (tMultiWorkerInit(&pMgmt->writeWorker, &cfg) != 0) {
|
if (tMultiWorkerInit(&pMgmt->writeWorker, &cfg) != 0) {
|
||||||
dError("failed to start bnode write worker since %s", terrstr());
|
dError("failed to start bnode write worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
|
@ -29,7 +29,7 @@ void dmInitMsgHandles(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
void dmGetMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet);
|
void dmGetMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet);
|
||||||
void dmUpdateMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet);
|
void dmUpdateMnodeEpSet(SDnodeMgmt *pMgmt, SEpSet *pEpSet);
|
||||||
void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
void dmSendRedirectRsp(SDnodeMgmt *pMgmt, const SRpcMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -54,7 +54,7 @@ int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t dmStartWorker(SDnodeMgmt *pMgmt);
|
int32_t dmStartWorker(SDnodeMgmt *pMgmt);
|
||||||
void dmStopWorker(SDnodeMgmt *pMgmt);
|
void dmStopWorker(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmStartThread(SDnodeMgmt *pMgmt);
|
int32_t dmStartThread(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -54,7 +54,7 @@ void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqd
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pMgmt->latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
void dmSendRedirectRsp(SDnodeMgmt *pMgmt, const SRpcMsg *pReq) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
SDnode *pDnode = pMgmt->pDnode;
|
||||||
|
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
|
@ -118,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void dmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void dmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by DNODE
|
// Requests handled by DNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, dmProcessMgmtMsg, VND_VGID);
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, VND_VGID);
|
||||||
}
|
}
|
|
@ -101,14 +101,14 @@ static void dmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
|
int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
|
||||||
SSingleWorkerCfg mgmtCfg = {
|
SSingleWorkerCfg mgmtCfg = {
|
||||||
.minNum = 1, .maxNum = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessQueue, .param = pMgmt};
|
.min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessQueue, .param = pMgmt};
|
||||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &mgmtCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &mgmtCfg) != 0) {
|
||||||
dError("failed to start dnode mgmt worker since %s", terrstr());
|
dError("failed to start dnode mgmt worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSingleWorkerCfg statusCfg = {
|
SSingleWorkerCfg statusCfg = {
|
||||||
.minNum = 1, .maxNum = 1, .name = "dnode-status", .fp = (FItem)dmProcessQueue, .param = pMgmt};
|
.min = 1, .max = 1, .name = "dnode-status", .fp = (FItem)dmProcessQueue, .param = pMgmt};
|
||||||
if (tSingleWorkerInit(&pMgmt->statusWorker, &statusCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->statusWorker, &statusCfg) != 0) {
|
||||||
dError("failed to start dnode status worker since %s", terrstr());
|
dError("failed to start dnode status worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -140,12 +140,14 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
|
||||||
dDebug("dnode workers are closed");
|
dDebug("dnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SDnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
||||||
if (pMsg->rpcMsg.msgType == TDMT_MND_STATUS_RSP) {
|
if (pMsg->rpcMsg.msgType == TDMT_MND_STATUS_RSP) {
|
||||||
pWorker = &pMgmt->statusWorker;
|
pWorker = &pMgmt->statusWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
aux_source_directory(src EXEC_SRC)
|
|
||||||
add_executable(taosd ${EXEC_SRC})
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
taosd
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(taosd dnode)
|
|
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
* 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 "dnd.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
bool dumpConfig;
|
||||||
|
bool generateGrant;
|
||||||
|
bool printAuth;
|
||||||
|
bool printVersion;
|
||||||
|
char envFile[PATH_MAX];
|
||||||
|
char apolloUrl[PATH_MAX];
|
||||||
|
SArray *pArgs; // SConfigPair
|
||||||
|
SDnode *pDnode;
|
||||||
|
ENodeType ntype;
|
||||||
|
} global = {0};
|
||||||
|
|
||||||
|
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
||||||
|
dInfo("signal:%d is received", signum);
|
||||||
|
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
||||||
|
if (pDnode != NULL) {
|
||||||
|
dndHandleEvent(pDnode, DND_EVENT_STOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndSetSignalHandle() {
|
||||||
|
taosSetSignal(SIGTERM, dndSigintHandle);
|
||||||
|
taosSetSignal(SIGHUP, dndSigintHandle);
|
||||||
|
taosSetSignal(SIGINT, dndSigintHandle);
|
||||||
|
taosSetSignal(SIGABRT, dndSigintHandle);
|
||||||
|
taosSetSignal(SIGBREAK, dndSigintHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
|
if (strcmp(argv[i], "-c") == 0) {
|
||||||
|
if (i < argc - 1) {
|
||||||
|
if (strlen(argv[++i]) >= PATH_MAX) {
|
||||||
|
printf("config file path overflow");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tstrncpy(configDir, argv[i], PATH_MAX);
|
||||||
|
} else {
|
||||||
|
printf("'-c' requires a parameter, default is %s\n", configDir);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (strcmp(argv[i], "-a") == 0) {
|
||||||
|
tstrncpy(global.apolloUrl, argv[++i], PATH_MAX);
|
||||||
|
} else if (strcmp(argv[i], "-e") == 0) {
|
||||||
|
tstrncpy(global.envFile, argv[++i], PATH_MAX);
|
||||||
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
|
global.generateGrant = true;
|
||||||
|
} else if (strcmp(argv[i], "-n") == 0) {
|
||||||
|
global.ntype = atoi(argv[++i]);
|
||||||
|
} else if (strcmp(argv[i], "-C") == 0) {
|
||||||
|
global.dumpConfig = true;
|
||||||
|
} else if (strcmp(argv[i], "-V") == 0) {
|
||||||
|
global.printVersion = true;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndGenerateGrant() {
|
||||||
|
// grantParseParameter();
|
||||||
|
printf("this feature is not implemented yet\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndPrintVersion() {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
char *releaseName = "enterprise";
|
||||||
|
#else
|
||||||
|
char *releaseName = "community";
|
||||||
|
#endif
|
||||||
|
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
||||||
|
printf("gitinfo: %s\n", gitinfo);
|
||||||
|
printf("buildInfo: %s\n", buildinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndDumpCfg() {
|
||||||
|
SConfig *pCfg = taosGetCfg();
|
||||||
|
cfgDumpCfg(pCfg, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SDnodeOpt dndGetOpt() {
|
||||||
|
SConfig *pCfg = taosGetCfg();
|
||||||
|
SDnodeOpt option = {0};
|
||||||
|
|
||||||
|
option.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
||||||
|
tstrncpy(option.dataDir, tsDataDir, sizeof(option.dataDir));
|
||||||
|
tstrncpy(option.firstEp, tsFirst, sizeof(option.firstEp));
|
||||||
|
tstrncpy(option.secondEp, tsSecond, sizeof(option.firstEp));
|
||||||
|
option.serverPort = tsServerPort;
|
||||||
|
tstrncpy(option.localFqdn, tsLocalFqdn, sizeof(option.localFqdn));
|
||||||
|
snprintf(option.localEp, sizeof(option.localEp), "%s:%u", option.localFqdn, option.serverPort);
|
||||||
|
option.pDisks = tsDiskCfg;
|
||||||
|
option.numOfDisks = tsDiskCfgNum;
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dndInitLog() {
|
||||||
|
char logName[12] = {0};
|
||||||
|
snprintf(logName, sizeof(logName), "%slog", dndNodeLogStr(global.ntype));
|
||||||
|
return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndSetProcName(char **argv) {
|
||||||
|
if (global.ntype != 0) {
|
||||||
|
const char *name = dndNodeProcStr(global.ntype);
|
||||||
|
prctl(PR_SET_NAME, name);
|
||||||
|
strcpy(argv[0], name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dndRunDnode() {
|
||||||
|
if (dndInit() != 0) {
|
||||||
|
dError("failed to initialize environment since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDnodeOpt option = dndGetOpt();
|
||||||
|
SDnode *pDnode = dndCreate(&option);
|
||||||
|
if (pDnode == NULL) {
|
||||||
|
dError("failed to to create dnode object since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
global.pDnode = pDnode;
|
||||||
|
dndSetSignalHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("start the service");
|
||||||
|
int32_t code = dndRun(pDnode);
|
||||||
|
dInfo("start shutting down the service");
|
||||||
|
|
||||||
|
global.pDnode = NULL;
|
||||||
|
dndClose(pDnode);
|
||||||
|
dndCleanup();
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupCfg();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[]) {
|
||||||
|
if (!taosCheckSystemIsSmallEnd()) {
|
||||||
|
printf("failed to start since on non-small-end machines\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dndParseArgs(argc, argv) != 0) {
|
||||||
|
printf("failed to start since parse args error\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (global.generateGrant) {
|
||||||
|
dndGenerateGrant();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (global.printVersion) {
|
||||||
|
dndPrintVersion();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dndInitLog() != 0) {
|
||||||
|
printf("failed to start since init log error\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosInitCfg(configDir, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
||||||
|
dError("failed to start since read config error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (global.dumpConfig) {
|
||||||
|
dndDumpCfg();
|
||||||
|
taosCleanupCfg();
|
||||||
|
taosCloseLog();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dndSetProcName((char **)argv);
|
||||||
|
return dndRunDnode();
|
||||||
|
}
|
|
@ -33,6 +33,7 @@
|
||||||
#include "tthread.h"
|
#include "tthread.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "tworker.h"
|
#include "tworker.h"
|
||||||
|
#include "tmsgcb.h"
|
||||||
|
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
@ -63,7 +64,7 @@ typedef struct SQnodeMgmt SQnodeMgmt;
|
||||||
typedef struct SSnodeMgmt SSnodeMgmt;
|
typedef struct SSnodeMgmt SSnodeMgmt;
|
||||||
typedef struct SBnodeMgmt SBnodeMgmt;
|
typedef struct SBnodeMgmt SBnodeMgmt;
|
||||||
|
|
||||||
typedef int32_t (*NodeMsgFp)(void *pMgmt, SNodeMsg *pMsg);
|
typedef int32_t (*NodeMsgFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
typedef int32_t (*OpenNodeFp)(SMgmtWrapper *pWrapper);
|
typedef int32_t (*OpenNodeFp)(SMgmtWrapper *pWrapper);
|
||||||
typedef void (*CloseNodeFp)(SMgmtWrapper *pWrapper);
|
typedef void (*CloseNodeFp)(SMgmtWrapper *pWrapper);
|
||||||
typedef int32_t (*StartNodeFp)(SMgmtWrapper *pWrapper);
|
typedef int32_t (*StartNodeFp)(SMgmtWrapper *pWrapper);
|
||||||
|
@ -130,15 +131,19 @@ typedef struct SDnode {
|
||||||
SMgmtWrapper wrappers[NODE_MAX];
|
SMgmtWrapper wrappers[NODE_MAX];
|
||||||
} SDnode;
|
} SDnode;
|
||||||
|
|
||||||
EDndStatus dndGetStatus(SDnode *pDnode);
|
const char *dndNodeLogStr(ENodeType ntype);
|
||||||
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
const char *dndNodeProcStr(ENodeType ntype);
|
||||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
EDndStatus dndGetStatus(SDnode *pDnode);
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
||||||
void dndSendMonitorReport(SDnode *pDnode);
|
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
||||||
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||||
|
void dndSendMonitorReport(SDnode *pDnode);
|
||||||
|
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg);
|
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp);
|
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp);
|
||||||
|
void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
|
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
|
@ -56,6 +56,7 @@ void dndCleanupServer(SDnode *pDnode);
|
||||||
int32_t dndInitClient(SDnode *pDnode);
|
int32_t dndInitClient(SDnode *pDnode);
|
||||||
void dndCleanupClient(SDnode *pDnode);
|
void dndCleanupClient(SDnode *pDnode);
|
||||||
int32_t dndInitMsgHandle(SDnode *pDnode);
|
int32_t dndInitMsgHandle(SDnode *pDnode);
|
||||||
|
void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -1,48 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* 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_DND_MAIN_H_
|
|
||||||
#define _TD_DND_MAIN_H_
|
|
||||||
|
|
||||||
#include "dnode.h"
|
|
||||||
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "tconfig.h"
|
|
||||||
#include "tglobal.h"
|
|
||||||
#include "tlog.h"
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
|
|
||||||
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
|
|
||||||
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
|
|
||||||
#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }}
|
|
||||||
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
|
|
||||||
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
|
|
||||||
|
|
||||||
void dndDumpCfg();
|
|
||||||
void dndPrintVersion();
|
|
||||||
void dndGenerateGrant();
|
|
||||||
SDnodeOpt dndGetOpt();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_DND_MAIN_H_*/
|
|
|
@ -77,6 +77,8 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dndRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
SMsgCb msgCb = dndCreateMsgcb(pWrapper);
|
||||||
|
tmsgSetDefaultMsgCb(&msgCb);
|
||||||
|
|
||||||
if (taosMkDir(pWrapper->path) != 0) {
|
if (taosMkDir(pWrapper->path) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -108,23 +110,25 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndClearNodesExecpt(SDnode *pDnode, ENodeType except) {
|
static void dndClearNodesExecpt(SDnode *pDnode, ENodeType except) {
|
||||||
dndCleanupServer(pDnode);
|
// dndCleanupServer(pDnode);
|
||||||
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
||||||
if (except == n) continue;
|
if (except == n) continue;
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
dndCloseNode(pWrapper);
|
pWrapper->required = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t msgLen, void *pCont, int32_t contLen) {
|
static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
dTrace("msg:%p, get from child queue", pMsg);
|
ProcFuncType ftype) {
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
pRpc->pCont = pCont;
|
pRpc->pCont = pCont;
|
||||||
|
dTrace("msg:%p, get from child queue, handle:%p app:%p", pMsg, pRpc->handle, pRpc->ahandle);
|
||||||
|
|
||||||
NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)];
|
NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)];
|
||||||
int32_t code = (*msgFp)(pWrapper, pMsg);
|
int32_t code = (*msgFp)(pWrapper, pMsg);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||||
if (pRpc->msgType & 1U) {
|
if (pRpc->msgType & 1U) {
|
||||||
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno};
|
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno};
|
||||||
dndSendRsp(pWrapper, &rsp);
|
dndSendRsp(pWrapper, &rsp);
|
||||||
|
@ -136,11 +140,27 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRsp, int32_t msgLen, void *pCont, int32_t contLen) {
|
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
dTrace("msg:%p, get from parent queue", pRsp);
|
ProcFuncType ftype) {
|
||||||
pRsp->pCont = pCont;
|
pMsg->pCont = pCont;
|
||||||
dndSendRsp(pWrapper, pRsp);
|
dTrace("msg:%p, get from parent queue, handle:%p app:%p", pMsg, pMsg->handle, pMsg->ahandle);
|
||||||
taosMemoryFree(pRsp);
|
|
||||||
|
switch (ftype) {
|
||||||
|
case PROC_REG:
|
||||||
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
|
break;
|
||||||
|
case PROC_RELEASE:
|
||||||
|
rpcReleaseHandle(pMsg->handle, (int8_t)pMsg->code);
|
||||||
|
rpcFreeCont(pCont);
|
||||||
|
break;
|
||||||
|
case PROC_REQ:
|
||||||
|
// todo send to dnode
|
||||||
|
dndSendReqToMnode(pWrapper, pMsg);
|
||||||
|
default:
|
||||||
|
dndSendRpcRsp(pWrapper, pMsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
taosMemoryFree(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
|
@ -151,6 +171,9 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dndRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
|
||||||
|
SMsgCb msgCb = dndCreateMsgcb(pWrapper);
|
||||||
|
tmsgSetDefaultMsgCb(&msgCb);
|
||||||
|
|
||||||
if (taosMkDir(pWrapper->path) != 0) {
|
if (taosMkDir(pWrapper->path) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("failed to create dir:%s since %s", pWrapper->path, terrstr());
|
dError("failed to create dir:%s since %s", pWrapper->path, terrstr());
|
||||||
|
@ -198,15 +221,23 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
dndClearNodesExecpt(pDnode, n);
|
dndClearNodesExecpt(pDnode, n);
|
||||||
|
|
||||||
dInfo("node:%s, will be initialized in child process", pWrapper->name);
|
dInfo("node:%s, will be initialized in child process", pWrapper->name);
|
||||||
dndOpenNode(pWrapper);
|
if (dndOpenNode(pWrapper) != 0) {
|
||||||
|
dInfo("node:%s, failed to init in child process since %s", pWrapper->name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosProcRun(pProc) != 0) {
|
||||||
|
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
dInfo("node:%s, will not start in parent process, child pid:%d", pWrapper->name, taosProcChildId(pProc));
|
dInfo("node:%s, will not start in parent process, child pid:%d", pWrapper->name, taosProcChildId(pProc));
|
||||||
pWrapper->procType = PROC_PARENT;
|
pWrapper->procType = PROC_PARENT;
|
||||||
}
|
if (taosProcRun(pProc) != 0) {
|
||||||
|
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
||||||
if (taosProcRun(pProc) != 0) {
|
return -1;
|
||||||
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,19 +80,6 @@ void dndSetStatus(SDnode *pDnode, EDndStatus status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dndStatStr(EDndStatus status) {
|
|
||||||
switch (status) {
|
|
||||||
case DND_STAT_INIT:
|
|
||||||
return "init";
|
|
||||||
case DND_STAT_RUNNING:
|
|
||||||
return "running";
|
|
||||||
case DND_STAT_STOPPED:
|
|
||||||
return "stopped";
|
|
||||||
default:
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
||||||
SStartupReq *pStartup = &pDnode->startup;
|
SStartupReq *pStartup = &pDnode->startup;
|
||||||
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
|
@ -1,138 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "dndMain.h"
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
bool dumpConfig;
|
|
||||||
bool generateGrant;
|
|
||||||
bool printAuth;
|
|
||||||
bool printVersion;
|
|
||||||
char envFile[PATH_MAX];
|
|
||||||
char apolloUrl[PATH_MAX];
|
|
||||||
SDnode *pDnode;
|
|
||||||
} global = {0};
|
|
||||||
|
|
||||||
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
|
||||||
dInfo("signal:%d is received", signum);
|
|
||||||
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
|
||||||
if (pDnode != NULL) {
|
|
||||||
dndHandleEvent(pDnode, DND_EVENT_STOP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dndSetSignalHandle() {
|
|
||||||
taosSetSignal(SIGTERM, dndSigintHandle);
|
|
||||||
taosSetSignal(SIGHUP, dndSigintHandle);
|
|
||||||
taosSetSignal(SIGINT, dndSigintHandle);
|
|
||||||
taosSetSignal(SIGABRT, dndSigintHandle);
|
|
||||||
taosSetSignal(SIGBREAK, dndSigintHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dndParseOption(int32_t argc, char const *argv[]) {
|
|
||||||
for (int32_t i = 1; i < argc; ++i) {
|
|
||||||
if (strcmp(argv[i], "-c") == 0) {
|
|
||||||
if (i < argc - 1) {
|
|
||||||
if (strlen(argv[++i]) >= PATH_MAX) {
|
|
||||||
printf("config file path overflow");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
tstrncpy(configDir, argv[i], PATH_MAX);
|
|
||||||
} else {
|
|
||||||
printf("'-c' requires a parameter, default is %s\n", configDir);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i], "-C") == 0) {
|
|
||||||
global.dumpConfig = true;
|
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
|
||||||
global.generateGrant = true;
|
|
||||||
} else if (strcmp(argv[i], "-V") == 0) {
|
|
||||||
global.printVersion = true;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dndRunDnode() {
|
|
||||||
if (dndInit() != 0) {
|
|
||||||
dInfo("failed to initialize dnode environment since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDnodeOpt option = dndGetOpt();
|
|
||||||
|
|
||||||
SDnode *pDnode = dndCreate(&option);
|
|
||||||
if (pDnode == NULL) {
|
|
||||||
dError("failed to to create dnode object since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
global.pDnode = pDnode;
|
|
||||||
dndSetSignalHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
dInfo("start the TDengine service");
|
|
||||||
int32_t code = dndRun(pDnode);
|
|
||||||
dInfo("start shutting down the TDengine service");
|
|
||||||
|
|
||||||
global.pDnode = NULL;
|
|
||||||
dndClose(pDnode);
|
|
||||||
dndCleanup();
|
|
||||||
taosCloseLog();
|
|
||||||
taosCleanupCfg();
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char const *argv[]) {
|
|
||||||
if (!taosCheckSystemIsSmallEnd()) {
|
|
||||||
dError("failed to start TDengine since on non-small-end machines");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dndParseOption(argc, argv) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global.generateGrant) {
|
|
||||||
dndGenerateGrant();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global.printVersion) {
|
|
||||||
dndPrintVersion();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosCreateLog("taosdlog", 1, configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
|
||||||
dError("failed to start TDengine since read log config error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosInitCfg(configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
|
||||||
dError("failed to start TDengine since read config error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (global.dumpConfig) {
|
|
||||||
dndDumpCfg();
|
|
||||||
taosCleanupCfg();
|
|
||||||
taosCloseLog();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dndRunDnode();
|
|
||||||
}
|
|
|
@ -42,6 +42,8 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pMsg->user, connInfo.user, TSDB_USER_LEN);
|
memcpy(pMsg->user, connInfo.user, TSDB_USER_LEN);
|
||||||
|
pMsg->clientIp = connInfo.clientIp;
|
||||||
|
pMsg->clientPort = connInfo.clientPort;
|
||||||
memcpy(&pMsg->rpcMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(&pMsg->rpcMsg, pRpc, sizeof(SRpcMsg));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -62,11 +64,11 @@ void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
|
|
||||||
if (pWrapper->procType == PROC_SINGLE) {
|
if (pWrapper->procType == PROC_SINGLE) {
|
||||||
dTrace("msg:%p, is created, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle, pMsg->user);
|
dTrace("msg:%p, is created, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle, pMsg->user);
|
||||||
code = (*msgFp)(pWrapper->pMgmt, pMsg);
|
code = (*msgFp)(pWrapper, pMsg);
|
||||||
} else if (pWrapper->procType == PROC_PARENT) {
|
} else if (pWrapper->procType == PROC_PARENT) {
|
||||||
dTrace("msg:%p, is created and will put into child queue, handle:%p app:%p user:%s", pMsg, pRpc->handle,
|
dTrace("msg:%p, is created and will put into child queue, handle:%p app:%p user:%s", pMsg, pRpc->handle,
|
||||||
pRpc->ahandle, pMsg->user);
|
pRpc->ahandle, pMsg->user);
|
||||||
code = taosProcPutToChildQueue(pWrapper->pProc, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen);
|
code = taosProcPutToChildQ(pWrapper->pProc, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen, PROC_REQ);
|
||||||
} else {
|
} else {
|
||||||
dTrace("msg:%p, should not processed in child process, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle,
|
dTrace("msg:%p, should not processed in child process, handle:%p app:%p user:%s", pMsg, pRpc->handle, pRpc->ahandle,
|
||||||
pMsg->user);
|
pMsg->user);
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* 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 "dndInt.h"
|
||||||
|
|
||||||
|
const char *dndStatStr(EDndStatus status) {
|
||||||
|
switch (status) {
|
||||||
|
case DND_STAT_INIT:
|
||||||
|
return "init";
|
||||||
|
case DND_STAT_RUNNING:
|
||||||
|
return "running";
|
||||||
|
case DND_STAT_STOPPED:
|
||||||
|
return "stopped";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dndNodeLogStr(ENodeType ntype) {
|
||||||
|
switch (ntype) {
|
||||||
|
case VNODES:
|
||||||
|
return "vnode";
|
||||||
|
case QNODE:
|
||||||
|
return "qnode";
|
||||||
|
case SNODE:
|
||||||
|
return "snode";
|
||||||
|
case MNODE:
|
||||||
|
return "mnode";
|
||||||
|
case BNODE:
|
||||||
|
return "bnode";
|
||||||
|
default:
|
||||||
|
return "taosd";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dndNodeProcStr(ENodeType ntype) {
|
||||||
|
switch (ntype) {
|
||||||
|
case VNODES:
|
||||||
|
return "taosv";
|
||||||
|
case QNODE:
|
||||||
|
return "taosq";
|
||||||
|
case SNODE:
|
||||||
|
return "taoss";
|
||||||
|
case MNODE:
|
||||||
|
return "taosm";
|
||||||
|
case BNODE:
|
||||||
|
return "taosb";
|
||||||
|
default:
|
||||||
|
return "taosd";
|
||||||
|
}
|
||||||
|
}
|
|
@ -309,7 +309,7 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndSendRpcReq(STransMgmt *pMgmt, SEpSet *pEpSet, SRpcMsg *pReq) {
|
static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
if (pMgmt->clientRpc == NULL) {
|
if (pMgmt->clientRpc == NULL) {
|
||||||
terrno = TSDB_CODE_DND_OFFLINE;
|
terrno = TSDB_CODE_DND_OFFLINE;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -319,9 +319,8 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pReq) {
|
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
if (pWrapper->procType == PROC_CHILD) {
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
} else {
|
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
if (dndGetStatus(pDnode) != DND_STAT_RUNNING) {
|
if (dndGetStatus(pDnode) != DND_STAT_RUNNING) {
|
||||||
terrno = TSDB_CODE_DND_OFFLINE;
|
terrno = TSDB_CODE_DND_OFFLINE;
|
||||||
|
@ -329,26 +328,27 @@ int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pReq)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return dndSendRpcReq(&pDnode->trans, pEpSet, pReq);
|
return dndSendRpcReq(&pDnode->trans, pEpSet, pReq);
|
||||||
|
} else {
|
||||||
|
while (taosProcPutToParentQ(pWrapper->pProc, pReq, sizeof(SRpcMsg), pReq->pCont, pReq->contLen, PROC_REQ) != 0) {
|
||||||
|
taosMsleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
||||||
if (pWrapper->procType == PROC_CHILD) {
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
} else {
|
STransMgmt *pTrans = &pDnode->trans;
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SEpSet epSet = {0};
|
||||||
STransMgmt *pTrans = &pDnode->trans;
|
|
||||||
SEpSet epSet = {0};
|
|
||||||
|
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
SMgmtWrapper *pWrapper2 = dndAcquireWrapper(pDnode, DNODE);
|
||||||
if (pWrapper != NULL) {
|
if (pWrapper2 != NULL) {
|
||||||
dmGetMnodeEpSet(pWrapper->pMgmt, &epSet);
|
dmGetMnodeEpSet(pWrapper2->pMgmt, &epSet);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper2);
|
||||||
}
|
|
||||||
return dndSendRpcReq(pTrans, &epSet, pReq);
|
|
||||||
}
|
}
|
||||||
|
return dndSendRpcReq(pTrans, &epSet, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSendRpcRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
if (pRsp->code == TSDB_CODE_APP_NOT_READY) {
|
if (pRsp->code == TSDB_CODE_APP_NOT_READY) {
|
||||||
SMgmtWrapper *pDnodeWrapper = dndAcquireWrapper(pWrapper->pDnode, DNODE);
|
SMgmtWrapper *pDnodeWrapper = dndAcquireWrapper(pWrapper->pDnode, DNODE);
|
||||||
if (pDnodeWrapper != NULL) {
|
if (pDnodeWrapper != NULL) {
|
||||||
|
@ -362,16 +362,45 @@ static void dndSendRpcRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
if (pWrapper->procType == PROC_CHILD) {
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
int32_t code = -1;
|
|
||||||
do {
|
|
||||||
code = taosProcPutToParentQueue(pWrapper->pProc, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen);
|
|
||||||
if (code != 0) {
|
|
||||||
taosMsleep(10);
|
|
||||||
}
|
|
||||||
} while (code != 0);
|
|
||||||
} else {
|
|
||||||
dndSendRpcRsp(pWrapper, pRsp);
|
dndSendRpcRsp(pWrapper, pRsp);
|
||||||
|
} else {
|
||||||
|
while (taosProcPutToParentQ(pWrapper->pProc, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_RSP) != 0) {
|
||||||
|
taosMsleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
|
} else {
|
||||||
|
while (taosProcPutToParentQ(pWrapper->pProc, pMsg, sizeof(SRpcMsg), pMsg->pCont, pMsg->contLen, PROC_REG) != 0) {
|
||||||
|
taosMsleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type) {
|
||||||
|
if (pWrapper->procType != PROC_CHILD) {
|
||||||
|
rpcReleaseHandle(handle, type);
|
||||||
|
} else {
|
||||||
|
SRpcMsg msg = {.handle = handle, .code = type};
|
||||||
|
while (taosProcPutToParentQ(pWrapper->pProc, &msg, sizeof(SRpcMsg), NULL, 0, PROC_RELEASE) != 0) {
|
||||||
|
taosMsleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper) {
|
||||||
|
SMsgCb msgCb = {
|
||||||
|
.pWrapper = pWrapper,
|
||||||
|
.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg,
|
||||||
|
.releaseHandleFp = dndReleaseHandle,
|
||||||
|
.sendMnodeReqFp = dndSendReqToMnode,
|
||||||
|
.sendReqFp = dndSendReqToDnode,
|
||||||
|
.sendRspFp = dndSendRsp,
|
||||||
|
};
|
||||||
|
return msgCb;
|
||||||
|
}
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "dndMain.h"
|
|
||||||
|
|
||||||
void dndGenerateGrant() {
|
|
||||||
#if 0
|
|
||||||
grantParseParameter();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void dndPrintVersion() {
|
|
||||||
#ifdef TD_ENTERPRISE
|
|
||||||
char *releaseName = "enterprise";
|
|
||||||
#else
|
|
||||||
char *releaseName = "community";
|
|
||||||
#endif
|
|
||||||
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
|
||||||
printf("gitinfo: %s\n", gitinfo);
|
|
||||||
printf("builuInfo: %s\n", buildinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dndDumpCfg() {
|
|
||||||
SConfig *pCfg = taosGetCfg();
|
|
||||||
cfgDumpCfg(pCfg, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDnodeOpt dndGetOpt() {
|
|
||||||
SConfig *pCfg = taosGetCfg();
|
|
||||||
SDnodeOpt option = {0};
|
|
||||||
|
|
||||||
option.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
|
||||||
tstrncpy(option.dataDir, tsDataDir, sizeof(option.dataDir));
|
|
||||||
tstrncpy(option.firstEp, tsFirst, sizeof(option.firstEp));
|
|
||||||
tstrncpy(option.secondEp, tsSecond, sizeof(option.firstEp));
|
|
||||||
option.serverPort = tsServerPort;
|
|
||||||
tstrncpy(option.localFqdn, tsLocalFqdn, sizeof(option.localFqdn));
|
|
||||||
snprintf(option.localEp, sizeof(option.localEp), "%s:%u", option.localFqdn, option.serverPort);
|
|
||||||
option.pDisks = tsDiskCfg;
|
|
||||||
option.numOfDisks = tsDiskCfgNum;
|
|
||||||
return option;
|
|
||||||
}
|
|
|
@ -55,13 +55,14 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
// mmWorker.c
|
// mmWorker.c
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
||||||
void mmStopWorker(SMnodeMgmt *pMgmt);
|
void mmStopWorker(SMnodeMgmt *pMgmt);
|
||||||
int32_t mmProcessWriteMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t mmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t mmProcessSyncMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t mmProcessReadMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t mmProcessReadMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t mmProcessQueryMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpcMsg);
|
|
||||||
int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpcMsg);
|
|
||||||
int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc);
|
int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc);
|
||||||
|
int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc);
|
||||||
|
int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc);
|
||||||
|
int32_t mmPutMsgToSyncQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -48,9 +48,11 @@ static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||||
msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue;
|
msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue;
|
||||||
msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue;
|
msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue;
|
||||||
msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue;
|
msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue;
|
||||||
|
msgCb.queueFps[SYNC_QUEUE] = mmPutMsgToWriteQueue;
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* 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 "mmInt.h"
|
||||||
|
|
||||||
|
int32_t mmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
|
SRpcMsg *pReq = &pMsg->rpcMsg;
|
||||||
|
|
||||||
|
SDCreateMnodeReq createReq = {0};
|
||||||
|
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createReq.replica <= 1 || createReq.dnodeId != pDnode->dnodeId) {
|
||||||
|
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
||||||
|
dError("failed to create mnode since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return mmOpenFromMsg(pWrapper, &createReq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
|
SRpcMsg *pReq = &pMsg->rpcMsg;
|
||||||
|
|
||||||
|
SDDropMnodeReq dropReq = {0};
|
||||||
|
if (tDeserializeSMCreateDropMnodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropReq.dnodeId != pDnode->dnodeId) {
|
||||||
|
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
||||||
|
dError("failed to drop mnode since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return mmDrop(pWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
SDnode *pDnode = pMgmt->pDnode;
|
||||||
|
SRpcMsg *pReq = &pMsg->rpcMsg;
|
||||||
|
|
||||||
|
SDAlterMnodeReq alterReq = {0};
|
||||||
|
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alterReq.dnodeId != pDnode->dnodeId) {
|
||||||
|
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
||||||
|
dError("failed to alter mnode since %s", terrstr());
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return mmAlter(pMgmt, &alterReq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
|
// Requests handled by DNODE
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
|
// Requests handled by MNODE
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
|
// Requests handled by VNODE
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MND_VGID);
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
|
|
||||||
dTrace("msg:%p, will be processed in mnode queue", pMsg);
|
dTrace("msg:%p, get from mnode queue", pMsg);
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
|
@ -31,9 +31,11 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRpc->msgType & 1U) {
|
if (pRpc->msgType & 1U) {
|
||||||
if (pRpc->handle == NULL) return;
|
if (pRpc->handle != NULL && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
if (code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != 0) {
|
||||||
if (code != 0) code = terrno;
|
code = terrno;
|
||||||
|
dError("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||||
|
}
|
||||||
SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .contLen = pMsg->rspLen, .pCont = pMsg->pRsp};
|
SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .contLen = pMsg->rspLen, .pCont = pMsg->pRsp};
|
||||||
dndSendRsp(pMgmt->pWrapper, &rsp);
|
dndSendRsp(pMgmt->pWrapper, &rsp);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +49,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
|
|
||||||
dTrace("msg:%p, will be processed in mnode queue", pMsg);
|
dTrace("msg:%p, get from mnode query queue", pMsg);
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
|
@ -55,8 +57,8 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
code = mndProcessMsg(pMsg);
|
code = mndProcessMsg(pMsg);
|
||||||
|
|
||||||
if (pRpc->msgType & 1U) {
|
if (pRpc->msgType & 1U) {
|
||||||
if (pRpc->handle == NULL) return;
|
if (pRpc->handle != NULL && code != 0) {
|
||||||
if (code != 0) {
|
dError("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||||
SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .ahandle = pRpc->ahandle};
|
SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .ahandle = pRpc->ahandle};
|
||||||
dndSendRsp(pMgmt->pWrapper, &rsp);
|
dndSendRsp(pMgmt->pWrapper, &rsp);
|
||||||
}
|
}
|
||||||
|
@ -67,83 +69,86 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) {
|
||||||
static int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SNodeMsg *pMsg) {
|
|
||||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessWriteMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t mmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return mmPutMsgToWorker(pMgmt, &pMgmt->writeWorker, pMsg);
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
mmPutMsgToWorker(&pMgmt->writeWorker, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessSyncMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg);
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
mmPutMsgToWorker(&pMgmt->syncWorker, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessReadMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t mmProcessReadMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return mmPutMsgToWorker(pMgmt, &pMgmt->readWorker, pMsg);
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
mmPutMsgToWorker(&pMgmt->readWorker, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessQueryMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return mmPutMsgToWorker(pMgmt, &pMgmt->queryWorker, pMsg);
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
mmPutMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mmPutRpcMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pRpc) {
|
static int32_t mmPutRpcMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pRpc) {
|
||||||
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||||
pMsg->rpcMsg = *pRpc;
|
pMsg->rpcMsg = *pRpc;
|
||||||
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
int32_t code = taosWriteQitem(pWorker->queue, pMsg);
|
return 0;
|
||||||
if (code != 0) {
|
|
||||||
dTrace("msg:%p, is freed", pMsg);
|
|
||||||
taosFreeQitem(pMsg);
|
|
||||||
rpcFreeCont(pRpc->pCont);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
|
||||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
|
||||||
return mmPutRpcMsgToWorker(pMgmt, &pMgmt->writeWorker, pRpc);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
|
||||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
|
||||||
return mmPutRpcMsgToWorker(pMgmt, &pMgmt->readWorker, pRpc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
return mmPutRpcMsgToWorker(pMgmt, &pMgmt->queryWorker, pRpc);
|
return mmPutRpcMsgToWorker(&pMgmt->queryWorker, pRpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return mmPutRpcMsgToWorker(&pMgmt->writeWorker, pRpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return mmPutRpcMsgToWorker(&pMgmt->readWorker, pRpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mmPutMsgToSyncQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pRpc);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
SSingleWorkerCfg cfg = {.minNum = 0, .maxNum = 1, .name = "mnode-read", .fp = (FItem)mmProcessQueue, .param = pMgmt};
|
SSingleWorkerCfg qCfg = {.min = 0, .max = 1, .name = "mnode-query", .fp = (FItem)mmProcessQueryQueue, .param = pMgmt};
|
||||||
SSingleWorkerCfg queryCfg = {.minNum = 0, .maxNum = 1, .name = "mnode-query", .fp = (FItem)mmProcessQueryQueue, .param = pMgmt};
|
if (tSingleWorkerInit(&pMgmt->queryWorker, &qCfg) != 0) {
|
||||||
|
|
||||||
if (tSingleWorkerInit(&pMgmt->queryWorker, &queryCfg) != 0) {
|
|
||||||
dError("failed to start mnode-query worker since %s", terrstr());
|
dError("failed to start mnode-query worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tSingleWorkerInit(&pMgmt->readWorker, &cfg) != 0) {
|
SSingleWorkerCfg rCfg = {.min = 0, .max = 1, .name = "mnode-read", .fp = (FItem)mmProcessQueue, .param = pMgmt};
|
||||||
|
if (tSingleWorkerInit(&pMgmt->readWorker, &rCfg) != 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 (tSingleWorkerInit(&pMgmt->writeWorker, &cfg) != 0) {
|
SSingleWorkerCfg wCfg = {.min = 0, .max = 1, .name = "mnode-write", .fp = (FItem)mmProcessQueue, .param = pMgmt};
|
||||||
|
if (tSingleWorkerInit(&pMgmt->writeWorker, &wCfg) != 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 (tSingleWorkerInit(&pMgmt->syncWorker, &cfg) != 0) {
|
SSingleWorkerCfg sCfg = {.min = 0, .max = 1, .name = "mnode-sync", .fp = (FItem)mmProcessQueue, .param = pMgmt};
|
||||||
|
if (tSingleWorkerInit(&pMgmt->syncWorker, &sCfg) != 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;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +158,8 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmStopWorker(SMnodeMgmt *pMgmt) {
|
void mmStopWorker(SMnodeMgmt *pMgmt) {
|
||||||
tSingleWorkerCleanup(&pMgmt->readWorker);
|
|
||||||
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
||||||
|
tSingleWorkerCleanup(&pMgmt->readWorker);
|
||||||
tSingleWorkerCleanup(&pMgmt->writeWorker);
|
tSingleWorkerCleanup(&pMgmt->writeWorker);
|
||||||
tSingleWorkerCleanup(&pMgmt->syncWorker);
|
tSingleWorkerCleanup(&pMgmt->syncWorker);
|
||||||
dDebug("mnode workers are closed");
|
dDebug("mnode workers are closed");
|
|
@ -1,165 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "mmInt.h"
|
|
||||||
|
|
||||||
int32_t mmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
|
||||||
SRpcMsg *pReq = &pMsg->rpcMsg;
|
|
||||||
|
|
||||||
SDCreateMnodeReq createReq = {0};
|
|
||||||
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (createReq.replica <= 1 || createReq.dnodeId != pDnode->dnodeId) {
|
|
||||||
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
|
||||||
dError("failed to create mnode since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return mmOpenFromMsg(pWrapper, &createReq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
|
||||||
SRpcMsg *pReq = &pMsg->rpcMsg;
|
|
||||||
|
|
||||||
SDDropMnodeReq dropReq = {0};
|
|
||||||
if (tDeserializeSMCreateDropMnodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropReq.dnodeId != pDnode->dnodeId) {
|
|
||||||
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
|
||||||
dError("failed to drop mnode since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return mmDrop(pWrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
|
||||||
SRpcMsg *pReq = &pMsg->rpcMsg;
|
|
||||||
|
|
||||||
SDAlterMnodeReq alterReq = {0};
|
|
||||||
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alterReq.dnodeId != pDnode->dnodeId) {
|
|
||||||
terrno = TSDB_CODE_NODE_INVALID_OPTION;
|
|
||||||
dError("failed to alter mnode since %s", terrstr());
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return mmAlter(pMgmt, &alterReq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
|
||||||
// Requests handled by DNODE
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
|
|
||||||
// Requests handled by MNODE
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
|
|
||||||
// Requests handled by VNODE
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)mmProcessQueryMsg, MND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)mmProcessQueryMsg, MND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)mmProcessQueryMsg, MND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)mmProcessQueryMsg, MND_VGID);
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)mmProcessQueryMsg, MND_VGID);
|
|
||||||
|
|
||||||
}
|
|
|
@ -48,8 +48,8 @@ int32_t qmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype);
|
||||||
|
|
||||||
int32_t qmStartWorker(SQnodeMgmt *pMgmt);
|
int32_t qmStartWorker(SQnodeMgmt *pMgmt);
|
||||||
void qmStopWorker(SQnodeMgmt *pMgmt);
|
void qmStopWorker(SQnodeMgmt *pMgmt);
|
||||||
int32_t qmProcessQueryMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t qmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t qmProcessFetchMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t qmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) {
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void qmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void qmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QND_VGID);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QND_VGID);
|
||||||
}
|
}
|
|
@ -49,14 +49,22 @@ static void qmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t qmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) {
|
static void qmPutMsgToWorker(SSingleWorker *pWorker, SNodeMsg *pMsg) {
|
||||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmProcessQueryMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg) { return qmPutMsgToWorker(&pMgmt->queryWorker, pMsg); }
|
int32_t qmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SQnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
qmPutMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t qmProcessFetchMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg) { return qmPutMsgToWorker(&pMgmt->fetchWorker, pMsg); }
|
int32_t qmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SQnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
qmPutMsgToWorker(&pMgmt->fetchWorker, pMsg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pRpc) {
|
static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pRpc) {
|
||||||
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
||||||
|
@ -66,15 +74,8 @@ static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SR
|
||||||
|
|
||||||
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||||
pMsg->rpcMsg = *pRpc;
|
pMsg->rpcMsg = *pRpc;
|
||||||
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
int32_t code = taosWriteQitem(pWorker->queue, pMsg);
|
return 0;
|
||||||
if (code != 0) {
|
|
||||||
dTrace("msg:%p, is freed", pMsg);
|
|
||||||
taosFreeQitem(pMsg);
|
|
||||||
rpcFreeCont(pRpc->pCont);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
int32_t qmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
@ -110,8 +111,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
||||||
int32_t minQueryThreads = TMAX((int32_t)(tsNumOfCores * tsRatioOfQueryCores), 1);
|
int32_t minQueryThreads = TMAX((int32_t)(tsNumOfCores * tsRatioOfQueryCores), 1);
|
||||||
int32_t maxQueryThreads = minQueryThreads;
|
int32_t maxQueryThreads = minQueryThreads;
|
||||||
|
|
||||||
SSingleWorkerCfg queryCfg = {.minNum = minQueryThreads,
|
SSingleWorkerCfg queryCfg = {.min = minQueryThreads,
|
||||||
.maxNum = maxQueryThreads,
|
.max = maxQueryThreads,
|
||||||
.name = "qnode-query",
|
.name = "qnode-query",
|
||||||
.fp = (FItem)qmProcessQueryQueue,
|
.fp = (FItem)qmProcessQueryQueue,
|
||||||
.param = pMgmt};
|
.param = pMgmt};
|
||||||
|
@ -121,8 +122,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSingleWorkerCfg fetchCfg = {.minNum = minFetchThreads,
|
SSingleWorkerCfg fetchCfg = {.min = minFetchThreads,
|
||||||
.maxNum = maxFetchThreads,
|
.max = maxFetchThreads,
|
||||||
.name = "qnode-fetch",
|
.name = "qnode-fetch",
|
||||||
.fp = (FItem)qmProcessFetchQueue,
|
.fp = (FItem)qmProcessFetchQueue,
|
||||||
.param = pMgmt};
|
.param = pMgmt};
|
|
@ -46,10 +46,10 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
// smWorker.c
|
// smWorker.c
|
||||||
int32_t smStartWorker(SSnodeMgmt *pMgmt);
|
int32_t smStartWorker(SSnodeMgmt *pMgmt);
|
||||||
void smStopWorker(SSnodeMgmt *pMgmt);
|
void smStopWorker(SSnodeMgmt *pMgmt);
|
||||||
int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t smProcessSharedMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t smProcessSharedMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t smProcessExecMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t smProcessExecMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) {
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
pOption->msgCb = msgCb;
|
pOption->msgCb = msgCb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void smInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void smInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by SNODE
|
// Requests handled by SNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, VND_VGID);
|
||||||
}
|
}
|
|
@ -57,7 +57,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMultiWorkerCfg cfg = {.maxNum = 1, .name = "snode-unique", .fp = smProcessUniqueQueue, .param = pMgmt};
|
SMultiWorkerCfg cfg = {.max = 1, .name = "snode-unique", .fp = smProcessUniqueQueue, .param = pMgmt};
|
||||||
|
|
||||||
if (tMultiWorkerInit(pUniqueWorker, &cfg) != 0) {
|
if (tMultiWorkerInit(pUniqueWorker, &cfg) != 0) {
|
||||||
dError("failed to start snode-unique worker since %s", terrstr());
|
dError("failed to start snode-unique worker since %s", terrstr());
|
||||||
|
@ -69,8 +69,8 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSingleWorkerCfg cfg = {.minNum = SND_SHARED_THREAD_NUM,
|
SSingleWorkerCfg cfg = {.min = SND_SHARED_THREAD_NUM,
|
||||||
.maxNum = SND_SHARED_THREAD_NUM,
|
.max = SND_SHARED_THREAD_NUM,
|
||||||
.name = "snode-shared",
|
.name = "snode-shared",
|
||||||
.fp = (FItem)smProcessSharedQueue,
|
.fp = (FItem)smProcessSharedQueue,
|
||||||
.param = pMgmt};
|
.param = pMgmt};
|
||||||
|
@ -107,7 +107,8 @@ static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SSnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, 0);
|
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, 0);
|
||||||
if (pWorker == NULL) {
|
if (pWorker == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -115,10 +116,12 @@ int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SSnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
int32_t index = smGetSWIdFromMsg(&pMsg->rpcMsg);
|
int32_t index = smGetSWIdFromMsg(&pMsg->rpcMsg);
|
||||||
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index);
|
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index);
|
||||||
if (pWorker == NULL) {
|
if (pWorker == NULL) {
|
||||||
|
@ -127,21 +130,24 @@ int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessSharedMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t smProcessSharedMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SSnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SSingleWorker *pWorker = &pMgmt->sharedWorker;
|
SSingleWorker *pWorker = &pMgmt->sharedWorker;
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessExecMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t smProcessExecMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
int32_t workerType = smGetSWTypeFromMsg(&pMsg->rpcMsg);
|
int32_t workerType = smGetSWTypeFromMsg(&pMsg->rpcMsg);
|
||||||
if (workerType == SND_WORKER_TYPE__SHARED) {
|
if (workerType == SND_WORKER_TYPE__SHARED) {
|
||||||
return smProcessSharedMsg(pMgmt, pMsg);
|
return smProcessSharedMsg(pWrapper, pMsg);
|
||||||
} else {
|
} else {
|
||||||
return smProcessUniqueMsg(pMgmt, pMsg);
|
return smProcessUniqueMsg(pWrapper, pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -108,12 +108,12 @@ int32_t vmPutMsgToFetchQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t vmPutMsgToApplyQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t vmPutMsgToApplyQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype);
|
int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype);
|
||||||
|
|
||||||
int32_t vmProcessWriteMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrappert, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -137,6 +137,7 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
||||||
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
|
@ -91,6 +91,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
msgCb.sendReqFp = dndSendReqToDnode;
|
msgCb.sendReqFp = dndSendReqToDnode;
|
||||||
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
msgCb.sendMnodeReqFp = dndSendReqToMnode;
|
||||||
msgCb.sendRspFp = dndSendRsp;
|
msgCb.sendRspFp = dndSendRsp;
|
||||||
|
msgCb.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg;
|
||||||
|
|
||||||
vnodeCfg.msgCb = msgCb;
|
vnodeCfg.msgCb = msgCb;
|
||||||
vnodeCfg.pTfs = pMgmt->pTfs;
|
vnodeCfg.pTfs = pMgmt->pTfs;
|
||||||
|
@ -281,11 +282,12 @@ void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, VND_VGID);
|
||||||
}
|
}
|
|
@ -179,9 +179,7 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) {
|
static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) {
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
int32_t code = -1;
|
|
||||||
|
|
||||||
SMsgHead *pHead = pRpc->pCont;
|
SMsgHead *pHead = pRpc->pCont;
|
||||||
pHead->contLen = ntohl(pHead->contLen);
|
pHead->contLen = ntohl(pHead->contLen);
|
||||||
pHead->vgId = ntohl(pHead->vgId);
|
pHead->vgId = ntohl(pHead->vgId);
|
||||||
|
@ -192,28 +190,30 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
switch (qtype) {
|
switch (qtype) {
|
||||||
case QUERY_QUEUE:
|
case QUERY_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-query queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-query queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pQueryQ, pMsg);
|
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case FETCH_QUEUE:
|
case FETCH_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-fetch queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-fetch queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pFetchQ, pMsg);
|
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case WRITE_QUEUE:
|
case WRITE_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-write queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-write queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pWriteQ, pMsg);
|
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case SYNC_QUEUE:
|
case SYNC_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-sync queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-sync queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pSyncQ, pMsg);
|
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case MERGE_QUEUE:
|
case MERGE_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-merge queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-merge queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pMergeQ, pMsg);
|
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
code = -1;
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -222,52 +222,73 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); }
|
int32_t vmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return vmPutNodeMsgToQueue(pMgmt, pMsg, SYNC_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessWriteMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, WRITE_QUEUE); }
|
int32_t vmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return vmPutNodeMsgToQueue(pMgmt, pMsg, WRITE_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, QUERY_QUEUE); }
|
int32_t vmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return vmPutNodeMsgToQueue(pMgmt, pMsg, QUERY_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); }
|
int32_t vmProcessFetchMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, MERGE_QUEUE); }
|
int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
|
return vmPutNodeMsgToQueue(pMgmt, pMsg, MERGE_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
||||||
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) {
|
static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) {
|
||||||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
int32_t code = -1;
|
|
||||||
SMsgHead *pHead = pRpc->pCont;
|
SMsgHead *pHead = pRpc->pCont;
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||||
if (pVnode == NULL) return -1;
|
if (pVnode == NULL) return -1;
|
||||||
|
|
||||||
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
SNodeMsg *pMsg = taosAllocateQitem(sizeof(SNodeMsg));
|
||||||
if (pMsg != NULL) {
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (pMsg == NULL) {
|
||||||
|
code = -1;
|
||||||
|
} else {
|
||||||
dTrace("msg:%p, is created, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
dTrace("msg:%p, is created, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
pMsg->rpcMsg = *pRpc;
|
pMsg->rpcMsg = *pRpc;
|
||||||
switch (qtype) {
|
switch (qtype) {
|
||||||
case QUERY_QUEUE:
|
case QUERY_QUEUE:
|
||||||
dTrace("msg:%p, will be put into vnode-query queue", pMsg);
|
dTrace("msg:%p, will be put into vnode-query queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pQueryQ, pMsg);
|
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case FETCH_QUEUE:
|
case FETCH_QUEUE:
|
||||||
dTrace("msg:%p, will be put into vnode-fetch queue", pMsg);
|
dTrace("msg:%p, will be put into vnode-fetch queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pFetchQ, pMsg);
|
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case APPLY_QUEUE:
|
case APPLY_QUEUE:
|
||||||
dTrace("msg:%p, will be put into vnode-apply queue", pMsg);
|
dTrace("msg:%p, will be put into vnode-apply queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pApplyQ, pMsg);
|
taosWriteQitem(pVnode->pApplyQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case MERGE_QUEUE:
|
case MERGE_QUEUE:
|
||||||
dTrace("msg:%p, will be put into vnode-merge queue", pMsg);
|
dTrace("msg:%p, will be put into vnode-merge queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pMergeQ, pMsg);
|
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
code = -1;
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +415,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
||||||
if (tWWorkerInit(pWPool) != 0) return -1;
|
if (tWWorkerInit(pWPool) != 0) return -1;
|
||||||
|
|
||||||
SSingleWorkerCfg cfg = {
|
SSingleWorkerCfg cfg = {
|
||||||
.minNum = 1, .maxNum = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
.min = 1, .max = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
||||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
||||||
dError("failed to start vnode-mgmt worker since %s", terrstr());
|
dError("failed to start vnode-mgmt worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
|
@ -28,6 +28,7 @@ SDbObj *mndAcquireDb(SMnode *pMnode, const char *db);
|
||||||
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
||||||
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
||||||
char *mnGetDbStr(char *src);
|
char *mnGetDbStr(char *src);
|
||||||
|
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,10 +731,10 @@ typedef struct {
|
||||||
int32_t vgNum;
|
int32_t vgNum;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
int8_t sourceType;
|
|
||||||
int8_t sinkType;
|
|
||||||
// int32_t sqlLen;
|
// int32_t sqlLen;
|
||||||
int32_t sinkVgId; // 0 for automatic
|
int8_t createdBy; // STREAM_CREATED_BY__USER or SMA
|
||||||
|
int32_t fixedSinkVgId; // 0 for shuffle
|
||||||
|
int64_t smaId; // 0 for unused
|
||||||
char* sql;
|
char* sql;
|
||||||
char* logicalPlan;
|
char* logicalPlan;
|
||||||
char* physicalPlan;
|
char* physicalPlan;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void mndCleanupScheduler(SMnode* pMnode);
|
||||||
|
|
||||||
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, int64_t smaId);
|
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||||
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans, int64_t smaId);
|
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,6 +276,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||||
if (pCfg->quorum > pCfg->replications) return -1;
|
if (pCfg->quorum > pCfg->replications) return -1;
|
||||||
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1;
|
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1;
|
||||||
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
|
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
|
||||||
|
if (pCfg->streamMode < TSDB_MIN_DB_STREAM_MODE || pCfg->streamMode > TSDB_MAX_DB_STREAM_MODE) return -1;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +286,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
||||||
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
|
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
|
||||||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = TSDB_DEFAULT_KEEP;
|
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||||
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = TSDB_DEFAULT_KEEP;
|
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
|
||||||
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MIN_ROW_FBLOCK;
|
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MIN_ROW_FBLOCK;
|
||||||
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAX_ROW_FBLOCK;
|
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAX_ROW_FBLOCK;
|
||||||
if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME;
|
if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME;
|
||||||
|
@ -298,6 +299,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->quorum < 0) pCfg->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
if (pCfg->quorum < 0) pCfg->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
||||||
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
||||||
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||||
|
if (pCfg->streamMode < 0) pCfg->streamMode = TSDB_DEFAULT_DB_STREAM_MODE;
|
||||||
|
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) {
|
static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) {
|
||||||
|
@ -431,11 +434,11 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
||||||
.daysToKeep2 = pCreate->daysToKeep2,
|
.daysToKeep2 = pCreate->daysToKeep2,
|
||||||
.minRows = pCreate->minRows,
|
.minRows = pCreate->minRows,
|
||||||
.maxRows = pCreate->maxRows,
|
.maxRows = pCreate->maxRows,
|
||||||
.fsyncPeriod = pCreate->fsyncPeriod,
|
|
||||||
.commitTime = pCreate->commitTime,
|
.commitTime = pCreate->commitTime,
|
||||||
|
.fsyncPeriod = pCreate->fsyncPeriod,
|
||||||
|
.walLevel = pCreate->walLevel,
|
||||||
.precision = pCreate->precision,
|
.precision = pCreate->precision,
|
||||||
.compression = pCreate->compression,
|
.compression = pCreate->compression,
|
||||||
.walLevel = pCreate->walLevel,
|
|
||||||
.replications = pCreate->replications,
|
.replications = pCreate->replications,
|
||||||
.quorum = pCreate->quorum,
|
.quorum = pCreate->quorum,
|
||||||
.update = pCreate->update,
|
.update = pCreate->update,
|
||||||
|
@ -445,7 +448,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
||||||
|
|
||||||
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
||||||
dbObj.cfg.pRetensions = pCreate->pRetensions;
|
dbObj.cfg.pRetensions = pCreate->pRetensions;
|
||||||
pCreate = NULL;
|
pCreate->pRetensions = NULL;
|
||||||
|
|
||||||
mndSetDefaultDbCfg(&dbObj.cfg);
|
mndSetDefaultDbCfg(&dbObj.cfg);
|
||||||
|
|
||||||
|
@ -955,7 +958,6 @@ void mndGetDBTableNum(SDbObj *pDb, SMnode *pMnode, int32_t *num) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
||||||
int32_t vindex = 0;
|
int32_t vindex = 0;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -991,7 +993,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
|
||||||
if (pDb && (vindex >= pDb->cfg.numOfVgroups)) {
|
if (pDb && (vindex >= pDb->cfg.numOfVgroups)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1000,6 +1002,28 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq) {
|
||||||
|
pRsp->pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo));
|
||||||
|
if (pRsp->pVgroupInfos == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfTable = 0;
|
||||||
|
mndGetDBTableNum(pDb, pMnode, &numOfTable);
|
||||||
|
|
||||||
|
if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable) {
|
||||||
|
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
pRsp->uid = pDb->uid;
|
||||||
|
pRsp->vgVersion = pDb->vgVersion;
|
||||||
|
pRsp->vgNum = taosArrayGetSize(pRsp->pVgroupInfos);
|
||||||
|
pRsp->hashMethod = pDb->hashMethod;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pNode;
|
SMnode *pMnode = pReq->pNode;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -1023,10 +1047,10 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto USE_DB_OVER;
|
goto USE_DB_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
||||||
usedbRsp.vgVersion = vgVersion++;
|
usedbRsp.vgVersion = vgVersion++;
|
||||||
|
|
||||||
if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) {
|
if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1058,7 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
||||||
usedbRsp.vgVersion = usedbReq.vgVersion;
|
usedbRsp.vgVersion = usedbReq.vgVersion;
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
||||||
|
|
||||||
// no jump, need to construct rsp
|
// no jump, need to construct rsp
|
||||||
} else {
|
} else {
|
||||||
|
@ -1057,24 +1081,10 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
||||||
goto USE_DB_OVER;
|
goto USE_DB_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
usedbRsp.pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo));
|
if (mndExtractDbInfo(pMnode, pDb, &usedbRsp, &usedbReq) < 0) {
|
||||||
if (usedbRsp.pVgroupInfos == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto USE_DB_OVER;
|
goto USE_DB_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTable = 0;
|
|
||||||
mndGetDBTableNum(pDb, pMnode, &numOfTable);
|
|
||||||
|
|
||||||
if (usedbReq.vgVersion < pDb->vgVersion || usedbReq.dbId != pDb->uid || numOfTable != usedbReq.numOfTable) {
|
|
||||||
mndBuildDBVgroupInfo(pDb, pMnode, usedbRsp.pVgroupInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(usedbRsp.db, pDb->name, TSDB_DB_FNAME_LEN);
|
|
||||||
usedbRsp.uid = pDb->uid;
|
|
||||||
usedbRsp.vgVersion = pDb->vgVersion;
|
|
||||||
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
|
||||||
usedbRsp.hashMethod = pDb->hashMethod;
|
|
||||||
code = 0;
|
code = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1148,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
usedbRsp.pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo));
|
usedbRsp.pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo));
|
||||||
if (usedbRsp.pVgroupInfos == NULL) {
|
if (usedbRsp.pVgroupInfos == NULL) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
@ -1364,11 +1374,11 @@ static int32_t mndGetDbMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMet
|
||||||
pSchema[cols].bytes = pShow->bytes[cols];
|
pSchema[cols].bytes = pShow->bytes[cols];
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
// pShow->bytes[cols] = 1;
|
// pShow->bytes[cols] = 1;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||||
// strcpy(pSchema[cols].name, "update");
|
// strcpy(pSchema[cols].name, "update");
|
||||||
// pSchema[cols].bytes = pShow->bytes[cols];
|
// pSchema[cols].bytes = pShow->bytes[cols];
|
||||||
// cols++;
|
// cols++;
|
||||||
|
|
||||||
pMeta->numOfColumns = cols;
|
pMeta->numOfColumns = cols;
|
||||||
pShow->numOfColumns = cols;
|
pShow->numOfColumns = cols;
|
||||||
|
@ -1396,14 +1406,15 @@ char *mnGetDbStr(char *src) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* getDataPosition(char* pData, SShowObj* pShow, int32_t cols, int32_t rows, int32_t capacityOfRow) {
|
static char *getDataPosition(char *pData, SShowObj *pShow, int32_t cols, int32_t rows, int32_t capacityOfRow) {
|
||||||
return pData + pShow->offset[cols] * capacityOfRow + pShow->bytes[cols] * rows;
|
return pData + pShow->offset[cols] * capacityOfRow + pShow->bytes[cols] * rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpDbInfoToPayload(char* data, SDbObj* pDb, SShowObj* pShow, int32_t rows, int32_t rowCapacity, int64_t numOfTables) {
|
static void dumpDbInfoToPayload(char *data, SDbObj *pDb, SShowObj *pShow, int32_t rows, int32_t rowCapacity,
|
||||||
|
int64_t numOfTables) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
char* pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
char *pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
||||||
char *name = mnGetDbStr(pDb->name);
|
char *name = mnGetDbStr(pDb->name);
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]);
|
||||||
|
@ -1497,20 +1508,28 @@ static void dumpDbInfoToPayload(char* data, SDbObj* pDb, SShowObj* pShow, int32_
|
||||||
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
|
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
// pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
// pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
||||||
// *(int8_t *)pWrite = pDb->cfg.update;
|
// *(int8_t *)pWrite = pDb->cfg.update;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setInformationSchemaDbCfg(SDbObj* pDbObj) {
|
static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
|
||||||
ASSERT(pDbObj != NULL);
|
ASSERT(pDbObj != NULL);
|
||||||
strncpy(pDbObj->name, TSDB_INFORMATION_SCHEMA_DB, tListLen(pDbObj->name));
|
strncpy(pDbObj->name, TSDB_INFORMATION_SCHEMA_DB, tListLen(pDbObj->name));
|
||||||
|
|
||||||
pDbObj->createdTime = 0;
|
pDbObj->createdTime = 0;
|
||||||
pDbObj->cfg.numOfVgroups = 0;
|
pDbObj->cfg.numOfVgroups = 0;
|
||||||
pDbObj->cfg.quorum = 1;
|
pDbObj->cfg.quorum = 1;
|
||||||
pDbObj->cfg.replications = 1;
|
pDbObj->cfg.replications = 1;
|
||||||
pDbObj->cfg.update = 1;
|
pDbObj->cfg.update = 1;
|
||||||
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||||
|
SVgObj *pVgroup = pObj;
|
||||||
|
int32_t *numOfTables = p1;
|
||||||
|
|
||||||
|
*numOfTables += pVgroup->numOfTables;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rowsCapacity) {
|
static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rowsCapacity) {
|
||||||
|
@ -1525,7 +1544,10 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dumpDbInfoToPayload(data, pDb, pShow, numOfRows, rowsCapacity, 0);
|
int32_t numOfTables = 0;
|
||||||
|
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL);
|
||||||
|
|
||||||
|
dumpDbInfoToPayload(data, pDb, pShow, numOfRows, rowsCapacity, numOfTables);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pDb);
|
sdbRelease(pSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,11 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
||||||
if (tEncodeI64(pEncoder, pObj->dbUid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->dbUid) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->logicalPlan) < 0) return -1;
|
/*if (tEncodeCStr(pEncoder, pObj->logicalPlan) < 0) return -1;*/
|
||||||
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
||||||
// TODO encode tasks
|
// TODO encode tasks
|
||||||
if (pObj->tasks) {
|
if (pObj->tasks) {
|
||||||
|
@ -69,8 +72,11 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
||||||
if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1;
|
/*if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1;*/
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
||||||
pObj->tasks = NULL;
|
pObj->tasks = NULL;
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
|
|
|
@ -20,138 +20,178 @@
|
||||||
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
|
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
|
||||||
static const SInfosTableSchema dnodesSchema[] = {{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
static const SInfosTableSchema dnodesSchema[] = {
|
||||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "max_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "max_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
};
|
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
static const SInfosTableSchema mnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
};
|
||||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
static const SInfosTableSchema mnodesSchema[] = {
|
||||||
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
};
|
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
static const SInfosTableSchema modulesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
};
|
||||||
{.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
static const SInfosTableSchema modulesSchema[] = {
|
||||||
};
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
static const SInfosTableSchema qnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
};
|
||||||
};
|
static const SInfosTableSchema qnodesSchema[] = {
|
||||||
static const SInfosTableSchema userDBSchema[] = {{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
};
|
||||||
{.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
static const SInfosTableSchema userDBSchema[] = {
|
||||||
{.name = "quorum", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "days", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "quorum", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "days", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "wallevel", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "precision", .bytes = 3 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
|
{.name = "wallevel", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
};
|
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
static const SInfosTableSchema userFuncSchema[] = {{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "precision", .bytes = 3 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
// {.name = "update", .bytes = 1, .type =
|
||||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
// TSDB_DATA_TYPE_TINYINT}, // disable update
|
||||||
};
|
};
|
||||||
static const SInfosTableSchema userIdxSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
static const SInfosTableSchema userFuncSchema[] = {
|
||||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "index_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "index_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "column_name", .bytes = 64, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
};
|
||||||
};
|
static const SInfosTableSchema userIdxSchema[] = {
|
||||||
static const SInfosTableSchema userStbsSchema[] = {{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "index_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "index_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "column_name", .bytes = 64, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT},
|
};
|
||||||
};
|
static const SInfosTableSchema userStbsSchema[] = {
|
||||||
static const SInfosTableSchema userStreamsSchema[] = {{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "dest_table", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
};
|
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
|
{.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
};
|
||||||
|
static const SInfosTableSchema userStreamsSchema[] = {
|
||||||
|
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "dest_table", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
|
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
};
|
||||||
static const SInfosTableSchema userTblsSchema[] = {
|
static const SInfosTableSchema userTblsSchema[] = {
|
||||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
};
|
};
|
||||||
static const SInfosTableSchema userTblDistSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
static const SInfosTableSchema userTblDistSchema[] = {
|
||||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "distributed_histogram", .bytes = 500, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "distributed_histogram", .bytes = 500, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
};
|
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
static const SInfosTableSchema userUsersSchema[] = {{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
};
|
||||||
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
static const SInfosTableSchema userUsersSchema[] = {
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
};
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
static const SInfosTableSchema vgroupsSchema[] = {{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
};
|
||||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
static const SInfosTableSchema vgroupsSchema[] = {
|
||||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "v1_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "v2_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "v1_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "v3_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "compacting", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "v2_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "v3_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
};
|
{.name = "compacting", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
};
|
||||||
|
|
||||||
static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)},
|
// TODO put into perf schema
|
||||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)},
|
static const SInfosTableSchema topicSchema[] = {
|
||||||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)},
|
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
{.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
};
|
||||||
{TSDB_INS_TABLE_USER_STREAMS, userStreamsSchema, tListLen(userStreamsSchema)},
|
|
||||||
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
|
||||||
{TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
|
||||||
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
|
||||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
|
||||||
};
|
|
||||||
|
|
||||||
//connection/application/
|
static const SInfosTableSchema consumerSchema[] = {
|
||||||
|
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "status", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
// ep
|
||||||
|
// up time
|
||||||
|
// topics
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SInfosTableSchema subscribeSchema[] = {
|
||||||
|
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SInfosTableMeta infosMeta[] = {
|
||||||
|
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)},
|
||||||
|
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)},
|
||||||
|
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)},
|
||||||
|
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_STREAMS, userStreamsSchema, tListLen(userStreamsSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
||||||
|
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// connection/application/
|
||||||
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||||
if (NULL == schema) {
|
if (NULL == schema) {
|
||||||
|
@ -161,7 +201,7 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S
|
||||||
|
|
||||||
for (int32_t i = 0; i < colNum; ++i) {
|
for (int32_t i = 0; i < colNum; ++i) {
|
||||||
strcpy(schema[i].name, pSrc[i].name);
|
strcpy(schema[i].name, pSrc[i].name);
|
||||||
|
|
||||||
schema[i].type = pSrc[i].type;
|
schema[i].type = pSrc[i].type;
|
||||||
schema[i].colId = i + 1;
|
schema[i].colId = i + 1;
|
||||||
schema[i].bytes = pSrc[i].bytes;
|
schema[i].bytes = pSrc[i].bytes;
|
||||||
|
@ -182,11 +222,11 @@ int32_t mndInsInitMeta(SHashObj *hash) {
|
||||||
for (int32_t i = 0; i < tListLen(infosMeta); ++i) {
|
for (int32_t i = 0; i < tListLen(infosMeta); ++i) {
|
||||||
strcpy(meta.tbName, infosMeta[i].name);
|
strcpy(meta.tbName, infosMeta[i].name);
|
||||||
meta.numOfColumns = infosMeta[i].colNum;
|
meta.numOfColumns = infosMeta[i].colNum;
|
||||||
|
|
||||||
if (mndInitInfosTableSchema(infosMeta[i].schema, infosMeta[i].colNum, &meta.pSchemas)) {
|
if (mndInitInfosTableSchema(infosMeta[i].schema, infosMeta[i].colNum, &meta.pSchemas)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
|
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -210,7 +250,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
||||||
}
|
}
|
||||||
|
|
||||||
*pRsp = *meta;
|
*pRsp = *meta;
|
||||||
|
|
||||||
pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
|
pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
|
||||||
if (pRsp->pSchemas == NULL) {
|
if (pRsp->pSchemas == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -237,13 +277,13 @@ void mndCleanupInfos(SMnode *pMnode) {
|
||||||
if (NULL == pMnode->infosMeta) {
|
if (NULL == pMnode->infosMeta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMnode->infosMeta, NULL);
|
void *pIter = taosHashIterate(pMnode->infosMeta, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
||||||
|
|
||||||
taosMemoryFreeClear(meta->pSchemas);
|
taosMemoryFreeClear(meta->pSchemas);
|
||||||
|
|
||||||
pIter = taosHashIterate(pMnode->infosMeta, pIter);
|
pIter = taosHashIterate(pMnode->infosMeta, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,5 +291,3 @@ void mndCleanupInfos(SMnode *pMnode) {
|
||||||
pMnode->infosMeta = NULL;
|
pMnode->infosMeta = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ typedef struct {
|
||||||
SQueryDesc *pQueries;
|
SQueryDesc *pQueries;
|
||||||
} SConnObj;
|
} SConnObj;
|
||||||
|
|
||||||
static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid, const char *app, int64_t startTime);
|
static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, uint16_t port, int32_t pid,
|
||||||
|
const char *app, int64_t startTime);
|
||||||
static void mndFreeConn(SConnObj *pConn);
|
static void mndFreeConn(SConnObj *pConn);
|
||||||
static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
|
static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
|
||||||
static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn);
|
static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn);
|
||||||
|
@ -94,7 +95,8 @@ void mndCleanupProfile(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid, const char *app, int64_t startTime) {
|
static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, uint16_t port, int32_t pid,
|
||||||
|
const char *app, int64_t startTime) {
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
|
||||||
int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1);
|
int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1);
|
||||||
|
@ -104,8 +106,8 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
|
||||||
SConnObj connObj = {.id = connId,
|
SConnObj connObj = {.id = connId,
|
||||||
.appStartTimeMs = startTime,
|
.appStartTimeMs = startTime,
|
||||||
.pid = pid,
|
.pid = pid,
|
||||||
.ip = pInfo->clientIp,
|
.ip = ip,
|
||||||
.port = pInfo->clientPort,
|
.port = port,
|
||||||
.killed = 0,
|
.killed = 0,
|
||||||
.loginTimeMs = taosGetTimestampMs(),
|
.loginTimeMs = taosGetTimestampMs(),
|
||||||
.lastAccessTimeMs = 0,
|
.lastAccessTimeMs = 0,
|
||||||
|
@ -114,17 +116,17 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
|
||||||
.pQueries = NULL};
|
.pQueries = NULL};
|
||||||
|
|
||||||
connObj.lastAccessTimeMs = connObj.loginTimeMs;
|
connObj.lastAccessTimeMs = connObj.loginTimeMs;
|
||||||
tstrncpy(connObj.user, pInfo->user, TSDB_USER_LEN);
|
tstrncpy(connObj.user, user, TSDB_USER_LEN);
|
||||||
tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN);
|
tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN);
|
||||||
|
|
||||||
int32_t keepTime = tsShellActivityTimer * 3;
|
int32_t keepTime = tsShellActivityTimer * 3;
|
||||||
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, failed to put into cache since %s, user:%s", connId, pInfo->user, terrstr());
|
mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, pInfo->user);
|
mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, user);
|
||||||
return pConn;
|
return pConn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,20 +186,14 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
||||||
SConnObj *pConn = NULL;
|
SConnObj *pConn = NULL;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SConnectReq connReq = {0};
|
SConnectReq connReq = {0};
|
||||||
|
char ip[30] = {0};
|
||||||
|
|
||||||
if (tDeserializeSConnectReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &connReq) != 0) {
|
if (tDeserializeSConnectReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &connReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CONN_OVER;
|
goto CONN_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcConnInfo info = {0};
|
taosIp2String(pReq->clientIp, ip);
|
||||||
if (rpcGetConnInfo(pReq->rpcMsg.handle, &info) != 0) {
|
|
||||||
mError("user:%s, failed to login while get connection info since %s", pReq->user, terrstr());
|
|
||||||
goto CONN_OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
char ip[30];
|
|
||||||
taosIp2String(info.clientIp, ip);
|
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
|
@ -216,7 +212,8 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pConn = mndCreateConn(pMnode, &info, connReq.pid, connReq.app, connReq.startTime);
|
pConn =
|
||||||
|
mndCreateConn(pMnode, pReq->user, pReq->clientIp, pReq->clientPort, connReq.pid, connReq.app, connReq.startTime);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
mError("user:%s, failed to login from %s while create connection since %s", pReq->user, ip, terrstr());
|
mError("user:%s, failed to login from %s while create connection since %s", pReq->user, ip, terrstr());
|
||||||
goto CONN_OVER;
|
goto CONN_OVER;
|
||||||
|
@ -241,7 +238,7 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
||||||
pReq->rspLen = contLen;
|
pReq->rspLen = contLen;
|
||||||
pReq->pRsp = pRsp;
|
pReq->pRsp = pRsp;
|
||||||
|
|
||||||
mDebug("user:%s, login from %s, conn:%d, app:%s", info.user, ip, pConn->id, connReq.app);
|
mDebug("user:%s, login from %s, conn:%d, app:%s", pReq->user, ip, pConn->id, connReq.app);
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mndQuery.h"
|
#include "mndQuery.h"
|
||||||
#include "mndMnode.h"
|
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
|
#include "mndMnode.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
|
||||||
int32_t mndProcessQueryMsg(SNodeMsg *pReq) {
|
int32_t mndProcessQueryMsg(SNodeMsg *pReq) {
|
||||||
mTrace("message in query queue is processing");
|
SMnode *pMnode = pReq->pNode;
|
||||||
SMnode *pMnode = pReq->pNode;
|
|
||||||
SReadHandle handle = {0};
|
SReadHandle handle = {0};
|
||||||
|
|
||||||
|
mTrace("msg:%p, in query queue is processing", pReq);
|
||||||
switch (pReq->rpcMsg.msgType) {
|
switch (pReq->rpcMsg.msgType) {
|
||||||
case TDMT_VND_QUERY:
|
case TDMT_VND_QUERY:
|
||||||
return qWorkerProcessQueryMsg(&handle, pMnode->pQuery, &pReq->rpcMsg);
|
return qWorkerProcessQueryMsg(&handle, pMnode->pQuery, &pReq->rpcMsg);
|
||||||
|
@ -35,9 +35,9 @@ int32_t mndProcessQueryMsg(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessFetchMsg(SNodeMsg *pReq) {
|
int32_t mndProcessFetchMsg(SNodeMsg *pReq) {
|
||||||
mTrace("message in fetch queue is processing");
|
|
||||||
SMnode *pMnode = pReq->pNode;
|
SMnode *pMnode = pReq->pNode;
|
||||||
|
mTrace("msg:%p, in fetch queue is processing", pReq);
|
||||||
|
|
||||||
switch (pReq->rpcMsg.msgType) {
|
switch (pReq->rpcMsg.msgType) {
|
||||||
case TDMT_VND_FETCH:
|
case TDMT_VND_FETCH:
|
||||||
return qWorkerProcessFetchMsg(pMnode, pMnode->pQuery, &pReq->rpcMsg);
|
return qWorkerProcessFetchMsg(pMnode, pMnode->pQuery, &pReq->rpcMsg);
|
||||||
|
@ -52,9 +52,9 @@ int32_t mndProcessFetchMsg(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndInitQuery(SMnode *pMnode) {
|
int32_t mndInitQuery(SMnode *pMnode) {
|
||||||
int32_t code = qWorkerInit(NODE_TYPE_MNODE, MND_VGID, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb);
|
if (qWorkerInit(NODE_TYPE_MNODE, MND_VGID, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb) != 0) {
|
||||||
if (code) {
|
mError("failed to init qworker in mnode since %s", terrstr());
|
||||||
return code;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_QUERY, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_VND_QUERY, mndProcessQueryMsg);
|
||||||
|
@ -67,4 +67,3 @@ int32_t mndInitQuery(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndCleanupQuery(SMnode *pMnode) { qWorkerDestroy((void **)&pMnode->pQuery); }
|
void mndCleanupQuery(SMnode *pMnode) { qWorkerDestroy((void **)&pMnode->pQuery); }
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,92 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, int64_t dbUid) {
|
||||||
return pVgroup;
|
return pVgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, int64_t smaId) {
|
int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
|
void* pIter = NULL;
|
||||||
|
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
||||||
|
|
||||||
|
ASSERT(taosArrayGetSize(pStream->tasks) == 1);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
SVgObj* pVgroup;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
if (pVgroup->dbUid != pStream->dbUid) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
|
if (pTask == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taosArrayPush(tasks, &pTask);
|
||||||
|
|
||||||
|
pTask->nodeId = pVgroup->vgId;
|
||||||
|
pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
|
||||||
|
// source
|
||||||
|
pTask->sourceType = TASK_SOURCE__MERGE;
|
||||||
|
|
||||||
|
// exec
|
||||||
|
pTask->execType = TASK_EXEC__NONE;
|
||||||
|
|
||||||
|
// sink
|
||||||
|
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
||||||
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
|
} else {
|
||||||
|
pTask->sinkType = TASK_SINK__TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dispatch
|
||||||
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
|
|
||||||
|
mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_VND_TASK_DEPLOY, pVgroup->vgId);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndAddFixedSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
|
ASSERT(pStream->fixedSinkVgId != 0);
|
||||||
|
SArray* tasks = taosArrayGetP(pStream->tasks, 0);
|
||||||
|
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||||
|
if (pTask == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taosArrayPush(tasks, &pTask);
|
||||||
|
|
||||||
|
pTask->nodeId = pStream->fixedSinkVgId;
|
||||||
|
SVgObj* pVgroup = mndAcquireVgroup(pMnode, pStream->fixedSinkVgId);
|
||||||
|
if (pVgroup == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
// source
|
||||||
|
pTask->sourceType = TASK_SOURCE__MERGE;
|
||||||
|
|
||||||
|
// exec
|
||||||
|
pTask->execType = TASK_EXEC__NONE;
|
||||||
|
|
||||||
|
// sink
|
||||||
|
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
||||||
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
|
} else {
|
||||||
|
pTask->sinkType = TASK_SINK__TABLE;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// dispatch
|
||||||
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
|
|
||||||
|
mndPersistTaskDeployReq(pTrans, pTask, &pTask->epSet, TDMT_VND_TASK_DEPLOY, pVgroup->vgId);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SSdb* pSdb = pMnode->pSdb;
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
||||||
if (pPlan == NULL) {
|
if (pPlan == NULL) {
|
||||||
|
@ -132,6 +217,19 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i
|
||||||
ASSERT(totLevel <= 2);
|
ASSERT(totLevel <= 2);
|
||||||
pStream->tasks = taosArrayInit(totLevel, sizeof(void*));
|
pStream->tasks = taosArrayInit(totLevel, sizeof(void*));
|
||||||
|
|
||||||
|
bool hasExtraSink = false;
|
||||||
|
if (totLevel == 2) {
|
||||||
|
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
||||||
|
taosArrayPush(pStream->tasks, &taskOneLevel);
|
||||||
|
// add extra sink
|
||||||
|
hasExtraSink = true;
|
||||||
|
if (pStream->fixedSinkVgId == 0) {
|
||||||
|
mndAddShuffledSinkToStream(pMnode, pTrans, pStream);
|
||||||
|
} else {
|
||||||
|
mndAddFixedSinkToStream(pMnode, pTrans, pStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t level = 0; level < totLevel; level++) {
|
for (int32_t level = 0; level < totLevel; level++) {
|
||||||
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level);
|
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level);
|
||||||
|
@ -164,9 +262,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i
|
||||||
// only for inplace
|
// only for inplace
|
||||||
pTask->sinkType = TASK_SINK__SHOW;
|
pTask->sinkType = TASK_SINK__SHOW;
|
||||||
pTask->showSink.reserved = 0;
|
pTask->showSink.reserved = 0;
|
||||||
if (smaId != -1) {
|
if (!hasExtraSink) {
|
||||||
pTask->sinkType = TASK_SINK__SMA;
|
#if 1
|
||||||
pTask->smaSink.smaId = smaId;
|
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
||||||
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
|
} else {
|
||||||
|
pTask->sinkType = TASK_SINK__TABLE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pTask->sinkType = TASK_SINK__NONE;
|
pTask->sinkType = TASK_SINK__NONE;
|
||||||
|
@ -175,17 +279,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i
|
||||||
// dispatch part
|
// dispatch part
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
pTask->dispatchType = TASK_DISPATCH__NONE;
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
// if inplace sink, no dispatcher
|
|
||||||
// if fixed ep, add fixed ep dispatcher
|
|
||||||
// if shuffle, add shuffle dispatcher
|
|
||||||
} else {
|
} else {
|
||||||
// add fixed ep dispatcher
|
// add fixed ep dispatcher
|
||||||
int32_t lastLevel = level - 1;
|
int32_t lastLevel = level - 1;
|
||||||
ASSERT(lastLevel == 0);
|
ASSERT(lastLevel == 0);
|
||||||
|
if (hasExtraSink) lastLevel++;
|
||||||
SArray* pArray = taosArrayGetP(pStream->tasks, lastLevel);
|
SArray* pArray = taosArrayGetP(pStream->tasks, lastLevel);
|
||||||
// one merge only
|
// one merge only
|
||||||
ASSERT(taosArrayGetSize(pArray) == 1);
|
ASSERT(taosArrayGetSize(pArray) == 1);
|
||||||
SStreamTask* lastLevelTask = taosArrayGetP(pArray, lastLevel);
|
SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0);
|
||||||
pTask->dispatchMsgType = TDMT_VND_TASK_MERGE_EXEC;
|
pTask->dispatchMsgType = TDMT_VND_TASK_MERGE_EXEC;
|
||||||
pTask->dispatchType = TASK_DISPATCH__FIXED;
|
pTask->dispatchType = TASK_DISPATCH__FIXED;
|
||||||
|
|
||||||
|
@ -222,8 +324,56 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, i
|
||||||
/*pTask->sinkType = TASK_SINK__NONE;*/
|
/*pTask->sinkType = TASK_SINK__NONE;*/
|
||||||
|
|
||||||
// dispatch part
|
// dispatch part
|
||||||
pTask->dispatchType = TASK_DISPATCH__SHUFFLE;
|
ASSERT(hasExtraSink);
|
||||||
pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC;
|
/*pTask->dispatchType = TASK_DISPATCH__NONE;*/
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
if (hasExtraSink) {
|
||||||
|
// add dispatcher
|
||||||
|
if (pStream->fixedSinkVgId == 0) {
|
||||||
|
pTask->dispatchType = TASK_DISPATCH__SHUFFLE;
|
||||||
|
|
||||||
|
pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC;
|
||||||
|
SDbObj* pDb = mndAcquireDb(pMnode, pStream->db);
|
||||||
|
ASSERT(pDb);
|
||||||
|
if (mndExtractDbInfo(pMnode, pDb, &pTask->shuffleDispatcher.dbInfo, NULL) < 0) {
|
||||||
|
sdbRelease(pSdb, pDb);
|
||||||
|
qDestroyQueryPlan(pPlan);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sdbRelease(pSdb, pDb);
|
||||||
|
|
||||||
|
// put taskId to useDbRsp
|
||||||
|
// TODO: optimize
|
||||||
|
SArray* pVgs = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
|
int32_t sz = taosArrayGetSize(pVgs);
|
||||||
|
SArray* sinkLv = taosArrayGetP(pStream->tasks, 0);
|
||||||
|
int32_t sinkLvSize = taosArrayGetSize(sinkLv);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i);
|
||||||
|
for (int32_t j = 0; j < sinkLvSize; j++) {
|
||||||
|
SStreamTask* pLastLevelTask = taosArrayGetP(sinkLv, j);
|
||||||
|
/*printf("vgid %d node id %d\n", pVgInfo->vgId, pTask->nodeId);*/
|
||||||
|
if (pLastLevelTask->nodeId == pVgInfo->vgId) {
|
||||||
|
pVgInfo->taskId = pLastLevelTask->taskId;
|
||||||
|
/*printf("taskid %d set to %d\n", pVgInfo->taskId, pTask->taskId);*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pTask->dispatchType = TASK_DISPATCH__FIXED;
|
||||||
|
pTask->dispatchMsgType = TDMT_VND_TASK_WRITE_EXEC;
|
||||||
|
SArray* pArray = taosArrayGetP(pStream->tasks, 0);
|
||||||
|
// one sink only
|
||||||
|
ASSERT(taosArrayGetSize(pArray) == 1);
|
||||||
|
SStreamTask* lastLevelTask = taosArrayGetP(pArray, 0);
|
||||||
|
pTask->fixedEpDispatcher.taskId = lastLevelTask->taskId;
|
||||||
|
pTask->fixedEpDispatcher.nodeId = lastLevelTask->nodeId;
|
||||||
|
pTask->fixedEpDispatcher.epSet = lastLevelTask->epSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// exec part
|
// exec part
|
||||||
pTask->execType = TASK_EXEC__MERGE;
|
pTask->execType = TASK_EXEC__MERGE;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue